private void btnRegisterImage_Click(object sender, EventArgs e) { SysUser user = new SysUser(); MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); SysUserBLL SysUserBLL = new SysUserBLL(); var MesDevice = MesDeviceBLL.GetList_Deparemaent(D_Code.Text, ""); user = SysUserBLL.getDetail(PrimaryKey); string url = "http://" + MesDevice[0].D_IP + ":8090/person/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("人脸识别注册成功!"); } }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("是否要保存", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); var rows = MesDeviceBLL.GetList(); if (rows.Count > 0) { for (int i = 0; i < rows.Count; i++) { string url = "http://" + rows[i].D_IP + ":8090/setIdentifyCallBack"; string postData = "pass="******"&" + "callbackUrl=" + txtUrl.Text; //http://192.168.1.140:8090/api/FaceRecording/GetUserInfo"; string strtemp = FaceRecognition.RequestWithHttps(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("人脸识别回调设置成功!"); } } } } }
private void btn_SettingPassword_Click(object sender, EventArgs e) { string url = "http://192.168.1.128:8090/setPassWord"; string postData = "oldPass="******"&newPass="******"该IP地址不可用!"); return; } JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp); string strData; if (bool.Parse(joModel["success"].ToString())) { strData = joModel["data"].ToString(); } else { strData = joModel["msg"].ToString(); } untCommon.InfoMsg(strData); }
private void cmb_Device_SelectedIndexChanged(object sender, EventArgs e) { try { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); pictureBox1.Image = null; } if (dataGridView.SelectedRows.Count < 1) { return; } string EnCode = dataGridView.SelectedRows[0].Cells["工号"].Value.ToString(); MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); var MesDevice = MesDeviceBLL.GetList_Name(cmb_Device.Text); if (MesDevice.Count < 1) { return; } string url = "http://" + MesDevice[0].D_IP + ":8090/face/find"; string postData = "pass="******"&personId=" + 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("人脸识别注册成功!"); var jData = (JArray)joModel["data"]; string strUrl = ""; List <string> list = new List <string>(); for (var i = 0; i < jData.Count; i++) { var jObj = (JObject)jData[i]; strUrl = (string)jObj["path"].ToString(); list.Add(strUrl); } Stream stream = FaceRecognition.Info(list[0].ToString()); pictureBox1.Image = Image.FromStream(stream); } } catch (Exception) { untCommon.InfoMsg("照片显示错误!"); } }
private void loadData() { try { MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); var rows = MesDeviceBLL.GetList(); if (rows == null || rows.Count < 1) { untCommon.InfoMsg("没有任何设备信息数据!"); dataGridView.DataSource = rows; return; } dataGridView.DataSource = rows; for (int i = 0; i < rows.Count; i++) { string url = "http://" + rows[i].D_IP + ":8090/getDeviceKey"; string postData = ""; string strtemp = FaceRecognition.Port(url, postData); if (FaceRecognition.json(strtemp)) { JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp); string strData; if (bool.Parse(joModel["success"].ToString())) { strData = joModel["result"].ToString(); } else { strData = joModel["msg"].ToString(); } if (strData == "1") { this.dataGridView.Rows[i].Cells["设备状态"].Value = "在线"; } else { this.dataGridView.Rows[i].Cells["设备状态"].Value = "离线"; } } else { //untCommon.InfoMsg("该IP地址不可用!"); this.dataGridView.Rows[i].Cells["设备状态"].Value = "离线"; } } } catch (Exception ex) { untCommon.ErrorMsg("设备信息加载数据异常:" + ex.Message); } }
/// <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 }
private void btnUploadServer(object sender, EventArgs e) { SysUserBLL userbll = new SysUserBLL(); SysUser user = userbll.getDetail(F_Account); 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/delete"; //string postData = "pass="******"\n" + "&personId=" + user.F_EnCode + "\n" + "&faceId=" + ID + "\n" + "&imgBase64:" + strBase64 + ""; string postData = "pass="******"&faceId=" + user.F_EnCode + ""; 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("人脸图片删除成功!"); } } }
/// <summary> /// 校验输入 /// </summary> /// <returns></returns> private bool checkInput() { if (string.IsNullOrEmpty(txt_DeviceName.Text.Trim())) { untCommon.InfoMsg("设备名称不能为空!"); return(false); } if (string.IsNullOrEmpty(cmb_Department.Text)) { untCommon.InfoMsg("部门不能为空!"); return(false); } if (string.IsNullOrEmpty(txt_IP.Text)) { untCommon.InfoMsg("IP地址不能为空!"); return(false); } else { string url = "http://" + txt_IP.Text + ":8090/getDeviceKey"; string postData = ""; string strtemp = FaceRecognition.Port(url, postData); if (!FaceRecognition.json(strtemp)) { untCommon.InfoMsg("该IP地址不可用!"); return(false); } JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp); if (!bool.Parse(joModel["success"].ToString())) { untCommon.InfoMsg("该IP地址不可用!"); return(false); } } return(true); }
private void button2_Click_1(object sender, EventArgs e) { MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); var MesDevice = MesDeviceBLL.GetList_Deparemaent(txtDepartment.Text, txtTeam.Text); SysUserBLL userbll = new SysUserBLL(); var user = userbll.getDetail_F_EnCode(F_Account); 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/person/delete"; string postData = "pass="******"&id=" + user[i].F_Account + ""; string strtemp = FaceRecognition.RequestWithHttps(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 { label3.Text = "未注册"; pictureBox1.Image = null; untCommon.InfoMsg("人脸识别用户删除成功!"); } } }
/// <summary> /// 注册人员到设备 /// </summary> private void RegFace() { #region MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); var MesDevice = MesDeviceBLL.GetList_Deparemaent(txtDepartment.Text, txtTeam.Text); SysUserBLL userbll = new SysUserBLL(); var user = userbll.getDetail_F_EnCode(F_Account); 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/person/create"; string postData = "pass="******"&person={\"id\":" + "\"" + user[i].F_Account + "\"," + "\"idcardNum\":" + "\"" + null + "\"," + "\"name\":" + "\"" + txtUserName.Text + "\"" + "}"; string strtemp = FaceRecognition.RequestWithHttps(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("人脸识别用户注册成功!"); } } #endregion }
private void btnFind_Click(object sender, EventArgs e) { AMBaseDepartmentBLL AMBaseDepartmentBLL = new AMBaseDepartmentBLL(); SysUserBLL SysUserBLL = new SysUserBLL(); SysUser SysUser = new SysUser(); List <SysUser> user = new List <SysUser>(); user.Clear(); string tree = treeView1.SelectedNode.Text; var rows = AMBaseDepartmentBLL.GetList_F_ID(tree); if (rows == null || rows.Count < 1) { untCommon.InfoMsg("该部门暂无人员,请选择正确的部门!"); return; } for (int i = 0; i < rows.Count; i++) { MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); SysUser = SysUserBLL.getDetail_F_DepartmentId(rows[i].F_DepartmentId); if (SysUser != null && !string.IsNullOrEmpty(SysUser.ToString())) { var MesDeviceID = MesDeviceBLL.GetList_Deparemaent(tree, ""); string personId = ""; if (string.IsNullOrEmpty(txt_name.Text)) { personId = "-1"; } else { personId = txt_name.Text.Trim();//SysUser.F_EnCode } for (int j = 0; i < rows.Count; i++) { SysUser.K_Device = MesDeviceID[j].D_Name; string url = "http://" + MesDeviceID[j].D_IP + ":8090/findRecords"; string postData = "pass=12345678&personId=" + personId + "&length=-1&index=0&startTime=0&endTime=0"; string strtemp = FaceRecognition.Port(url, postData); if (FaceRecognition.json(strtemp)) { JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp); string strData; if (bool.Parse(joModel["success"].ToString())) { strData = joModel["result"].ToString(); } else { strData = joModel["msg"].ToString(); untCommon.InfoMsg(strData); } if (joModel["result"].ToString() == "1") { //this.dataGridView.Rows[i].Cells["状态"].Value = "在线"; SysUser.K_Status = "签到成功"; var data = joModel["data"]; var records = (JArray)data["records"]; var jObj = (JObject)records[0]; var strTime = (string)jObj["time"].ToString(); DateTime time = FaceRecognition.ConvertToDateTime(strTime); SysUser.K_Time = time.ToString(); } else { //this.dataGridView.Rows[i].Cells["状态"].Value = "离线"; SysUser.K_Status = "签到失败"; } } else { untCommon.InfoMsg("该IP地址不可用!"); //this.dataGridView.Rows[i].Cells["状态"].Value = "离线"; SysUser.K_Status = "签到失败"; } user.Add(SysUser); } } } if (user == null || user.Count < 1) { untCommon.InfoMsg("该部门暂无人员!"); return; } dataGridView.DataSource = user; }
private void btnDelete_Click(object sender, EventArgs e) { try { if (pictureBox1.Image == null) { untCommon.InfoMsg("请选择正确的照片!"); return; } photo(); MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); AMBaseAnnexesFileBLL AMBaseAnnexesFileBLL = new AMBaseAnnexesFileBLL(); string D_Code = dataGridView.SelectedRows[0].Cells["部门"].Value.ToString(); var MesDevice = MesDeviceBLL.GetList_Deparemaent(D_Code, ""); string F_Account = dataGridView.SelectedRows[0].Cells["账号"].Value.ToString(); SysUserBLL SysUserBLL = new SysUserBLL(); var rows = SysUserBLL.getDetail(F_Account); string faceId = ""; switch (cmb_Image.Text) { case "照片1": faceId = rows.F_Picture1; rows.F_Picture1 = null; break; case "照片2": faceId = rows.F_Picture2; rows.F_Picture2 = null; break; case "照片3": faceId = rows.F_Picture3; rows.F_Picture3 = null; break; } string url = "http://" + MesDevice[0].D_IP + ":8090/face/delete"; //string postData = "pass="******"\n" + "&personId=" + user.F_EnCode + "\n" + "&faceId=" + ID + "\n" + "&imgBase64:" + strBase64 + ""; string postData = "pass="******"&faceId=" + faceId + ""; 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 { if (SysUserBLL.Edit(rows) > 0) { AMBaseAnnexesFileBLL.DeleteEntity(faceId); untCommon.InfoMsg("照片删除成功!"); pictureBox1.Image.Dispose(); pictureBox1.Image = null; } } } catch (Exception ex) { untCommon.ErrorMsg("照片删除失败!"); } }
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("人脸识别注册成功!"); * }*/ }
private void frmFaceRecognitionRegistration_Load(object sender, EventArgs e) { #region SysUserBLL userbll = new SysUserBLL(); SysUser user = userbll.getDetail(F_Account); imagefile = Application.StartupPath + "\\img\\" + user.F_Account + ".jpg"; string urlpicture = "http://183.236.45.60:7001/picture/" + user.F_Account + ".jpg"; Down(imagefile, urlpicture); //if(!File.Exists(imagefile)) //{ // untCommon.InfoMsg("该用户还没有图片,请先上传图片!"); // this.Close(); // return; //} if (File.Exists(imagefile)) { FileStream fs = new FileStream(imagefile, FileMode.Open, FileAccess.Read); Byte[] mybyte = new byte[fs.Length]; fs.Read(mybyte, 0, mybyte.Length); fs.Close(); MemoryStream ms = new MemoryStream(mybyte); Bitmap myimge = new Bitmap(ms); pictureBox1.Image = myimge; } AMBaseDepartmentBLL AMBaseDepartmentBLL = new AMBaseDepartmentBLL(); // var rows = AMBaseDepartmentBLL.GetList_ID(user.F_DepartmentId); List <AMBaseDepartmentEntity> rows = AMBaseDepartmentBLL.GetList_D_Name(); txtDepartment.Text = user.D_Code; txtUserName.Text = user.F_RealName; txtTeam.Text = user.F_TeamName; MesDeviceBLL MesDeviceBLL = new MesDeviceBLL(); var MesDevice = MesDeviceBLL.GetList_Deparemaent(txtDepartment.Text, txtTeam.Text); if (MesDevice.Count < 1 || MesDevice == null) { untCommon.InfoMsg("该部门暂无人脸识别设备!"); this.Close(); return; } string url = "http://" + MesDevice[0].D_IP + ":8090/person/findByPage"; string postData = "pass=12345678&personId=" + user.F_Account; string strtemp = FaceRecognition.Port(url, postData); if (!FaceRecognition.json(strtemp)) { label3.Text = "该部门暂无可用设备"; return; } JObject joModel = (JObject)JsonConvert.DeserializeObject(strtemp); if (!bool.Parse(joModel["success"].ToString())) { label3.Text = "未注册"; return; } else { label3.Text = "已注册"; } #endregion }
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("照片上传失败!"); } }