public void TryCleaningEachTable() { CleanTestBase.RunAutomatically(false); using (var db1 = new DatabaseSetup("TryCleaningEach")) { var alltables = LongtermTests.GetTableList(db1); db1.Cleanup(); for (var index = 0; index < alltables.Count; index++) { Logger.Info("processing table " + index + " out of " + alltables.Count); var table = alltables[index]; if (table == "tblLPGVersion") { continue; } using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { DBBase.HideDeleteMessages(); Command.HideDeleteMessages(); db.ClearTable(table); var oldSim = new Simulator(db.ConnectionString); // need to load it for testing Logger.Info(oldSim.ModularHouseholds.It.Count.ToString(CultureInfo.InvariantCulture)); db.Cleanup(); } } } CleanTestBase.RunAutomatically(true); }
public Game() { log = new Logger(); log.Info("Setting up game..."); trySetConnectDetails(); Window.Title = "Test Client"; Window.AllowUserResizing = false; graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; config = new NetPeerConfiguration(appName); config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse); client = new NetClient(config); // Start with an empty player manager. playerManager = new PlayerManager(); NetDebugComponent netDebugComponent = new NetDebugComponent(this, ref client); this.Components.Add(netDebugComponent); netDebugComponent.Visible = true; PlayerListDebugComponent playerListDebugComponent = new PlayerListDebugComponent(this, ref playerManager); this.Components.Add(playerListDebugComponent); playerListDebugComponent.Visible = true; }
public void RunHouseholdTemplate() { using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { Simulator sim = new Simulator(db.ConnectionString); string dir = wd.Combine("DirectHouseJobs"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Random rnd = new Random(); List <string> houseTypes = sim.HouseTypes.It.Select(x => x.Name.Substring(0, x.Name.IndexOf(" ", StringComparison.Ordinal))).ToList(); foreach (var mhh in sim.HouseholdTemplates.It) { for (int i = 0; i < 100; i++) { HouseCreationAndCalculationJob hj = new HouseCreationAndCalculationJob("TemplatedRandomHouseType", "2019", "TK", HouseDefinitionType.HouseData); string ht = houseTypes[rnd.Next(houseTypes.Count)]; Logger.Info(ht); hj.House = new HouseData(Guid.NewGuid().ToStrGuid(), ht, 10000, 10000, "House for " + mhh.Name + " " + i); hj.House.Households.Add(new HouseholdData(Guid.NewGuid().ToString(), mhh.Name, null, null, null, null, HouseholdDataSpecificationType.ByTemplateName)); hj.House.Households[0].HouseholdTemplateSpec = new HouseholdTemplateSpecification(mhh.Name); SetCalcSpec(hj, sim); if (hj.CalcSpec?.CalcOptions == null) { throw new LPGException("calcoption not set"); } hj.CalcSpec.CalcOptions.Add(CalcOption.EnergyCarpetPlot); hj.CalcSpec.CalcOptions.Add(CalcOption.HouseSumProfilesFromDetailedDats); string fn = Path.Combine(dir, AutomationUtili.CleanFileName(mhh.Name) + "." + i + ".json"); File.WriteAllText(fn, JsonConvert.SerializeObject(hj, Formatting.Indented)); } } //CopyAll(new DirectoryInfo(dir), new DirectoryInfo(@"X:\HouseJobs\Blockstrom\TemplatedHouses")); } } }
public void MakeCalcLocationsTestWithDeviceCategory() { using WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()); var builder = new ContainerBuilder(); var r = new Random(1); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(2018, 1, 1) .SetEndDate(new DateTime(2018, 1, 1, 2, 0, 0)).SetSettlingDays(0).EnableShowSettlingPeriod(); //CalcFactoryParameters.SetSkipChecking(true); //var nr = new NormalRandom(0, 1, r); var locations = new List <Location>(); var loc = new Location("loc", 1, string.Empty, Guid.NewGuid().ToStrGuid()); locations.Add(loc); var devices = new ObservableCollection <RealDevice>(); var dc = new DeviceCategory("dc", -1, string.Empty, false, devices, Guid.NewGuid().ToStrGuid(), 1, true); var rd = new RealDevice("rd", 1, string.Empty, dc, string.Empty, false, false, string.Empty, Guid.NewGuid().ToStrGuid(), 1); var rd2 = new RealDevice("rd2", 1, string.Empty, dc, string.Empty, false, false, string.Empty, Guid.NewGuid().ToStrGuid(), 1); dc.SubDevices.Add(rd); loc.AddDevice(dc, false); loc.AddDevice(rd2, false); var deviceLocationDict = new Dictionary <CalcLocationDto, List <IAssignableDevice> >(); List <DeviceCategoryDto> devcat = new List <DeviceCategoryDto> { new DeviceCategoryDto(dc.FullPath, Guid.NewGuid().ToStrGuid()) }; devices.Add(rd); devices.Add(rd2); //var dict =new Dictionary<CalcLocation, List<IAssignableDevice>>(); var allDeviceActions = new ObservableCollection <DeviceAction>(); //var locdict = new Dictionary<Location, CalcLocation>(); builder.Register(x => new CalcLoadTypeDtoDictionary(new Dictionary <VLoadType, CalcLoadTypeDto>())).As <CalcLoadTypeDtoDictionary>() .SingleInstance(); builder.Register(x => new CalcLoadTypeDictionary(new Dictionary <CalcLoadTypeDto, CalcLoadType>())).As <CalcLoadTypeDictionary>() .SingleInstance(); builder.Register(x => new DeviceCategoryPicker(r, null)).As <IDeviceCategoryPicker>().SingleInstance(); builder.Register(x => calcParameters).As <CalcParameters>().SingleInstance(); //builder.RegisterType<CalcLocationFactory>().As<CalcLocationFactory>().SingleInstance(); Mock <IOnlineDeviceActivationProcessor> odapmock = new Mock <IOnlineDeviceActivationProcessor>(); builder.Register(x => odapmock.Object).As <IOnlineDeviceActivationProcessor>().SingleInstance(); builder.Register(x => r).As <Random>().SingleInstance(); var idl = wd.InputDataLogger; builder.Register(x => idl).As <IInputDataLogger>().SingleInstance(); string path = wd.WorkingDirectory; builder.Register(x => new FileFactoryAndTracker(path, "HH1", idl)).As <FileFactoryAndTracker>() .SingleInstance(); builder.Register(x => new SqlResultLoggingService(path)).As <SqlResultLoggingService>().SingleInstance(); builder.Register(x => new DateStampCreator(x.Resolve <CalcParameters>())).As <DateStampCreator>().SingleInstance(); builder.Register(x => new DateStampCreator(x.Resolve <CalcParameters>())).As <DateStampCreator>().SingleInstance(); builder.Register(x => new OnlineLoggingData(x.Resolve <DateStampCreator>(), x.Resolve <IInputDataLogger>(), x.Resolve <CalcParameters>())) .As <OnlineLoggingData>().SingleInstance(); builder.Register(x => new LogFile(calcParameters, x.Resolve <FileFactoryAndTracker>())).As <ILogFile>().SingleInstance(); builder.RegisterType <CalcDeviceFactory>().As <CalcDeviceFactory>().SingleInstance(); builder.RegisterType <CalcLocationFactory>().As <CalcLocationFactory>().SingleInstance(); builder.RegisterType <CalcPersonFactory>().As <CalcPersonFactory>().SingleInstance(); builder.RegisterType <CalcModularHouseholdFactory>().As <CalcModularHouseholdFactory>().SingleInstance(); builder.RegisterType <CalcLocationDtoFactory>().As <CalcLocationDtoFactory>(); builder.RegisterType <InputDataLogger>().As <InputDataLogger>().SingleInstance(); builder.RegisterType <CalcRepo>().As <CalcRepo>().SingleInstance(); var container = builder.Build(); using (var scope = container.BeginLifetimeScope()) { var cldt = scope.Resolve <CalcLocationDtoFactory>(); var calcRepo = scope.Resolve <CalcRepo>(); LocationDtoDict calclocdict = new LocationDtoDict(); var locdtos = cldt.MakeCalcLocations(locations, new HouseholdKey("HH1"), EnergyIntensityType.EnergySaving, deviceLocationDict, allDeviceActions, calclocdict, devcat); CalcLocationFactory clf = scope.Resolve <CalcLocationFactory>(); DtoCalcLocationDict dtl = new DtoCalcLocationDict(); var clocations = clf.MakeCalcLocations(locdtos, dtl, calcRepo); clocations.Count.Should().Be(1); clocations[0].LightDevices.Count.Should().Be(2); foreach (var device in clocations[0].LightDevices) { Logger.Info(device.Name); } } wd.CleanUp(); }
/// <summary> /// Server entry point /// </summary> /// <param name="args"></param> static void Main(string[] args) { log = new Logger(); setupServer(); while (!Console.KeyAvailable || Console.ReadKey().Key != ConsoleKey.Escape) { if (isShuttingDown) break; handleIncomingMessages(); handleOutgoingMessages(); // sleep to allow other processes to run smoothly Thread.Sleep(1); } server.Shutdown("Server shutting down"); log.Info("Server shut down"); Console.ReadLine(); }
public static void Info(string message, Exception exception) { Logger?.Info(exception, message); }
public static void Info(string message) { Logger?.Info(message); }