Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.IMS_FACE_BLACKLIST model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update IMS_FACE_BLACKLIST set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Sex=@Sex,");
            strSql.Append("FacePic=@FacePic,");
            strSql.Append("Description=@Description");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.VarChar,    50),
                new SqlParameter("@Sex",         SqlDbType.TinyInt,     1),
                new SqlParameter("@FacePic",     SqlDbType.VarChar,   500),
                new SqlParameter("@Description", SqlDbType.VarBinary, 500),
                new SqlParameter("@ID",          SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Sex;
            parameters[2].Value = model.FacePic;
            parameters[3].Value = model.Description;
            parameters[4].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(Maticsoft.Model.IMS_FACE_BLACKLIST model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into IMS_FACE_BLACKLIST(");
            strSql.Append("Name,Sex,FacePic,Description)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Sex,@FacePic,@Description)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.VarChar,    50),
                new SqlParameter("@Sex",         SqlDbType.TinyInt,     1),
                new SqlParameter("@FacePic",     SqlDbType.VarChar,   500),
                new SqlParameter("@Description", SqlDbType.VarBinary, 500)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Sex;
            parameters[2].Value = model.FacePic;
            parameters[3].Value = model.Description;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToDecimal(obj));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.IMS_FACE_BLACKLIST DataRowToModel(DataRow row)
 {
     Maticsoft.Model.IMS_FACE_BLACKLIST model = new Maticsoft.Model.IMS_FACE_BLACKLIST();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = decimal.Parse(row["ID"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Sex"] != null && row["Sex"].ToString() != "")
         {
             model.Sex = int.Parse(row["Sex"].ToString());
         }
         if (row["FacePic"] != null)
         {
             model.FacePic = row["FacePic"].ToString();
         }
         if (row["Description"] != null && row["Description"].ToString() != "")
         {
             model.Description = (byte[])row["Description"];
         }
     }
     return(model);
 }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 private void listFaces_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
 {
     if (listFaces.SelectedItems.Count > 0)
     {
         Maticsoft.Model.IMS_FACE_BLACKLIST bl = (Maticsoft.Model.IMS_FACE_BLACKLIST)listFaces.SelectedItems[0].Tag;
         tbName.Text = bl.Name;
         try
         {
             tbDesc.Text = Encoding.UTF8.GetString(bl.Description);
         }
         catch (Exception)
         {
         }
         if (bl.Sex == null)
         {
             bl.Sex = 0;
         }
         if (bl.Sex == 0)
         {
             tbSex.Text = "未知";
         }
         else if (bl.Sex == 1)
         {
             tbSex.Text = "男";
         }
         else
         {
             tbSex.Text = "女";
         }
         if (picBox.Image != null)
         {
             picBox.Image.Dispose();
             picBox.Image = null;
         }
         WebImageReader.ReadImageAsync(bl.FacePic, new WebImageReader.ReadImageCallBack((i, ee) =>
         {
             if (i != null)
             {
                 lock (this)
                 {
                     this.Invoke(new Action(() =>
                     {
                         picBox.Image = i;
                     }));
                 }
             }
         }));
     }
 }
Ejemplo n.º 7
0
        private void biModify_Click(object sender, EventArgs e)
        {
            FrmEditorFaceBackList frmlist = new FrmEditorFaceBackList();

            if (listFaces.SelectedItems.Count == 0)
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择修改的人脸!");
                return;
            }
            Maticsoft.Model.IMS_FACE_BLACKLIST bl = (Maticsoft.Model.IMS_FACE_BLACKLIST)listFaces.SelectedItems[0].Tag;
            frmlist.FACE = bl;
            if (frmlist.ShowDialog(this) == DialogResult.OK)
            {
                AddFace(frmlist.FACE, listFaces.SelectedItems[0]);
            }
        }
Ejemplo n.º 8
0
        private void AddFace(Maticsoft.Model.IMS_FACE_BLACKLIST bl, ListViewItem item = null)
        {
            ListViewItem lvi = null;

            if (item != null)
            {
                lvi = item;
            }
            else
            {
                lvi = new ListViewItem(bl.Name);
                listFaces.Items.Add(lvi);
            }
            lvi.Tag = bl;
            if (lvi.ImageKey == null || lvi.ImageKey == "")
            {
                lvi.ImageKey = "loading";
            }
            if (lvi.ImageKey != "loading")
            {
                Image image = imageList.Images[lvi.ImageKey];
                imageList.Images.RemoveByKey(lvi.ImageKey);
                image.Dispose();
            }
            WebImageReader.ReadImageAsync(bl.FacePic, new WebImageReader.ReadImageCallBack((i, e) =>
            {
                if (i != null)
                {
                    lock (this)
                    {
                        this.Invoke(new Action(() =>
                        {
                            string k = Guid.NewGuid().ToString("N");
                            imageList.Images.Add(k, i);
                            lvi.ImageKey = k;
                        }));
                    }
                }
            }));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.IMS_FACE_BLACKLIST GetModel(decimal ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Name,Sex,FacePic,Description from IMS_FACE_BLACKLIST ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Decimal)
            };
            parameters[0].Value = ID;

            Maticsoft.Model.IMS_FACE_BLACKLIST model = new Maticsoft.Model.IMS_FACE_BLACKLIST();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }