コード例 #1
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);
     }
 }
コード例 #2
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));
 }
コード例 #3
0
 private static void SyncCurrentAndActualDevices(List <BcDevices> actualDevices)
 {
     foreach (BcDevices bcDevices in actualDevices)
     {
         BcDevices d1 = bcDevices;
         BcDevices d2 = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)ExtractorServer.AllDevices, (Func <BcDevices, bool>)(bcDevice => bcDevice.Id == d1.Id));
         if (d2 != null)
         {
             if (ExtractorServer.HasDifferProperties(d1, d2))
             {
                 ExtractorServer.BreakExtractor(d2.Id);
                 d2.SetData(d1.GetData());
                 ExtractorServer.UnBreakExtractor(d2.Id);
             }
         }
         else
         {
             d1.CurrentThread = new Thread(new ParameterizedThreadStart(ExtractorServer.VideoThread))
             {
                 IsBackground = true
             };
             d1.CurrentThread.Start((object)d1);
             ExtractorServer.AllDevices.Add(d1);
         }
         ExtractorServer.ReloadExtractors();
     }
     foreach (BcDevices bcDevices in Enumerable.ToArray <BcDevices>(Enumerable.Where <BcDevices>((IEnumerable <BcDevices>)ExtractorServer.AllDevices, (Func <BcDevices, bool>)(d => Enumerable.All <BcDevices>((IEnumerable <BcDevices>)actualDevices, (Func <BcDevices, bool>)(d2 => d2.Id != d.Id))))))
     {
         BcDevices bcDevicese = bcDevices;
         ExtractorServer.AllDevices.Remove(bcDevicese);
         foreach (ExtractorServer.KeyExtractor keyExtractor in Enumerable.ToArray <ExtractorServer.KeyExtractor>(Enumerable.Where <ExtractorServer.KeyExtractor>((IEnumerable <ExtractorServer.KeyExtractor>)ExtractorServer.Extractors, (Func <ExtractorServer.KeyExtractor, bool>)(d => d.Device.Id == bcDevicese.Id))))
         {
             keyExtractor.StopFlag = true;
             keyExtractor.WaitForStop();
             ExtractorServer.DestroyIfNeeded(keyExtractor.Device.CurrentThread);
         }
     }
 }