public void ClearTargetDirectory([NotNull] ScenarioSliceParameters slice) { var fullpath = FilenameHelpers.GetTargetDirectory(MyStage, SequenceNumber, Name, slice, Services.RunningConfig); if (Directory.Exists(fullpath)) { try { DirectoryInfo di = new DirectoryInfo(fullpath); var files = di.GetFiles("*.*", SearchOption.AllDirectories); foreach (var fileInfo in files) { fileInfo.Delete(); } di.Delete(true); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { #pragma warning restore CA1031 // Do not catch general exception types SLogger.Error(e.Message); } } if (!Directory.Exists(fullpath)) { Directory.CreateDirectory(fullpath); Thread.Sleep(250); } }
private void CopyCSVFiles([NotNull] ScenarioSliceParameters parameters, int sequence, [NotNull] string exporteRName, [NotNull] string subPath) { var path = FilenameHelpers.GetTargetDirectory(Stage.ProfileExport, sequence, exporteRName, parameters); var di = new DirectoryInfo(Path.Combine(path, "Export")); if (!di.Exists) { throw new FlaException("Directory " + di.FullName + " does not exist"); } var csvfiles = di.GetFiles("*.csv"); if (csvfiles.Length == 0) { throw new FlaException("No exported files found"); } string dstpath = @"v:\tstcopy\v01"; dstpath = Path.Combine(dstpath, parameters.DstScenario.ToString(), parameters.DstYear.ToString(), subPath); if (Directory.Exists(dstpath)) { Directory.Delete(dstpath, true); Thread.Sleep(500); } Directory.CreateDirectory(dstpath); Thread.Sleep(500); foreach (var fileInfo in csvfiles) { string dstfullName = Path.Combine(dstpath, fileInfo.Name); Info("Copying " + dstfullName); fileInfo.CopyTo(dstfullName); } }
private void MakeResultExcel([NotNull][ItemNotNull] List <CSVFile> csvs, [NotNull] ScenarioSliceParameters slice) { string suffix = csvs[0].GenerationOrLoad.ToString(); using (var p = new ExcelPackage()) { var ws = p.Workbook.Worksheets.Add("MySheet"); var tgt = FilenameHelpers.GetTargetDirectory(MyStage, SequenceNumber, nameof(C01_CSVProfileVisualizer), slice, Services.RunningConfig); var row = 1; var col = 1; ws.Cells[row, col++].Value = "TrafoKreis"; ws.Cells[row, col++].Value = "ISN ID"; ws.Cells[row, col++].Value = "CSV Energy"; ws.Cells[row, col].Value = "DB Energy"; row++; foreach (var csvFile in csvs) { foreach (var csvLine in csvFile.Lines) { col = 1; ws.Cells[row, col++].Value = csvFile.TsName; ws.Cells[row, col++].Value = csvLine.HausanschlussID; var csvEnergy = csvLine.CalculateTotalEnergy(); ws.Cells[row, col].Value = csvEnergy; } } p.SaveAs(new FileInfo(Path.Combine(tgt, "ComparisonCSVvsDB" + suffix + ".xlsx"))); } }
protected override void RunActualProcess(ScenarioSliceParameters slice) { string srcPath = FilenameHelpers.GetTargetDirectory(Stage.ProfileGeneration, 500, nameof(E_ApplySmartGridToGeneratedProfiles), slice, Services.RunningConfig); string lz4ProfilePath = Path.Combine(srcPath, "addedProfile.lz4"); byte[] arr = File.ReadAllBytes(lz4ProfilePath); var addedProfileraw = LZ4MessagePackSerializer.Deserialize <Profile>(arr); var pos = addedProfileraw.GetOnlyPositive("pos"); var neg = addedProfileraw.GetOnlyNegative("neg"); var addedProfile = pos.Add(neg, "added"); var maxDailyGen = addedProfile.MakeDailyAverages().Values.Max() * 24 * 4; double storageSize = maxDailyGen * 2; MakeXlsForCurrentProfile(slice); MakeExampleWsForSmartgrid(slice, addedProfile, storageSize, 1); MakeExampleWsForSmartgrid(slice, addedProfile, storageSize, 0.5); MakeStorageSizeSheet(slice, maxDailyGen, addedProfile); MakeAbregelungWorksheet(slice, maxDailyGen, addedProfile); }
protected override void RunActualProcess(ScenarioSliceParameters slice) { var fn = Path.Combine(FilenameHelpers.GetTargetDirectory(MyStage, SequenceNumber, Name, slice, Services.RunningConfig), "Export"); HouseProcessor hp = new HouseProcessor(Services, fn, MyStage); hp.ProcessAllHouses(slice, MakeAndRegisterFullFilename, HouseProcessor.ProcessingMode.Preparing, DevelopmentStatus); }
protected override void RunActualProcess(ScenarioSliceParameters slice) { { var smartSlice = slice.CopyThisSlice(); smartSlice.SmartGridEnabled = true; var path = FilenameHelpers.GetTargetDirectory(Stage.ProfileGeneration, E_ApplySmartGridToGeneratedProfiles.MySequenceNumber, nameof(E_ApplySmartGridToGeneratedProfiles), smartSlice, Services.RunningConfig); var di = new DirectoryInfo(path); if (di.Exists) { // not every scenario has a smart version var csvs1 = ReadCSVFiles(GenerationOrLoad.Load, di); ProcessAllCharts(csvs1, smartSlice); var csvs2 = ReadCSVFiles(GenerationOrLoad.Generation, di); ProcessAllCharts(csvs2, smartSlice); } } { var path = FilenameHelpers.GetTargetDirectory(Stage.ProfileGeneration, B_LoadProfileGenerator.MySequenceNumber, nameof(B_LoadProfileGenerator), slice, Services.RunningConfig); var di = new DirectoryInfo(Path.Combine(path, "Export")); if (!di.Exists) { throw new FlaException("Directory " + di.FullName + " does not exist"); } var csvs1 = ReadCSVFiles(GenerationOrLoad.Load, di); ProcessAllCharts(csvs1, slice); var csvs2 = ReadCSVFiles(GenerationOrLoad.Generation, di); ProcessAllCharts(csvs2, slice); } }
protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> scenarioSliceList) { ScenarioSliceParameters slice = scenarioSliceList.Last(); // Create a MigraDoc document var pdfDstPath = FilenameHelpers.GetTargetDirectory(Stage.PDF, SequenceNumber, Name, slice); var document = CreateDocument(); ProcessScenario(document, slice.DstScenario); var renderer = new PdfDocumentRenderer(true) { Document = document }; renderer.RenderDocument(); // Save the document... if (!Directory.Exists(pdfDstPath)) { Directory.CreateDirectory(pdfDstPath); } var filename = "Report." + slice.DstScenario + ".pdf"; var dstFullName = Path.Combine(pdfDstPath, filename); if (File.Exists(dstFullName)) { File.Delete(dstFullName); } renderer.PdfDocument.Save(dstFullName); GC.WaitForPendingFinalizers(); GC.Collect(); // ...and start a viewer. // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (Startpdf) { Process.Start(dstFullName); } }
public string GetResultFullPath(int sequenceNumber, [JetBrains.Annotations.NotNull] string className) => FilenameHelpers.GetTargetDirectory(MyStage, sequenceNumber, className, _slice, _config);
public string FullTargetDirectory() => FilenameHelpers.GetTargetDirectory(_stage, _sequenceNumber, _className, _slice, _services.RunningConfig);
public string FullPyFileName() { var targetdir = FilenameHelpers.GetTargetDirectory(_stage, _sequenceNumber, _className, _slice, _services.RunningConfig); return(Path.Combine(targetdir, ArrowName + ".py")); }
public string GetThisTargetDirectory() => FilenameHelpers.GetTargetDirectory(MyStage, SequenceNumber, Name, Constants.PresentSlice, Services.RunningConfig);