Exemple #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            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;
            for (int i = 0; i < connList.Count; i++)
            {
                Application.DoEvents();
                if (!isRealing)
                {
                    break;
                }
                connInfo = connList[i];
                DeviceObject.objMJ.Init(ref connInfo);
                if (watchIndex[i] == 0)
                {
                    if (!DeviceObject.objMJ.GetMacInfo(ref macInfo))
                    {
                        continue;
                    }
                    watchIndex[i] = macInfo.RecordCount + 1;
                }
                if (!DeviceObject.objMJ.GetMacRecordReal(watchIndex[i], ref RecordCount, ref doorStatus))
                {
                    continue;
                }
                for (int j = 0; j < RecordCount; j++)
                {
                    if (DeviceObject.objMJ.GetMacRecordValue(j, ref recInfo))
                    {
                        ShowRealData(recInfo, connInfo.MacSN);
                    }
                }
                watchIndex[i] += RecordCount;
                SetMacDoorState(connInfo.MacSN, doorStatus);
                Application.DoEvents();
            }
            if (isRealing)
            {
                timer1.Enabled = true;
            }
        }
Exemple #2
0
        private void SaveDB(QHKS.TMJRecordInfo recInfo, string MacSN)
        {
            DateTime t      = recInfo.CardTime;
            int      MJTime = t.Hour * 60 * 60 + t.Minute * 60 + t.Second;
            string   memo   = "";
            string   sql    = "";

            if (recInfo.IsCard == 0)
            {
                memo = Pub.GetResText("", "MJRecordMemo" + recInfo.AlarmType.ToString(), "");
                sql  = Pub.GetSQL(DBCode.DB_003005, new string[] { "1", t.ToString(SystemInfo.SQLDateFMT), MJTime.ToString(),
                                                                   MacSN, recInfo.DoorID.ToString(), recInfo.AlarmType.ToString(), memo, OprtInfo.OprtSysID });
            }
            else
            {
                memo = Pub.GetResText("", "MJRecordMemo144", "") + "[" + recInfo.CardNo + "]";
                string IsPass = "******";
                if (recInfo.IsPass == 1)
                {
                    IsPass = "******";
                }
                sql = Pub.GetSQL(DBCode.DB_003005, new string[] { "0", SystemInfo.CardProtocol.ToString(), recInfo.CardNo,
                                                                  t.ToString(SystemInfo.SQLDateFMT), MJTime.ToString(), MacSN, Pub.GetMJReaderID(MacSN, recInfo.ReaderID),
                                                                  OprtInfo.OprtSysID, memo, IsPass });
            }
            try
            {
                db.ExecSQL(sql);
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E, sql);
                return;
            }
            db.WriteSYLog(this.Text, CurrentTool, sql);
        }
