public AirConditionerController(DevicesContext context) { this.db = context; if (!db.AirConditioners.Any()) { db.AirConditioners.Add(new AirConditioner { Name = "Кондиционер А-505", Company = "Bosh", Power = false, IsConect = false, Mode = 0, Temperature = 0, TemperatureSensorReadings = 0, IsWater = false }); db.AirConditioners.Add(new AirConditioner { Name = "Ионизатор воздуха напольный R-351", Company = "Polaris", Power = true, IsConect = false, Mode = 5, Temperature = 20, TemperatureSensorReadings = 15, IsWater = true }); db.SaveChanges(); } }
public MoveSensorController(DevicesContext context) { this.db = context; if (!db.MoveSensors.Any()) { db.MoveSensors.Add(new MoveSensor { Name = "SCP-173", Company = "Secure Contain Protect", Power = false, IsConect = false, IsMove = false, IsSecureMod = false }); db.MoveSensors.Add(new MoveSensor { Name = "Move-500", Company = "Shield", Power = true, IsConect = false, IsMove = false, IsSecureMod = false }); db.SaveChanges(); } }
public DoorLockController(DevicesContext context) { this.db = context; if (!db.DoorLocks.Any()) { db.DoorLocks.Add(new DoorLock { Name = "Замок ESP8266", Company = "OOO Electronic", Power = false, IsConect = false, IsOpen = false }); db.DoorLocks.Add(new DoorLock { Name = "Замок Малютка", Company = "www.DoorLocks.com", Power = false, IsConect = false, IsOpen = false }); db.DoorLocks.Add(new DoorLock { Name = "Еврозамок", Company = "www.DoorLocks.com", Power = false, IsConect = true, IsOpen = true }); db.SaveChanges(); } }
public LampController(DevicesContext context) { this.db = context; if (!db.Lamps.Any()) { db.Lamps.Add(new Lamp { Name = "Lamp 220v", Company = "Light And Magic", Power = false, IsConect = true, Brightness = 0 }); db.Lamps.Add(new Lamp { Name = "Lamp 220v", Company = "Light And Magic", Power = false, IsConect = false, Brightness = 0 }); db.Lamps.Add(new Lamp { Name = "Lamp 100w", Company = "Panasonic", Power = true, IsConect = true, Brightness = 255 }); db.SaveChanges(); } }
public HomeController(DevicesContext context) { this.db = context; /* * if (db.Devices.Count() == 0) * { * * Device rosberyPi1 = new Device { Name = "Dimmmas_Rosbery" }; * Device rosberyPi2 = new Device { Name = "Mxs_Rosbery" }; * * * Product product1 = new Product { Name = "Tomato", Device = rosberyPi1, Count = 19 }; * Product product2 = new Product { Name = "Cucumber", Device = rosberyPi1, Count = 2 }; * Product product3 = new Product { Name = "Beer", Device = rosberyPi1, Count = 3 }; * Product product4 = new Product { Name = "Beet", Device = rosberyPi1, Count = 5 }; * Product product5 = new Product { Name = "Egg", Device = rosberyPi2, Count = 1 }; * Product product6 = new Product { Name = "Tomato", Device = rosberyPi2, Count = 0 }; * Product product7 = new Product { Name = "Cucumber", Device = rosberyPi2, Count = 6 }; * Product product8 = new Product { Name = "Beet", Device = rosberyPi2, Count = 21 }; * * rosberyPi1.Products.Add(product1); * rosberyPi1.Products.Add(product2); * rosberyPi1.Products.Add(product3); * rosberyPi1.Products.Add(product4); * rosberyPi2.Products.Add(product5); * rosberyPi2.Products.Add(product6); * rosberyPi2.Products.Add(product7); * rosberyPi2.Products.Add(product8); * * NotificationFromDevice notification1 = new NotificationFromDevice { Massage = "in" , Product = product1 }; * NotificationFromDevice notification2 = new NotificationFromDevice { Massage = "out", Product = product2 }; * NotificationFromDevice notification3 = new NotificationFromDevice { Massage = "out", Product = product3 }; * NotificationFromDevice notification4 = new NotificationFromDevice { Massage = "in", Product = product4 }; * NotificationFromDevice notification5 = new NotificationFromDevice { Massage = "in", Product = product5 }; * NotificationFromDevice notification6 = new NotificationFromDevice { Massage = "out", Product = product6 }; * NotificationFromDevice notification7 = new NotificationFromDevice { Massage = "out", Product = product7 }; * NotificationFromDevice notification8 = new NotificationFromDevice { Massage = "in", Product = product8 }; * * product1.UpdatesList.Add(notification1); * product2.UpdatesList.Add(notification2); * product3.UpdatesList.Add(notification3); * product4.UpdatesList.Add(notification4); * product5.UpdatesList.Add(notification5); * product6.UpdatesList.Add(notification6); * product7.UpdatesList.Add(notification7); * product8.UpdatesList.Add(notification8); * * * db.Devices.AddRange(rosberyPi1, rosberyPi2); * db.Products.AddRange(product1, product2, product3, product4, product5, product6, product7, product8); * db.NotificationFromDevices.AddRange(notification1, notification2, notification3, notification4, notification5, * notification6, notification7, notification8); * db.SaveChanges(); * }*/ }
//TODO public List <Device> GetDeviceBySerial(string serial) { List <Device> devices = new List <Device>(); using (var db = new DevicesContext(_options)) { devices = db.Devices.Where(x => x.d_serial.ToLower() == serial.Trim().ToLower()).ToList(); } return(devices); }
public PostgreSQLFixture() { if (_container == null) { _container = BuildConsulContainer(); _container.StartAsync(); // Let's wait for the container startup. Task.Delay(20 * 1000).Wait(); } var dbContext = new DevicesContext(new DbContextOptionsBuilder().UseNpgsql(CONNECTION_STRING).Options); _dataProvider = new DataProvider(dbContext); }
//TODO public string InsertCounter(string serial, string brand, string model, string type) { using (var db = new DevicesContext(_options)) { db.Devices.Add(new Device { d_serial = serial }); db.Counters.Add(new Counter { c_serial = serial, c_brand = brand, c_model = model, c_type = type }); db.SaveChanges(); } return("Counter registered successfully."); }
//TODO public string InsertGateway(string serial, string brand, string ip, string port) { using (var db = new DevicesContext(_options)) { db.Devices.Add(new Device { d_serial = serial }); db.Gateways.Add(new Gateway { g_serial = serial, g_brand = brand, g_ip = ip, g_port = port }); db.SaveChanges(); } return("Gateway registered successfully."); }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); var configuration = builder.Build(); var connectionString = configuration.GetConnectionString("Devices"); var optionsBuilder = new DbContextOptionsBuilder <DevicesContext>(); optionsBuilder.UseSqlite(connectionString, b => b.MigrationsAssembly("ANSDataContextHelper")); var context = new DevicesContext(optionsBuilder.Options); Console.WriteLine("Total devices in DB: {0}", context.Devices.Count()); }
static void Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); var configuration = builder.Build(); var connectionString = configuration.GetConnectionString("Devices"); var context = DevicesContext.CreateContextWithSQLite(connectionString); Console.WriteLine("Total registered devices: {0}", context.Devices.Count()); var applePusher = new Pusher { Configuration = configuration }; var api = new AdamantApi(configuration); var worker = new AdamantPollingWorker { Delay = TimeSpan.FromSeconds(2), Pusher = applePusher, AdamantApi = api, Context = context }; if (!Boolean.TryParse(configuration["PollingOptions:Warmup"], out bool warmup)) { warmup = true; } Console.WriteLine("Any key to stop..."); applePusher.Start(); worker.StartPolling(warmup); Console.ReadKey(); applePusher.Stop(); worker.StopPolling(); }
public HeaterController(DevicesContext context) { this.db = context; if (!db.Heaters.Any()) { db.Heaters.Add(new Heater { Name = "Обогреватель Ламповый", Company = "PodogrevPlus", Power = false, IsConect = false, Temperature = 0 }); db.Heaters.Add(new Heater { Name = "Обогреватель 11Mega", Company = "iChill", Power = true, IsConect = false, Temperature = 20 }); db.SaveChanges(); } }
public PowerSocketController(DevicesContext context) { this.db = context; if (!db.PowerSockets.Any()) { db.PowerSockets.Add(new PowerSocket { Name = "Розетка 1", Company = "Electronic", Power = false, IsConect = false, IsOn = true }); db.PowerSockets.Add(new PowerSocket { Name = "Розетка 2", Company = "Thunderstorm", Power = true, IsConect = false, IsOn = false }); db.SaveChanges(); } }
public TemperatureSensorController(DevicesContext context) { this.db = context; if (!db.TemperatureSensors.Any()) { db.TemperatureSensors.Add(new TemperatureSensor { Name = "SCP-106", Company = "Secure Contain Protect", Power = false, IsConect = false, TemperatureSensorReadings = 0 }); db.TemperatureSensors.Add(new TemperatureSensor { Name = "Температурный датчик Е241", Company = "Polaris", Power = true, IsConect = false, TemperatureSensorReadings = 15, }); db.SaveChanges(); } }
public DevicesController(DevicesContext context) { _context = context; }
public CheckoutService(DevicesContext context) { _context = context; }
public ClaimsTransformer(DevicesContext context) { _context = context; }
internal DevicesStatesWatcher(DevicesContext context, ILogger logger) { _logger = logger; _context = context; }
public UserService(DevicesContext context) { _context = context; }
public NotificationFromDevicesController(DevicesContext context) { _context = context; }
public DevicesService(IConfiguration configuration, DevicesContext context) { _configuration = configuration; _context = context; }
public SiteService(DevicesContext context) { _context = context; }
public DataEntity(DevicesContext dbContext) { _dbContext = dbContext; }
public DataProvider(DevicesContext dbContext) { _dbContext = dbContext; _consumerDataEntity = new DataEntity <Consumer>(_dbContext); _deviceDataEntity = new DataEntity <Device>(_dbContext); }