/// <summary> /// 初始化时间 /// </summary> private void IntiQueryTime() { //开始时间 long startTime = -1; if (!string.IsNullOrEmpty(cRQViewModel.StartDay)) { startTime = DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(cRQViewModel.StartDay), new DateTime(1970, 1, 1)); if (cRQViewModel.SelectedStartHour > -1) { startTime = startTime + int.Parse(cRQViewModel.SelectedStartHour.ToString()) * 60 * 60 + combCompRecordStarTimeMinutes.SelectedIndex * 60; } } cRQViewModel.captureRecordQueryValue.StartDayValue = startTime; //结束时间 long endTime = -1; if (!string.IsNullOrEmpty(cRQViewModel.EndDay)) { endTime = DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(cRQViewModel.EndDay), new DateTime(1970, 1, 1)); if (cRQViewModel.SelectedEndHour > -1) { endTime = endTime + int.Parse(cRQViewModel.SelectedEndHour.ToString()) * 60 * 60 + combCompRecordEndTimeMinutes.SelectedIndex * 60 + 3660; } } else { endTime = DateTimeConvert.ToLongFromSubstract(DateTime.Now, new DateTime(1970, 1, 1)); } cRQViewModel.captureRecordQueryValue.EndDayValue = endTime; }
/// <summary> /// 初始化查询时间 /// </summary> /// <param name="corViewModel"></param> private void IntiQueryTime(CompOfRecordsViewModel corViewModel) { try { long startDate = -1; if (!string.IsNullOrEmpty(corViewModel.StartDay)) { startDate = DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(corViewModel.StartDay), new DateTime(1970, 1, 1)); if (corViewModel.SelectedStartHour != -1) { startDate = startDate + int.Parse(corViewModel.SelectedStartHour.ToString()) * 60 * 60 + SelectedStartMinutes * 60; } } corViewModel.CompOfRecordsValueObj.StartDayValue = startDate; //结束时间 long endDate = -1; if (!string.IsNullOrEmpty(corViewModel.EndDay)) { endDate = DateTimeConvert.ToLongFromSubstract(Convert.ToDateTime(corViewModel.EndDay), new DateTime(1970, 1, 1)); if (corViewModel.SelectedEndHour != -1) { endDate = endDate + int.Parse(corViewModel.SelectedEndHour.ToString()) * 60 * 60 + SelectedEndMinutes * 60 + 3660; } } else { endDate = DateTimeConvert.ToLongFromSubstract(DateTime.Now, new DateTime(1970, 1, 1)); } corViewModel.CompOfRecordsValueObj.EndDayValue = endDate; } catch (Exception ex) { Logger <CompOfRecordsViewModel> .Log.Error("IntiQueryTime", ex); } }
/// <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); } }
/// <summary> /// 查询方法 /// </summary> /// <param name="pageIndex"></param> /// <param name="cORViewModel"></param> private void GetAllInfo(int pageIndex, CompOfRecordsViewModel cORViewModel) { cORViewModel.LoadingVisiblity = Visibility.Visible; try { int _pageSize = cORViewModel.CompOfRecordsValueObj.PageSize; List <int> dailyPageSum = new List <int>(); int pageSum = 0; int index = 0; List <MyCapFaceLogWithImg> listMyCapFaceLogWithImg = new List <MyCapFaceLogWithImg>(); List <SCountInfo> resultCount = new List <SCountInfo>(); if (GlobalCache.AppType == 0)//筛选端 { resultCount = thirft.QueryCmpRecordTotalCountH(cORViewModel.CompOfRecordsValueObj) ?? null; } else//接收端 { resultCount = thirft.QueryCmpRecordTotalCountHSX(cORViewModel.CompOfRecordsValueObj, GlobalCache.AppRegion) ?? null; } if (resultCount == null) { return; } //按日拆分后的数据 resultCount[0].Dayarr.Reverse(); foreach (SCountInfoOneDay item in resultCount[0].Dayarr) { pageSum += (item.Count / _pageSize + (item.Count % _pageSize == 0 ? 0 : 1)); dailyPageSum.Add(pageSum); } cORViewModel.CurrPage = pageIndex;//currentPageIndex cORViewModel.MaxPage = pageSum; cORViewModel.MaxDataCount = resultCount[0].Count; //根据页数判断是属于哪一天 for (int i = 0; i < dailyPageSum.Count; i++) { if (pageIndex <= dailyPageSum[i]) { index = i; //修改当前的时间 和 最大的结果数量 DateTime dt1 = Convert.ToDateTime(resultCount[0].Dayarr[i].Daystr.Insert(6, "/").Insert(4, "/")); long _date = DateTimeConvert.ToLongFromSubstract(dt1, new DateTime(1970, 1, 1)); if (_date > cORViewModel.CompOfRecordsValueObj.StartDayValue) { cORViewModel.CompOfRecordsValueObj.StartDayValue = _date; } if (pageIndex != cORViewModel.MaxPage) { long endTime = _date + 24 * 60 * 60; var todayEndtime = DateTimeConvert.ToLongFromSubstract(dt1.AddDays(1), new DateTime(1970, 1, 1)); if (endTime > todayEndtime) { endTime = todayEndtime; } cORViewModel.CompOfRecordsValueObj.EndDayValue = endTime; } cORViewModel.CompOfRecordsValueObj.MaxDataCount = resultCount[0].Dayarr[i].Count; break; } } if (pageIndex > 1) { int pageTem = 0; if (index == 0) { pageTem = 0; } else { pageTem = dailyPageSum[index - 1]; } cORViewModel.CompOfRecordsValueObj.PageStartRow = cORViewModel.CompOfRecordsValueObj.MaxDataCount - ((pageIndex - pageTem) * _pageSize); if (cORViewModel.CompOfRecordsValueObj.PageStartRow < 0) { cORViewModel.CompOfRecordsValueObj.PageStartRow = 0; } } else { cORViewModel.CompOfRecordsValueObj.PageStartRow = cORViewModel.CompOfRecordsValueObj.MaxDataCount - _pageSize; if (cORViewModel.CompOfRecordsValueObj.PageStartRow < 0) { cORViewModel.CompOfRecordsValueObj.PageStartRow = 0; } } int countTem = 0; resultCount[0].Dayarr.Reverse(); for (int n = 0; n <= index; n++) { var dayary = resultCount[0].Dayarr[resultCount[0].Dayarr.Count - 1 - n].Count; countTem += dayary; } cORViewModel.CompOfRecordsValueObj.MaxDataCount = countTem; if (GlobalCache.AppType == 0) { cORViewModel.ListMyCmpFaceLogWidthImgs = thirft.QueryCmpLog(cORViewModel.CompOfRecordsValueObj); } else { cORViewModel.ListMyCmpFaceLogWidthImgs = thirft.QueryCmpLogSX(cORViewModel.CompOfRecordsValueObj, GlobalCache.AppRegion); } } catch (Exception ex) { Logger <CompOfRecordsViewModel> .Log.Error("GetAllInfo(int pageIndex, CompOfRecordsViewModel cORViewModel)", ex); } finally { cORViewModel.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); }