public static void MakePage([JetBrains.Annotations.NotNull] Document doc, [JetBrains.Annotations.NotNull] string dstdir,
                                    bool requireAll, FileCreationMode fileCreationMode,
                                    [CanBeNull] Section tocSection, [JetBrains.Annotations.NotNull] string csvCharacter)
        {
            string filename = null;

            if (fileCreationMode == FileCreationMode.Settlement && File.Exists(Path.Combine(dstdir, "totals.csv")))
            {
                filename = Path.Combine(dstdir, DirectoryNames.CalculateTargetdirectory(TargetDirectory.Root),
                                        "Totals.csv");
            }

            if (fileCreationMode == FileCreationMode.Household && File.Exists(Path.Combine(dstdir,
                                                                                           DirectoryNames.CalculateTargetdirectory(TargetDirectory.Reports), "TotalsPerLoadtype.csv")))
            {
                filename = Path.Combine(dstdir, DirectoryNames.CalculateTargetdirectory(TargetDirectory.Reports),
                                        "TotalsPerLoadtype.csv");
            }
            if (filename == null)
            {
                if (requireAll)
                {
                    throw new LPGException("Missing totals files.");
                }
                return;
            }

            var sec = doc.AddSection();

            var para = sec.AddParagraph();

            para.Format.Alignment   = ParagraphAlignment.Justify;
            para.Format.Font.Name   = "Times New Roman";
            para.Format.Font.Size   = 20;
            para.Format.Font.Bold   = true;
            para.Format.SpaceAfter  = "0.5cm";
            para.Format.SpaceBefore = "1cm";
            para.Format.Font.Color  = Colors.DarkGray;
            para.AddText("Totals");
            ChartPageBase.MakeTocEntry(tocSection, "Totals");
            para.AddBookmark("Totals");

            switch (fileCreationMode)
            {
            case FileCreationMode.Household:
                var totals = TotalsReader(filename, false, csvCharacter);
                SetHouseholdEntries(totals, doc, sec);
                SetPerDayTable(totals, doc, sec);
                SetMinMaxTable(totals, doc, sec);
                SetPerPersonTable(totals, doc, sec);
                SetPerPersonDayTable(totals, doc, sec);
                return;

            case FileCreationMode.Settlement:
                SetSettlementEntries(doc, sec, filename, csvCharacter);
                return;

            default: throw new LPGException("Forgotten File Creation Mode");
            }
        }
Esempio n. 2
0
        public void MakePage(Document doc, string dstdir, bool requireAll, List <string> pngFiles, Section tocSection)
        {
            var di    = new DirectoryInfo(dstdir);
            var files = di.GetFiles("Persons.*.txt");

            if (files.Length == 0)
            {
                if (requireAll)
                {
                    throw new LPGException("Missing Persons files");
                }
                return;
            }
            var sec = doc.AddSection();
            // Add a single paragraph with some text and format information.
            var para = sec.AddParagraph();

            para.Format.Alignment   = ParagraphAlignment.Justify;
            para.Format.Font.Name   = "Times New Roman";
            para.Format.Font.Size   = 20;
            para.Format.Font.Bold   = true;
            para.Format.SpaceAfter  = "1cm";
            para.Format.SpaceBefore = "1cm";
            para.Format.Font.Color  = Colors.DarkGray;
            para.AddText("Persons");
            ChartPageBase.MakeTocEntry(tocSection, "Persons");
            para.AddBookmark("Persons");
            var format1 = new ParagraphFormat {
                Font = { Size = 14 }, SpaceBefore = "0.2cm", SpaceAfter = "0.2cm", ListInfo = { ListType = ListType.BulletList1 }
            };
            var format2 = new ParagraphFormat {
                Font = { Size = 12 }, ListInfo = { ListType = ListType.BulletList2 }, LeftIndent = "3cm"
            };

            foreach (var file in files)
            {
                var household = file.Name.Substring(file.Name.IndexOf(".", StringComparison.Ordinal) + 1);
                household = household.Substring(0, household.IndexOf(".", StringComparison.Ordinal));
                var para1 = sec.AddParagraph();
                para1.Format.Alignment = ParagraphAlignment.Left;
                para1.Format           = format1.Clone();
                para1.AddText(household);
                var persons = PersonsReader(file.FullName);
                foreach (var person in persons)
                {
                    var para2 = sec.AddParagraph();
                    para2.Format.Alignment = ParagraphAlignment.Left;
                    para2.Format           = format2.Clone();
                    para2.AddText(person);
                }
            }
        }