Esempio n. 1
0
 private static void Host_PostWirelessTest(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         ReceivedManager.SetReceivedFunction <WirelessTest>();
         byte[] by = PortAgreement.OpenTheDoorAndVoice(new OpenTheDoorParam2()
         {
             DeviceAddress      = 0,
             IcCardNumber       = "093D2446",
             LicensePlateNumber = "福A000000",
             LicensePlateColor  = LicensePlateColors.Blue,
             Time = DateTime.Now,
         });
         SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
     finally
     {
         OverTimeManager.Stop();
     }
 }
Esempio n. 2
0
        private static void Host_PostPersonnelIssue(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                int index = e.Arguments[0].IntValue;
                Chromium.Remote.CfrTime cTime = e.Arguments[1].DateValue;
                DateTime time       = new DateTime(cTime.Year, cTime.Month, cTime.DayOfMonth);
                int      partition  = e.Arguments[2].IntValue;
                int      dataType   = e.Arguments[3].IntValue;
                string   customData = e.Arguments[4].StringValue;

                CardInfo info = CardManager.CardInfos[index];
                info.CardTime      = time;
                info.CardPartition = partition;

                byte[] by = PersonnelIssue.Issue(info, dataType, customData);

                bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <CardIssuePersonnel>();
                    ReceivedManager.GetReceivedFun <CardIssuePersonnel>().IssueInfo = info;
                }
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 3
0
        private static void Host_PostTestPort(object sender, CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                if (SerialPortManager.Device2.SerialPortDevice.BaudRate != WinApi.B38400)
                {
                    SerialPortManager.Device2.SerialPortDevice.SetBaudRate(WinApi.B38400);
                    Thread.Sleep(10);
                }

                byte[] by  = PortAgreement.TestPort(SerialPortManager.Device2Address);
                bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, by);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <TestPort>();
                }
                e.SetReturnValue(ret);
            }
            catch (Exception ex)
            {
                SerialPortManager.Device2.SerialPortDevice.SetBaudRate(WinApi.B19200);

                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 4
0
        private static void Host_PostBatch(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            UpdateBatchParam(e);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    int index = -1;
                    CardBatch batchReceived = null;
                    foreach (CardInfo item in CardManager.CardInfos)
                    {
                        if (item.Id == 0 && item.CardType < 3)
                        {
                            index += 1;

                            item.CardTime            = CardManager.BatchParam.CardTime;
                            item.CardDistance        = CardManager.BatchParam.CardDistance;
                            item.ParkingRestrictions = CardManager.BatchParam.ParkingRestrictions;
                            item.CardPartition       = CardManager.BatchParam.CardPartition;

                            byte[] by = DistanceIssue.Issue(item);
                            bool ret  = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                            if (ret)
                            {
                                ReceivedManager.SetReceivedFunction <CardBatch>();
                                if (batchReceived == null)
                                {
                                    batchReceived = ReceivedManager.GetReceivedFun <CardBatch>();
                                }
                                batchReceived.IssueInfo = item;

                                for (int i = 0; i < 250; i++)
                                {
                                    Thread.Sleep(10);
                                    if (batchReceived.IssueInfo == null)
                                    {
                                        if (item.Id > 0)
                                        {
                                            ViewCallFunction.ViewDisplayBatchContent(item, index);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log4Helper.ErrorInfo(ex.Message, ex);
                    ViewCallFunction.ViewAlert(ex.Message);
                }
                finally
                {
                    int count = CardManager.CardInfos.Where(w => w.Id == 0 && w.CardType < 3).Count();
                    ViewCallFunction.ViewBatchOver(count);
                }
            });
        }
Esempio n. 5
0
 private static void Host_RefreshOperation(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     //刷新操作
     CardManager.CardInfos.Clear();
     byte[] bys;
     try
     {
         bys = PortAgreement.ReadAllCard();
         bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys);
         if (ret)
         {
             ReceivedManager.SetReceivedFunction <CardRefresh>();
         }
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
     finally
     {
         bys = null;
     }
 }
Esempio n. 6
0
        private static void Host_PostIcDeviceEncrypt(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                string pwd = e.Arguments[0].StringValue;

                byte[] bys = PortAgreement.IcDeviceEncryption(pwd);
                SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys);

                ReceivedManager.SetReceivedFunction <IcDeviceEncrypt>();
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 7
0
 private static void Host_PostDownloadTime(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         byte[] bys = PortAgreement.SetPersonnelHostTime();
         bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, bys);
         if (ret)
         {
             ReceivedManager.SetReceivedFunction <TimeDownload>();
         }
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 8
0
        private static void Host_PostReadIcCard(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                byte[] by = PortAgreement.ReadIc();
                SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);

                ReceivedManager.SetReceivedFunction <ReadIcCard>();
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
            finally
            {
                OverTimeManager.Stop();
            }
        }
Esempio n. 9
0
        private static void Host_PostDownloadNumber(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                int      index = e.Arguments[0].IntValue;
                UserInfo info  = UserManager.UserInfos[index];

                byte[] bys = PortAgreement.SetPersonnelHostNumber(info.UserNumber);
                bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, bys);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <NumberDownload>();
                }
                e.SetReturnValue(ret);
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 10
0
        private static void Host_PostDownloadPassword(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                string oldpwd = e.Arguments[0].StringValue;
                string newpwd = e.Arguments[1].StringValue;

                byte[] by  = PortAgreement.SetPersonnelHostPassword(oldpwd, newpwd);
                bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, by);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <PasswordDownload>();
                }
                e.SetReturnValue(ret);
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 11
0
 private static void Host_PostPersonnelRecovery(object sender, CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string          loseCardNumber = GetLoseNumber(e);
         List <CardInfo> list           = CardManager.GetCardInfos(loseCardNumber);
         CardManager.LossLists = list;
         byte[] by  = PortAgreement.ReadACard("797979", 1);
         bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
         if (ret)
         {
             ReceivedManager.SetReceivedFunction <PersonnelCardLoss>();
         }
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 12
0
        private static void Host_PostDistanceCardEncrypt(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                string oldpwd       = e.Arguments[0].StringValue;
                string pwd          = e.Arguments[1].StringValue;
                string clientnumber = e.Arguments[2].StringValue;

                byte[] bys = PortAgreement.DistanceDeviceEncryption(clientnumber, oldpwd);
                bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <DistanceCardEncrypt>();
                    DistanceCardEncrypt received = ReceivedManager.GetReceivedFun <DistanceCardEncrypt>();
                    received.ClientNumber = clientnumber;
                    received.NewPwd       = pwd;
                }
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 13
0
 private static SettingModule SettingReceived()
 {
     ReceivedManager.SetReceivedFunction <SettingModule>();
     return(ReceivedManager.GetReceivedFun <SettingModule>());
 }
Esempio n. 14
0
        private static void Host_PostWirelessQuery(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    ReceivedManager.SetReceivedFunction <WirelessQuery>();
                    WirelessQuery queryReceived = ReceivedManager.GetReceivedFun <WirelessQuery>();
                    try
                    {
                        ViewCallFunction.ViewWirelessMessage("打开模块设置功能。");
                        byte[] by = PortAgreement.OpenModular();
                        SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                        Thread.Sleep(20);

                        for (int i = 0; i < 3; i++)
                        {
                            queryReceived.SettingOver = false;
                            ViewCallFunction.ViewWirelessMessage("关闭模块回传功能。");
                            by = PortAgreement.SetModuleComesBack(0);
                            SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                            Thread.Sleep(250);
                            if (queryReceived.SettingOver)
                            {
                                break;
                            }
                        }

                        ViewCallFunction.ViewWirelessMessage("关闭模块设置功能。");
                        by = PortAgreement.CloseModular();
                        SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                        Thread.Sleep(20);

                        ViewCallFunction.ViewWirelessMessage("查询无线ID(编号)。");
                        string strQueryFrequency = "AT+FREQ?";
                        by = PortAgreement.SetModular(strQueryFrequency);
                        SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                        Thread.Sleep(250);

                        ViewCallFunction.ViewWirelessMessage("查询无线的频率。");
                        string strQueryRid = "AT+TID?";
                        by = PortAgreement.SetModular(strQueryRid);
                        SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                        Thread.Sleep(250);
                    }
                    catch (Exception ex)
                    {
                        Log4Helper.ErrorInfo(ex.Message, ex);
                        ViewCallFunction.ViewAlert(ex.Message);
                    }
                    finally
                    {
                        OverTimeManager.Stop();
                        ViewCallFunction.ViewWirelessOver();
                    }
                });
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 15
0
        private static void Host_PostIssue(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                int index = e.Arguments[0].IntValue;
                Chromium.Remote.CfrTime cTime = e.Arguments[1].DateValue;
                DateTime time      = new DateTime(cTime.Year, cTime.Month, cTime.DayOfMonth);
                int      distance  = e.Arguments[2].IntValue;
                int      limit     = e.Arguments[3].IntValue;
                int      type      = e.Arguments[4].IntValue;
                int      partition = e.Arguments[5].IntValue;

                CardInfo info = CardManager.CardInfos[index];
                info.CardType            = type;
                info.CardDistance        = distance;
                info.CardTime            = time;
                info.ParkingRestrictions = limit;
                info.CardPartition       = partition;
                info.CardCount           = DistanceIssue.SetCount(info.CardCount);

                byte[] by;
                if (info.CardType == (int)PortEnums.CardTypes.Card2 && (info.ViceCardInfos != null && info.ViceCardInfos.Count > 0))
                {
                    info.CardTime = info.ViceCardInfos.Max(w => w.CardTime);

                    ViceCardRemoveLock lockReceived = null;
                    foreach (CardInfo item in info.ViceCardInfos)
                    {
                        if (item.CardLock == 1)
                        {
                            by = DistanceIssue.Issue(item);
                            SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);

                            ReceivedManager.SetReceivedFunction <ViceCardRemoveLock>();
                            if (lockReceived == null)
                            {
                                lockReceived = ReceivedManager.GetReceivedFun <ViceCardRemoveLock>();
                            }
                            lockReceived.RemoveLockInfo = item;

                            for (int i = 0; i < 250; i++)
                            {
                                Thread.Sleep(10);
                                if (lockReceived.RemoveLockInfo == null)
                                {
                                    if (item.CardLock == 0)
                                    {
                                        ViewCallFunction.ViewRemoveLock(info.ViceCardInfos);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }

                by = DistanceIssue.Issue(info);
                bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <CardIssue>();
                    ReceivedManager.GetReceivedFun <CardIssue>().IssueInfo = info;
                }
                e.SetReturnValue(ret);
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }