public static void ConnectToOnvifService(out OdmSession onvifHelper, BcDevices dev) { onvifHelper = (OdmSession)null; if (!(dev.Type == "Onvif Kipod Server")) { return; } try { NvtSessionFactory nvtSessionFactory = new NvtSessionFactory(new NetworkCredential(dev.Login, dev.Password)); DetectorServer.Logger.Info((object)"onvifHelper Successfuly created"); DetectorServer.Logger.Info((object)"subscribing to evets..."); DetectorServer.Logger.Info((object)"Start Subscribe"); try { } catch (Exception ex) { DetectorServer.Logger.Error((object)"Error subscribe ", ex); } } catch (Exception ex) { DetectorServer.Logger.Error((object)"Onvif Error", ex); } }
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); } }
public static void SendCommand(BcDevices dev, int accessId, int sfinksId) { try { IdentificationServer.DeviceClient.SendCommand(IdentificationServer.LoginCom); IdentificationServer.DeviceClient.SendCommand(string.Concat(new object[4] { (object)"CASCADE_FACEDETECTED ", (object)sfinksId, (object)" ", (object)dev.Id.ToString().Replace("-", "") })); if (accessId == -1) { return; } BcAccessCategory catout; IdentificationServer.ReadWriteAccessCategory(false, accessId, (BcAccessCategory)null, out catout); if (catout == null || !IdentificationServer.DeviceClient.IsConnected) { return; } BcObjects bcObjects = Enumerable.FirstOrDefault <BcObjects>((IEnumerable <BcObjects>)catout.Data, (Func <BcObjects, bool>)(o => o.Id == dev.ObjectId)); if (bcObjects == null) { return; } if (bcObjects.Device && dev.TableId == Guid.Empty) { try { IdentificationServer.DeviceClient.SendCommand(IdentificationServer.LoginCom); IdentificationServer.DeviceClient.SendCommand(IdentificationServer.AllowPass); } catch (Exception ex) { IdentificationServer.Logger.Error((object)"sfinks net error", ex); } } else if (dev.TableId != Guid.Empty) { if (BcObjectsData.GetObjectById(bcObjects.Data, dev.TableId).Device) { try { IdentificationServer.DeviceClient.SendCommand(IdentificationServer.LoginCom); IdentificationServer.DeviceClient.SendCommand(IdentificationServer.AllowPass); } catch (Exception ex) { IdentificationServer.Logger.Error((object)"sfinks net error", ex); } } } } catch (Exception ex) { IdentificationServer.Logger.Error((object)"sfinks net error", ex); } }
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); } }
public void UpdateDevice(BcDevices bcDevices) { if (bcDevices == null) { throw new ArgumentNullException(); } if (this._device != null && bcDevices.Id != this._device.Id) { throw new InvalidOperationException("bcDevices.Id != _device.Id"); } if (!this.HasDifferProperties(bcDevices)) { return; } lock (this._processingWorkers) { ParallelEnumerable.ForAll <Worker>(ParallelEnumerable.AsParallel <Worker>((IEnumerable <Worker>) this._processingWorkers), (Action <Worker>)(worker => worker.Pause())); this._device = bcDevices; this._detectionConfiguration = new DetectionConfiguration() { MinFace = (uint)this._device.MinFace, DetectionThreshold = (double)this._device.DetectorScore }; this.SyncProcessorCount(); ParallelEnumerable.ForAll <Worker>(ParallelEnumerable.AsParallel <Worker>((IEnumerable <Worker>) this._processingWorkers), (Action <Worker>)(worker => worker.Resume())); } }
public CompareRequest(BcDevices bcDevice, ILog logger, IEngineWorker engineWorker) { this._logger = logger; this._engineWorker = engineWorker; this._device = bcDevice; this.RequestStatus = RequestStatus.Wait; }
private static IReadOnlyDictionary <string, string> GetDeviceOptions(BcDevices device) { switch (device.Type) { case "Web": string capability = device.Capability; if (string.IsNullOrEmpty(capability)) { return((IReadOnlyDictionary <string, string>)null); } int num1 = capability.IndexOf(' '); string str1 = capability.Substring(0, num1); int num2 = capability.IndexOf("fps"); string str2 = capability.Substring(num1, num2 - num1); return((IReadOnlyDictionary <string, string>) new Dictionary <string, string>() { { "FrameSize", str1 }, { "FPS", str2 } }); default: return((IReadOnlyDictionary <string, string>)null); } }
public DataTable GetDeviceInfo() { DataTable dataTable = new DataTable() { TableName = "DResults" }; dataTable.Columns.Add("ID", typeof(Guid)); dataTable.Columns.Add("DetectionCount", typeof(int)); dataTable.Columns.Add("DetectionFaces", typeof(int)); dataTable.Columns.Add("DSState", typeof(string)); dataTable.Columns.Add("CPUUsage", typeof(int)); dataTable.Columns.Add("ThreadCount", typeof(int)); dataTable.Columns.Add("MaxThreadCount", typeof(int)); dataTable.Columns.Add("FrameCount", typeof(int)); int cpuUsage = DetectorServer.GetCpuUsage(); int processorCount = Environment.ProcessorCount; int num = Enumerable.Sum <KeyValuePair <Guid, Detector> >((IEnumerable <KeyValuePair <Guid, Detector> >)DetectorServer.Detectors, (Func <KeyValuePair <Guid, Detector>, int>)(kvp => kvp.Value.Count)); foreach (KeyValuePair <Guid, Detector> keyValuePair in DetectorServer.Detectors) { BcDevices device = keyValuePair.Value.Device; if (device != null) { dataTable.Rows.Add((object)keyValuePair.Key, (object)device.DetectionCount, (object)device.DetectionFaces, (object)"Работает", (object)cpuUsage, (object)num, (object)processorCount, (object)device.FrameCount); } } if (dataTable.Rows.Count == 0) { dataTable.Rows.Add((object)Guid.Empty, (object)0, (object)0, (object)"Работает", (object)cpuUsage, (object)num, (object)processorCount); } return(dataTable); }
public static void VideoThread(object device) { BcDevices bcDevices = (BcDevices)device; while (!IdentificationServer.StopFlag) { try { if (!bcDevices.IsActive) { Thread.Sleep(1000); continue; } BcExtractorServer bcExtractorServer = BcExtractorServer.LoadById(bcDevices.Esid); using (ExtractorServerClient extractorServerClient = new ExtractorServerClient(new InstanceContext((object)new IdentificationServer.ExtarctorClient()))) { extractorServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcExtractorServer.Ip + ":" + (string)(object)bcExtractorServer.Port + "/FaceExtractorServer/ExtractorServer"); extractorServerClient.Open(); while (!IdentificationServer.StopFlag && bcDevices.IsActive) { KeyFrame lastFrame = extractorServerClient.GetLastFrame(bcDevices.Id); if (lastFrame == null) { Thread.Sleep(50); } else { IdentificationServer.Logger.Warn((object)("New template recieved deviceId = " + (object)bcDevices.Id)); byte[] imageIcon = IdentificationServer.GetImageIcon(lastFrame.Frame.Frame); if (lastFrame.Key != null && (int)lastFrame.Key[0] != 0) { FrameInfo frameInfo = new FrameInfo() { Image = lastFrame.Frame.Frame, ImageIcon = imageIcon, Template = lastFrame.Key, Date = lastFrame.Frame.Date.Ticks, Device = bcDevices, MinScore = (double)bcDevices.MinScore, DetectedFrameId = lastFrame.Frame.FrameId }; IdentificationServer.Requests.Enqueue(frameInfo); } } } } } catch (CommunicationException ex) { IdentificationServer.Logger.Error((object)("Unable to connect to FaceExtractorServer " + ex.Message)); } catch (Exception ex) { IdentificationServer.Logger.Error((object)ex); } Thread.Sleep(1000); } }
public static void WorkerThread(object extractor) { ExtractorServer.KeyExtractor keyExtractor = (ExtractorServer.KeyExtractor)extractor; while (!keyExtractor.StopFlag) { while (keyExtractor.BreakFlag) { keyExtractor.Breaked = true; if (!keyExtractor.StopFlag) { Thread.Sleep(30); } else { break; } } keyExtractor.Breaked = false; BcDevices bcDevices = keyExtractor.Device; try { Engine.Initialize(0U); using (Engine engine = new Engine()) { while (!keyExtractor.BreakFlag && !keyExtractor.StopFlag) { FaceFrame orDefault = LimitedConcurrentQueueExtensions.GetOrDefault <FaceFrame>(ExtractorServer._faceframes); if (orDefault == null) { Thread.Sleep(10); } else { byte[] template = ExtractorServer.ExtractTemplate(orDefault, (IEngine)engine); bcDevices.AddKeyFrame(new KeyFrame() { Frame = orDefault, Key = template }); ++bcDevices.ExtractCount; } } } } catch (Exception ex) { ExtractorServer.Logger.Error((object)string.Concat(new object[4] { (object)"Extractor Thread Error ", (object)ex.Message, (object)" Extractor Index ", (object)ExtractorServer.Extractors.IndexOf(keyExtractor) })); } } keyExtractor.Stopped = true; }
public KeyFrame GetLastFrame(Guid deviceId) { BcDevices bcDevices = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)ExtractorServer.AllDevices, (Func <BcDevices, bool>)(d => d.Id == deviceId)); if (bcDevices == null) { return((KeyFrame)null); } return(bcDevices.GetKeyFrame()); }
public void SetDevice(Guid id, bool delete) { BcDevices device = BcDevicesStorageExtensions.LoadById(id); if (device.Vsid != VideoServerContractImpl.Instance.Id) { VideoServerContractImpl.Instance.TryToRemoveVideoSource(id); } else { VideoServerContractImpl.Instance.TryAddOrUpdateVideoSource(device); } }
public FrmDevices(List <BcDevices> devs) { this.InitializeComponent(); try { this._objects = BcObjects.LoadAll(); BcDevices[] array = new BcDevices[devs.Count]; devs.CopyTo(array, 0); this.ActiveDevices.AddRange((IEnumerable <BcDevices>)array); FrmImages.SqlServerState = true; } catch (Exception ex) { int num = (int)XtraMessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Hand); FrmImages.SqlServerState = false; } }
public static void VideoThread(object device) { BcDevices dev = (BcDevices)device; while (!ExtractorServer.StopFlag) { try { if (!dev.IsActive) { Thread.Sleep(1000); continue; } if (dev.Dsid != Guid.Empty) { ExtractorServer.DetectorClientCallback detectorClientCallback = new ExtractorServer.DetectorClientCallback(); BcDetectorServer ds = BcDetectorServer.LoadById(dev.Dsid); WcfExtensions.Using <DetectorServerClient>(new DetectorServerClient(new InstanceContext((object)detectorClientCallback)), (Action <DetectorServerClient>)(server => { server.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)ds.Ip + ":" + (string)(object)ds.Port + "/CSDetectorServer/DetectorServer"); server.Open(); while (dev.IsActive && !ExtractorServer.StopFlag) { ExtractorServer._logger.Debug((object)string.Format("Request to Detector DevId={0}", (object)dev.Id)); FaceFrame lastFrame = server.GetLastFrame(dev.Id); if (lastFrame == null) { Thread.Sleep(20); } else { ExtractorServer._logger.Debug((object)string.Format("Response from Detector DevId={0} FrameId={1} FrameIndex={2}", (object)dev.Id, (object)lastFrame.FrameId, (object)lastFrame.FrameIndex)); ExtractorServer._faceframes.Enqueue(lastFrame); } } })); } } catch (Exception ex) { ExtractorServer.Logger.Error((object)"Video Thread error ", ex); } Thread.Sleep(1000); } }
public void TryAddOrUpdateVideoSource(BcDevices device) { this.TryToRemoveVideoSource(device.Id); string connectionString = VideoServer.GetDeviceConnectionString(device); IReadOnlyDictionary <string, string> deviceOptions = VideoServer.GetDeviceOptions(device); CS.VideoSources.Core.IVideoSource videoSource = VideoServer.CreateVideoSource(device.Type, connectionString, device.Login, device.Password, deviceOptions); if (videoSource != null) { this.VideoSources.Add(device.Id, videoSource); videoSource.VideoSourceError += new CS.VideoSources.Core.VideoSourceErrorEventHandler(this.HandleVideoSourceError); } if (videoSource != null) { return; } this._logger.WarnFormat("Unable to create Video source of type {0} and id {1}", (object)device.Type, (object)device.Id); }
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)); }
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); } } }
private static void SyncCurrentAndActualDevices(List <BcDevices> actualDevices) { foreach (Guid key in Enumerable.Except <Guid>((IEnumerable <Guid>)DetectorServer.Detectors.Keys, Enumerable.Select <BcDevices, Guid>((IEnumerable <BcDevices>)actualDevices, (Func <BcDevices, Guid>)(devices => devices.Id)))) { Detector detector; if (DetectorServer.Detectors.TryRemove(key, out detector)) { detector.Dispose(); } } foreach (KeyValuePair <Guid, Detector> keyValuePair in DetectorServer.Detectors) { KeyValuePair <Guid, Detector> detector = keyValuePair; BcDevices bcDevices = Enumerable.First <BcDevices>((IEnumerable <BcDevices>)actualDevices, (Func <BcDevices, bool>)(devices => devices.Id == detector.Key)); detector.Value.UpdateDevice(bcDevices); } foreach (BcDevices bcDevices in Enumerable.Where <BcDevices>((IEnumerable <BcDevices>)actualDevices, (Func <BcDevices, bool>)(devices => !DetectorServer.Detectors.ContainsKey(devices.Id)))) { Detector detector = new Detector(DetectorServer.Logger, DetectorServer.BcFrameManager, DetectorServer.VideoServerInteraction, DetectorServer.Engine); DetectorServer.Detectors[bcDevices.Id] = detector; detector.UpdateDevice(bcDevices); } }
private static string GetDeviceConnectionString(BcDevices device) { switch (device.Type) { case "Basler Aviator Series": return(device.ConnectionString); case "Axis": return("http://" + device.ConnectionString + "/axis-cgi/mjpg/video.cgi"); case "Vocord": return("http://" + device.ConnectionString + ":82/video/data.mjpg"); case "Basler": return("http://" + device.ConnectionString + "/cgi-bin/mjpeg"); case "Arecont": return("http://" + device.ConnectionString + "/mjpeg?"); case "Panasonic": return("http://" + device.ConnectionString + "/cgi-bin/mjpeg?"); case "HTTP MJPEG": return(device.ConnectionString); case "Image": case "File": return(device.ConnectionString); case "Web": return(device.ConnectionString); default: return((string)null); } }
public static void SendNotify(BcDevices dev, BcLog log, bool hasface, BcNotificationSystem sys) { QueueParameters notificationQueue = new QueueParameters() { HostName = sys.HostName, Password = sys.Password, UserName = sys.UserName, VirtualHost = sys.VirtualHost, QueueName = string.Concat(new object[4] { (object)sys.Fqdn, (object)".", (object)sys.SystemId, (object)".NotificationAPI.input" }) }; string str1 = ""; string str2 = ""; string str3 = ""; string str4 = ""; try { byte[] numArray = (byte[])null; DateTime dateTime = DateTime.Now; Guid faceId = log.FaceId; try { if (hasface) { using (SqlCommand sqlCommand = new SqlCommand("Select ImageIcon,Surname,FirstName,LastName, Birthday, AccessCategory.Name as category from Faces left outer join\r\n AccessCategory on Accesscategory.ID = Faces.AccessID Where Faces.ID=@ID", new SqlConnection(CommonSettings.ConnectionString))) { sqlCommand.Parameters.Add(new SqlParameter("@ID", (object)log.FaceId)); sqlCommand.Connection.Open(); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); sqlDataReader.Read(); numArray = (byte[])sqlDataReader[0]; str1 = sqlDataReader["category"].ToString(); str3 = sqlDataReader["FirstName"].ToString(); str4 = sqlDataReader["Surname"].ToString(); str2 = sqlDataReader["LastName"].ToString(); dateTime = (DateTime)sqlDataReader["Birthday"]; sqlCommand.Connection.Close(); } } } catch (Exception ex) { IdentificationServer.Logger.Error((object)"Notification error", ex); } NotificationParameters parameters = new NotificationParameters() { Id = Guid.NewGuid(), Category = str1, Camera = dev.Name, EventTime = DateTime.Now, Image1 = log.Image, Image2 = numArray }; if (hasface) { parameters.NotificationData.Add("Birthday", dateTime.ToString()); parameters.NotificationData.Add("FaceID", faceId.ToString()); } parameters.NotificationData["Lastname"] = str2; parameters.NotificationData["Name"] = str3; parameters.NotificationData["Surname"] = str4; using (NotificationProtocolClient notificationProtocolClient = new NotificationProtocolClient(notificationQueue)) { notificationProtocolClient.Open(); notificationProtocolClient.SendNotification("Identification", parameters); } } catch (Exception ex) { IdentificationServer.Logger.Error((object)"Notification error", ex); } }
protected bool HasDifferProperties(BcDevices d2) { return(this._device == null || this._device.DetectorCount != d2.DetectorCount || (this._device.SaveUnidentified != d2.SaveUnidentified || this._device.SaveImage != d2.SaveImage) || this._device.SaveFace != d2.SaveFace || this._device.Vsid != d2.Vsid); }
private static bool HasDifferProperties(BcDevices d1, BcDevices d2) { return(d1.ExtractorCount != d2.ExtractorCount); }
public void SetDevice(Guid id, Hashtable row, bool delete) { try { BcDevices deviceById = ExtractorServer.GetDeviceById(id); BcDevices bcDevices1 = BcDevicesStorageExtensions.LoadById(id); if (bcDevices1.Esid != ExtractorServer.MainServer.Id) { delete = true; } if (!delete) { if (deviceById.Id != Guid.Empty) { int extractorCount = deviceById.ExtractorCount; ExtractorServer.BreakExtractor(deviceById.Id); deviceById.SetData(row); if (extractorCount != deviceById.ExtractorCount) { ExtractorServer.ReloadExtractors(); } ExtractorServer.UnBreakExtractor(deviceById.Id); } else { try { if (bcDevices1.Esid != ExtractorServer.MainServer.Id) { BcDevices bcDevices2 = BcDevicesStorageExtensions.LoadById(id); bcDevices2.CurrentThread = new Thread(new ParameterizedThreadStart(ExtractorServer.VideoThread)) { IsBackground = true }; bcDevices2.CurrentThread.Start((object)bcDevices2); ExtractorServer.AllDevices.Add(bcDevices2); ExtractorServer.ReloadExtractors(); } } catch (Exception ex) { ExtractorServer.Logger.Error((object)"Set device error", ex); } } } else { for (int index = 0; index < ExtractorServer.Extractors.Count; ++index) { if (ExtractorServer.Extractors.Count > 0 && index >= 0 && index < ExtractorServer.Extractors.Count) { ExtractorServer.KeyExtractor keyExtractor = ExtractorServer.Extractors[index]; if (keyExtractor.Device.Id == id) { keyExtractor.StopFlag = true; keyExtractor.WaitForStop(); ExtractorServer.Extractors.RemoveAt(index); break; } } } for (int index = 0; index < ExtractorServer.AllDevices.Count; ++index) { if (ExtractorServer.AllDevices[index].Id == id) { ExtractorServer.AllDevices.RemoveAt(index); break; } } } } catch { } }