예제 #1
0
 public static bool catinfoEnroll(deviceJson device)
 {
     try
     {
         cat_server.CAT_info currentinfo = new cat_server.CAT_info();
         deviceRefresh(ref currentinfo, device);
         using (cat_server.lab_server lab_server = new cat_server.lab_server())
         {
             if (CatReg.connect)
             {
                 var serverinfo = (from _uut in lab_server.CAT_info where _uut.SN == device.sn select _uut).FirstOrDefault();
                 if (serverinfo == null)
                 {
                     currentinfo.STATUS                  = CatStatus.uutStatus.STANDBY.ToString();
                     currentinfo.CurrentTask             = CatStatus.taskName.NO_TASK.ToString();
                     currentinfo.LastUsedTime            = DateTime.Now;
                     lab_server.Entry(currentinfo).State = System.Data.Entity.EntityState.Added;
                 }
                 else
                 {
                     lab_server.Entry(serverinfo).State = System.Data.Entity.EntityState.Modified;
                     currentinfo.STATUS       = CatReg.status.ToString();
                     currentinfo.CurrentTask  = CatReg.task_name;
                     currentinfo.LastUsedTime = DateTime.Now;
                     currentinfoCompare(ref serverinfo, currentinfo);
                 }
                 lab_server.SaveChanges();
             }
         }
         Console.WriteLine("enroll finish");
         return(true);
     }
     catch (DbEntityValidationException ex)
     {
         var entityError      = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
         var getFullMessage   = string.Join("; ", entityError);
         var exceptionMessage = string.Concat(ex.Message, "errors are: ", getFullMessage);
         //NLog
         Log(exceptionMessage);
         Console.WriteLine(exceptionMessage);
     }
     catch (Exception e)
     {
         Log(e.ToString());
         Console.WriteLine(e.ToString());
     }
     return(false);
 }
예제 #2
0
 private static void deviceRefresh(ref cat_server.CAT_info currentinfo, deviceJson device)
 {
     currentinfo.SN            = device.sn;
     currentinfo.BIOS          = device.bios;
     currentinfo.OS            = device.os;
     currentinfo.Image         = device.image;
     currentinfo.Platform      = device.platform;
     currentinfo.WWAN_Driver   = device.wwan[0].driver;
     currentinfo.WWAN_Firmware = device.wwan[0].firmware;
     currentinfo.WWAN_Modem    = device.wwan[0].modem;
     currentinfo.WWAN_Module   = device.wwan[0].hwid;
     currentinfo.WLAN_Driver   = device.wlan[0].driver;
     currentinfo.WLAN_Module   = device.wlan[0].hwid;
     currentinfo.NIC_Driver    = device.lan[0].driver;
     currentinfo.NIC_Module    = device.lan[0].hwid;
     currentinfo.BT_Driver     = device.bt[0].driver;
     currentinfo.BT_Module     = device.bt[0].hwid;
     currentinfo.NFC_Driver    = device.nfc[0].driver;
     currentinfo.NFC_Module    = device.nfc[0].hwid;
     currentinfo.RFID_Driver   = device.rfid[0].driver;
     currentinfo.RFID_Module   = device.rfid[0].hwid;
     currentinfo.GNSS_Driver   = device.wwan[0].gnss;
 }
예제 #3
0
 public static bool catinfoUpdate(cat_server.CAT_info catinfo)
 {
     try
     {
         using (cat_server.lab_server lab_server = new cat_server.lab_server())
         {
             if (CatReg.connect)
             {
                 var uut = (from _uut in lab_server.CAT_info where _uut.SN == catinfo.SN select _uut).FirstOrDefault();
                 if (uut == null)
                 {
                     throw new Exception("UUT NOT FOUND");
                 }
                 currentinfoCompare(ref uut, catinfo);
                 lab_server.Entry(uut).State = System.Data.Entity.EntityState.Modified;
                 lab_server.SaveChanges();
                 return(true);
             }
         }
     }
     catch (DbEntityValidationException ex)
     {
         var entityError      = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
         var getFullMessage   = string.Join("; ", entityError);
         var exceptionMessage = string.Concat(ex.Message, "errors are: ", getFullMessage);
         //NLog
         Log(exceptionMessage);
         Console.WriteLine(exceptionMessage);
     }
     catch (Exception e)
     {
         Log(e.ToString());
         Console.WriteLine(e.ToString());
     }
     return(false);
 }
예제 #4
0
 private static void currentinfoCompare(ref cat_server.CAT_info refreshinfo, cat_server.CAT_info currentinfo)
 {
     if (refreshinfo.BIOS != currentinfo.BIOS)
     {
         refreshinfo.BIOS = currentinfo.BIOS;
     }
     if (refreshinfo.BT_Driver != currentinfo.BT_Driver)
     {
         refreshinfo.BT_Driver = currentinfo.BT_Driver;
     }
     if (refreshinfo.BT_Module != currentinfo.BT_Module)
     {
         refreshinfo.BT_Module = currentinfo.BT_Module;
     }
     if (refreshinfo.GNSS_Driver != currentinfo.GNSS_Driver)
     {
         refreshinfo.GNSS_Driver = currentinfo.GNSS_Driver;
     }
     if (refreshinfo.GNSS_Module != currentinfo.GNSS_Module)
     {
         refreshinfo.GNSS_Module = currentinfo.GNSS_Module;
     }
     if (refreshinfo.Image != currentinfo.Image)
     {
         refreshinfo.Image = currentinfo.Image;
     }
     if (refreshinfo.NFC_Driver != currentinfo.NFC_Driver)
     {
         refreshinfo.NFC_Driver = currentinfo.NFC_Driver;
     }
     if (refreshinfo.NFC_Module != currentinfo.NFC_Module)
     {
         refreshinfo.NFC_Module = currentinfo.NFC_Module;
     }
     if (refreshinfo.NIC_Driver != currentinfo.NIC_Driver)
     {
         refreshinfo.NIC_Driver = currentinfo.NIC_Driver;
     }
     if (refreshinfo.NIC_Module != currentinfo.NIC_Module)
     {
         refreshinfo.NIC_Module = currentinfo.NIC_Module;
     }
     if (refreshinfo.OS != currentinfo.OS)
     {
         refreshinfo.OS = currentinfo.OS;
     }
     if (refreshinfo.Platform != currentinfo.Platform)
     {
         refreshinfo.Platform = currentinfo.Platform;
     }
     if (refreshinfo.RFID_Driver != currentinfo.RFID_Driver)
     {
         refreshinfo.RFID_Driver = currentinfo.RFID_Driver;
     }
     if (refreshinfo.RFID_Module != currentinfo.RFID_Module)
     {
         refreshinfo.RFID_Module = currentinfo.RFID_Module;
     }
     if (refreshinfo.WLAN_Driver != currentinfo.WLAN_Driver)
     {
         refreshinfo.WLAN_Driver = currentinfo.WLAN_Driver;
     }
     if (refreshinfo.WLAN_Module != currentinfo.WLAN_Module)
     {
         refreshinfo.WLAN_Module = currentinfo.WLAN_Module;
     }
     if (refreshinfo.WWAN_Driver != currentinfo.WWAN_Driver)
     {
         refreshinfo.WWAN_Driver = currentinfo.WWAN_Driver;
     }
     if (refreshinfo.WWAN_Firmware != currentinfo.WWAN_Firmware)
     {
         refreshinfo.WWAN_Firmware = currentinfo.WWAN_Firmware;
     }
     if (refreshinfo.WWAN_Modem != currentinfo.WWAN_Modem)
     {
         refreshinfo.WWAN_Modem = currentinfo.WWAN_Modem;
     }
     if (refreshinfo.WWAN_Module != currentinfo.WWAN_Module)
     {
         refreshinfo.WWAN_Module = currentinfo.WWAN_Module;
     }
     if (refreshinfo.LastUsedTime != currentinfo.LastUsedTime)
     {
         refreshinfo.LastUsedTime = currentinfo.LastUsedTime;
     }
     if (refreshinfo.CurrentTask != currentinfo.CurrentTask)
     {
         refreshinfo.CurrentTask = currentinfo.CurrentTask;
     }
     if (refreshinfo.STATUS != currentinfo.STATUS)
     {
         refreshinfo.STATUS = currentinfo.STATUS;
     }
     //if (refreshinfo.Tag != currentinfo.Tag) refreshinfo.Tag = currentinfo.Tag;
 }