예제 #1
0
        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);
        }
예제 #2
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();
                }
            }));
        }