예제 #1
0
        public void SetDevice(Guid id, Hashtable row, bool delete)
        {
            BcDevices deviceById = IdentificationServer.GetDeviceById(id);
            BcDevices bcDevices1 = BcDevicesStorageExtensions.LoadById(id);

            if (bcDevices1.Isid != IdentificationServer.MainServer.Id)
            {
                delete = true;
            }
            if (delete)
            {
                BcDevices bcDevices2 = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(d => d.Id == id));
                if (bcDevices2 == null)
                {
                    return;
                }
                IdentificationServer.DestroyIfNeeded(bcDevices2.CurrentThread);
                IdentificationServer.AllDevices.Remove(bcDevices2);
            }
            else if (deviceById.Id != Guid.Empty)
            {
                deviceById.SetData(row);
            }
            else if (bcDevices1.Isid == IdentificationServer.MainServer.Id)
            {
                deviceById.SetData(row);
                IdentificationServer.AllDevices.Add(deviceById);
                deviceById.CurrentThread = new Thread(new ParameterizedThreadStart(IdentificationServer.VideoThread))
                {
                    IsBackground = true
                };
                deviceById.CurrentThread.Start((object)deviceById);
            }
        }
예제 #2
0
 private static void TrySyncDevices()
 {
     try
     {
         List <BcDevices> devices = BcDevicesStorageExtensions.LoadByIsid(IdentificationServer.ServerId);
         foreach (BcDevices bcDevices1 in devices)
         {
             BcDevices newDev     = bcDevices1;
             BcDevices bcDevices2 = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(n => n.Id == newDev.Id));
             if (bcDevices2 == null)
             {
                 IdentificationServer.AllDevices.Add(newDev);
                 newDev.CurrentThread = new Thread(new ParameterizedThreadStart(IdentificationServer.VideoThread))
                 {
                     IsBackground = true
                 };
                 newDev.CurrentThread.Start((object)newDev);
             }
             else
             {
                 bcDevices2.SetData(newDev.GetData());
             }
         }
         foreach (BcDevices bcDevices in Enumerable.ToArray <BcDevices>(Enumerable.Where <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(n => Enumerable.All <BcDevices>((IEnumerable <BcDevices>)devices, (Func <BcDevices, bool>)(nn => nn.Id != n.Id))))))
         {
             IdentificationServer.DestroyIfNeeded(bcDevices.CurrentThread);
         }
     }
     catch (Exception ex)
     {
         IdentificationServer.Logger.Error((object)ex);
     }
 }
예제 #3
0
 public static void LoadServer(Guid serverId)
 {
     IdentificationServer.ServerId   = serverId;
     IdentificationServer.MainServer = BcIdentificationServer.LoadById(IdentificationServer.ServerId);
     try
     {
         List <BcDevices> actualDevices = BcDevicesStorageExtensions.LoadByIsid(IdentificationServer.ServerId);
         foreach (BcDevices bcDevices in Enumerable.ToArray <BcDevices>(Enumerable.Where <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(devices => Enumerable.All <BcDevices>((IEnumerable <BcDevices>)actualDevices, (Func <BcDevices, bool>)(bcDevices => bcDevices.Id != devices.Id))))))
         {
             if (bcDevices.CurrentThread != null)
             {
                 IdentificationServer.DestroyIfNeeded(bcDevices.CurrentThread);
             }
             IdentificationServer.AllDevices.Remove(bcDevices);
         }
         foreach (BcDevices bcDevices1 in actualDevices)
         {
             BcDevices d1         = bcDevices1;
             BcDevices bcDevices2 = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(dev => dev.Id == d1.Id));
             if (bcDevices2 != null)
             {
                 bcDevices2.SetData(d1.GetData());
             }
             else
             {
                 IdentificationServer.AllDevices.Add(d1);
                 d1.CurrentThread = new Thread(new ParameterizedThreadStart(IdentificationServer.VideoThread))
                 {
                     IsBackground = true
                 };
                 d1.CurrentThread.Start((object)d1);
             }
         }
     }
     catch (Exception ex)
     {
         IdentificationServer.Logger.Error((object)ex);
     }
     IdentificationServer.IsLoaded = true;
     IdentificationServer.SetGetServerSettings(true);
     Task.Factory.StartNew(new Action(IdentificationServer.RefreshFaces));
     Task.Factory.StartNew(new Action(IdentificationServer.RefreshDevices));
 }