private void doSearch(string strWhere, int startIndex, int endIndex) { Maticsoft.BLL.SMT_STAFF_FACEDEV bll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); var models = bll.GetModelListEx(strWhere, startIndex, endIndex); this.Invoke(new Action(() => { dgvStaffs.Rows.Clear(); foreach (var item in models) { DataGridViewRow row = new DataGridViewRow(); string state = ""; Color color = row.DefaultCellStyle.BackColor; if (item.IS_FORBIDDEN) { state = "已禁用"; color = Color.LightGray; } else if (item.IS_UPLOAD) { state = "已上传"; } else { if (item.PHOTO == null || item.PHOTO.Length == 0) { state = "未上传(无照片)"; color = Color.FromArgb(0xEE, 0x00, 0x00); } else { state = "未上传"; color = Color.FromArgb(0xEE, 0x40, 0x00); } } row.CreateCells(dgvStaffs, item.FACEDEV_NAME, item.STAFF_NO, item.REAL_NAME, item.ORG_NAME, state, item.END_VALID_TIME.ToString("yyyy-MM-dd"), "修改", "删除", item.IS_UPLOAD ?"重上传":"上传"); row.Tag = item; row.DefaultCellStyle.ForeColor = color; dgvStaffs.Rows.Add(row); } })); }
private void doDelete(List <Maticsoft.Model.SMT_STAFF_FACEDEV> list, bool research, params DataGridViewRow[] rows) { if (DialogResult.Cancel == MessageBox.Show("确定删除选择" + list.Count + "项的授权?", "确认", MessageBoxButtons.OKCancel)) { return; } CtrlWaiting waiting = new CtrlWaiting(() => { string errMsg = ""; try { var sdfs = UploadPrivate.DeleteFace(list, out errMsg); if (sdfs != null && sdfs.Count > 0) { foreach (var item in sdfs) { Maticsoft.BLL.SMT_STAFF_FACEDEV bll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); bll.Delete(item.STAFF_ID, item.FACEDEV_ID); } if (research) { DoSearch(null, null, null); } else if (rows != null) { this.Invoke(new Action(() => { try { foreach (var item in rows) { dgvStaffs.Rows.Remove(item); } } catch (Exception) { } })); } } } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "删除存在异常:" + ex.Message + "," + errMsg); } }); waiting.Show(this); }
private void biForceUpload_Click(object sender, EventArgs e) { CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_STAFF_FACEDEV bll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); var models = bll.GetModelListEx("", 1, -1); DoUpload(models, true, false); } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "上传发生异常:" + ex.Message); } }); waiting.Show(this); }
private void DoSearch(string staffname, string staffno, string staffdept, bool bunUpload = false) { string selectdeviceIds = null; string strWhere = "1=1"; if (_selectDevices != null && _selectDevices.Count > 0) { foreach (var item in _selectDevices) { selectdeviceIds += item.ID + ","; } selectdeviceIds = selectdeviceIds.TrimEnd(','); } if (!string.IsNullOrWhiteSpace(selectdeviceIds)) { strWhere += " and FACEDEV_ID in (" + selectdeviceIds + ")"; } if (!string.IsNullOrWhiteSpace(staffname)) { strWhere += " and REAL_NAME like '%" + staffname + "%'"; } if (!string.IsNullOrWhiteSpace(staffno)) { strWhere += " and STAFF_NO like '%" + staffno + "%'"; } if (!string.IsNullOrWhiteSpace(staffdept)) { strWhere += " and ORG_NAME like '%" + staffdept + "%'"; } if (bunUpload) { strWhere += " and IS_UPLOAD !=1"; } if (!UserInfoHelper.IsManager) { strWhere += " and FACEDEV_ID IN (SELECT RF.FUN_ID FROM SMT_ROLE_FUN RF,SMT_USER_INFO UI WHERE RF.ROLE_TYPE=4 AND RF.ROLE_ID=UI.ROLE_ID AND UI.ID=" + UserInfoHelper.UserID + ")"; } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_STAFF_FACEDEV bll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); int count = bll.GetRecordCountEx(strWhere); this.Invoke(new Action(() => { pageDataGridView.PageControl.TotalRecords = count; pageDataGridView.PageControl.CurrentPage = 1; pageDataGridView.PageControl.Tag = strWhere; dgvStaffs.Rows.Clear(); })); if (count > 0) { doSearch(strWhere, pageDataGridView.PageControl.StartIndex, pageDataGridView.PageControl.EndIndex); } } catch (Exception ex) { log.Error("查询授权记录异常:", ex); WinInfoHelper.ShowInfoWindow(this, "查询授权信息异常:" + ex.Message); } }); waiting.Show(this); }
private void DoLoadReadPrivates() { CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_STAFF_FACEDEV sfBll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); List <Maticsoft.Model.SMT_STAFF_FACEDEV> list = sfBll.GetModelList("FACEDEV_ID in (" + string.Join(",", _selectDeviceIds) + ")"); var g = list.GroupBy(m => m.STAFF_ID); foreach (var item in g) { if (item.Count() == _selectDeviceIds.Count) { _inprivateStaffIds.Add(item.Key); } } if (_inprivateStaffIds.Count > 0) { Maticsoft.BLL.SMT_STAFF_INFO staffBll = new Maticsoft.BLL.SMT_STAFF_INFO(); _inprivateStaffInfos = staffBll.GetSimpleModelList("ID in (" + string.Join(",", _inprivateStaffIds.ToArray()) + ")"); if (_inprivateStaffInfos.Count > 0) { var depts = DeptDataHelper.GetDepts(false); foreach (var item in _inprivateStaffInfos) { var dept = depts.Find(m => m.ID == item.ORG_ID); if (dept != null) { item.ORG_NAME = dept.ORG_NAME; item.ORG_CODE = dept.ORG_CODE; } } this.Invoke(new Action(() => { foreach (var item in _inprivateStaffInfos) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvStaffs, item.STAFF_NO, item.REAL_NAME, item.ORG_NAME + "[" + item.ORG_CODE + "]", item.VALID_ENDTIME.ToString("yyyy-MM-dd") ); row.Tag = item; dgvSelected.Rows.Add(row); if (_selectMaxDate == null) { _selectMaxDate = item.VALID_ENDTIME; } else { if (item.VALID_ENDTIME > _selectMaxDate) { _selectMaxDate = item.VALID_ENDTIME; } } } if (_selectMaxDate != null) { dtpEnd.Value = (DateTime)_selectMaxDate; } })); } } } catch (Exception ex) { log.Error("加载已授权人员异常:" + ex.Message, ex); WinInfoHelper.ShowInfoWindow(this, "加载已授权人员异常:" + ex.Message); } }); waiting.Show(this); }
private void DoSave(bool isupload = false) { if (dgvSelected.Rows.Count == 0) { if (_inprivateStaffInfos.Count == 0) { WinInfoHelper.ShowInfoWindow(this, "请至少选一个授权的人员!"); return; } } var hasPrivates = _inprivateStaffInfos.ToList(); List <Maticsoft.Model.SMT_STAFF_INFO> staffInfos = new List <Maticsoft.Model.SMT_STAFF_INFO>(); foreach (DataGridViewRow item in dgvSelected.Rows) { staffInfos.Add((Maticsoft.Model.SMT_STAFF_INFO)item.Tag); } CtrlWaiting waiting = new CtrlWaiting(() => { Maticsoft.BLL.SMT_STAFF_FACEDEV sfbll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); List <Maticsoft.Model.SMT_STAFF_FACEDEV> addmodels = new List <Maticsoft.Model.SMT_STAFF_FACEDEV>(); List <Maticsoft.Model.SMT_STAFF_FACEDEV> updatemodels = new List <Maticsoft.Model.SMT_STAFF_FACEDEV>(); List <Maticsoft.Model.SMT_STAFF_FACEDEV> deletemodels = new List <Maticsoft.Model.SMT_STAFF_FACEDEV>(); try { foreach (var staff in staffInfos) { foreach (var dev in _selectDevices) { var model = sfbll.GetModel(staff.ID, dev.ID); if (model == null) { model = new Maticsoft.Model.SMT_STAFF_FACEDEV(); model.ADD_TIME = DateTime.Now; model.END_VALID_TIME = dtpEnd.Value.Date + new TimeSpan(23, 59, 59); model.FACEDEV_ID = dev.ID; model.IS_UPLOAD = false; model.STAFF_DEV_ID = Guid.NewGuid().ToString("N"); model.STAFF_ID = staff.ID; model.START_VALID_TIME = dtpStart.Value.Date; model.UPLOAD_TIME = DateTime.Now; sfbll.Add(model); } else { hasPrivates.RemoveAll(m => m.ID == model.STAFF_ID); model.START_VALID_TIME = dtpStart.Value.Date; model.END_VALID_TIME = dtpEnd.Value.Date + new TimeSpan(23, 59, 59); if (string.IsNullOrWhiteSpace(model.STAFF_DEV_ID)) { model.STAFF_DEV_ID = Guid.NewGuid().ToString("N"); } sfbll.Update(model); } model.STAFF_INFO = staff; model.FACERECG_DEVICE = dev; if (!model.IS_UPLOAD) { addmodels.Add(model); } } } foreach (var item in hasPrivates) { foreach (var dev in _selectDevices) { var model = sfbll.GetModel(item.ID, dev.ID); if (model != null) { deletemodels.Add(model); } } } } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message); log.Error("保存异常:", ex); return; } if (deletemodels.Count > 0) { string errMsg = ""; var delre = UploadPrivate.DeleteFace(deletemodels, out errMsg); if (delre != null && delre.Count > 0) { foreach (var item in delre) { sfbll.Delete(item.STAFF_ID, item.FACEDEV_ID); } } } if (isupload) { string errMsg = ""; SmartAccess.Common.Datas.UploadPrivate.CancelObject cancelObject = new UploadPrivate.CancelObject(); bool ret = UploadPrivate.UploadFace(cancelObject, addmodels, updatemodels, out errMsg); if (!ret || !string.IsNullOrWhiteSpace(errMsg)) { WinInfoHelper.ShowInfoWindow(this, "保存成功,部分权限上传异常:" + errMsg); } } this.Invoke(new Action(() => { this.DialogResult = DialogResult.OK; this.Close(); })); }); waiting.Show(this); }
//保存记录 public void SaveRecord(decimal ctrlrId, List <Maticsoft.Model.BST.staff_log> records) { try { Dictionary <string, Maticsoft.Model.SMT_STAFF_FACEDEV> staffDevDic = new Dictionary <string, Maticsoft.Model.SMT_STAFF_FACEDEV>(); Maticsoft.BLL.SMT_FACE_RECORD bllRecord = new Maticsoft.BLL.SMT_FACE_RECORD(); foreach (var record in records) { string strTime = record.id.Substring(0, "2018/09/23_22:48:39".Length); string staffdevId = record.id.Substring("2018/09/23_22:48:39".Length + 1); Maticsoft.Model.SMT_STAFF_FACEDEV sfmodel = null; if (staffDevDic.ContainsKey(staffdevId)) { sfmodel = staffDevDic[staffdevId]; } else { Maticsoft.BLL.SMT_STAFF_FACEDEV ssfbll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); List <Maticsoft.Model.SMT_STAFF_FACEDEV> modelSFDs = ssfbll.GetModelList("STAFF_DEV_ID='" + staffdevId + "'"); if (modelSFDs.Count == 0) { log.Warn("无此ID:" + staffdevId + " 授权注册!"); continue; } sfmodel = modelSFDs[0]; Maticsoft.BLL.SMT_STAFF_INFO sbll = new Maticsoft.BLL.SMT_STAFF_INFO(); sfmodel.STAFF_INFO = sbll.GetModel(sfmodel.STAFF_ID); staffDevDic.Add(staffdevId, sfmodel); } Maticsoft.Model.SMT_FACE_RECORD modelRecord = new Maticsoft.Model.SMT_FACE_RECORD(); modelRecord.FACEDEV_ID = ctrlrId; modelRecord.FREC_AUTHORITY = record.authority; modelRecord.FREC_FACE_IMAGE = record.imagesql; double dec = 0.8; double.TryParse(record.info, out dec); modelRecord.FREC_FACE_LEVEL = (decimal)dec; modelRecord.FREC_VIDEO_IMAGE = record.imagevideo; DateTime now = DateTime.Now; DateTime.TryParse(strTime.Replace("_", " "), out now); modelRecord.FREC_TIME = now; modelRecord.ID = -1; modelRecord.FREC_PARAM3 = record.data_keepon3; modelRecord.FREC_PARAM4 = record.data_keepon4; modelRecord.FREC_SRC_ID = record.id; modelRecord.FREC_STAFF_ID = sfmodel.STAFF_ID; if (sfmodel.STAFF_INFO == null) { modelRecord.FREC_STAFF_NAME = record.name; modelRecord.FREC_STAFF_NO = record.data_keepon1; modelRecord.FREC_STAFF_TYPE = record.data_keepon4; } else { modelRecord.FREC_STAFF_NAME = sfmodel.STAFF_INFO.REAL_NAME; modelRecord.FREC_STAFF_NO = sfmodel.STAFF_INFO.STAFF_NO; modelRecord.FREC_STAFF_TYPE = sfmodel.STAFF_INFO.STAFF_TYPE; } bllRecord.Add(modelRecord); } } catch (Exception ex) { log.Error("记录保存失败:CTRLID=" + ctrlrId, ex); throw ex; } }
private void DoSaveDevices(List <Maticsoft.Model.SMT_FACERECG_DEVICE> devices, bool upload = false) { if (dtpStart.Value.Date > dtpEnd.Value.Date) { WinInfoHelper.ShowInfoWindow(this, "起始时间不能小于结束时间!"); return; } CtrlWaiting ctrlWaiting = new CtrlWaiting("正在保存...", () => { try { Maticsoft.BLL.SMT_STAFF_FACEDEV sfBLL = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); var sfList = sfBLL.GetModelList("STAFF_ID=" + _staffInfo.ID); List <Maticsoft.Model.SMT_FACERECG_DEVICE> tempDevs = new List <Maticsoft.Model.SMT_FACERECG_DEVICE>(); tempDevs.AddRange(devices); List <Maticsoft.Model.SMT_STAFF_FACEDEV> addPrivates = new List <Maticsoft.Model.SMT_STAFF_FACEDEV>(); List <Maticsoft.Model.SMT_STAFF_FACEDEV> updatePrivates = new List <Maticsoft.Model.SMT_STAFF_FACEDEV>(); List <Maticsoft.Model.SMT_STAFF_FACEDEV> delPrivates = new List <Maticsoft.Model.SMT_STAFF_FACEDEV>(); foreach (var item in sfList) { var sc = devices.Find(m => m.ID == item.FACEDEV_ID); if (sc == null)//不存在,则权限删除 { delPrivates.Add(item); // sfBLL.Delete(item.STAFF_ID, item.FACEDEV_ID);//删除权限 } else { item.START_VALID_TIME = dtpStart.Value.Date; item.END_VALID_TIME = dtpEnd.Value.Date + new TimeSpan(23, 59, 59); if (_staffInfo.VALID_STARTTIME.Date > item.START_VALID_TIME.Date) { item.START_VALID_TIME = _staffInfo.VALID_STARTTIME.Date; } if (_staffInfo.VALID_ENDTIME.Date < item.END_VALID_TIME.Date) { item.END_VALID_TIME = _staffInfo.VALID_ENDTIME.Date + new TimeSpan(23, 59, 59); } sfBLL.Update(item); tempDevs.Remove(sc); if (!item.IS_UPLOAD) { addPrivates.Add(item); } else { if (_imageChanged) { addPrivates.Add(item); } else { updatePrivates.Add(item); } } } } foreach (var item in tempDevs)//添加的权限 { Maticsoft.Model.SMT_STAFF_FACEDEV newSd = new Maticsoft.Model.SMT_STAFF_FACEDEV(); newSd.ADD_TIME = DateTime.Now; newSd.FACEDEV_ID = item.ID; newSd.IS_UPLOAD = false; newSd.UPLOAD_TIME = DateTime.Now; newSd.STAFF_ID = _staffInfo.ID; newSd.STAFF_DEV_ID = Guid.NewGuid().ToString("N"); newSd.START_VALID_TIME = dtpStart.Value.Date; newSd.END_VALID_TIME = dtpEnd.Value.Date + new TimeSpan(23, 59, 59); if (_staffInfo.VALID_STARTTIME.Date > newSd.START_VALID_TIME.Date) { newSd.START_VALID_TIME = _staffInfo.VALID_STARTTIME.Date; } if (_staffInfo.VALID_ENDTIME.Date < newSd.END_VALID_TIME.Date) { newSd.END_VALID_TIME = _staffInfo.VALID_ENDTIME.Date + new TimeSpan(23, 59, 59); } sfBLL.Add(newSd); addPrivates.Add(newSd); } if (upload) { string errMsg; if (delPrivates.Count > 0) { var delResults = UploadPrivate.DeleteFace(delPrivates, out errMsg); if (delResults != null && delResults.Count > 0) { foreach (var item in delResults) { Maticsoft.BLL.SMT_STAFF_FACEDEV bll = new Maticsoft.BLL.SMT_STAFF_FACEDEV(); bll.Delete(item.STAFF_ID, item.FACEDEV_ID); } } } errMsg = ""; if (addPrivates.Count > 0 || updatePrivates.Count > 0) { SmartAccess.Common.Datas.UploadPrivate.CancelObject cancelObject = new UploadPrivate.CancelObject(); bool ret = UploadPrivate.UploadFace(cancelObject, addPrivates, updatePrivates, out errMsg); if (ret && errMsg != "") { WinInfoHelper.ShowInfoWindow(this, "上传权限存在异常:" + errMsg); log.Warn("上传权限存在异常:" + errMsg); return; } } WinInfoHelper.ShowInfoWindow(null, "上传权限结束!"); } this.Invoke(new Action(() => { this.DialogResult = DialogResult.OK; this.Close(); })); } catch (System.Exception ex) { log.Error("保存异常:", ex); WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message); } }); ctrlWaiting.Show(this); }