Exemple #1
0
        public string QueryTheNumberOfAlreadyRegisteredUsers()
        {
            try
            {
                if (!checkCardReader("QueryTheNumberOfAlreadyRegisteredUsers"))
                {
                    return("99,99");
                }

                EventLog.Write("{0}-{1}", "QueryTheNumberOfAlreadyRegisteredUsers", "Start");

                var re = new SemacV14.Request.CommonRequest(TerminalID, Define.CommandType.QueryTheNumberOfAlreadyRegisteredUsers);
                var Ea = new SemacV14.Service.ExecuteArgz(ChannelID, re);

                //Execute
                SemacV14.Service.Actor Wrk = new Actor(Ea);
                Ea = Wrk.SendAndReceive(); //  'Send command,and return result

                // check the result
                if (Ea.IsCompleted == true)
                {
                    EventLog.Write("{0}-{1}", "QueryTheNumberOfAlreadyRegisteredUsers", "Success");

                    //Msg = String.Format("筆數:{0},TerminalID={1}, ChannelID={2}", Ea.EntityList.Count.ToString(), TerminalID, ChannelID);
                    //EventLog.Write("{0}-{1}", "QueryTheNumberOfAlreadyRegisteredUsers", Msg);

                    SemacV14.Entity.QueryTheNumberOfAlreadyRegisteredUsersEntity En = (SemacV14.Entity.QueryTheNumberOfAlreadyRegisteredUsersEntity)Ea.CallbackEntity;

                    BO.UpdateCardReaderUserCount(TerminalID.ToString(), En.RegisteredCount.ToString());

                    return("1," + En.RegisteredCount.ToString());
                }
                else
                {
                    EventLog.Write("{0}-{1}", "QueryTheNumberOfAlreadyRegisteredUsers", "Failure");
                    Msg = String.Format("ErrorMsg:{0},TerminalID={1}, ChannelID={2}", Ea.ErrorMessage, TerminalID, ChannelID);
                    EventLog.Write("{0}-{1}", "QueryTheNumberOfAlreadyRegisteredUsers", Msg);
                    return("0," + Ea.ErrorMessage);
                }
                //SemacV14.Service.Actor act = new Actor(Ea);

                //act.OnEntityDataArrival += HandleEntity;
                //act.Send();

                //return true;
            }
            catch (Exception ex)
            {
                Msg = String.Format("ErrorMsg:{0},TerminalID={1}, ChannelID={2}", ex.Message, TerminalID, ChannelID);
                EventLog.WriteError("{0}-{1}", "QueryTheNumberOfAlreadyRegisteredUsers", Msg);
                return("99,99");
            }
        }
Exemple #2
0
        /// <summary>
        /// 取得卡機內 UserID List
        /// </summary>
        /// <returns></returns>
        private int RetrievingUserIDList()
        {
            try
            {
                if (!checkCardReader("RetrievingUserIDList"))
                {
                    return(99);
                }

                var re = new SemacV14.Request.CommonRequest(TerminalID, Define.CommandType.RetrievingUserIDList);
                var Ea = new SemacV14.Service.ExecuteArgz(ChannelID, re);

                //Execute
                SemacV14.Service.Actor Wrk = new Actor(Ea);
                Wrk.TimeoutMinisecond = 10 * 60 * 1000; //those cmd may need more time,but in default , timeout checking was 10 seconds.
                Ea = Wrk.SendAndReceive();              //  'Send command,and return result

                // check the result
                if (Ea.IsCompleted == true)
                {
                    EventLog.Write("{0}-{1}", "RetrievingUserIDList", "Success");
                    SemacV14.Entity.RetrievingUserIDListEntity En = (SemacV14.Entity.RetrievingUserIDListEntity)Ea.CallbackEntity;

                    BO.insertCheckUserLog(TerminalID.ToString(), En.Count.ToString());
                    string SEQ = BO.getCheckUserLogSEQ(TerminalID.ToString());

                    int iCount = 0;
                    foreach (uint Item in En.Items)
                    {
                        iCount++;
                        Console.WriteLine(iCount.ToString() + "-" + String.Format("{0:X}", Convert.ToInt64(Item.ToString())));
                        BO.insertCheckUserList(TerminalID.ToString(), String.Format("{0:X}", Convert.ToInt64(Item.ToString())));
                        BO.insertCheckUserListTemp(SEQ, TerminalID.ToString(), String.Format("{0:X}", Convert.ToInt64(Item.ToString())));
                    }
                    return(1);
                }
                else
                {
                    EventLog.WriteCU("{0}-{1}", "RetrievingUserIDList.Ea.IsCompleted=false", "失敗:" + Ea.ErrorMessage.ToString());
                    //EventLog.Write("{0}-{1}", "RetrievingUserIDList", "Failure");
                    return(0);
                }
            }
            catch (Exception ex)
            {
                Msg = String.Format("ErrorMsg:{0},TerminalID={1}, ChannelID={2}", ex.Message, TerminalID, ChannelID);
                EventLog.WriteCU("{0}-{1}", "RetrievingUserIDList", Msg);
                return(99);
            }
        }
Exemple #3
0
        //private void SyncUser()
        //{
        //    DataTable dt = BO.getPersonCard();
        //    DataTable dtSyncCardReaderUserLog = BO.getSyncCardReaderUserLog();

        //    foreach (DataRow drT in TerminalTable.Rows)
        //    {
        //        ChannelID = drT["ChannelID"].ToString();
        //        TerminalID = Convert.ToInt32(drT["TerminalID"].ToString());
        //        MacAddress = drT["MacAddress"].ToString();

        //        //判斷今天是否已同步完成 0:未, 1:完成
        //        int iYN = 0;
        //        foreach (DataRow drCRUL in dtSyncCardReaderUserLog.Rows)
        //        {
        //            if (TerminalID.ToString().Equals(drCRUL["TerminalID"].ToString()))
        //            {
        //                Msg = String.Format("今日已同步【白名單】,TerminalID={0}, MacAddress={1}", TerminalID, MacAddress);
        //                EventLog.Write("{0}-{1}", "SyncUser", Msg);
        //                iYN = 1;
        //            }
        //        }

        //        if (iYN == 0)
        //        {
        //            Msg = String.Format("DeleteAllUser,TerminalID={0}, MacAddress={1}", TerminalID, MacAddress);
        //            EventLog.Write("{0}-{1}", "SyncUser", Msg);
        //            DeleteAllUser();
        //            System.Threading.Thread.Sleep(1000 * 10);
        //            Msg = String.Format("AddUser-Start,TerminalID={0}, MacAddress={1}", TerminalID, MacAddress);
        //            EventLog.Write("{0}-{1}", "SyncUser", Msg);
        //            int iCount = 0;
        //            foreach (DataRow dr in dt.Rows)
        //            {
        //                try {
        //                    User user = new User
        //                    {
        //                        //UserID = Convert.ToUInt32(dr["Uid"].ToString()),
        //                        UserID = UInt32.Parse(dr["HexCardOrderNo"].ToString(), System.Globalization.NumberStyles.HexNumber),
        //                        EmployeeID = UInt32.Parse(dr["HexCardOrderNo"].ToString(), System.Globalization.NumberStyles.HexNumber).ToString(),
        //                        OverWrite = true,
        //                        CardNo = UInt32.Parse(dr["HexCardOrderNo"].ToString(), System.Globalization.NumberStyles.HexNumber).ToString(),
        //                        UserName = dr["Cn"].ToString(),
        //                        CheckExpire = true,
        //                        ExpiredFrom = Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss")),
        //                        ExpiredTo = Convert.ToDateTime(DateTime.Now.AddDays(30).ToString("yyyy/MM/dd HH:mm:ss")),
        //                        EnabledStatus = true,//!entry.Black && entry.ExpireOn.Value >= DateTime.Now,
        //                        UserType = 0,
        //                        Group01 = 1,
        //                        Group02 = 0,
        //                        Group03 = 0,
        //                        Group04 = 0,
        //                        BypassTimeZoneLevel = 1,
        //                        PersonalPassword = ""
        //                    };

        //                    if (GetOneUser(user.UserID) == 0)
        //                    {
        //                        if (!AddUser(user))
        //                            iCount++;
        //                        else if (!AddUser(user))
        //                            iCount++;
        //                        else if (!AddUser(user))
        //                            iCount++;
        //                        else if (!AddUser(user))
        //                            iCount++;
        //                    }
        //                    else
        //                        iCount++;

        //                    System.Threading.Thread.Sleep(500);
        //                }
        //                catch (Exception ex) {
        //                    iCount++;
        //                    EventLog.WriteError("{0}-{1}", "SyncUser", ex.ToString()); }
        //            }
        //            Msg = String.Format("已同步【白名單】,人員筆數:{0},成功筆數:{1},失敗筆數:{2},TerminalID={3}, MacAddress={4}"
        //                , dt.Rows.Count.ToString(), (dt.Rows.Count - iCount).ToString(), iCount.ToString(), TerminalID, MacAddress);
        //            EventLog.Write("{0}-{1}", "SyncUser", Msg);
        //            BO.insertSyncUserLog(TerminalID.ToString(), Msg);
        //            if (iCount == 0)
        //            {
        //                BO.insertSyncCardReaderUserLog(TerminalID.ToString());

        //                //查詢卡機人員筆數
        //                QueryTheNumberOfAlreadyRegisteredUsers();
        //            }
        //        }
        //    }

        //    //查檢今日是否都已同步完成
        //    dtSyncCardReaderUserLog = BO.getSyncCardReaderUserLog();
        //    foreach (DataRow drT in TerminalTable.Rows)
        //    {
        //        ChannelID = drT["ChannelID"].ToString();
        //        TerminalID = Convert.ToInt32(drT["TerminalID"].ToString());
        //        MacAddress = drT["MacAddress"].ToString();

        //        //判斷今天是否已同步完成 0:未, 1:完成
        //        foreach (DataRow drCRUL in dtSyncCardReaderUserLog.Rows)
        //        {
        //            if (TerminalID.ToString().Equals(drCRUL["TerminalID"].ToString()))
        //                _timer.Enabled = false;
        //        }
        //    }
        //}

        #region 卡機指令

        public string DeleteAllUser()
        {
            try
            {
                if (!checkCardReader("DeleteAllUser"))
                {
                    return("99,99");
                }

                EventLog.Write("{0}-{1}", "DeleteAllUser", "Start");

                var re = new SemacV14.Request.CommonRequest(TerminalID, Define.CommandType.AllUsersDeletion);
                var Ea = new SemacV14.Service.ExecuteArgz(ChannelID, re);

                //Execute
                SemacV14.Service.Actor Wrk = new Actor(Ea);
                Ea = Wrk.SendAndReceive(); //  'Send command,and return result

                // check the result
                if (Ea.IsCompleted == true)
                {
                    EventLog.Write("{0}-{1}", "DeleteAllUser", "Success");
                    return("1,1");
                }
                else
                {
                    EventLog.Write("{0}-{1}", "DeleteAllUser", "Fialure");
                    return("0," + Ea.ErrorMessage);
                }
                //SemacV14.Service.Actor act = new Actor(Ea);

                //act.OnEntityDataArrival += HandleEntity;
                //act.Send();

                //return true;
            }
            catch (Exception ex)
            {
                Msg = String.Format("刪除所有使用者發生錯誤:{0},TerminalID={1}, ChannelID={2}"
                                    , ex.Message, TerminalID, ChannelID);
                EventLog.WriteError("{0}-{1}", "DeleteAllUser", Msg);
                return("99,99");
            }
        }
