public static void Remove(int id) { using (var db = new IotContext()) { db.Database.ExecuteSqlCommand(@"DELETE FROM CellCultivations WHERE Id=?;", id); } }
protected override void OnStartup(StartupEventArgs e) { var processName = Assembly.GetExecutingAssembly().GetName().Name; int processCount = Process.GetProcessesByName(processName).Length; if (processCount > 1) { MessageBox.Show("程序运行中,请关闭后重试"); Environment.Exit(-2); } base.OnStartup(e); var bootstrapper = new Bootstrapper(); bootstrapper.Run(); // Application.Current.MainWindow.GoFullscreen(); var _regionManager = bootstrapper.Container.Resolve <IRegionManager>(); _regionManager?.RequestNavigate("ContentRegion", "Index"); Config.DetectorId = 0x01; Task.Run(() => { using (var ctx = new IotContext()) { ctx.Initialize(); } }); }
public static IList <CellCultivation> GetCultivationsFromDb() { using (var db = new IotContext()) { return(db.CellCultivations.ToList()); } }
public static IList <AppException> GetUnhandleException() { using (var db = new IotContext()) { return(db.AppExceptions.ToList()); } }
public static void RemovePumpCultivationsByCultivationId(int id) { using (var db = new IotContext()) { db.Database.ExecuteSqlCommand(@"DELETE FROM TPumpCultivation WHERE CultivationId=?;", id); } }
public static void SaveGasRecord(GasRecord record) { using (var ctx = new IotContext()) { ctx.GasRecords.Add(record); ctx.SaveChanges(); } }
public static void SaveTemperatureRecord(TemperatureRecord record) { using (var ctx = new IotContext()) { ctx.TemperatureRecords.Add(record); ctx.SaveChanges(); } }
public static void MarkException(AppException exception) { using (var db = new IotContext()) { db.AppExceptions.Remove(exception); db.SaveChanges(); } }
public static void Save(AppException exception) { using (var db = new IotContext()) { db.AppExceptions.Add(exception); db.SaveChanges(); } }
public static IotContext GetIotContext() { var options = new DbContextOptionsBuilder <IotContext>() .UseSqlite($"Data Source=augmento.db") .Options; var context = new IotContext(options); context.Initilize(); return(context); }
public static string GetLastDbName() { using (var db = new IotContext()) { var p = db.CellCultivations.OrderByDescending(each => each.CreatedAt).FirstOrDefault(); if (p == null) { return(string.Empty); } return(p.CreatedAt + ".db"); } }
public static int GetLastCultivationId() { var id = CurrentContext.SysCache?.System?.CellCultivation?.Id ?? 0; if (id > 0) { return(id); } using (var db = new IotContext()) { var p = db.CellCultivations.OrderByDescending(doc => doc.Id).FirstOrDefault(); return(p?.Id ?? 0); } }
public static SystemIntegration SaveCultivations(SystemIntegration schedule) { if (schedule == null) { return(null); } DeviceService.InitData(); var tSchedule = schedule.CellCultivation; tSchedule.BatchNumber = CurrentContext.BatchNumber; tSchedule.CreatedAt = Common.Utility.Common.ToUnixTime(DateTime.Now); using (var db = new IotContext()) { db.CellCultivations.Add(tSchedule); db.SaveChanges(); } using (var db = new IotContext()) { schedule.Rocker.CultivationId = tSchedule.Id; db.Rockers.Add(schedule.Rocker); schedule.Gas.CultivationId = tSchedule.Id; db.Gases.Add(schedule.Gas); schedule.TemperatureGauge.DeviceId = tSchedule.Id; db.TemperatureGauges.Add(schedule.TemperatureGauge); var p = new List <Pump>() { schedule.PumpIn, schedule.PumpOut }; foreach (var each in p) { each.CultivationId = tSchedule.Id; db.Pumps.Add(each); } db.SaveChanges(); } return(schedule); }
public static void Initilize(this IotContext _context) { _context.Database.Migrate(); _context.Database.EnsureCreated(); }
public SiteService(IotContext context) { _context = context; }
public LocationService(IotContext context) { _context = context; }
public BuildingService(IotContext context) { _context = context; }
public RegionService(IotContext context) { _context = context; }