Beispiel #1
0
 // resolve unique/common page relations..
 private void ResolveCommonPages()
 {
     foreach (PagiPlanDataEdition ed in plan.editionList)
     {
         foreach (PagiPlanDataSection sec in ed.sectionList)
         {
             foreach (PagiPlanDataPage page in sec.pageList)
             {
                 if (page.uniquePage == PageUniqueType.Common)
                 {
                     PagiPlanDataEdition mastered = plan.GetEditionObject(page.masterEdition);
                     if (mastered != null)
                     {
                         bool found = false;
                         foreach (PagiPlanDataSection mastersec in mastered.sectionList)
                         {
                             foreach (PagiPlanDataPage masterpage in mastersec.pageList)
                             {
                                 if (masterpage.pageName == page.pageName)
                                 {
                                     page.masterPageID = masterpage.pageID;
                                     found             = true;
                                     break;
                                 }
                             }
                             if (found)
                             {
                                 break;
                             }
                         }
                     }
                 }
                 else
                 {
                     page.masterPageID = page.pageID;
                 }
             }
         }
     }
 }
Beispiel #2
0
        public bool ParseFile(string pageFileName, ref int paginationstart)
        {
            paginationstart = 1;
            string [] lines;

            if (File.Exists(pageFileName) == false)
            {
                return(false);
            }

            try
            {
                lines = File.ReadAllLines(pageFileName);
            }
            catch
            {
                return(false);
            }

            int pageoffset = -1;

            string thisEdition      = "";
            string thisSection      = "";
            int    pageCount        = 1;
            int    pageIndex        = 1;
            PagiPlanDataSection sec = null;
            PagiPlanDataEdition ed  = null;

            foreach (string line in lines)
            {
                string[] elements = line.Split('\t');
                if (elements.Length < 15)
                {
                    continue;
                }

                if (elements[PAGI_EDITION] != thisEdition)
                {
                    ed = new PagiPlanDataEdition(elements[PAGI_EDITION]);
                    ed.masterEdition  = (elements[PAGI_EDITION] == elements[PAGI_MASTEREDITION]);
                    ed.editionComment = ed.editionName;


                    plan.editionList.Add(ed);
                    thisEdition = ed.editionName;
                }

                string section = elements[PAGI_SECTION];
                if (section.IndexOf("SUP") < 0)
                {
                    section = "Main";
                }

                if (section != thisSection)
                {
                    sec = new PagiPlanDataSection(section);
                    sec.pagesInSection = 0;

                    ed.sectionList.Add(sec);
                    pageCount   = 1;
                    thisSection = section;
                }

                PagiPlanDataPage page = new PagiPlanDataPage(elements[PAGI_PAGENAME]);
                page.fileName      = elements[PAGI_FILENAME];
                page.masterEdition = elements[PAGI_MASTEREDITION];
                page.pageIndex     = Globals.TryParse(elements[PAGI_PAGEINDEX], pageCount);

                int pagination = Globals.TryParse(elements[PAGI_PAGINATION], pageCount++);
                if (pageoffset == -1)
                {
                    pageoffset = pagination;
                }

                // Adjust pagination for covers to start at 1
                page.pagination = pagination - (pageoffset - 1);
                if (pagination > 1)
                {
                    page.pageIndex = page.pagination;
                }
                page.priority   = Globals.TryParse(elements[PAGI_PRIORITY], 0);
                page.uniquePage = (elements[PAGI_UNIQUEPAGE] == "X") ? PageUniqueType.Unique : PageUniqueType.Common;
                page.pageType   = (elements[PAGI_PAGETYPE] != "") ? PageType.Panorama : PageType.Normal;

                page.monoPage    = elements[PAGI_COLORS] != "Q";
                page.comment     = elements[PAGI_PAGENAMECOMMENT];
                page.miscstring1 = elements[PAGI_LAYOUT];
                page.miscstring2 = elements[PAGI_PLATETEXT];
                page.version     = 0;

                page.pageID       = pageIndex.ToString();
                page.masterPageID = pageIndex.ToString();
                pageIndex++;

                plan.publicationDate  = String2DateTime(elements[PAGI_PUBDATE]);
                plan.publicationName  = elements[PAGI_PUBLICATION];
                plan.publicationAlias = plan.publicationName;

                if (elements.Length > 16)
                {
                    plan.publicationAlias = elements[PAGI_PECOMPUBLICATION];
                }

                if (elements.Length > 17)
                {
                    ed.editionComment = elements[PAGI_PECOMEDITION];
                }

                sec.pageList.Add(page);
            }

            ResolveCommonPages();

            paginationstart = pageoffset > 0 ? pageoffset : 1;

            return(true);
        }