public static void MakeChartsAndPDF(CalculationProfiler calculationProfiler, string resultPath) { Exception innerException = null; var t = new Thread(() => { try { SqlResultLoggingService srls = new SqlResultLoggingService(resultPath); CalcParameterLogger cpl = new CalcParameterLogger(srls); InputDataLogger idl = new InputDataLogger(Array.Empty <IDataSaverBase>()); var calcParameters = cpl.Load(); Logger.Info("Checking for charting parameters"); if (!calcParameters.IsSet(CalcOption.MakePDF) && !calcParameters.IsSet(CalcOption.MakeGraphics)) { Logger.Info("No charts wanted"); return; } calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - Charting"); using (FileFactoryAndTracker fileFactoryAndTracker = new FileFactoryAndTracker(resultPath, "Name", idl)) { calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - Chart Generator RunAll"); ChartCreationParameters ccp = new ChartCreationParameters(144, 1600, 1000, false, calcParameters.CSVCharacter, new DirectoryInfo(resultPath)); var cg = new ChartGeneratorManager(calculationProfiler, fileFactoryAndTracker, ccp); cg.Run(resultPath); calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - Chart Generator RunAll"); if (calcParameters.IsSet(CalcOption.MakePDF)) { calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - PDF Creation"); Logger.ImportantInfo( "Creating the PDF. This will take a really long time without any progress report..."); MigraPDFCreator mpc = new MigraPDFCreator(calculationProfiler); mpc.MakeDocument(resultPath, "", false, false, calcParameters.CSVCharacter, fileFactoryAndTracker); calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - PDF Creation"); } } Logger.Info("Finished making the charts"); calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - Charting"); CalculationDurationFlameChart cdfc = new CalculationDurationFlameChart(); cdfc.Run(calculationProfiler, resultPath, "CalcManager"); } catch (Exception ex) { innerException = ex; Logger.Exception(ex); } }); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); if (innerException != null) { Logger.Error("Exception during the PDF creation!"); Logger.Exception(innerException); throw innerException; } }
public static void MakeFlameChart([NotNull] DirectoryInfo di, [NotNull] CalculationProfiler calculationProfiler) { string targetfile = Path.Combine(di.FullName, Constants.CalculationProfilerJson); using (StreamWriter sw = new StreamWriter(targetfile)) { calculationProfiler.WriteJson(sw); CalculationDurationFlameChart cdfc = new CalculationDurationFlameChart(); Thread t = new Thread(() => { try { cdfc.Run(calculationProfiler, di.FullName, "CommandlineCalc"); } catch (Exception ex) { Logger.Exception(ex); } }); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); } }