Ejemplo n.º 1
0
 public static void WorkerThread()
 {
     while (!IdentificationServer.StopFlag)
     {
         IdentificationServer.ClearCompletedTasks();
         if (!IdentificationServer.IsLoaded)
         {
             Thread.Sleep(100);
         }
         else if (IdentificationServer.Requests.IsEmpty)
         {
             Thread.Sleep(100);
         }
         else
         {
             int       trackingPeriod = IdentificationServer.SetGetServerSettings(false).TrackingPeriod * 1000;
             FrameInfo result;
             while (!IdentificationServer.StopFlag && IdentificationServer.Requests.TryDequeue(out result))
             {
                 try
                 {
                     FrameInfo frame = result;
                     IdentificationServer.ClearCompletedTasks();
                     bool flag = false;
                     foreach (CompareRequest compareRequest in Enumerable.Where <CompareRequest>((IEnumerable <CompareRequest>)IdentificationServer.CommonRequests, (Func <CompareRequest, bool>)(request => request.DeviceId == frame.Device.Id && request.RequestStatus == RequestStatus.Wait)))
                     {
                         if (compareRequest.HasSimilar(Settings.Default.MinScore, frame) && compareRequest.RequestStatus == RequestStatus.Wait)
                         {
                             compareRequest.Add(frame);
                             flag = true;
                         }
                     }
                     if (!flag)
                     {
                         CompareRequest compareRequest = new CompareRequest(frame.Device, IdentificationServer.Logger, IdentificationServer.EngineWorker);
                         compareRequest.Add(frame);
                         compareRequest.ProcessAfter(trackingPeriod);
                         IdentificationServer.CommonRequests.Add(compareRequest);
                     }
                 }
                 catch (Exception ex)
                 {
                     IdentificationServer.Logger.Error((object)"WorkerThread Errror - ", ex);
                 }
             }
         }
     }
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 3
0
 public void SetServerSettings()
 {
     IdentificationServer.SetGetServerSettings(true);
 }