Beispiel #1
0
        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); }
        }
Beispiel #2
0
        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 { }
            }
        }
Beispiel #3
0
 public BMachineStatistic GetStatistic(string Date)
 {
     try
     {
         using (BeamCutContext = new BeamCutContext(database))
         {
             return(BeamCutContext.BMachineStatistices.Where(i => i.Date == Date).First());
         }
     }
     catch { return(null); }
 }
Beispiel #4
0
 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); }
 }
Beispiel #5
0
 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); }
 }
Beispiel #6
0
 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); }
 }
Beispiel #7
0
 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); }
 }
Beispiel #8
0
 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); }
 }
Beispiel #9
0
 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); }
 }
Beispiel #10
0
 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); }
 }