public void RunTest() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { HouseholdKeyLogger ael = new HouseholdKeyLogger(wd.SqlResultLoggingService); HouseholdKey key = new HouseholdKey("hhkey"); List <IDataSaverBase> savers = new List <IDataSaverBase> { ael }; InputDataLogger idl = new InputDataLogger(savers.ToArray()); HouseholdKeyEntry ae1 = new HouseholdKeyEntry(key, "hhname", HouseholdKeyType.House, "desc", null, null); idl.Save(ae1); List <HouseholdKeyEntry> aes = new List <HouseholdKeyEntry> { ae1 }; var res = ael.Load(); var s1 = JsonConvert.SerializeObject(aes, Formatting.Indented); var s2 = JsonConvert.SerializeObject(res, Formatting.Indented); s1.Should().Be(s2); wd.CleanUp(); } }
public void RunTest() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { ActionEntryLogger ael = new ActionEntryLogger(wd.SqlResultLoggingService); HouseholdKey key = new HouseholdKey("hhkey"); List <IDataSaverBase> savers = new List <IDataSaverBase> { ael }; InputDataLogger idl = new InputDataLogger(savers.ToArray()); TimeStep ts = new TimeStep(1, 0, true); ActionEntry ae1 = new ActionEntry("blub", key, ts, DateTime.Now, "123".ToStrGuid(), "name", false, "affname", "affguid".ToStrGuid(), 0, BodilyActivityLevel.Low); List <IHouseholdKey> aes = new List <IHouseholdKey> { ae1 }; idl.SaveList(aes); var res = ael.Read(key); var s1 = JsonConvert.SerializeObject(aes, Formatting.Indented); var s2 = JsonConvert.SerializeObject(res, Formatting.Indented); s1.Should().Be(s2); wd.CleanUp(); } }
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 void RunColumnEntryLoggerTest() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { ColumnEntryLogger ael = new ColumnEntryLogger(wd.SqlResultLoggingService); HouseholdKey key = new HouseholdKey("hhkey"); List <IDataSaverBase> savers = new List <IDataSaverBase> { ael }; InputDataLogger idl = new InputDataLogger(savers.ToArray()); CalcLoadTypeDto cltd = new CalcLoadTypeDto("ltname", "kw", "kwh", 1, false, "guid".ToStrGuid()); CalcDeviceDto cdd = new CalcDeviceDto("device", "guid".ToStrGuid(), key, OefcDeviceType.Device, "devcatname", "", "guid".ToStrGuid(), "guid".ToStrGuid(), "loc"); ColumnEntry ce = new ColumnEntry("name", 1, "locname", "guid".ToStrGuid(), key, cltd, "oefckey", "devicecategory", cdd); List <ColumnEntry> aes = new List <ColumnEntry> { ce }; idl.Save(aes); var res = ael.Read(key); var s1 = JsonConvert.SerializeObject(aes, Formatting.Indented); var s2 = JsonConvert.SerializeObject(res, Formatting.Indented); File.WriteAllText(wd.Combine("original.json"), s1); File.WriteAllText(wd.Combine("deserialized.json"), s2); s1.Should().Be(s2); } //wd.CleanUp(); }
public void CalcAffordanceDtoLoggerTest() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { CalcAffordanceDtoLogger ael = new CalcAffordanceDtoLogger(wd.SqlResultLoggingService); HouseholdKey key = new HouseholdKey("hhkey"); List <IDataSaverBase> savers = new List <IDataSaverBase> { ael }; InputDataLogger idl = new InputDataLogger(savers.ToArray()); //CalcLoadTypeDto cldto = new CalcLoadTypeDto("loadtype", 1, "kw", "kwh", 1, true, "guid"); CalcProfileDto cpd = new CalcProfileDto("name", 1, ProfileType.Absolute, "source", Guid.NewGuid().ToStrGuid()); AvailabilityDataReferenceDto adrd = new AvailabilityDataReferenceDto("blub", "availguid".ToStrGuid()); CalcAffordanceDto cadto = new CalcAffordanceDto("blub", 1, cpd, "locname", "locguid".ToStrGuid(), true, new List <CalcDesireDto>(), 1, 100, PermittedGender.All, true, 1, 1, 1, 1, "affcat", false, false, new List <CalcAffordanceVariableOpDto>(), new List <VariableRequirementDto>(), ActionAfterInterruption.GoBackToOld, "timelimitname", 100, true, "srctrait", "guid".ToStrGuid(), adrd, key, BodilyActivityLevel.Low); cadto.AddDeviceTuple("devname", "deviguid".ToStrGuid(), cpd, "calcloadtypename", "loadtypeguid".ToStrGuid(), 1, new TimeSpan(0, 1, 0), 1, 1); List <IHouseholdKey> aes = new List <IHouseholdKey> { cadto }; idl.SaveList(aes); var res = ael.Load(key); var s1 = JsonConvert.SerializeObject(aes, Formatting.Indented); var s2 = JsonConvert.SerializeObject(res, Formatting.Indented); s1.Should().Be(s2); wd.CleanUp(); } }
public void ReadTest() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { DeviceActivationEntryLogger ael = new DeviceActivationEntryLogger(wd.SqlResultLoggingService); HouseholdKey key = new HouseholdKey("hhkey"); List <IDataSaverBase> savers = new List <IDataSaverBase> { ael }; InputDataLogger idl = new InputDataLogger(savers.ToArray()); CalcLoadTypeDto cldto = new CalcLoadTypeDto("loadtype", "kw", "kwh", 1, true, "guid".ToStrGuid()); TimeStep ts = new TimeStep(1, 1, true); CalcDeviceDto cdd = new CalcDeviceDto("devicename", "device".ToStrGuid(), key, OefcDeviceType.Device, "devicecategoryname", "additionalname", "deviceguid".ToStrGuid(), "locationguid".ToStrGuid(), "locationname"); DeviceActivationEntry ae1 = new DeviceActivationEntry("affordancename", cldto, 1, "activator", 1, ts, cdd); List <IHouseholdKey> aes = new List <IHouseholdKey> { ae1 }; idl.SaveList(aes); var res = ael.Read(key); var s1 = JsonConvert.SerializeObject(aes, Formatting.Indented); var s2 = JsonConvert.SerializeObject(res, Formatting.Indented); s1.Should().Be(s2); wd.CleanUp(); } }
public void InitializeDataLogging() { SqlResultLoggingService = new SqlResultLoggingService(_lastDirectory); List <IDataSaverBase> loggers = new List <IDataSaverBase> { new CalcAutoDevDtoLogger(SqlResultLoggingService), new CalcDeviceDtoLogger(SqlResultLoggingService) }; InputDataLogger = new InputDataLogger(loggers.ToArray()); }