예제 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int            index = tabControl1.SelectedIndex;
            TMapDoorInfo   door;
            TMJWatch       watch = new TMJWatch("", 0);
            TConnInfoNewMJ connInfo;

            timer1.Enabled = false;
            bool       findWatch;
            PictureBox btn;

            AccessV2API.TYPE_Setting setting = new AccessV2API.TYPE_Setting();
            for (int i = 0; i < tabControl1.TabPages[index].Controls[0].Controls.Count; i++)
            {
                Application.DoEvents();
                if (!isRealing)
                {
                    break;
                }
                btn      = (PictureBox)tabControl1.TabPages[index].Controls[0].Controls[i];
                door     = (TMapDoorInfo)btn.Tag;
                connInfo = Pub.ValueToNewMJConnInfo(door.MacSN, door.MacConnType, door.MacIPAddress, door.MacPort, door.MacConnPWD);
                DeviceObject.objMJNew.NewDevice(connInfo, 0);
                findWatch = false;
                for (int j = 0; j < watchIndex.Count; j++)
                {
                    if (watchIndex[j].MacSN == door.MacSN)
                    {
                        findWatch = true;
                        watch     = watchIndex[j];
                        break;
                    }
                }
                if (!findWatch)
                {
                    watch = new TMJWatch(door.MacSN, 0);
                    watchIndex.Add(watch);
                }
                if (!DeviceObject.objMJNew.ReadSetting(out setting))
                {
                    continue;
                }
                int DoorID = 0;
                int.TryParse(door.DoorID, out DoorID);
                if (DoorID > 0 && DoorID <= 4)
                {
                    if (setting.DoorState[DoorID - 1] == 0)
                    {
                        btn.Image = Properties.Resources.doorclose;
                    }
                    else
                    {
                        btn.Image = Properties.Resources.dooropen;
                    }
                }
                if (watch.Index == 0)
                {
                    watch.Index = setting.LogCount;
                    if (watch.Index == 1)
                    {
                        watch.Index = 0;
                    }
                }
                AccessV2API.TYPE_Log log;
                if (!DeviceObject.objMJNew.ReadLog(watch.Index, out log))
                {
                    continue;
                }
                if (log.Door == 0 || log.Door == 255)
                {
                    continue;
                }
                QHKS.TMJRecordInfo recInfo = new QHKS.TMJRecordInfo();
                recInfo.AlarmType = Convert.ToByte(log.WarnCode);
                recInfo.CardNo    = log.CardNo.ToString("0000000000");
                recInfo.CardTime  = DeviceObject.objMJNew.MJDateTimeToDateTime(log.DateTime);
                recInfo.DoorID    = Convert.ToByte(log.Door);
                recInfo.IsCard    = Convert.ToByte(log.CardNo > 0);
                if (recInfo.DoorID > 0 && recInfo.DoorID <= 4)
                {
                    recInfo.IsPass = Convert.ToByte(log.DoorState[recInfo.DoorID - 1] > 0);
                    if (recInfo.IsCard == 1 && recInfo.AlarmType >= 0x80 && recInfo.AlarmType <= 0x86)
                    {
                        recInfo.IsPass = 1;
                    }
                }
                recInfo.ReaderID = Convert.ToByte(log.Reader);
                ShowRealData(recInfo, connInfo.MacSN.ToString());
                watch.Index++;
                Application.DoEvents();
            }
            if (isRealing)
            {
                timer1.Enabled = true;
            }
        }
예제 #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int          index = tabControl1.SelectedIndex;
            TMapDoorInfo door;
            TMJWatch     watch = new TMJWatch("", 0);

            QHKS.TMJConnInfo   connInfo;
            QHKS.TMJMacInfo    macInfo    = new QHKS.TMJMacInfo();
            QHKS.TMJDoorStatus doorStatus = new QHKS.TMJDoorStatus();
            QHKS.TMJRecordInfo recInfo    = new QHKS.TMJRecordInfo();
            int RecordCount = 0;

            timer1.Enabled = false;
            bool       findWatch;
            PictureBox btn;

            for (int i = 0; i < tabControl1.TabPages[index].Controls[0].Controls.Count; i++)
            {
                Application.DoEvents();
                if (!isRealing)
                {
                    break;
                }
                btn      = (PictureBox)tabControl1.TabPages[index].Controls[0].Controls[i];
                door     = (TMapDoorInfo)btn.Tag;
                connInfo = Pub.ValueToMJConnInfo(door.MacSN, door.MacConnType, door.MacIPAddress, door.MacPort, door.MacConnPWD);
                DeviceObject.objMJ.Init(ref connInfo);
                findWatch = false;
                for (int j = 0; j < watchIndex.Count; j++)
                {
                    if (watchIndex[j].MacSN == door.MacSN)
                    {
                        findWatch = true;
                        watch     = watchIndex[j];
                        break;
                    }
                }
                if (!findWatch)
                {
                    watch = new TMJWatch(door.MacSN, 0);
                    watchIndex.Add(watch);
                }
                if (watch.Index == 0)
                {
                    if (!DeviceObject.objMJ.GetMacInfo(ref macInfo))
                    {
                        continue;
                    }
                    watch.Index = macInfo.RecordCount + 1;
                }
                if (!DeviceObject.objMJ.GetMacRecordReal(watch.Index, ref RecordCount, ref doorStatus))
                {
                    continue;
                }
                for (int j = 0; j < RecordCount; j++)
                {
                    if (DeviceObject.objMJ.GetMacRecordValue(j, ref recInfo))
                    {
                        if (FindDoorID(recInfo.DoorID))
                        {
                            ShowRealData(recInfo, connInfo.MacSN);
                        }
                    }
                }
                watch.Index += RecordCount;
                if (doorStatus.Door[Convert.ToInt32(door.DoorID) - 1] == 0)
                {
                    btn.Image = Properties.Resources.doorclose;
                }
                else
                {
                    btn.Image = Properties.Resources.dooropen;
                }
                Application.DoEvents();
            }
            if (isRealing)
            {
                timer1.Enabled = true;
            }
        }