private void listComparisonRecord_MouseDoubleClick(object sender, RoutedEventArgs e) { ThriftServiceNameSpace.ThriftService thirft = new ThriftServiceNameSpace.ThriftService(); MyCmpFaceLogWidthImgModel cmpFaceLogWidthImg = listComparisonRecord.SelectedItem as MyCmpFaceLogWidthImgModel; if (cmpFaceLogWidthImg != null) { if (!isHeader) { try { List <byte[]> senceImg = thirft.QuerySenceImg(cmpFaceLogWidthImg.ID, cmpFaceLogWidthImg.date.Split(' ')[0].Replace(@"/", "").Replace(@"/", "")); if (senceImg != null && senceImg.Count > 0 && senceImg[0].Length > 0) { CompInfo comInfoWin = new CompInfo(); BitmapImage bitImage = ImageConvert.ToBitmapImage(senceImg[0]); comInfoWin.SetCmpInfo(cmpFaceLogWidthImg.SnapImage, cmpFaceLogWidthImg.T1.TemplateImage, bitImage, cmpFaceLogWidthImg.score, cmpFaceLogWidthImg.T1.UserName, cmpFaceLogWidthImg.type, cmpFaceLogWidthImg.date + " " + cmpFaceLogWidthImg.time, cmpFaceLogWidthImg.channelName); comInfoWin.Show(); } else { MB_MODULES.Views.MyMessage.showYes("获取抓拍实时帧失败!"); } } catch (Exception ex) { MB_MODULES.Views.MyMessage.showYes(ex.Message); Logger <OperaExcel> .Log.Error("listComparisonRecord_MouseDoubleClick", ex); } } } }
public static async void AsyncSelectFaceType() { ThriftServiceNameSpace.ThriftService thirft = new ThriftServiceNameSpace.ThriftService(); await Task.Run(() => { GlobalCache.FaceTypeList = thirft.QueryDefFaceObjTypeH(-1); }).ConfigureAwait(false); }
private static int SendCmpToClient(RealtimeCmpInfoLBS info) { int res = -1; ThriftServiceNameSpace.ThriftService thirft = new ThriftServiceNameSpace.ThriftService(); ThriftServiceUtilities thrift = new ThriftServiceUtilities(); try { string errMsg = string.Empty; if ("WIFI".Equals(GlobalCache.NetworkMode)) { res = thrift.UpdateRealtimeCmpToDbFlag(new List <string> { info.CapID }, GlobalCache.AppRegion); if (res != 0) { MyMessage.Show("推送失败"); } } else { foreach (var area in Config.RegionList) { if (info.Channel.Contains(area.RegionName)) { foreach (var ip in area.Hosts) { if (UpdateCmp(info, ip) != 0) { errMsg += ip + ";"; } else { res = thirft.UpdateCmpLog(info.CapID, info.ObjID, System.DateTime.Now.ToString("yyyyMMdd"), area.RegionNO); } } } } } if (!string.IsNullOrEmpty(errMsg)) { MyMessage.showYes("往" + errMsg + "推送失败!"); } } catch (Exception ex) { MyMessage.showYes("推送比对信息出错"); Logger <WarningMessageCmd> .Log.Error("SendCmpToClient", ex); } return(res); }
/// <summary> /// 点击登录按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SignUp_Click(object sender, RoutedEventArgs e) { try { ThriftServiceNameSpace.ThriftService its = new ThriftServiceNameSpace.ThriftService(); string ip = IP.Text; string port = Port.Text; int result = ThriftServiceBasic.Singin(ref ip, ref port); if (result == 200) { if (GlobalCache.Func_AutoSignin) { autoLogin.Stop(); //auto singin funcation } if (Config.SaveUserInfo(IP.Text, Port.Text) == 200) //save ip&port { AppConfigs.AsyncSelectFaceType(); var config = Config.RegionList.FirstOrDefault(region => region.RegionNO == GlobalCache.AppRegion); if (config != null) { try { GlobalCache.AppLocation = config.RegionName; MainWindow _mainWindow = new MainWindow(); this.Close(); _mainWindow.Show(); xiaowen = true; } catch (Exception ex) { string err = ex.Message; Logger <Login> .Log.Error("SignUp_Click", ex); MyMessage.Show("该问题需要联系技术人员处理,\n数据或程序问题"); return; } } else { MyMessage.Show("exe.config文件与AreaInfo.xml文件中的区域类型不一致"); return; } } else { MyMessage.Show("请您先检查userinfo.xml文件是否存在,若存在,\n请联系技术人员处理"); } } else if (result == 404) { MyMessage.Show(string.Format("无法连接到 {0}:{1}", ip, port)); } } catch (Exception ex) { Logger <Login> .Log.Error("SignUp_Click", ex); } finally { LoadingVisiblity = Visibility.Collapsed; } }
/// <summary> /// 确定按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDetermineAddTemplate_Click(object sender, RoutedEventArgs e) { List <ErrorInfo> ListErrorInfo; ThriftServiceNameSpace.ThriftService thirft = new ThriftServiceNameSpace.ThriftService(); try { /** * 姓名 * 性别 * 年龄 * 类型:普通、黑名单 * 备注 * 1张主照片 * 4张附属照片 均为模板照片,指向一个人 * **/ #region 验证 if (string.IsNullOrEmpty(txtName.Text.Trim())) { MyMessage.showYes("名称必填!"); return; } if (string.IsNullOrEmpty(txtAge.Text.Trim())) { MyMessage.showYes("年龄必填!"); return; } #endregion #region 添加输入项 tIPViewModel._FaceObj.TcUuid = guid; tIPViewModel._FaceObj.TcName = txtName.Text.Trim(); string message = _validationRule.intValidationRule(this.txtAge.Text.Trim()); if (message != "") { MyMessage.showYes(message); return; } tIPViewModel._FaceObj.NAge = int.Parse(txtAge.Text.Trim()); tIPViewModel._FaceObj.NSex = combSex.SelectedIndex; //暂时没确定 tIPViewModel._FaceObj.NType = (GlobalCache.FaceTypeList.Cast <STypeInfo>().FirstOrDefault(x => x.Description == tIPViewModel.Type[combType.SelectedIndex]) ?? new STypeInfo()).Type; tIPViewModel._FaceObj.TcRemarks = txtRemarks.Text.Trim(); #endregion tIPViewModel._FaceObj.Tmplate = new List <FaceObjTemplate>(); //遍历照片存放数组,必须添加至少一张照片 var isExistPhoto = templateData.FirstOrDefault(x => x != null) ?? null; if (isExistPhoto == null) { MyMessage.showYes("至少要一张照片才能注册成功!"); return; } int nj = -1; for (int i = 0; i < 5; i++) { if (templateData[i] != null) { FaceObjTemplate templateObj = new FaceObjTemplate(); templateObj.TcUuid = System.Guid.NewGuid().ToString().Replace("-", "");; templateObj.TcObjid = tIPViewModel._FaceObj.TcUuid; //判断前面是不是有空位置,有那么排到前面去 for (int j = 0; j < i; j++) { if (templateData[j] == null) { templateObj.NIndex = j; nj = j; break; } } if (templateObj.NIndex == 0) { if (nj == -1) { templateObj.NIndex = i; } else { templateObj.NIndex = nj; } } //时间 long addDateTime = DateTimeConvert.ToLongFromSubstract(DateTime.Now, new DateTime(1970, 1, 1)); templateObj.DTm = addDateTime;//模板时间 if (tIPViewModel._FaceObj.DTm == 0) { tIPViewModel._FaceObj.DTm = addDateTime; } if (_mainTemplateStream != null) { if (_mainTemplateStream.Equals(templateData[i])) { tIPViewModel._FaceObj.NMain_ftID = i;//主照片ID } else if (i == tIPViewModel._FaceObj.NMain_ftID) { tIPViewModel._FaceObj.NMain_ftID = templateObj.NIndex;//主照片ID } } else { tIPViewModel._FaceObj.NMain_ftID = 0;//主模板ID为 0 } templateObj.Img = templateData[i]; tIPViewModel._FaceObj.Tmplate.Add(templateObj);//Add Template to db.face_template/db.face_object if (nj != -1) { templateData[nj] = templateData[i]; templateData[i] = null; nj = -1; } } } //具体的操作(添加,修改) if (tIPViewModel.Title.Contains("添加")) { ListErrorInfo = thirft.AddFaceObj(tIPViewModel._FaceObj); } else { ListErrorInfo = thirft.ModifyFaceObj(tIPViewModel.Id, tIPViewModel._FaceObj); } //判断是否成功 if (ListErrorInfo.Count == 0)//判断成功,提示成功 { MyMessage.showYes("成功!"); this.Close(); } else//添加不成功,显示错误 { if ("Add Face To Compare Server Failed, Because img repeat".Equals(ListErrorInfo[0].ID)) { MyMessage.Show("模板照片已存在,请取消并重新添加模板"); return; } else { MyMessage.showYes("添加模板ID:" + ListErrorInfo[0].ID + "失败,\n失败信息:" + ListErrorInfo[0].ErrCode); return; } } } catch (Exception ex) { Logger <TempleteInfoPop> .Log.Error("AddTemplate:btnRemove_Click", ex); } }
async void AsyncSignUpFunc() { LoadingVisiblity = Visibility.Visible; try { if (string.IsNullOrEmpty(Host) && string.IsNullOrEmpty(Port)) { MyMessage.Show("IP和端口不能为空"); return; } ThriftServiceNameSpace.ThriftService its = new ThriftServiceNameSpace.ThriftService(); string ip = Host; string port = Port; int result = ThriftServiceBasic.Singin(ref ip, ref port); if (result == 200) { if (GlobalCache.Func_AutoSignin) { autoLogin.Stop(); //auto singin funcation } if (Config.SaveUserInfo(Host, Port) == 200) //save ip&port { AppConfigs.AsyncSelectFaceType(); var config = Config.RegionList.FirstOrDefault(region => region.RegionNO == GlobalCache.AppRegion); if (config != null) { try { GlobalCache.AppLocation = config.RegionName; HomeView home = new HomeView(); CurrentWindow.Close(); home.Show(); } catch (Exception ex) { string err = ex.Message; Logger <SignUpViewModel> .Log.Error("SignUp_Click", ex); MyMessage.Show("该问题需要联系技术人员处理,\n数据或程序问题"); return; } } else { MyMessage.Show("exe.config文件与AreaInfo.xml文件中的区域类型不一致"); return; } } else { MyMessage.Show("请您先检查userinfo.xml文件是否存在,若存在,\n请联系技术人员处理"); } } else if (result == 404) { MyMessage.Show(string.Format("无法连接到 {0}:{1}", ip, port)); } } catch (Exception ex) { Logger <SignUpViewModel> .Log.Error("SignUp_Click", ex); } finally { LoadingVisiblity = Visibility.Collapsed; } }
/// <summary> /// 推送一条 /// </summary> /// <param name="signleObj"></param> public static int SendOneResultInfo(MyCmpFaceLogWidthImgModel signleObj) { int res = -1; ThriftServiceNameSpace.ThriftService thirft = new ThriftServiceNameSpace.ThriftService(); try { RealtimeCmpInfoLBS newRci = new RealtimeCmpInfoLBS(); newRci.CapID = signleObj.ID; newRci.ObjID = signleObj.tcUuid; newRci.Name = signleObj.name; newRci.Channel = signleObj.channelName; newRci.Longitude = signleObj.Longitude; newRci.Latitude = signleObj.Latitude; newRci.Address = signleObj.Address; List <byte[]> snapImgStream = thirft.QueryCmpLogImageH( signleObj.ID, DataConvert.DatetimeConvertToStr.ConvertToString(Convert.ToDateTime(signleObj.time), "yyyyMMdd") ); if (snapImgStream.Count > 0 && snapImgStream[0].Length > 0) { newRci.CapImg = snapImgStream[0]; } List <FaceObj> templateList = thirft.QueryFaceObj(signleObj.tcUuid); if (templateList.Count > 0) { newRci.Name += "|" + templateList[0].TcRemarks; if (templateList[0].NMain_ftID > 0) { newRci.ObjImg = templateList[0].Tmplate.FirstOrDefault(x => x.NIndex == templateList[0].NMain_ftID - 1).Img; } else { newRci.ObjImg = templateList[0].Tmplate[0].Img; } } #region old //RealtimeCmpInfo info = new RealtimeCmpInfo(); //info.CapID = signleObj.ID; //info.ObjID = signleObj.tcUuid; //info.Name = signleObj.name; //info.Channel = signleObj.channelName; //List<byte[]> listImageBytes = thirft.QueryCmpLogImageH(signleObj.ID, DataConvert.DatetimeConvertToStr.ConvertToString(Convert.ToDateTime(signleObj.time), "yyyyMMdd")); //if (listImageBytes.Count > 0 && listImageBytes[0].Length > 0) //{ // info.CapImg = listImageBytes[0]; // Console.WriteLine("抓拍照片大小为:" + listImageBytes[0].Length); //} //List<FaceObj> ListFaceObj = thirft.QueryFaceObj(signleObj.tcUuid); //if (ListFaceObj.Count > 0) //{ // info.Name += "|" + ListFaceObj[0].TcRemarks; // if (ListFaceObj[0].NMain_ftID > 0) // { // for (int i = 0; i < ListFaceObj[0].Tmplate.Count; i++)//遍历查找主模板照片 // { // if (ListFaceObj[0].NMain_ftID - 1 == ListFaceObj[0].Tmplate[i].NIndex) // { // info.ObjImg = ListFaceObj[0].Tmplate[i].Img; // Console.WriteLine("模版照片大小为:" + ListFaceObj[0].Tmplate[i].Img.Length); // } // } // } // else // { // info.ObjImg = ListFaceObj[0].Tmplate[0].Img; // Console.WriteLine("模版照片大小为:" + ListFaceObj[0].Tmplate[0].Img.Length); // } //} #endregion newRci.Time = DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(signleObj.time), new DateTime(1970, 1, 1)); //info.Type = cORViewModel.Type.IndexOf(cmpface.type) + 1; newRci.Type = 2; newRci.Score = signleObj.score; res = SendCmpToClient(newRci); } catch (Exception ex) { MB_MODULES.Views.MyMessage.showYes(ex.Message); } return(res); }