Esempio n. 1
0
 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);
     }
 }
Esempio 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));
 }
Esempio n. 3
0
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     if (pictureEdit1.Image == null)
     {
         return;
     }
     if (MainForm.Engine.DetectAllFaces(((Bitmap)pictureEdit1.Image).ConvertFrom(), null).Length > 0)
     {
         foreach (BcIdentificationServer identificationServer in BcIdentificationServer.LoadAll())
         {
             try
             {
                 IdentificationServerClient identificationServerClient = new IdentificationServerClient(new InstanceContext(_client));
                 identificationServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)identificationServer.Ip + ":" + (string)(object)identificationServer.Port + "/FaceIdentification/IdentificationServer");
                 identificationServerClient.Open();
                 List <Guid> list = new List <Guid>();
                 foreach (CheckedListBoxItem checkedListBoxItem in lvObjects.Items)
                 {
                     if (checkedListBoxItem.CheckState == CheckState.Checked)
                     {
                         list.Add((Guid)checkedListBoxItem.Value);
                     }
                 }
                 _startDate = DateTime.Now;
                 marqueeProgressBarControl1.Visible = true;
                 _maintimer.Enabled = true;
             }
             catch (Exception ex)
             {
                 int num = (int)XtraMessageBox.Show(ex.Message, Messages.IdentificationServerUnavailble, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
     else
     {
         int num1 = (int)XtraMessageBox.Show(Messages.NoFaceWasFound, Messages.Message, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
 }
Esempio n. 4
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            if (pictureEdit1.Image == null)
            {
                return;
            }
            foreach (DataRow dataRow in (InternalDataCollectionBase)_mainTable.Rows)
            {
                try
                {
                    ((System.Drawing.Image)dataRow["Image"]).Dispose();
                }
                catch
                {
                }
            }
            _mainTable.Rows.Clear();
            Image    image = ((Bitmap)pictureEdit1.Image).ConvertFrom();
            FaceInfo face  = MainForm.Engine.DetectMaxFace(image, null);

            if (face != null)
            {
                foreach (BcIdentificationServer identificationServer in BcIdentificationServer.LoadAll())
                {
                    try
                    {
                        byte[]                     template                   = MainForm.Engine.ExtractTemplate(image, face);
                        BcServerSettings           bcServerSettings           = BcServerSettings.Load();
                        IdentificationServerClient identificationServerClient = new IdentificationServerClient(new InstanceContext(_client));
                        identificationServerClient.Endpoint.Address = new EndpointAddress("net.tcp://" + (object)bcServerSettings.Ip + ":" + (string)(object)bcServerSettings.Port + "/FaceIdentification/IdentificationServer");
                        identificationServerClient.Open();
                        List <Guid> list   = new List <Guid>();
                        long        dtFrom = 0;
                        if (this.dtFrom.Text != "")
                        {
                            dtFrom = this.dtFrom.DateTime.Date.Ticks;
                        }
                        long dtBefore = 0;
                        if (this.dtBefore.Text != "")
                        {
                            dtBefore = this.dtBefore.DateTime.Date.Ticks;
                        }
                        if (template != null)
                        {
                            identificationServerClient.DbSearch((int)spinEdit1.Value, Convert.ToSingle(tbScore.Text), dtFrom, dtBefore, cbSex.SelectedIndex, template);
                            _startDate = DateTime.Now;
                            marqueeProgressBarControl1.Visible = true;
                            _maintimer.Enabled = true;
                            break;
                        }
                        int num = (int)XtraMessageBox.Show(Messages.Error, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    catch (Exception ex)
                    {
                        int num = (int)XtraMessageBox.Show(ex.Message, Messages.IdentificationServerUnavailble, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
            else
            {
                int num1 = (int)XtraMessageBox.Show(Messages.NoFaceWasFound, Messages.Message, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }