예제 #1
0
        private void cbTreeDept_SelectionChanged(object sender, DevComponents.AdvTree.AdvTreeNodeEventArgs e)
        {
            Maticsoft.Model.SMT_ORG_INFO orgInfo = e.Node.Tag as Maticsoft.Model.SMT_ORG_INFO;
            if (orgInfo == null)
            {
                orgInfo    = new Maticsoft.Model.SMT_ORG_INFO();
                orgInfo.ID = -1;
            }
            if (orgInfo != null)
            {
                CtrlWaiting waiting = new CtrlWaiting(() =>
                {
                    try
                    {
                        Maticsoft.BLL.SMT_STAFF_INFO staffBll = new Maticsoft.BLL.SMT_STAFF_INFO();
                        string strWhere = "";
                        List <Maticsoft.Model.SMT_STAFF_INFO> staffInfos = null;
                        if (orgInfo.ID == -1)
                        {
                            strWhere  += "ORG_ID=-1 or ORG_ID is null";
                            staffInfos = staffBll.GetModelList("(" + strWhere + ") and IS_DELETE=0");
                        }
                        else
                        {
                            // Maticsoft.BLL.SMT_ORG_INFO orgBll = new Maticsoft.BLL.SMT_ORG_INFO();
                            // var orgS = orgBll.GetModelList("PAR_ID=" + orgInfo.ID);
                            // foreach (var org in orgS)
                            // {
                            //var subInfos = staffBll.GetModelList("ORG_ID=" + org.ID + " and IS_DELETE=0");
                            staffInfos = staffBll.GetModelListByParOrgId(orgInfo.ID);
                            //  }
                        }
                        var depts = DeptDataHelper.GetDepts(false);
                        foreach (var item in staffInfos)
                        {
                            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(() =>
                        {
                            DoShowInfos(staffInfos);
                        }));
                    }
                    catch (Exception ex)
                    {
                        log.Error("获取人员异常:", ex);
                        WinInfoHelper.ShowInfoWindow(this, "获取人员异常:" + ex.Message);
                    }
                });
                waiting.Show(this);
            }
        }
예제 #2
0
        private void cbTreeDept_SelectionChanged(object sender, DevComponents.AdvTree.AdvTreeNodeEventArgs e)
        {
            Maticsoft.Model.SMT_ORG_INFO orgInfo = e.Node.Tag as Maticsoft.Model.SMT_ORG_INFO;
            if (orgInfo == null)
            {
                orgInfo    = new Maticsoft.Model.SMT_ORG_INFO();
                orgInfo.ID = -1;
            }
            if (orgInfo != null)
            {
                CtrlWaiting waiting = new CtrlWaiting(() =>
                {
                    try
                    {
                        Maticsoft.BLL.SMT_STAFF_INFO staffBll = new Maticsoft.BLL.SMT_STAFF_INFO();
                        string strWhere = "ORG_ID=" + orgInfo.ID;
                        if (orgInfo.ID == -1)
                        {
                            strWhere += " or ORG_ID is null";
                        }
                        var staffInfos = staffBll.GetModelList("(" + strWhere + ") and IS_DELETE=0");

                        if (orgInfo.ID != -1)
                        {
                            Maticsoft.BLL.SMT_ORG_INFO orgBll = new Maticsoft.BLL.SMT_ORG_INFO();
                            var orgS = orgBll.GetModelList("PAR_ID=" + orgInfo.ID);
                            foreach (var org in orgS)
                            {
                                var subInfos = staffBll.GetModelList("ORG_ID=" + org.ID + " and IS_DELETE=0");
                                staffInfos.AddRange(subInfos);
                            }
                        }


                        this.Invoke(new Action(() =>
                        {
                            DoShowInfos(staffInfos);
                        }));
                    }
                    catch (Exception ex)
                    {
                        log.Error("获取人员异常:", ex);
                        WinInfoHelper.ShowInfoWindow(this, "获取人员异常:" + ex.Message);
                    }
                });
                waiting.Show(this);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        private void AddWatchData(Controller ctrlr, bool connected, ControllerState state, bool doorstate, bool relaystate)
        {
            string cardNo = null;

            if (state != null)
            {
                if (_cards == null)
                {
                    Maticsoft.BLL.SMT_CARD_INFO cardBll = new Maticsoft.BLL.SMT_CARD_INFO();
                    _cards = cardBll.GetModelList("");
                }
                cardNo = state.cardOrNoNumber;
                var card = _cards.Find(m => m.CARD_WG_NO == state.cardOrNoNumber);
                if (card != null)
                {
                    cardNo = card.CARD_NO;
                }
                else
                {
                    Maticsoft.BLL.SMT_CARD_INFO cardBll = new Maticsoft.BLL.SMT_CARD_INFO();
                    var c = cardBll.GetModelList("CARD_WG_NO='" + state.cardOrNoNumber + "'");
                    if (c.Count > 0)
                    {
                        _cards.Add(c[0]);
                        cardNo = c[0].CARD_NO;
                    }
                }
            }
            string staffname = "未知";
            string orgname   = "未知";

            Maticsoft.Model.SMT_STAFF_INFO sinfo = null;
            if (cardNo != null)
            {
                try
                {
                    Maticsoft.BLL.SMT_STAFF_INFO siBll = new Maticsoft.BLL.SMT_STAFF_INFO();
                    var ds   = siBll.GetListByCardNum(cardNo);
                    var list = siBll.DataTableToListWithDept(ds.Tables[0]);
                    if (list.Count > 0)
                    {
                        staffname = list[0].REAL_NAME;
                        orgname   = list[0].ORG_NAME;
                        sinfo     = list[0];
                    }
                }
                catch (Exception ex)
                {
                    log.Error("读取职员异常:", ex);
                }
            }
            this.Invoke(new Action(() =>
            {
                foreach (MapCtrl item in _detectedMaps)
                {
                    List <Maticsoft.Model.SMT_DOOR_INFO> doors;
                    List <Maticsoft.Model.SMT_FACERECG_DEVICE> faces;
                    GetDoors(item, out doors, out faces);
                    foreach (var door in doors)
                    {
                        if ((decimal)door.CTRL_ID != ctrlr.id)
                        {
                            continue;
                        }
                        var doorRect = item.GetDoor(door.ID, 1);
                        if (doorRect == null)
                        {
                            continue;
                        }
                        doorRect.IsOnline = connected;

                        int doorIndex = (int)door.CTRL_DOOR_INDEX;
                        bool doorLock = false;
                        if (state != null)
                        {
                            //更新状态
                            switch (doorIndex)
                            {
                            case 1:
                                doorLock = state.isOpenDoorOfLock1;
                                break;

                            case 2:
                                doorLock = state.isOpenDoorOfLock2;
                                break;

                            case 3:
                                doorLock = state.isOpenDoorOfLock3;
                                break;

                            case 4:
                                doorLock = state.isOpenDoorOfLock4;
                                break;

                            default:
                                break;
                            }

                            //更新状态
                            doorRect.IsOpen = doorLock;
                            door.OPEN_STATE = doorLock ? 1 : 0;
                            DoorDataHelper.UpdateDoorSync(door);
                        }
                        if ((!connected || state == null) && !doorstate)
                        {
                            door.OPEN_STATE   = 2;
                            doorRect.IsOnline = false;
                            DoorDataHelper.UpdateDoorSync(door);
                            //item.ImageIndex = connected ? 0 : 2;

                            /*DataGridViewRow row = new DataGridViewRow();
                             * row.Tag = ctrlr;
                             * row.CreateCells(dgvRealLog, DateTime.Now, door.DOOR_NAME, string.Format("控制器:IP={0},SN={1} {2}!", ctrlr.ip, ctrlr.sn, connected ? "连接成功" : "无法连接"));
                             * row.DefaultCellStyle.BackColor = Color.Yellow;
                             * dgvRealLog.Rows.Insert(0, row);*/
                        }
                        else if ((byte)door.CTRL_DOOR_INDEX == state.doorNum)
                        {
                            DataGridViewRow row = new DataGridViewRow();
                            row.Tag             = state;
                            if (!relaystate)
                            {
                                string actionname = AccessHelper.GetRecordReasonString(state.reasonNo);
                                if (!doorLock)
                                {
                                    actionname += ",锁状态:关";
                                }
                                else
                                {
                                    actionname += ",锁状态:开";
                                }
                                if (doorstate)
                                {
                                    row.CreateCells(dgvRealLog, state.recordTime, door.DOOR_NAME + (state.isEnterDoor ? "-进门" : "-出门"), string.Format("人员:{0},部门:{1},门禁:{2},卡号:{3},动作:{4}", staffname, orgname, door.DOOR_NAME, cardNo, actionname));
                                    dgvRealLog.Rows.Insert(0, row);
                                    row.Tag = new object[] { sinfo, state };
                                    ShowStaffInfo(row, row.Tag as object[]);
                                    while (dgvRealLog.Rows.Count > 2000)
                                    {
                                        dgvRealLog.Rows.RemoveAt(dgvRealLog.Rows.Count - 1);
                                    }
                                }
                            }
                        }
                    }
                    item.Invalidate();
                }
            }));
        }
예제 #5
0
        private void DoSaveDoors(List <Maticsoft.Model.SMT_DOOR_INFO> doors, bool upload = false)
        {
            if (dtpStart.Value.Date > dtpEnd.Value.Date)
            {
                WinInfoHelper.ShowInfoWindow(this, "起始时间不能小于结束时间!");
                return;
            }
            int          timenum = 0;
            ComboBoxItem cbi     = (ComboBoxItem)cbTimeNum.SelectedItem;

            if (cbi.Tag is Maticsoft.Model.SMT_TIMESCALE_INFO)
            {
                Maticsoft.Model.SMT_TIMESCALE_INFO tsInfo = (Maticsoft.Model.SMT_TIMESCALE_INFO)cbi.Tag;
                timenum = tsInfo.TIME_NO;
            }
            else
            {
                timenum = 1;
            }

            CtrlWaiting ctrlWaiting = new CtrlWaiting("正在保存...", () =>
            {
                try
                {
                    Maticsoft.BLL.SMT_STAFF_DOOR sdBLL = new Maticsoft.BLL.SMT_STAFF_DOOR();
                    var sdList = sdBLL.GetModelList("STAFF_ID=" + staffInfo.ID);
                    List <Maticsoft.Model.SMT_DOOR_INFO> tempDoors = new List <Maticsoft.Model.SMT_DOOR_INFO>();
                    tempDoors.AddRange(doors);
                    foreach (var item in sdList)
                    {
                        var sc = doors.Find(m => m.ID == item.DOOR_ID);
                        if (sc == null)                                //权限删除
                        {
                            sdBLL.Delete(item.STAFF_ID, item.DOOR_ID); //删除权限
                        }
                        else
                        {
                            item.TIME_NUM  = timenum;
                            item.IS_UPLOAD = false;
                            sdBLL.Update(item);
                            tempDoors.Remove(sc);
                        }
                    }
                    foreach (var item in tempDoors) //添加的权限
                    {
                        Maticsoft.Model.SMT_STAFF_DOOR newSd = new Maticsoft.Model.SMT_STAFF_DOOR();
                        newSd.ADD_TIME    = DateTime.Now;
                        newSd.DOOR_ID     = item.ID;
                        newSd.IS_UPLOAD   = false;
                        newSd.UPLOAD_TIME = DateTime.Now;
                        newSd.STAFF_ID    = staffInfo.ID;
                        newSd.TIME_NUM    = timenum;

                        sdBLL.Add(newSd);
                    }
                    if (staffInfo.VALID_STARTTIME != dtpStart.Value || staffInfo.VALID_ENDTIME != dtpEnd.Value)
                    {
                        Maticsoft.BLL.SMT_STAFF_INFO staffBll = new Maticsoft.BLL.SMT_STAFF_INFO();
                        staffInfo.VALID_STARTTIME             = dtpStart.Value.Date;
                        staffInfo.VALID_ENDTIME = dtpEnd.Value.Date + new TimeSpan(23, 59, 59);
                        staffBll.Update(staffInfo);
                    }

                    if (upload)
                    {
                        string errMsg;
                        bool ret = UploadPrivate.Upload(staffInfo, out errMsg);
                        if (ret && errMsg != "")
                        {
                            WinInfoHelper.ShowInfoWindow(this, "上传权限存在异常:" + errMsg);
                            log.Warn("上传权限存在异常:" + errMsg);
                            return;
                        }
                        else if (!ret)
                        {
                            return;
                        }
                        else
                        {
                            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);
        }
예제 #6
0
        private void DoSave(bool isupload = false)
        {
            if (dgvSelected.Rows.Count == 0)
            {
                WinInfoHelper.ShowInfoWindow(this, "请至少选一个人员!");
                return;
            }
            if (cbIsValidValid.Checked &&
                (
                    (dtValidStart.LockUpdateChecked && dtValidStart.IsEmpty) ||
                    (dtValidEnd.LockUpdateChecked && dtValidEnd.IsEmpty)
                )
                )
            {
                WinInfoHelper.ShowInfoWindow(this, "请设置选择有效的开始或结束时间!");
                return;
            }
            bool isvaliddatechanged = false;

            if (cbIsValidValid.Checked &&
                (
                    (dtValidStart.LockUpdateChecked && !dtValidStart.IsEmpty) || (dtValidEnd.LockUpdateChecked && !dtValidEnd.IsEmpty)
                )
                )
            {
                isvaliddatechanged = true;
            }
            if (isvaliddatechanged)
            {
                if (cbIsValidValid.Checked && dtValidStart.LockUpdateChecked && dtValidEnd.LockUpdateChecked && dtValidStart.Value > dtValidEnd.Value)
                {
                    WinInfoHelper.ShowInfoWindow(this, "结束时间不能小于开始时间!");
                    return;
                }
            }
            if (!isvaliddatechanged && !cbisForbidden.Checked)
            {
                WinInfoHelper.ShowInfoWindow(this, "请选择要修改的信息!");
                return;
            }

            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_INFO staffBll = new Maticsoft.BLL.SMT_STAFF_INFO();
                try
                {
                    foreach (var item in staffInfos)
                    {
                        if (isvaliddatechanged)
                        {
                            if (dtValidStart.LockUpdateChecked && !dtValidStart.IsEmpty)
                            {
                                item.VALID_STARTTIME = dtValidStart.Value.Date;
                            }
                            if (dtValidEnd.LockUpdateChecked && !dtValidEnd.IsEmpty)
                            {
                                item.VALID_ENDTIME = dtValidEnd.Value.Date + new TimeSpan(23, 59, 59);
                            }
                        }
                        if (cbisForbidden.Checked)
                        {
                            item.IS_FORBIDDEN = !cbNormal.Checked;
                        }
                        staffBll.Update(item);
                    }
                }
                catch (Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存异常:" + ex.Message);
                    log.Error("保存异常:", ex);
                    return;
                }
                if (isupload)
                {
                    string errMsg = "";
                    bool ret      = UploadPrivate.Upload(staffInfos, out errMsg);
                    if (!ret || !string.IsNullOrWhiteSpace(errMsg))
                    {
                        WinInfoHelper.ShowInfoWindow(this, "保存成功,部分权限上传异常:" + errMsg);
                    }
                }
                this.Invoke(new Action(() =>
                {
                    this.Close();
                }));
            });

            waiting.Show(this);
        }
예제 #7
0
        //保存记录
        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;
            }
        }