예제 #1
0
        private void evtNewInfoCallBack(string recd)
        {
            string uuid = Guid.NewGuid().ToString();
            wgMjControllerSwipeRecord rec = new wgMjControllerSwipeRecord(recd);

            onEvent(rec.ControllerSN, rec.CardID, rec.ReadDate, rec.ReaderNo, uuid);
        }
예제 #2
0
        /// <summary>
        /// 解析 运行 信息
        /// </summary>
        private void txtInfoUpdateEntry(object info)
        {
            try
            {
                wgMjControllerSwipeRecord mjrec = new wgMjControllerSwipeRecord(info as string);
                if (mjrec.ControllerSN > 0)
                {
                    //如果不处于监控的控制器 则不作数据处理
                    int iSn = (int)mjrec.ControllerSN;
                    try
                    {
                        if (!watching.WatchingController.ContainsKey(iSn))
                        {
                            return; //不属于监控的控制器发出的信息 则返回
                        }
                    }
                    catch (Exception)
                    {
                        return;
                    }

                    #region  解析运行状态

                    int iCount = listWg.Count;
                    for (int iIndex = 0; iIndex < iCount; iIndex++)
                    {
                        if (listWg[iIndex] != null)
                        {
                            if (listWg[iIndex].IntSn == iSn)
                            {
                                string str = mjrec.ToDisplaySimpleInfo(true);

                                string strStart  = "Swipe Status: \t";
                                string strEnd    = "\r\nRead Date:";
                                string strStatus = DoorTimeInfo(str, strStart, strEnd);
                                //卡号
                                string strCardNo = "";
                                //门号
                                string strDoorNo = "";

                                #region 取得 卡号和门号

                                if (strStatus == WgOpenDoorType.刷卡开门.ToString() || strStatus == "刷卡禁止通过: 没有权限")
                                {
                                    strStart  = "CardID: \t";
                                    strEnd    = "\r\nDoorNO: \t";
                                    strCardNo = DoorTimeInfo(str, strStart, strEnd);
                                    if (strCardNo.Length == 6)
                                    {
                                        strCardNo = "00" + strCardNo;
                                    }
                                    if (strCardNo.Length == 7)
                                    {
                                        strCardNo = "0" + strCardNo;
                                    }
                                    strStart  = "DoorNO: \t";
                                    strEnd    = "\r\n \t[";
                                    strDoorNo = DoorTimeInfo(str, strStart, strEnd);
                                }
                                else if (strStatus == WgOpenDoorType.超级密码开门.ToString())
                                {
                                    strStart  = "DoorNO: \t";
                                    strEnd    = "\r\nSwipe";
                                    strDoorNo = DoorTimeInfo(str, strStart, strEnd);
                                }

                                #endregion

                                #region  更新 刷卡信息

                                if (listWg[iIndex].listDoor != null)
                                {
                                    int iCountDoor = listWg[iIndex].listDoor.Count;
                                    for (int iIndexDoor = 0; iIndexDoor < iCountDoor; iIndexDoor++)
                                    {
                                        int iDoorIndex = listWg[iIndex].listDoor[iIndexDoor].IntDoorIndex;
                                        if (strDoorNo == iDoorIndex.ToString())
                                        {
                                            if (strStatus == WgOpenDoorType.刷卡开门.ToString())
                                            {
                                                string strGroup = "";
                                                string strUser  = "";
                                                commonCls.GetWgUserGroup(strCardNo, ref strGroup, ref strUser);

                                                lock (listWg)
                                                {
                                                    listWg[iIndex].listDoor[iIndexDoor].StrOpenType = OpenDoorType.刷卡.ToString();
                                                    listWg[iIndex].listDoor[iIndexDoor].StrGroup    = strGroup;
                                                    listWg[iIndex].listDoor[iIndexDoor].StrUser     = strUser;
                                                }
                                            }
                                            else if (strStatus == WgOpenDoorType.超级密码开门.ToString())
                                            {
                                                lock (listWg)
                                                {
                                                    listWg[iIndex].listDoor[iIndexDoor].StrOpenType = OpenDoorType.密码.ToString();
                                                }
                                            }
                                            else if (strStatus == "刷卡禁止通过: 没有权限")
                                            {
                                                //报警显示
                                            }
                                            break;
                                        }
                                    }
                                }

                                #endregion

                                break;
                            }
                        }
                    }

                    #endregion
                }
            }
            catch (Exception ex)
            {
                if (frmMain.blDebug)
                {
                    MessageUtil.ShowTips(ex.Message);
                }
            }
        }
예제 #3
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("Getting swipe records");

            // Serial Number
            int serialNumber = 0;

            foreach (string s in req.Headers.GetValues("X-M46-RFID-SN"))
            {
                serialNumber = int.Parse(s);
            }

            // IP
            string ip = "";

            foreach (string i in req.Headers.GetValues("X-M46-RFID-IP"))
            {
                ip = i;
            }

            // Port
            int port = 60000;

            foreach (string p in req.Headers.GetValues("X-M46-RFID-PORT"))
            {
                port = int.Parse(p);
            }

            var controller = new wgMjController
            {
                ControllerSN = serialNumber,
                IP           = ip,
                PORT         = port
            };

            DataTable dtSwipeRecords = new DataTable("SwipeRecords");

            dtSwipeRecords.Columns.Add("f_Index", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_ReadDate", System.Type.GetType("System.DateTime"));
            dtSwipeRecords.Columns.Add("f_CardNO", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_DoorNO", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_InOut", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_ReaderNO", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_EventCategory", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_ReasonNo", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_ControllerSN", System.Type.GetType("System.UInt32"));
            dtSwipeRecords.Columns.Add("f_RecordAll", System.Type.GetType("System.String"));

            var passes = new List <Pass>();

            int num = -1;

            await Task.Run(() =>
            {
                using (wgMjControllerSwipeOperate swipe4GetRecords = new wgMjControllerSwipeOperate())
                {
                    swipe4GetRecords.Clear();
                    num = swipe4GetRecords.GetSwipeRecords(controller.ControllerSN, controller.IP, controller.PORT, ref dtSwipeRecords);
                }
                Console.WriteLine($"Got {num} records");

                if (num > 0)
                {
                    wgMjControllerSwipeRecord mjrec = new wgMjControllerSwipeRecord();
                    for (int i = 0; i < num; i++)
                    {
                        mjrec.Update(dtSwipeRecords.Rows[i]["f_RecordAll"] as string);
                        log.Info(mjrec.CardID.ToString());
                        var pass = new Pass
                        {
                            id           = (int)mjrec.CardID,
                            readerNumber = mjrec.DoorNo,
                            readDate     = mjrec.ReadDate,
                            direction    = mjrec.IsEnterIn ? "in" : "out"
                        };
                        passes.Add(pass);
                    }
                }
            });

            if (num < 0)
            {
                return(req.CreateResponse(HttpStatusCode.InternalServerError, "Unable to get records"));
            }

            return(req.CreateResponse(HttpStatusCode.OK, passes, JsonMediaTypeFormatter.DefaultMediaType));
        }
예제 #4
0
        private void txtInfoUpdateEntry(object info)
        {
            #region

            wgMjControllerSwipeRecord mjrec = new wgMjControllerSwipeRecord(info as string);
            if (mjrec.ControllerSN > 0)
            {
                //如果不处于监控的控制器 则不作数据处理

                int iSn = (int)mjrec.ControllerSN;
                try
                {
                    if (!watching.WatchingController.ContainsKey(iSn))
                    {
                        return; //不属于监控的控制器发出的信息 则返回
                    }
                }
                catch (Exception)
                {
                    return;
                }

                #region  解析运行状态

                int iCount = listWg.Count;
                for (int iIndex = 0; iIndex < iCount; iIndex++)
                {
                    if (listWg[iIndex] != null)
                    {
                        if (listWg[iIndex].IntSn == iSn)
                        {
                            string str = mjrec.ToDisplaySimpleInfo(true);

                            string strStart  = "Swipe Status: \t";
                            string strEnd    = "\r\nRead Date:";
                            string strStatus = DoorTimeInfo(str, strStart, strEnd);
                            //卡号
                            string strCardNo = "";
                            //门号
                            string strDoorNo = "";
                            if (strStatus == OpenDoorType.刷卡.ToString() || strStatus == "刷卡禁止通过: 没有权限")
                            {
                                strStart  = "CardID: \t";
                                strEnd    = "\r\nDoorNO: \t";
                                strCardNo = DoorTimeInfo(str, strStart, strEnd);
                                if (strCardNo.Length == 6)
                                {
                                    strCardNo = "00" + strCardNo;
                                }
                                if (strCardNo.Length == 7)
                                {
                                    strCardNo = "0" + strCardNo;
                                }
                                strStart  = "DoorNO: \t";
                                strEnd    = "\r\n \t[";
                                strDoorNo = DoorTimeInfo(str, strStart, strEnd);
                            }

                            //刷卡开门
                            if (strStatus == OpenDoorType.刷卡.ToString())
                            {
                                UserAndGroup userGroup         = GetPeopleAndGroup(strCardNo);
                                string       strOpenDoorPeople = userGroup.strUser;
                                string       strGroupName      = userGroup.strGroup;
                                lock (listWg)
                                {
                                    if (strDoorNo == "1")
                                    {
                                        listWg[iIndex].StrOpenTypeDoor1 = OpenDoorType.刷卡.ToString();
                                        listWg[iIndex].StrOpenGroup1    = strGroupName;
                                        listWg[iIndex].StrOpenName1     = strOpenDoorPeople;
                                    }
                                    else if (strDoorNo == "2")
                                    {
                                        listWg[iIndex].StrOpenTypeDoor2 = OpenDoorType.刷卡.ToString();
                                        listWg[iIndex].StrOpenGroup2    = strGroupName;
                                        listWg[iIndex].StrOpenName2     = strOpenDoorPeople;
                                    }
                                }
                            }
                            else if (strStatus == "刷卡禁止通过: 没有权限")
                            {
                                string strType    = AlarmsType.门禁.ToString();
                                string strContent = "刷卡禁止通过:无权限  卡号:" + strCardNo;
                                string strPoint   = "";
                                if (listWg[iIndex].WgDoorCount == DoorCount.双门)
                                {
                                    if (strDoorNo == "1")
                                    {
                                        strPoint = listWg[iIndex].StrNameDoor1;
                                    }
                                    else if (strDoorNo == "2")
                                    {
                                        strPoint = listWg[iIndex].StrNameDoor2;
                                    }
                                }



                                NewAlarmEvent(strContent, true, strPoint);
                            }
                            else if (strStatus == OpenDoorType.超级密码开门.ToString())
                            {
                                strStart  = "DoorNO: \t";
                                strEnd    = "\r\nSwipe";
                                strDoorNo = DoorTimeInfo(str, strStart, strEnd);

                                lock (listWg)
                                {
                                    if (strDoorNo == "1")
                                    {
                                        listWg[iIndex].StrOpenTypeDoor1 = OpenDoorType.超级密码开门.ToString();
                                    }
                                    else if (strDoorNo == "2")
                                    {
                                        listWg[iIndex].StrOpenTypeDoor2 = OpenDoorType.超级密码开门.ToString();
                                    }
                                }
                            }
                            break;
                        }
                    }
                }

                #endregion
            }

            #endregion

            //try
            //{

            //}
            //catch (Exception ex)
            //{
            //    if (frmMain.blDebug)
            //        MessageUtil.ShowTips(ex.Message);
            //}
        }
예제 #5
0
        private void evtNewInfoCallBack(string recd)
        {
            wgMjControllerSwipeRecord rec = new wgMjControllerSwipeRecord(recd);

            onEvent(rec.ControllerSN, rec.CardID, rec.ReadDate, rec.ReaderNo);
        }