Exemplo n.º 1
0
        private void FaceBlackListMgr_Load(object sender, EventArgs e)
        {
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.IMS_FACE_BLACKLIST blBll = new Maticsoft.BLL.IMS_FACE_BLACKLIST();
                    var models = blBll.GetModelList("");
                    this.Invoke(new Action(() =>
                    {
                        listFaces.Items.Clear();
                        foreach (var item in models)
                        {
                            AddFace(item);
                        }
                    }));
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "加载人脸黑名单异常:" + ex.Message);
                    log.Error("加载人脸黑名单异常", ex);
                }
            });

            waiting.Show(this);
        }
Exemplo n.º 2
0
        private void biDelete_Click(object sender, EventArgs e)
        {
            if (listFaces.SelectedItems.Count == 0)
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择删除的人脸!");
                return;
            }
            if (MessageBox.Show("确定删除选择项?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                List <ListViewItem> items = new List <ListViewItem>();
                foreach (ListViewItem item in listFaces.SelectedItems)
                {
                    items.Add(item);
                }
                CtrlWaiting waiting = new CtrlWaiting(() =>
                {
                    try
                    {
                        List <decimal> ids = new List <decimal>();

                        foreach (var item in items)
                        {
                            Maticsoft.Model.IMS_FACE_BLACKLIST bl = (Maticsoft.Model.IMS_FACE_BLACKLIST)item.Tag;
                            ids.Add(bl.ID);
                        }

                        Maticsoft.BLL.IMS_FACE_BLACKLIST blBll = new Maticsoft.BLL.IMS_FACE_BLACKLIST();
                        blBll.DeleteList(string.Join(",", ids));

                        this.Invoke(new Action(() =>
                        {
                            foreach (var lvi in items)
                            {
                                if (lvi.ImageKey == null || lvi.ImageKey == "" || lvi.ImageKey == "loading")
                                {
                                    listFaces.Items.Remove(lvi);
                                }
                                else
                                {
                                    Image image = imageList.Images[lvi.ImageKey];
                                    imageList.Images.RemoveByKey(lvi.ImageKey);
                                    image.Dispose();
                                    listFaces.Items.Remove(lvi);
                                }
                            }
                        }));
                    }
                    catch (Exception ex)
                    {
                        WinInfoHelper.ShowInfoWindow(this, "删除人脸黑名单异常:" + ex.Message);
                        log.Error("删除人脸黑名单异常", ex);
                    }
                });
                waiting.Show(this);
            }
        }
Exemplo n.º 3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbName.Text))
            {
                WinInfoHelper.ShowInfoWindow(this, "名称不能为空!");
                tbName.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(tbPicPath.Text))
            {
                WinInfoHelper.ShowInfoWindow(this, "人脸照片不能为空!");
                return;
            }
            if (FACE == null)
            {
                FACE    = new Maticsoft.Model.IMS_FACE_BLACKLIST();
                FACE.ID = -1;
            }
            FACE.FacePic     = tbPicPath.Text;
            FACE.Name        = tbName.Text.Trim();
            FACE.Description = Encoding.UTF8.GetBytes(tbDesc.Text);
            FACE.Sex         = cbSex.SelectedIndex;
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    Maticsoft.BLL.IMS_FACE_BLACKLIST flBll = new Maticsoft.BLL.IMS_FACE_BLACKLIST();
                    if (FACE.ID == -1)
                    {
                        FACE.ID = flBll.Add(FACE);
                    }
                    else
                    {
                        flBll.Update(FACE);
                    }
                    this.BeginInvoke(new Action(() =>
                    {
                        if (picBox.Image != null)
                        {
                            picBox.Image.Dispose();
                            picBox.Image = null;
                        }
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }));
                }
                catch (Exception ex)
                {
                    log.Error("保存人脸异常:", ex);
                    WinInfoHelper.ShowInfoWindow(this, "保存人脸异常:" + ex.Message);
                }
            });

            waiting.Show(this);
        }