//保存记录 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 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 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); }