Ejemplo n.º 1
0
 public void CheckMesInfo(object sender, ElapsedEventArgs e)
 {
     if (AppCurrent.IsRunning && Current.Mes.IsEnabled && !Current.Mes.IsOffline)
     {
         MES.UploadMachineInfo("S");
         MES.Upload();
     }
 }
Ejemplo n.º 2
0
        public static void Insert()
        {
            if (Battery.Id > 0)
            {
                Context.InsulationContext.DataLogs.Add(new InsulationDataLog()
                {
                    User        = AppCurrent.User,
                    Battery     = Battery,
                    Resistance  = 0,
                    Voltage     = 0,
                    TimeSpan    = 0,
                    Temperature = 0,
                    IsUploaded  = false,
                    DateTime    = DateTime.Now
                });
                Context.InsulationContext.SaveChanges();

                AppCurrent.YieldNow.FeedingOK++;

                Battery = new Battery();
            }

            if (Resistance > -1)
            {
                var data = Context.InsulationContext.DataLogs.Where(d => d.Resistance == 0)
                           .OrderByDescending(d => d.DateTime).Take(3).OrderBy(d => d.DateTime).FirstOrDefault();
                if (data != null)
                {
                    data.Resistance = Resistance;
                    data.Voltage    = Voltage;
                    data.TimeSpan   = TimeSpan;
                    Context.InsulationContext.SaveChanges();
                }
                Resistance = -1;
            }

            if (Temperature > -1)
            {
                var data = Context.InsulationContext.DataLogs.Where(d => d.Temperature == 0)
                           .OrderByDescending(d => d.DateTime).Take(3).OrderBy(d => d.DateTime).FirstOrDefault();
                if (data != null)
                {
                    data.Temperature = Temperature;
                    Context.InsulationContext.SaveChanges();

                    if (data.Id > 0)
                    {
                        MES.Upload(data.Id);
                    }
                }
                Temperature = -1;
            }
        }