/// <summary>
        /// 更新照片
        /// </summary>
        private void UpdatePicture()
        {
            #region
            try
            {
                SysUserBLL userbll = new SysUserBLL();
                SysUser    user    = userbll.getDetail(F_Account);

                string strBase64 = FaceRecognition.ImageToBase64(imagefile);//照片转base64

                MesDeviceBLL MesDeviceBLL = new MesDeviceBLL();
                var          MesDevice    = MesDeviceBLL.GetList_Deparemaent(txtDepartment.Text, txtTeam.Text);
                if (MesDevice.Count < 1 || MesDevice == null)
                {
                    untCommon.InfoMsg("该部门暂无人脸识别设备!");
                    return;
                }

                for (int i = 0; i < MesDevice.Count; i++)
                {
                    string url      = "http://" + MesDevice[i].D_IP + ":8090/face/update";
                    string postData = "pass="******"&personId=" + user.F_Account + "&faceId=" + user.F_Account + "&imgBase64=" + strBase64 + "";
                    string strtemp  = FaceRecognition.HttpPost(url, postData);
                    if (!FaceRecognition.json(strtemp))
                    {
                        untCommon.InfoMsg("该IP地址不可用!");
                        pictureBox1.Image.Dispose();
                        pictureBox1.Image = null;
                        return;
                    }
                    JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp);
                    if (!bool.Parse(joModel["success"].ToString()))
                    {
                        untCommon.InfoMsg(joModel["msg"].ToString());
                        return;
                    }
                    else
                    {
                        untCommon.InfoMsg("人脸识别更新成功!");
                    }
                }
            }
            catch (Exception ex)
            {
                untCommon.ErrorMsg("照片上传失败!");
            }
            #endregion
        }
Esempio n. 2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (pictureBox1.Image != null)
                {
                    pictureBox1.Image.Dispose();
                    pictureBox1.Image = null;
                }
                if (dataGridView.SelectedRows.Count < 1)
                {
                    return;
                }
                photo();
                if (pictureBox1.Image == null)
                {
                    untCommon.InfoMsg("请选择正确的照片!");
                    return;
                }
                if (file())
                {
                    string     ID         = Guid.NewGuid().ToString("N");//照片名称
                    SysUser    user       = new SysUser();
                    SysUserBLL SysUserBLL = new SysUserBLL();
                    string     F_Account  = dataGridView.SelectedRows[0].Cells["账号"].Value.ToString();
                    user = SysUserBLL.getDetail(F_Account);
                    AMBaseAnnexesFileEntity AMBaseAnnexesFileEntity = new AMBaseAnnexesFileEntity();
                    AMBaseAnnexesFileBLL    AMBaseAnnexesFileBLL    = new AMBaseAnnexesFileBLL();
                    AMBaseAnnexesFileEntity.F_Id             = ID;
                    AMBaseAnnexesFileEntity.F_FolderId       = Guid.NewGuid().ToString();
                    AMBaseAnnexesFileEntity.F_FileName       = Path.GetFileName(imagefile);//获取文件名和扩展名
                    AMBaseAnnexesFileEntity.F_FilePath       = "D:/fileAnnexes/shop_erp/System/" + DateTime.Now.ToString("yyyyMMdd") + "/" + AMBaseAnnexesFileEntity.F_Id;
                    AMBaseAnnexesFileEntity.F_FileSize       = fileInfoLength;
                    AMBaseAnnexesFileEntity.F_FileExtensions = Path.GetExtension(imagefile);                        //获取文件扩展名
                    AMBaseAnnexesFileEntity.F_FileType       = imagefile.Substring(imagefile.LastIndexOf(".") + 1); // Path.GetExtension(imagefile).Substring(0, 1);
                    //AMBaseAnnexesFileEntity.F_DownloadCount = "";
                    AMBaseAnnexesFileEntity.F_CreateDate     = DateTime.Now;
                    AMBaseAnnexesFileEntity.F_CreateUserId   = SysUser.F_Account.ToString();
                    AMBaseAnnexesFileEntity.F_CreateUserName = SysUser.F_RealName.ToString();

                    user.F_Account = F_Account;
                    switch (cmb_Image.Text)
                    {
                    case "照片1":
                        user.F_Picture1 = AMBaseAnnexesFileEntity.F_Id;
                        break;

                    case "照片2":
                        user.F_Picture2 = AMBaseAnnexesFileEntity.F_Id;
                        break;

                    case "照片3":
                        user.F_Picture3 = AMBaseAnnexesFileEntity.F_Id;
                        break;
                    }

                    //Computer MyComputer = new Computer();
                    //imagefile = System.AppDomain.CurrentDomain.BaseDirectory;
                    //MyComputer.FileSystem.RenameFile(imagefile, image);//imagefile是所要重命名的文件的全路径,image是目标文件名
                    //image = Path.GetFileNameWithoutExtension(imagefile);// 没有扩展名的文件名
                    //FaceRecognition.Get_zjdz(imagefile);
                    string strBase64 = FaceRecognition.ImageToBase64(imagefile);//照片转base64

                    MesDeviceBLL MesDeviceBLL = new MesDeviceBLL();
                    string       D_Code       = dataGridView.SelectedRows[0].Cells["部门"].Value.ToString();
                    var          MesDevice    = MesDeviceBLL.GetList_Deparemaent(D_Code, "");
                    if (MesDevice.Count < 1 || MesDevice == null)
                    {
                        untCommon.InfoMsg("该部门暂无人脸识别设备!");
                        return;
                    }
                    string url = "http://" + MesDevice[0].D_IP + ":8090/face/update";

                    //string postData = "pass="******"\n" + "&personId=" + user.F_EnCode + "\n" + "&faceId=" + ID + "\n" + "&imgBase64:" + strBase64 + "";

                    string postData = "pass="******"&personId=" + user.F_EnCode + "&faceId=" + ID + "&imgBase64=" + strBase64 + "";
                    string strtemp  = FaceRecognition.HttpPost(url, postData);
                    if (!FaceRecognition.json(strtemp))
                    {
                        untCommon.InfoMsg("该IP地址不可用!");
                        return;
                    }
                    JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp);
                    if (!bool.Parse(joModel["success"].ToString()))
                    {
                        untCommon.InfoMsg(joModel["msg"].ToString());
                        return;
                    }
                    else
                    {
                        untCommon.InfoMsg("人脸识别更新成功!");
                        string F_Picture = "";
                        switch (cmb_Image.Text)
                        {
                        case "照片1":
                            user.F_Picture1 = F_Picture;
                            break;

                        case "照片2":
                            user.F_Picture2 = F_Picture;
                            break;

                        case "照片3":
                            user.F_Picture3 = F_Picture;
                            break;
                        }
                        if (AMBaseAnnexesFileBLL.SaveEntityTrans("", user.F_UserId, F_Picture, AMBaseAnnexesFileEntity, user) > 0)
                        {
                            untCommon.InfoMsg("照片上传成功!");
                        }
                        else
                        {
                            untCommon.InfoMsg("照片上传失败!");
                        }
                    }
                    //if (AMBaseAnnexesFileBLL.SaveEntity("", AMBaseAnnexesFileEntity) > 0)
                    //{
                    //    if (SysUserBLL.Edit(user) > 0)
                    //    {

                    //    }
                    //    else
                    //    {
                    //        untCommon.InfoMsg("上传失败!");
                    //    }
                    //}
                    //else
                    //{
                    //    untCommon.InfoMsg("上传失败!");
                    //}
                    //string url = "183.236.45.60";
                    //if (FaceRecognition.uploadFileByHttp(url, imagefile))
                    //{
                    //}
                }
            }
            catch (Exception ex)
            {
                untCommon.ErrorMsg("照片上传失败!");
            }
        }
        private void btnRegisterImage_Click(object sender, EventArgs e)
        {
            SysUserBLL userbll = new SysUserBLL();
            SysUser    user    = userbll.getDetail(F_Account);

            string strBase64 = FaceRecognition.ImageToBase64(imagefile);//照片转base64

            MesDeviceBLL MesDeviceBLL = new MesDeviceBLL();
            var          MesDevice    = MesDeviceBLL.GetList_Deparemaent(txtDepartment.Text, txtTeam.Text);

            if (MesDevice.Count < 1 || MesDevice == null)
            {
                untCommon.InfoMsg("该部门暂无人脸识别设备!");
                return;
            }
            for (int i = 0; i < MesDevice.Count; i++)
            {
                string url = "http://" + MesDevice[i].D_IP + ":8090/face/create";

                //string postData = "pass="******"\n" + "&personId=" + user.F_EnCode + "\n" + "&faceId=" + ID + "\n" + "&imgBase64:" + strBase64 + "";

                string postData = "pass="******"&personId=" + user.F_EnCode + "&faceId=" + user.F_EnCode + "&imgBase64=" + strBase64 + "";
                string strtemp  = FaceRecognition.HttpPost(url, postData);
                if (!FaceRecognition.json(strtemp))
                {
                    untCommon.InfoMsg("该IP地址不可用!");
                    pictureBox1.Image.Dispose();
                    pictureBox1.Image = null;
                    return;
                }
                JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp);
                if (!bool.Parse(joModel["success"].ToString()))
                {
                    untCommon.InfoMsg(joModel["msg"].ToString());
                    return;
                }
                else
                {
                    untCommon.InfoMsg("人脸识别注册成功!");
                }
            }

            /*SysUser user = new SysUser();
             * MesDeviceBLL MesDeviceBLL = new MesDeviceBLL();
             * SysUserBLL SysUserBLL = new SysUserBLL();
             * var MesDevice = MesDeviceBLL.GetList_Deparemaent(txtDepartment.Text,txtTeam.Text);
             * user = SysUserBLL.getDetail(F_Account);
             * if (MesDevice.Count <1)
             * {
             *  untCommon.InfoMsg("该部门没有可用设备!");
             *  return;
             * }
             * string url = "http://" + MesDevice[0].D_IP + ":8090/face/takeImg";
             *
             * string postData = "pass=12345678&personId=" + user.F_EnCode + "";
             *
             * string strtemp = FaceRecognition.Port(url, postData);
             * if (!FaceRecognition.json(strtemp))
             * {
             *  untCommon.InfoMsg("该IP地址不可用!");
             *  return;
             * }
             * JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp);
             * if (!bool.Parse(joModel["success"].ToString()))
             * {
             *  untCommon.InfoMsg(joModel["msg"].ToString());
             *  return;
             * }
             * else
             * {
             *  untCommon.InfoMsg("人脸识别注册成功!");
             * }*/
        }
Esempio n. 4
0
        private void btnUploadImage_Click(object sender, EventArgs e)
        {
            try
            {
                if (file())
                {
                    string     ID         = Guid.NewGuid().ToString("N");//照片名称
                    SysUser    user       = new SysUser();
                    SysUserBLL SysUserBLL = new SysUserBLL();
                    AMBaseAnnexesFileEntity AMBaseAnnexesFileEntity = new AMBaseAnnexesFileEntity();
                    AMBaseAnnexesFileBLL    AMBaseAnnexesFileBLL    = new AMBaseAnnexesFileBLL();
                    AMBaseAnnexesFileEntity.F_Id             = ID;
                    AMBaseAnnexesFileEntity.F_FolderId       = Guid.NewGuid().ToString();
                    AMBaseAnnexesFileEntity.F_FileName       = Path.GetFileName(imagefile);//获取文件名和扩展名
                    AMBaseAnnexesFileEntity.F_FilePath       = "D:/fileAnnexes/shop_erp/System/" + DateTime.Now.ToString("yyyyMMdd") + "/" + AMBaseAnnexesFileEntity.F_Id;
                    AMBaseAnnexesFileEntity.F_FileSize       = fileInfoLength;
                    AMBaseAnnexesFileEntity.F_FileExtensions = Path.GetExtension(imagefile);                        //获取文件扩展名
                    AMBaseAnnexesFileEntity.F_FileType       = imagefile.Substring(imagefile.LastIndexOf(".") + 1); // Path.GetExtension(imagefile).Substring(0, 1);
                    //AMBaseAnnexesFileEntity.F_DownloadCount = "";
                    AMBaseAnnexesFileEntity.F_CreateDate     = DateTime.Now;
                    AMBaseAnnexesFileEntity.F_CreateUserId   = SysUser.F_Account.ToString();
                    AMBaseAnnexesFileEntity.F_CreateUserName = SysUser.F_RealName.ToString();

                    user.F_Account = PrimaryKey;
                    switch (cmbImage.Text)
                    {
                    case "照片1":
                        user.F_Picture1 = AMBaseAnnexesFileEntity.F_Id;
                        break;

                    case "照片2":
                        user.F_Picture2 = AMBaseAnnexesFileEntity.F_Id;
                        break;

                    case "照片3":
                        user.F_Picture3 = AMBaseAnnexesFileEntity.F_Id;
                        break;

                    case "照片4":
                        user.F_Picture4 = AMBaseAnnexesFileEntity.F_Id;
                        break;

                    case "照片5":
                        user.F_Picture5 = AMBaseAnnexesFileEntity.F_Id;
                        break;
                    }

                    //Computer MyComputer = new Computer();
                    //imagefile = System.AppDomain.CurrentDomain.BaseDirectory;
                    //MyComputer.FileSystem.RenameFile(imagefile, image);//imagefile是所要重命名的文件的全路径,image是目标文件名
                    //image = Path.GetFileNameWithoutExtension(imagefile);// 没有扩展名的文件名
                    //FaceRecognition.Get_zjdz(imagefile);
                    string str = FaceRecognition.ImageToBase64(imagefile);

                    if (AMBaseAnnexesFileBLL.SaveEntity("", AMBaseAnnexesFileEntity) > 0)
                    {
                        if (SysUserBLL.Edit(user) > 0)
                        {
                            MesDeviceBLL MesDeviceBLL = new MesDeviceBLL();
                            var          MesDevice    = MesDeviceBLL.GetList_Deparemaent(D_Code.Text, "");
                            user = SysUserBLL.getDetail(PrimaryKey);

                            string url = "http://" + MesDevice[0].D_IP + ":8090/person/create";

                            string postData = "pass=12345678&personId=" + user.F_EnCode + "&faceId=" + ID + "&imgBase64" + str + "";

                            string strtemp = FaceRecognition.Port(url, postData);
                            if (!FaceRecognition.json(strtemp))
                            {
                                untCommon.InfoMsg("该IP地址不可用!");
                                return;
                            }
                            JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp);
                            if (!bool.Parse(joModel["success"].ToString()))
                            {
                                untCommon.InfoMsg(joModel["msg"].ToString());
                                return;
                            }
                            else
                            {
                                untCommon.InfoMsg("人脸识别注册成功!");
                            }
                            switch (cmbImage.Text)
                            {
                            case "照片1":
                                AMBaseAnnexesFileBLL.DeleteEntity(user.F_Picture1);
                                break;

                            case "照片2":
                                AMBaseAnnexesFileBLL.DeleteEntity(user.F_Picture2);
                                break;

                            case "照片3":
                                AMBaseAnnexesFileBLL.DeleteEntity(user.F_Picture3);
                                break;

                            case "照片4":
                                AMBaseAnnexesFileBLL.DeleteEntity(user.F_Picture4);
                                break;

                            case "照片5":
                                AMBaseAnnexesFileBLL.DeleteEntity(user.F_Picture5);
                                break;
                            }
                        }
                        else
                        {
                            untCommon.InfoMsg("上传失败!");
                        }
                    }
                    else
                    {
                        untCommon.InfoMsg("上传失败!");
                    }
                    //string url = "183.236.45.60";
                    //if (FaceRecognition.uploadFileByHttp(url, imagefile))
                    //{
                    //}
                }
            }
            catch (Exception ex)
            {
                untCommon.ErrorMsg("照片上传失败!");
            }
        }