/// <summary>
        /// 开关门 信息显示 和记录
        /// </summary>
        private void OnOffDoorInfoRecord(WgDoorType doorOrBox, string strDoorName, DoorsState state, string strOpenType, string strGroup, string strUser, DateTime timeOpen, string strArea)
        {
            EventType eventType = EventType.门禁;

            if (doorOrBox == WgDoorType.门禁)
            {
                if (state == DoorsState.开门)
                {
                    commonCls.NewDoorInOut(state, strOpenType, strDoorName, strGroup, strUser, "");
                }
                else if (state == DoorsState.关门)
                {
                    TimeSpan timeSpan = DateTime.Now - timeOpen;//listWg[iIndex].listDoor[iIndexDoor].TimeOpenDoor;
                    string   strSpan  = clsCommon.CalculateTime(timeSpan);
                    commonCls.NewDoorInOut(state, "", "", "", "", strSpan);
                }
            }
            else if (doorOrBox == WgDoorType.工具柜)
            {
                eventType = EventType.工具柜;
                commonCls.BoxOnOffRecord(strArea, strDoorName, state, strOpenType, strGroup, strUser);
            }
            if (NewEventShowEvent != null)
            {
                NewEventShowEvent(new NewEventEventArgs(eventType, strDoorName, state.ToString(), strUser, strOpenType, DateTime.Now));
            }
        }
Exemple #2
0
        private void timer_Execute()
        {
            try
            {
                for (int iIndex = 0; iIndex < listZk.Count; iIndex++)
                {
                    if (listZk[iIndex].BlConnoct == false)
                    {
                        TimeSpan span = DateTime.Now - listZk[iIndex].TimeConnectLast;
                        if (span.TotalMinutes > 2)
                        {
                            bool blRet = ConnectZk(iIndex);
                            if (blRet)
                            {
                                if (listZk[iIndex].StateOfNet != CommuniState.已连接)
                                {
                                    lock (listZk)
                                    {
                                        listZk[iIndex].StateOfNet = CommuniState.已连接;
                                    }
                                    //异常事件
                                    NetErrInfoAndRecord(iIndex, ErrorContent.通信恢复正常.ToString());
                                }
                            }
                            lock (listZk)
                            {
                                listZk[iIndex].TimeConnectLast = DateTime.Now;
                            }
                        }
                    }
                    else
                    {
                        DoorsState state = DoorsState.初值;
                        bool       blRet = listZk[iIndex].GetDoorState(ref state);
                        if (blRet)
                        {
                            if (state != listZk[iIndex].doorInfo.StateOfDoor)
                            {
                                listZk[iIndex].doorInfo.StateOfDoor = state;

                                if (state == DoorsState.关门)
                                {
                                    listZk[iIndex].doorInfo.StrOpenType = "";
                                    listZk[iIndex].doorInfo.StrGroup    = "";
                                    listZk[iIndex].doorInfo.StrUser     = "";
                                }
                                if (listZk[iIndex].doorInfo.IsOfRfid == DeviceUsing.启用)
                                {//確定是哪个门禁关联RFID
                                    if (state == DoorsState.关门)
                                    {
                                        clsRfidRead.strOpenUser = "";
                                    }
                                    else if (state == DoorsState.开门)
                                    {
                                        clsRfidRead.strOpenUser = listZk[iIndex].doorInfo.StrUser;
                                    }
                                }

                                //if (state == DoorsState.关门)
                                //{
                                //    listZk[iIndex].doorInfo.StrOpenType = "";
                                //    listZk[iIndex].doorInfo.StrGroup = "";
                                //    listZk[iIndex].doorInfo.StrUser = "";
                                //    if (listZk[iIndex].doorInfo.IsOfRfid == DeviceUsing.启用)
                                //    {
                                //        clsRfidRead.strOpenUser = "";
                                //    }
                                //}
                                //else if (state == DoorsState.开门 )
                                //{
                                //    if (listZk[iIndex].doorInfo.IsOfRfid == DeviceUsing.启用)
                                //    {
                                //        clsRfidRead.strOpenUser  = listZk[iIndex].doorInfo.StrUser;
                                //    }
                                //}
                                //开关门事件
                                if (NewEventShowEvent != null)
                                {
                                    string strPoint = listZk[iIndex].doorInfo.StrDoorName;
                                    string strType  = "非法开门";
                                    if (!String.IsNullOrEmpty(listZk[iIndex].doorInfo.StrOpenType))
                                    {
                                        strType = listZk[iIndex].doorInfo.StrOpenType;
                                    }
                                    else
                                    {
                                        strType = state.ToString();
                                    }
                                    string strUser  = listZk[iIndex].doorInfo.StrUser;
                                    string StrGroup = listZk[iIndex].doorInfo.StrGroup;
                                    NewEventShowEvent(new NewEventEventArgs(EventType.门禁, strPoint, state.ToString(), strUser, strType, DateTime.Now));
                                    commonCls.NewDoorInOut(state, strType, strPoint, StrGroup, strUser, "");
                                }
                            }
                        }
                        else
                        {
                            if (listZk[iIndex].BlConnoct)
                            {
                                DisConnectZkAndClearEvent(iIndex);
                                if (listZk[iIndex].StateOfNet != CommuniState.已断开)
                                {
                                    lock (listZk)
                                    {
                                        listZk[iIndex].StateOfNet = CommuniState.已断开;
                                    }
                                    //异常事件
                                    NetErrInfoAndRecord(iIndex, ErrorContent.通信异常.ToString());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (frmMain.blDebug)
                {
                    MessageUtil.ShowTips(ex.Message);
                }
            }
        }