Esempio n. 1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            wndDevice WndDevice = new wndDevice();

            if (WndDevice.ShowDialog() == true)
            {
                Members.Device dev = new Members.Device();
                dev.Name     = WndDevice.DevName;
                dev.IP       = WndDevice.IP;
                dev.WorkToTO = WndDevice.WorkToTo;
                dev.IsComm   = false;
                Devices.Add(dev);
                ent.Devices.Add(new MonitoringDGU.Devices()
                {
                    Name = dev.Name, IP = dev.IP, FullWork = 0, WorkToTO = dev.WorkToTO
                });
                ent.SaveChanges();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Функция обновления наработки
 /// </summary>
 /// <param name="obj"></param>
 private void UpdateWorkTime(object obj)
 {
     try
     {
         foreach (var device in Devices)
         {
             if (device.IsComm == false && device.IsActive && device.FreqEngine > 0)
             {
                 device.FullWork++;
                 device.WorkToTO--;
                 //Обновляем наработку и время до то в БД.
                 LocalDataEntities ent = new LocalDataEntities();
                 var devFromDb         = ent.Devices.FirstOrDefault(d => d.ID == device.ID);
                 devFromDb.WorkToTO = device.WorkToTO;
                 devFromDb.FullWork = device.FullWork;
                 ent.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
     }
 }