Exemple #1
0
        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);
            }
        }
Exemple #2
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);
     }
 }
Exemple #3
0
 public VideoCaptureDeviceForm()
 {
     this.InitializeComponent();
     this.FormBorderStyle = FormBorderStyle.FixedDialog;
     this.Icon            = Resources.TechServIcon;
     try
     {
         this._videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         foreach (FilterInfo filterInfo in (CollectionBase)this._videoDevices)
         {
             this._devicesCombo.Properties.Items.Add((object)filterInfo.Name);
             this._devices.Add(new BcDevices());
         }
         foreach (BcDevices bcDevices in BcDevicesStorageExtensions.LoadAll())
         {
             this._devices.Add(bcDevices);
             this._devicesCombo.Properties.Items.Add((object)bcDevices.Name);
         }
     }
     catch (ApplicationException ex)
     {
         this._devicesCombo.Properties.Items.Add((object)"No local capture devices");
         this._devicesCombo.Enabled = false;
         this._okButton.Enabled     = false;
     }
     this._devicesCombo.SelectedIndex = 0;
 }
 private void LoadDevices()
 {
     foreach (BcDevices device in BcDevicesStorageExtensions.LoadByVsid(this.Id))
     {
         this.TryAddOrUpdateVideoSource(device);
     }
 }
 private static void TryRefreshDevices()
 {
     try
     {
         DetectorServer.SyncCurrentAndActualDevices(BcDevicesStorageExtensions.LoadByDsid(DetectorServer.MainServer.Id));
     }
     catch (Exception ex)
     {
         DetectorServer.Logger.Error((object)"refresh device error ", ex);
     }
 }
Exemple #6
0
 public void ReloadObjects()
 {
     Devices  = BcDevicesStorageExtensions.LoadAll();
     _objects = BcObjects.LoadAll();
     lvObjects.Items.Clear();
     foreach (BcDevices bcDevices in Devices)
     {
         lvObjects.Items.Add(bcDevices.Name);
         lvObjects.Items[lvObjects.Items.Count - 1].Value       = bcDevices.Id;
         lvObjects.Items[lvObjects.Items.Count - 1].Description = bcDevices.Name;
     }
 }
        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);
            }
        }
 private void RefreshForm()
 {
     this._loading = true;
     this._mainTable.Rows.Clear();
     try
     {
         this._devices = BcDevicesStorageExtensions.LoadAllByWorkStationId(FrmImages.CurrentStation.Id);
         foreach (BcDevices bcDevices1 in this._devices)
         {
             string str = Messages.Active;
             if (!bcDevices1.IsActive)
             {
                 str = Messages.NoActive;
             }
             bool flag = false;
             foreach (BcDevices bcDevices2 in this.ActiveDevices)
             {
                 if (bcDevices2.Id == bcDevices1.Id)
                 {
                     flag = true;
                     break;
                 }
             }
             this._mainTable.Rows.Add((object)bcDevices1.Id, (object)(bool)(flag ? 1 : 0), (object)bcDevices1.Name, (object)bcDevices1.ConnectionString, (object)"", (object)str);
             foreach (BcObjects bcObjects in this._objects)
             {
                 if (bcObjects.Id == bcDevices1.ObjectId)
                 {
                     bcObjects.GetData();
                     if (bcDevices1.TableId != Guid.Empty)
                     {
                         this._mainTable.Rows[this._mainTable.Rows.Count - 1]["Comment"] = (object)(bcObjects.Name + "-" + BcObjectsData.GetObjectById(bcObjects.Data, bcDevices1.TableId).Name);
                     }
                 }
             }
         }
         this.gridControl2.DataSource = (object)this._mainTable;
         FrmImages.SqlServerState     = true;
     }
     catch (Exception ex)
     {
         int num = (int)XtraMessageBox.Show(ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand);
         FrmImages.SqlServerState = false;
     }
     this._loading = false;
 }
 private void CheckDevices()
 {
     while (!this._signalToStop)
     {
         try
         {
             List <BcDevices> list = BcDevicesStorageExtensions.LoadByVsid(this.Id);
             this.AddOrUpdateVideoSources((IEnumerable <BcDevices>)list);
             this.RemoveVideoSources((IEnumerable <BcDevices>)list);
         }
         catch (Exception ex)
         {
             this._logger.Error((object)ex);
         }
         Thread.Sleep(4000);
     }
 }
Exemple #10
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));
 }
Exemple #11
0
 public void ReloadObjects()
 {
     try
     {
         Results.dtImageType.Rows.Clear();
         Results.dtCategories.Rows.Clear();
         Results.dtDevices.Rows.Clear();
         Devices  = BcDevicesStorageExtensions.LoadAll();
         _objects = BcObjects.LoadAll();
         _bases   = BcLogBases.LoadAll();
         lvObjects.Items.Clear();
         foreach (BcDevices bcDevices in Devices)
         {
             lvObjects.Items.Add("");
             lvObjects.Items[lvObjects.Items.Count - 1].Value       = bcDevices.Id;
             lvObjects.Items[lvObjects.Items.Count - 1].Description = bcDevices.Name + "-";
             foreach (BcObjects bcObjects in _objects)
             {
                 if (bcObjects.Id == bcDevices.ObjectId)
                 {
                     bcObjects.GetData();
                     if (bcDevices.TableId != Guid.Empty)
                     {
                         CheckedListBoxItem checkedListBoxItem = lvObjects.Items[lvObjects.Items.Count - 1];
                         string             str1 = checkedListBoxItem.Description + "(" + bcObjects.Name + "-" + BcObjectsData.GetObjectById(bcObjects.Data, bcDevices.TableId).Name + ")";
                         checkedListBoxItem.Description = str1;
                         string str2 = bcObjects.Name + "-" + BcObjectsData.GetObjectById(bcObjects.Data, bcDevices.TableId).Name;
                         Results.dtDevices.Rows.Add((object)bcDevices.Id, (object)bcDevices.Name, (object)bcDevices.ObjectId, (object)bcDevices.TableId, (object)str2);
                         break;
                     }
                     lvObjects.Items[lvObjects.Items.Count - 1].Description += bcObjects.Name;
                     string str = "(" + bcObjects.Name + ")";
                     Results.dtDevices.Rows.Add((object)bcDevices.Id, (object)bcDevices.Name, (object)bcDevices.ObjectId, (object)bcDevices.TableId, (object)str);
                     break;
                 }
             }
         }
     }
     catch
     {
     }
 }
Exemple #12
0
 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
     {
     }
 }
Exemple #13
0
 private static void RefreshDevices()
 {
     ExtractorServer.SyncCurrentAndActualDevices(BcDevicesStorageExtensions.LoadByEsid(ExtractorServer.MainServer.Id));
 }