Exemple #3
0
        public void ShowRealData(QHKS.TMJRecordInfo recInfo, string MacSN)
        {
            string          EmpSysID      = "";
            string          EmpNo         = "";
            string          EmpName       = "";
            string          DepartID      = "";
            string          DepartName    = "";
            string          CardSectorNo  = "";
            string          MacDoorName   = "";
            string          MacPassState  = Pub.GetResText("MJMacReal", "AllowPass", "");
            string          MacReadImpact = "";
            string          Memo          = "";
            string          readerid      = Pub.GetMJReaderID(MacSN, recInfo.ReaderID);
            string          wavFile       = "";
            DataTableReader dr            = null;

            try
            {
                if (recInfo.IsCard == 1)
                {
                    dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "1", recInfo.CardNo }));
                    if (dr.Read())
                    {
                        EmpSysID   = dr["EmpSysID"].ToString();
                        EmpNo      = dr["EmpNo"].ToString();
                        EmpName    = dr["EmpName"].ToString();
                        DepartID   = dr["DepartID"].ToString();
                        DepartName = dr["DepartName"].ToString();
                        if (SystemInfo.HasFaCard)
                        {
                            CardSectorNo = dr["CardSectorNo"].ToString();
                        }
                        else
                        {
                            CardSectorNo = dr["CardPhysicsNo10"].ToString();
                        }
                    }
                    dr.Close();
                }
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "3", MacSN, readerid }));
                if (dr.Read())
                {
                    MacDoorName   = dr["MacDoorName"].ToString();
                    MacReadImpact = dr["MacReadImpact"].ToString();
                }
            }
            catch
            {
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            string msg = "";

            if ((EmpSysID == "") || (recInfo.IsPass == 0))
            {
                int IndexNum = recInfo.AlarmType;
                if (recInfo.IsCard == 1)
                {
                    IndexNum = 144;
                }
                Memo = Pub.GetResText(formCode, "MJRecordMemo" + IndexNum.ToString(), "");
                if (recInfo.IsCard == 1)
                {
                    Memo   += "[" + recInfo.CardNo + "]";
                    wavFile = "PassDis.wav";
                }
                else if (IndexNum == 140)
                {
                    wavFile = "NormalIn.wav";
                }
                else if (IndexNum == 141)
                {
                    wavFile = "AlarmDur.wav";
                }
                else if (IndexNum == 142)
                {
                    wavFile = "DoorTime.wav";
                }
                else if ((IndexNum == 143) || (IndexNum == 145) || (IndexNum == 146))
                {
                    wavFile = "Alarm.wav";
                }
                else if (IndexNum == 148)
                {
                    wavFile = "AlarmDis.wav";
                }
                if (wavFile != "")
                {
                    wavFile = wavPath + wavFile;
                    Pub.PlaySound(wavFile);
                }
                msg = recInfo.CardTime.ToString() + "  " + MacSN + "  " + MacDoorName + "  " + Memo;
            }
            else
            {
                if (MacReadImpact.ToLower() == "in")
                {
                    wavFile = "NormalIn.wav";
                }
                else
                {
                    wavFile = "NormalIn.wav";
                }
                wavFile = wavPath + wavFile;
                Pub.PlaySound(wavFile);
                msg = CardSectorNo + "  " + recInfo.CardTime.ToString() + "  " + EmpNo + "  " + EmpName + "  " +
                      DepartID + "  " + DepartName + "  " + MacSN + "  " + MacDoorName + "  " + MacPassState + "  " + MacReadImpact;
            }
            TCommonType ctype = new TCommonType(EmpSysID, "", msg, true);

            lbMsg.Items.Add(ctype);
            while (lbMsg.Items.Count > maxCount)
            {
                lbMsg.Items.RemoveAt(0);
            }
            lbMsg.SelectedIndex = lbMsg.Items.Count - 1;
        }
Exemple #4
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;
            }
        }
Exemple #5
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;
            }
        }
