private static Document CreateDocument([JetBrains.Annotations.NotNull] string destinationDirectory, bool requireAll, [JetBrains.Annotations.NotNull] string csvCharacter)
        {
            // Create a new MigraDoc document
            var document = new Document {
                Info = { Title = "LoadProfileGenerator", Subject = "Overview", Author = "Noah Pflugradt" }
            };
            var di  = new DirectoryInfo(destinationDirectory);
            var fis = di.GetFiles("Results.General.sqlite"); // TotalsPerLoadtype.csv

            if (fis.Length > 0)
            {
                ProcessHousehold(document, destinationDirectory, requireAll, csvCharacter); // household
            }
            else if (File.Exists(Path.Combine(di.FullName, "Information.txt")))
            {
                // settlement
                var subdirs = di.GetDirectories();
                CoverPage.DefineSettlementCover(document, destinationDirectory);
                TotalsPage.MakePage(document, destinationDirectory, requireAll, FileCreationMode.Settlement,
                                    null,
                                    csvCharacter);
                foreach (var directoryInfo in subdirs)
                {
                    ProcessHousehold(document, directoryInfo.FullName, requireAll, csvCharacter); // household
                }
            }
            else
            {
                throw new LPGException("Couldn't find any files for the PDF generation?!?");
            }
            return(document);
        }
        private static void ProcessHousehold([JetBrains.Annotations.NotNull] Document document, [JetBrains.Annotations.NotNull] string path, bool requireAll, [JetBrains.Annotations.NotNull] string csvCharacter)
        {
            var di       = new DirectoryInfo(path);
            var fis      = di.GetFiles("*.png", SearchOption.AllDirectories);
            var pngfiles = fis.Select(x => x.Name).ToList();

            var cp = new CoverPage();

            cp.MakePage(document, path, requireAll);
            var tocSection = SetTocSection(document);

            TotalsPage.MakePage(document, path, requireAll, FileCreationMode.Household, tocSection, csvCharacter);
            var pp = new PersonPage();

            pp.MakePage(document, path, requireAll, pngfiles, tocSection);
            // How they spend their time

            var afp = new ActivityFrequencyPages();

            afp.MakePage(document, path, requireAll, pngfiles, tocSection);
            var app = new ActivityPercentagePages();

            app.MakePage(document, path, requireAll, pngfiles, tocSection);
            var atu = new AffordanceTimeUsePages();

            atu.MakePage(document, path, requireAll, pngfiles, tocSection);
            var affordanceEnergyUsePerPersonPages =
                new AffordanceEnergyUsePerPersonPages();

            affordanceEnergyUsePerPersonPages.MakePage(document, path, requireAll, pngfiles, tocSection);

            var ats = new AffordanceTaggingSetPages();

            ats.MakePage(document, path, requireAll, pngfiles, tocSection);
            var cpp = new CarpetplotPages();

            cpp.MakePage(document, path, requireAll, tocSection);

            var eaop = new ExecutedActionsOverviewPages();

            eaop.MakePage(document, path, requireAll, pngfiles, tocSection);

            var timeOfUseProfilesPages = new TimeOfUseProfilesPages();

            timeOfUseProfilesPages.MakePage(document, path, requireAll, pngfiles, tocSection);

            // energy use
            var aeu = new AffordanceEnergyUse();

            aeu.MakePage(document, path, requireAll, pngfiles, tocSection);
            var dsp = new DeviceSumsPages();

            dsp.MakePage(document, path, requireAll, pngfiles, tocSection);

            // energy quality
            var deviceDurationCurvesPages = new DeviceDurationCurvesPages();

            deviceDurationCurvesPages.MakePage(document, path, requireAll, pngfiles, tocSection);
            var dcp = new DurationCurvePages();

            dcp.MakePage(document, path, requireAll, pngfiles, tocSection);
            var deviceTaggingSetPages = new DeviceTaggingSetPages();

            deviceTaggingSetPages.MakePage(document, path, requireAll, pngfiles, tocSection);
            var energyCarpetplotPages = new EnergyCarpetplotPages();

            energyCarpetplotPages.MakePage(document, path, requireAll, pngfiles, tocSection);

            var dpp = new DeviceProfilePages();

            dpp.MakePage(document, path, requireAll, pngfiles, tocSection);
            var timeOfUseEnergyProfilePages = new TimeOfUseEnergyProfilePages();

            timeOfUseEnergyProfilePages.MakePage(document, path, requireAll, pngfiles, tocSection);
            var wpp = new WeekdayProfilesPages();

            wpp.MakePage(document, path, requireAll, pngfiles, tocSection);

            // location
            var lsp = new LocationStatisticsPages();

            lsp.MakePage(document, path, requireAll, pngfiles, tocSection);

            // other
            var dp = new DesirePages();

            dp.MakePage(document, path, requireAll, pngfiles, tocSection);
            var tep = new TemperaturePages();

            tep.MakePage(document, path, requireAll, pngfiles, tocSection);
            var actionsPages = new ActionsPages();

            actionsPages.MakePage(document, path, requireAll, tocSection);
            var spp = new SumProfilePages();

            spp.MakePage(document, path, requireAll, pngfiles, tocSection);
            var sumProfilePagesExternal = new SumProfilePagesExternal();

            sumProfilePagesExternal.MakePage(document, path, requireAll, pngfiles, tocSection);
            var thoughtsp = new ThoughtsPages();

            thoughtsp.MakePage(document, path, requireAll, tocSection);
            var daylight = new DaylightTimePages();

            daylight.MakePage(document, path, requireAll, tocSection);
            var criticalPage = new CriticalThresholdViolationsPage();

            criticalPage.MakePage(document, path, requireAll, pngfiles, tocSection);
            var dpExternalPages = new DeviceProfileExternalPages();

            dpExternalPages.MakePage(document, path, requireAll, pngfiles, tocSection);
            var tpp = new TimeProfilesPages();

            tpp.MakePage(document, path, requireAll, tocSection);
            var vp = new VariablePages();

            vp.MakePage(document, path, requireAll, pngfiles, tocSection);
            var filtered = new List <string>();

            foreach (var pngfile in pngfiles)
            {
                var isok = true;
                if (pngfile.StartsWith("HouseholdPlan.", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("CarpetplotLegend.", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("Carpetplot.", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("CarpetplotLabeled.", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("EnergyCarpetplot.", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("DeviceSums_Monthly.", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("LocationCarpetPlot", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("TransportationStateCarpetPlot", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("TransportationDeviceUserCarpetPlot", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("TransportationDeviceSiteCarpetPlot", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (pngfile.StartsWith("CalculationDurationFlameChart", StringComparison.Ordinal))
                {
                    isok = false;
                }
                if (isok)
                {
                    filtered.Add(pngfile);
                }
            }
            if (filtered.Count > 0)
            {
                foreach (var pngfile in filtered)
                {
                    Logger.Info(pngfile);
                }
                throw new LPGException("Forgotten PNGs:" + filtered.Count);
            }
        }