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)); }
public static BcIdentificationServer SetGetServerSettings(bool set) { lock (IdentificationServer.MainServer) { if (!set) { return(IdentificationServer.MainServer); } try { IdentificationServer.MainServer = BcIdentificationServer.LoadById(IdentificationServer.ServerId); } catch (Exception exception_0) { IdentificationServer.Logger.Error((object)"Error while loading BcIdentificationServer", exception_0); } return(IdentificationServer.MainServer); } }