Exemple #6
0
        public void ShowRealData(QHKS.TMJRecordInfo recInfo, string MacSN)
        {
            string          EmpSysID      = "";
            string          EmpNo         = "";
            string          EmpName       = "";
            string          DepartID      = "";
            string          DepartName    = "";
            string          CardSectorNo  = "";
            string          MacDoorName   = "";
            string          MacPassState  = Pub.GetResText(formCode, "AllowPass", "");
            string          MacReadImpact = "";
            string          Memo          = "";
            string          readerid      = Pub.GetMJReaderID(MacSN, recInfo.ReaderID);
            string          wavFile       = "";
            DataTableReader dr            = null;

            try
            {
                if (recInfo.IsCard == 1)
                {
                    if (SystemInfo.CardProtocol == 0)
                    {
                        dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "0", recInfo.CardNo }));
                    }
                    else
                    {
                        dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "1", recInfo.CardNo }));
                    }
                    if (dr.Read())
                    {
                        EmpSysID   = dr["EmpSysID"].ToString();
                        EmpNo      = dr["EmpNo"].ToString();
                        EmpName    = dr["EmpName"].ToString();
                        DepartID   = dr["DepartID"].ToString();
                        DepartName = dr["DepartName"].ToString();
                        if (SystemInfo.HasFaCard)
                        {
                            CardSectorNo = dr["CardSectorNo"].ToString();
                        }
                        else
                        {
                            CardSectorNo = dr["CardPhysicsNo10"].ToString();
                        }
                    }
                    dr.Close();
                }
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003006, new string[] { "2", MacSN, readerid }));
                if (dr.Read())
                {
                    MacDoorName   = dr["MacDoorName"].ToString();
                    MacReadImpact = dr["MacReadImpact"].ToString();
                }
            }
            catch
            {
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if ((EmpSysID == "") || (recInfo.IsPass == 0))
            {
                int IndexNum = recInfo.AlarmType;
                if (recInfo.IsCard == 1)
                {
                    IndexNum = 144;
                }
                Memo = Pub.GetResText(formCode, "MJRecordMemo" + IndexNum.ToString(), "");
                if (recInfo.IsCard == 1)
                {
                    Memo   += "[" + recInfo.CardNo + "]";
                    wavFile = "PassDis.wav";
                }
                else if (IndexNum == 140)
                {
                    wavFile = "NormalIn.wav";
                }
                else if (IndexNum == 141)
                {
                    wavFile = "AlarmDur.wav";
                }
                else if (IndexNum == 142)
                {
                    wavFile = "DoorTime.wav";
                }
                else if ((IndexNum == 143) || (IndexNum == 145) || (IndexNum == 146))
                {
                    wavFile = "Alarm.wav";
                }
                else if (IndexNum == 148)
                {
                    wavFile = "AlarmDis.wav";
                }
                if (wavFile != "")
                {
                    wavFile = wavPath + wavFile;
                    Pub.PlaySound(wavFile);
                }
                alarmGrid.Rows.Add();
                while (alarmGrid.RowCount > maxCount)
                {
                    alarmGrid.Rows.RemoveAt(0);
                }
                alarmGrid[0, alarmGrid.RowCount - 1].Value      = recInfo.CardTime;
                alarmGrid[1, alarmGrid.RowCount - 1].Value      = MacSN;
                alarmGrid[2, alarmGrid.RowCount - 1].Value      = MacDoorName;
                alarmGrid[3, alarmGrid.RowCount - 1].Value      = readerid;
                alarmGrid[4, alarmGrid.RowCount - 1].Value      = IndexNum;
                alarmGrid[5, alarmGrid.RowCount - 1].Value      = Memo;
                alarmGrid.Rows[alarmGrid.RowCount - 1].Selected = true;
                alarmGrid.CurrentCell     = alarmGrid.Rows[alarmGrid.RowCount - 1].Cells[0];
                tabControl1.SelectedIndex = 1;
            }
            else
            {
                if (MacReadImpact.ToLower() == "in")
                {
                    wavFile = "NormalIn.wav";
                }
                else
                {
                    wavFile = "NormalIn.wav";
                }
                wavFile = wavPath + wavFile;
                Pub.PlaySound(wavFile);
                realGrid.Rows.Add();
                while (realGrid.RowCount > maxCount)
                {
                    realGrid.Rows.RemoveAt(0);
                }
                realGrid[0, realGrid.RowCount - 1].Value      = CardSectorNo;
                realGrid[1, realGrid.RowCount - 1].Value      = recInfo.CardTime;
                realGrid[2, realGrid.RowCount - 1].Value      = EmpNo;
                realGrid[3, realGrid.RowCount - 1].Value      = EmpName;
                realGrid[4, realGrid.RowCount - 1].Value      = DepartID;
                realGrid[5, realGrid.RowCount - 1].Value      = DepartName;
                realGrid[6, realGrid.RowCount - 1].Value      = MacSN;
                realGrid[7, realGrid.RowCount - 1].Value      = MacDoorName;
                realGrid[8, realGrid.RowCount - 1].Value      = MacPassState;
                realGrid[9, realGrid.RowCount - 1].Value      = MacReadImpact;
                realGrid[10, realGrid.RowCount - 1].Value     = EmpSysID;
                realGrid.Rows[realGrid.RowCount - 1].Selected = true;
                realGrid.CurrentCell = realGrid.Rows[realGrid.RowCount - 1].Cells[0];
                if (realGrid.RowCount == 1)
                {
                    realGrid_SelectionChanged(null, null);
                }
                tabControl1.SelectedIndex = 0;
            }
            if (isSaveDB)
            {
                SaveDB(recInfo, MacSN);
            }
        }
