private void DoLoadByArea(List <Maticsoft.Model.SMT_CONTROLLER_ZONE> areas, string filter = null) { CtrlWaiting waiting = new CtrlWaiting(() => { try { string strWhere = "1=1"; if (areas != null && areas.Count > 0) { strWhere = "AREA_ID in ("; foreach (var item in areas) { strWhere += item.ID + ","; } strWhere = strWhere.TrimEnd(','); strWhere += ")"; } List <Maticsoft.Model.SMT_FACERECG_DEVICE> ctrls = FaceRecgHelper.GetList(strWhere, true);//获取所有人脸设备 this.Invoke(new Action(() => { ShowDevs(ctrls, filter); })); } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "加载人脸识别设备异常:" + ex.Message); log.Error("加载人脸识别设备异常:", ex); } }); waiting.Show(this); }
private void InitDoors() { CtrlWaiting waiting = new CtrlWaiting(() => { try { var doors = DoorDataHelper.GetDoors(); Maticsoft.BLL.SMT_CARD_INFO cardBll = new Maticsoft.BLL.SMT_CARD_INFO(); _cards = cardBll.GetModelList(""); this.Invoke(new Action(() => { AddDoorsToView(doors); })); var facedevs = FaceRecgHelper.GetList(""); this.Invoke(new Action(() => { AddFaceDevsToView(facedevs); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "加载门禁异常!" + ex.Message); log.Error("加载门禁异常:", ex); } }); waiting.Show(this, 200); }
private void GetDoors(MapCtrl mapCtrl, out List <Maticsoft.Model.SMT_DOOR_INFO> doors, out List <Maticsoft.Model.SMT_FACERECG_DEVICE> faceDevs) { Maticsoft.Model.SMT_MAP_INFO mapInfo = (Maticsoft.Model.SMT_MAP_INFO)mapCtrl.Tag; doors = new List <Maticsoft.Model.SMT_DOOR_INFO>(); faceDevs = new List <Maticsoft.Model.SMT_FACERECG_DEVICE>(); if (mapInfo.MAP_DOORS == null || mapInfo.MAP_DOORS.Count == 0) { return; } foreach (var item in mapInfo.MAP_DOORS) { if (item.DOOR_TYPE == 1) { if (!item.DOOR.IS_ENABLE || item.DOOR.CTRL_ID == null || item.DOOR.CTRL_DOOR_INDEX == null) { continue; } if (DoorDataHelper.LastDoors != null) { if (DoorDataHelper.LastDoors.Exists(m => m.ID == item.DOOR.ID)) { doors.Add(item.DOOR); } } else { doors.Add(item.DOOR); } } else if (item.DOOR_TYPE == 2) { if (!item.FACE.FACEDEV_IS_ENABLE) { continue; } var faces = FaceRecgHelper.GetList("", false, false); if (faces != null) { if (faces.Exists(m => m.ID == item.FACE.ID)) { faceDevs.Add(item.FACE); } } else { faceDevs.Add(item.FACE); } } } }
private void DoDelete(DataGridViewRow row) { if (MessageBox.Show("确定删除该控制器?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { CtrlWaiting ctrlWaiting = new CtrlWaiting("正在删除中...", () => { try { Maticsoft.Model.SMT_FACERECG_DEVICE dev = (Maticsoft.Model.SMT_FACERECG_DEVICE)row.Tag; DialogResult dr = DialogResult.No; this.Invoke(new Action(() => { dr = MessageBox.Show("是否清除该人脸识别设备权限?", "提示", MessageBoxButtons.YesNo); })); if (dr == DialogResult.Yes) { ThreadPool.QueueUserWorkItem(new WaitCallback((o) => { try { BSTFaceRecg c = FaceRecgHelper.ToFaceController(dev); c.ClearFaces(); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "权限清除异常,可能设备离线或者不存在:" + ex.Message); } })); Thread.Sleep(1000); } Maticsoft.BLL.SMT_FACERECG_DEVICE ctrlBll = new Maticsoft.BLL.SMT_FACERECG_DEVICE(); ctrlBll.Delete(dev.ID); //置门关联控制器为空 Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_STAFF_FACEDEV where FACEDEV_ID=" + dev.ID); SmtLog.Info("设备", "人脸识别设备删除:" + dev.FACEDEV_IP + "," + dev.FACEDEV_NAME); this.Invoke(new Action(() => { dgvCtrlr.Rows.Remove(row); })); } catch (System.Exception ex) { log.Error("删除人脸识别设备异常:", ex); WinInfoHelper.ShowInfoWindow(this, "删除失败:" + ex.Message); } }); ctrlWaiting.Show(this); } }
private void Init(int time = 300) { CtrlWaiting waiting = new CtrlWaiting(() => { try { List <Maticsoft.Model.SMT_FACERECG_DEVICE> devs = FaceRecgHelper.GetList("1=1", true); //获取所有控制器 List <Maticsoft.Model.SMT_CONTROLLER_ZONE> areas = AreaDataHelper.GetAreas(true); //获取所有区域 this.Invoke(new Action(() => { ShowAreas(areas); ShowDevs(devs); })); } catch (System.Exception ex) { WinInfoHelper.ShowInfoWindow(this, "加载异常:" + ex.Message); log.Error("加载异常:", ex); } }); waiting.Show(this, time); }
private void Init() { dtpStart.Value = DateTime.Now.Date; CtrlWaiting waiting = new CtrlWaiting(() => { Maticsoft.BLL.SMT_FACERECG_DEVICE faceBll = new Maticsoft.BLL.SMT_FACERECG_DEVICE(); var depts = DeptDataHelper.GetDepts(false); var facedevs = faceBll.GetModelList(""); var areas = AreaDataHelper.GetAreas(); this.Invoke(new Action(() => { var deptNodes = DeptDataHelper.ToTree(depts); Node deptNone = new Node("--无--"); deptNodes.Insert(0, deptNone); cboDeptTree.Nodes.AddRange(deptNodes.ToArray()); cboDeptTree.SelectedNode = deptNone; foreach (Node item in cboDeptTree.Nodes) { item.Expand(); } var devNodes = FaceRecgHelper.ToFaceTree(facedevs, areas); cboFaceTree.Nodes.AddRange(devNodes.ToArray()); foreach (Node item in cboFaceTree.Nodes) { item.ExpandAll(); } })); }); waiting.Show(this, 300); }
private void Save(bool isupload) { if (!CheckInput()) { return; } try { Maticsoft.Model.SMT_FACERECG_DEVICE devInfo = new Maticsoft.Model.SMT_FACERECG_DEVICE(); if (_dev != null) { devInfo.ID = _dev.ID; } else { devInfo.ID = -1; } if (string.IsNullOrWhiteSpace(tbName.Text)) { devInfo.FACEDEV_NAME = ipDevIp.Value; } else { devInfo.FACEDEV_NAME = tbName.Text; } devInfo.FACEDEV_IS_ENABLE = cbIsEnable.Checked; devInfo.FACEDEV_SN = tbDevSn.Text; devInfo.FACEDEV_IP = ipDevIp.Value; devInfo.FACEDEV_CTRL_PORT = iiDevCtrlPort.Value; devInfo.FACEDEV_HEART_PORT = iiDevHeartPort.Value; devInfo.FACEDEV_DB_PORT = iiDbPort.Value; devInfo.FACEDEV_DB_NAME = tbDbName.Text; devInfo.FACEDEV_DB_USER = tbDbUserName.Text; devInfo.FACEDEV_DB_PWD = tbDbPassword.Text; devInfo.FVIDEO_RTSP_COUNT = cbVideoCount1.Checked ? 1 : 3; devInfo.FVIDEO_RTSP = tbRtsp1.Text; devInfo.FVIDEO_RTSP2 = tbRtsp2.Text; devInfo.FVIDEO_RTSP3 = tbRtsp3.Text; devInfo.FVIDEO_FACE_LEVEL = (decimal)diFaceLevel.Value; devInfo.FVIDEO_RIO_X = (decimal)diRIO_X.Value; devInfo.FVIDEO_RIO_Y = (decimal)diRIO_Y.Value; devInfo.FVIDEO_RIO_W = (decimal)diRIO_W.Value; devInfo.FVIDEO_RIO_H = (decimal)diRIO_H.Value; devInfo.FVIDEO_SINGLE = cbModelSingle.Checked ? "Y" : "N"; devInfo.FVIDEO_TITLE1 = tbDevTitle1.Text; devInfo.FVIDEO_TITLE2 = tbDevTitle2.Text; devInfo.AREA_ID = -1; if (cboTreeArea.SelectedNode != null && cboTreeArea.SelectedNode.Tag is Maticsoft.Model.SMT_CONTROLLER_ZONE) { var area = cboTreeArea.SelectedNode.Tag as Maticsoft.Model.SMT_CONTROLLER_ZONE; devInfo.AREA_ID = area.ID; devInfo.AREA_NAME = area.ZONE_NAME; } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_FACERECG_DEVICE bllDev = new Maticsoft.BLL.SMT_FACERECG_DEVICE(); if (devInfo.ID == -1) { var models = bllDev.GetModelList("FACEDEV_IP='" + devInfo.FACEDEV_IP + "'"); if (models.Count > 0) { WinInfoHelper.ShowInfoWindow(this, "已存在IP为:" + devInfo.FACEDEV_IP + "的设备!"); return; } devInfo.ID = bllDev.Add(devInfo); } else { var models = bllDev.GetModelList("FACEDEV_IP='" + devInfo.FACEDEV_IP + "' and ID != " + devInfo.ID); if (models.Count > 0) { WinInfoHelper.ShowInfoWindow(this, "已存在IP为:" + devInfo.FACEDEV_IP + "的设备!"); return; } bllDev.Update(devInfo); } _dev = devInfo; if (isupload) { try { using (var faceRecg = FaceRecgHelper.ToFaceController(devInfo)) { var video = FaceRecgHelper.ToFaceVideo(devInfo); bool ret = faceRecg.SetVideo(video); if (!ret) { WinInfoHelper.ShowInfoWindow(null, "上传视频设置失败!"); } else if (!devInfo.FACEDEV_IS_ENABLE) { faceRecg.ClearFaces(); } } } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(null, "上传视频设置失败:" + ex.Message); } } WinInfoHelper.ShowInfoWindow(null, "保存成功。"); this.BeginInvoke(new Action(() => { this.DialogResult = DialogResult.OK; this.Close(); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message); log.Error("保存异常:" + ex.Message, ex); } }); waiting.Show(this); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message); log.Error("保存异常:" + ex.Message, ex); } }
private void DoLoadCtrlrs(List <decimal> areaIds) { List <Maticsoft.Model.SMT_FACERECG_DEVICE> devs = FaceRecgHelper.GetList(areaIds); }