Exemple #4
0
        /// <summary>刪除已接收過的讀卡紀錄</summary>
        public string DeletingAllEntryExitLog()
        {
            try
            {
                if (!checkCardReader("DeletingAllEntryExitLog"))
                {
                    return("99,99");
                }

                EventLog.Write("{0}-{1}", "DeletingAllEntryExitLog", "Start");

                var re = new SemacV14.Request.CommonRequest(TerminalID, Define.CommandType.DeletingAllEntryExitLog);
                var Ea = new SemacV14.Service.ExecuteArgz(ChannelID, re);

                //Execute
                SemacV14.Service.Actor Wrk = new Actor(Ea);
                Ea = Wrk.SendAndReceive(); //  'Send command,and return result

                // check the result
                if (Ea.IsCompleted == true)
                {
                    EventLog.Write("{0}-{1}", "DeletingAllEntryExitLog", "Success");

                    return("1,1");
                }
                else
                {
                    EventLog.Write("{0}-{1}", "DeletingAllEntryExitLog", "Failure");
                    Msg = String.Format("ErrorMsg:{0},TerminalID={1}, ChannelID={2}", Ea.ErrorMessage, TerminalID, ChannelID);
                    EventLog.Write("{0}-{1}", "DeletingAllEntryExitLog", Msg);
                    return("0," + Ea.ErrorMessage);
                }
            }
            catch (Exception ex)
            {
                Msg = String.Format("ErrorMsg:{0},TerminalID={1}, ChannelID={2}", ex.Message, TerminalID, ChannelID);
                EventLog.WriteError("{0}-{1}", "DeletingAllEntryExitLog", Msg);
                return("99,99");
            }
        }