Exemple #7
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     timer1.Enabled = false;
     AccessV2API.TYPE_Setting setting = new AccessV2API.TYPE_Setting();
     for (int i = 0; i < connList.Count; i++)
     {
         Application.DoEvents();
         if (!isRealing)
         {
             break;
         }
         TConnInfoNewMJ connInfo = connList[i];
         DeviceObject.objMJNew.NewDevice(connInfo, 0);
         if (!DeviceObject.objMJNew.ReadSetting(out setting))
         {
             continue;
         }
         SetMacDoorState(connInfo.MacSN.ToString(), setting.DoorState);
         if (watchIndex[i] == 0)
         {
             watchIndex[i] = setting.LogCount;
             if (watchIndex[i] == 1)
             {
                 watchIndex[i] = 0;
             }
         }
         AccessV2API.TYPE_Log log;
         if (!DeviceObject.objMJNew.ReadLog(watchIndex[i], out log))
         {
             continue;
         }
         if (log.DateTime.wYear > 3099)
         {
             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());
         watchIndex[i]++;
         Application.DoEvents();
         //AccessV2API.TYPE_LogPack LogPack = new AccessV2API.TYPE_LogPack();
         //UInt32 PackIndex = 0;
         //int PackCount;
         //while (true)
         //{
         //    if (!isRealing) break;
         //    Application.DoEvents();
         //    PackCount = DeviceObject.objMJNew.ReadBlockLog(PackIndex, ref LogPack);
         //    if (PackCount <= 0 || LogPack.Count == 0) break;
         //    PackIndex++;
         //    for (int j = 0; j < LogPack.Count; j++)
         //    {
         //        if (LogPack.Log[j].Door != 0 && LogPack.Log[j].Door != 255)
         //        {
         //            QHKS.TMJRecordInfo recInfo = new QHKS.TMJRecordInfo();
         //            recInfo.AlarmType = Convert.ToByte(LogPack.Log[j].WarnCode);
         //            recInfo.CardNo = LogPack.Log[j].CardNo.ToString("0000000000");
         //            recInfo.CardTime = DeviceObject.objMJNew.MJDateTimeToDateTime(LogPack.Log[j].DateTime);
         //            recInfo.DoorID = Convert.ToByte(LogPack.Log[j].Door);
         //            recInfo.IsCard = Convert.ToByte(LogPack.Log[j].CardNo > 0);
         //            if (recInfo.DoorID > 0 && recInfo.DoorID <= 4)
         //            {
         //                recInfo.IsPass = Convert.ToByte(LogPack.Log[j].DoorState[recInfo.DoorID - 1] > 0);
         //                if (recInfo.IsCard == 1 && recInfo.AlarmType >= 0x80 && recInfo.AlarmType <= 0x86) recInfo.IsPass = 1;
         //            }
         //            recInfo.ReaderID = Convert.ToByte(LogPack.Log[j].Reader);
         //            ShowRealData(recInfo, connInfo.MacSN.ToString());
         //            Application.DoEvents();
         //        }
         //    }
         //}
     }
     if (isRealing)
     {
         timer1.Enabled = true;
     }
 }