public List <BeamCutInterface> GetBeamCutInterfaces(int bdeviceId, DateTime begin, DateTime end) { try { using (BeamCutContext = new BeamCutContext(database)) { var binfs = BeamCutContext.BeamCutInterfaces .Where(i => i.BeamCutDevice_Id == bdeviceId) .ToList(); begin = new DateTime(begin.Year, begin.Month, begin.Day, 0, 0, 0); end = new DateTime(end.Year, end.Month, end.Day, 23, 0, 0); List <BeamCutInterface> result = new List <BeamCutInterface>(); foreach (var item in binfs) { try { DateTime dateTime = (DateTime)item.StartCutTime; if (dateTime >= begin && dateTime <= end) { result.Add(item); } } catch { } } return(result); } } catch { return(null); } }
public void BeamCutDevices() { using (var context = new BeamCutContext(Database)) { if (context.Database.Exists()) { Console.WriteLine("BeamCutContext is existing"); return; } context.Database.Create(); Console.WriteLine("BeamCutContext is created successfully"); for (int i = 1; i <= 10; i++) { context.BeamCutDevices.Add(new BeamCutDevice { Building_Id = 1, Name = $"BC{i}", }); context.SaveChanges(); } try { context.Database.ExecuteSqlCommand("DROP TABLE [__MigrationHistory]"); context.SaveChanges(); } catch { } } }
public BMachineStatistic GetStatistic(string Date) { try { using (BeamCutContext = new BeamCutContext(database)) { return(BeamCutContext.BMachineStatistices.Where(i => i.Date == Date).First()); } } catch { return(null); } }
public BeamCutPo GetBeamCutPo(int originalPoId, int componentId) { try { using (BeamCutContext = new BeamCutContext(database)) { return(BeamCutContext.BeamCutPos .Where(i => i.OriginalPo_Id == originalPoId && i.Component_Id == componentId) .First()); } } catch { return(null); } }
public ICollection <BeamCutPo> GetBeamCutPos(int originalPoId) { try { using (BeamCutContext = new BeamCutContext(database)) { return(BeamCutContext.BeamCutPos .Where(i => i.OriginalPo_Id == originalPoId) .ToList()); } } catch { return(null); } }
public BeamCutPo GetBeamCutPo(int clonePoId) { try { using (BeamCutContext = new BeamCutContext(database)) { return(BeamCutContext.BeamCutPos .Include("BeamCutSeqs") .Where(i => i.id == clonePoId) .First()); } } catch { return(null); } }
public BeamCutInterface GetLastInterface(int deviceId) { try { using (BeamCutContext = new BeamCutContext(database)) { return(BeamCutContext.BeamCutInterfaces .Where(i => i.BeamCutDevice_Id == deviceId) .OrderByDescending(i => i.id) .FirstOrDefault()); } } catch { return(null); } }
public List <BDeviceCutTimeRecord> GetBeamCutDeviceTimeLineRecorde(int bdeviceId, DateTime date) { try { using (BeamCutContext = new BeamCutContext(database)) { string Date = date.ToString("dd / MM/yyyy"); return(BeamCutContext.BDeviceCutTimeRecords .Where(i => i.BeamCutDevice_Id == bdeviceId && i.Date.Contains(Date)) .ToList()); } } catch { return(null); } }
public BDeviceOrder GetBDeviceOrder(Schedule schedule) { try { using (BeamCutContext = new BeamCutContext(database)) { return(BeamCutContext.BDeviceOrders .Where(i => i.PoNumber == schedule.PoNumber && i.ProductionLine_Id == schedule.ProductionLine_Id && i.PoQty == schedule.Quantity) .First()); } } catch { return(null); } }
public BeamCutPo AddNewBeamCutPo(int originalPoId, int componentId) { try { using (BeamCutContext = new BeamCutContext(database)) { var result = BeamCutContext.BeamCutPos.Add(new BeamCutPo { OriginalPo_Id = originalPoId, Component_Id = componentId }); BeamCutContext.SaveChanges(); return(result); } } catch { return(null); } }