public MyColumn([JetBrains.Annotations.NotNull] string name, int column, [CanBeNull] DeviceTaggingSetInformation taggingSet, [JetBrains.Annotations.NotNull] DirectoryInfo basisPath, [JetBrains.Annotations.NotNull] FileFactoryAndTracker fft, CalcParameters parameters) { Tag = ""; RawName = name; Column = column; if (name.Contains(" [")) { var deviceWithRoom = name.Substring(name.IndexOf(" - ", StringComparison.Ordinal) + 3); deviceWithRoom = deviceWithRoom.Substring(0, deviceWithRoom.IndexOf(" [", StringComparison.Ordinal)).Trim(); var device = deviceWithRoom.Substring(deviceWithRoom.IndexOf(" - ", StringComparison.Ordinal) + 3).Trim(); try { if (taggingSet == null) { throw new LPGException("Tagging set was null"); } if (parameters.IsSet(CalcOption.HouseholdContents) && !taggingSet.TagByDeviceName.ContainsKey(device)) { var fileName = Path.Combine(basisPath.FullName, "missingCategories.txt"); if (!fft.CheckForFile(ResultFileID.MissingTags, Constants.GeneralHouseholdKey)) { fft.RegisterFile(fileName, "Devices that are missing device tags", false, ResultFileID.MissingTags, Constants.GeneralHouseholdKey, TargetDirectory.Root, CalcOption.HouseholdContents); } taggingSet.TagByDeviceName.Add(device, "Other"); using (var sw = new StreamWriter(fileName, true)) { sw.WriteLine(device); } Logger.Error("Missing entry in the device tagging set " + taggingSet.Name + " for the device " + device); } } catch (Exception ex) { Logger.Error( "Couldn't write to missing categories file: " + basisPath + " Error message was:" + ex.Message); Logger.Exception(ex); } if (taggingSet == null) { throw new LPGException("Tagging set was null"); } Tag = taggingSet.TagByDeviceName[device]; } }
public void MakeDocument([JetBrains.Annotations.NotNull] string pdfDstPath, [JetBrains.Annotations.NotNull] string calcObjectName, bool startpdf, bool requireAll, [JetBrains.Annotations.NotNull] string csvCharacter, [JetBrains.Annotations.NotNull] FileFactoryAndTracker fft) { // Create a MigraDoc document _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - PDF Layout"); var document = CreateDocument(pdfDstPath, requireAll, csvCharacter); _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - PDF Layout"); _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - PDF Render"); #pragma warning disable 618 var renderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always) #pragma warning restore 618 { Document = document }; Logger.ImportantInfo("Rendering the PDF. This will take a really long time without any progress report..."); renderer.RenderDocument(); _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - PDF Render"); _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - PDF Cleanup"); // Save the document... if (!Directory.Exists(pdfDstPath)) { Directory.CreateDirectory(pdfDstPath); } var filename = "Overview." + AutomationUtili.CleanFileName(calcObjectName) + ".pdf"; var dstFullName = Path.Combine(pdfDstPath, filename); if (File.Exists(dstFullName)) { File.Delete(dstFullName); } Logger.ImportantInfo("----"); Logger.ImportantInfo(dstFullName); Logger.ImportantInfo("----"); Logger.ImportantInfo("Saving the PDF..."); renderer.PdfDocument.Save(dstFullName); GC.WaitForPendingFinalizers(); GC.Collect(); // ...and start a viewer. if (startpdf) { Process.Start(dstFullName); } fft.RegisterFile(filename, "Overview of all results", true, ResultFileID.PDF, Constants.GeneralHouseholdKey, TargetDirectory.Root, CalcOption.MakePDF); _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - PDF Cleanup"); //return new ResultFileEntry("Overview", filename, dstFullName, true); }