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 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 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 { } }