Esempio n. 1
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. 2
0
        public void DataReceived(byte[] by)
        {
            PortDataParameter param = DataParsing.Parsing(by);

            if (param.DistanceCardParam == null)
            {
                return;
            }
            if (param.DistanceCardParam.Command == PortEnums.DistanceCommands.WriteACard)
            {
                OverTimeManager.Stop();
                if (IssueInfo == null)
                {
                    return;
                }
                try
                {
                    if (param.DistanceCardParam.AuxiliaryCommand == PortEnums.AuxiliaryCommands.Success)
                    {
                        IssueInfo.Id = CardManager.Insert(IssueInfo);
                    }
                }
                catch (Exception ex)
                {
                    Log4Helper.ErrorInfo(ex.Message, ex);
                }
                finally
                {
                    IssueInfo = null;
                }
            }
        }
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 void DataReceived(int port)
        {
            Thread.Sleep(10);
            int len = SerialPortDevice.GetIqueue;

            if (len <= 0)
            {
                return;
            }
            byte[] by = SerialPortDevice.Read(len);
            try
            {
                by = m_Validation.Combination(by);
                if (by != null && ReceivedManager.ReceivedFunction != null)
                {
                    ReceivedManager.ReceivedFunction.DataReceived(by);
                }
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
            }
            finally
            {
                by = null;
            }
        }
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_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. 7
0
 private static void SerialPortDataReceived(int port)
 {
     Thread.Sleep(10);
     byte[] by;
     try
     {
         int len = m_SerialPort.GetIqueue;
         if (len <= 0)
         {
             by = m_Validation.Combination(m_Bytes.ToArray());
             if (by != null)
             {
                 m_Over = true;
                 m_Bytes.Clear();
             }
             return;
         }
         by = m_SerialPort.Read(len);
         m_Bytes.AddRange(by);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
     }
 }
Esempio n. 8
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. 9
0
 public void DataReceived(byte[] by)
 {
     try
     {
         PortDataParameter param = DataParsing.Parsing(by);
         if (param.DistanceCardParam == null)
         {
             return;
         }
         OverTimeManager.Stop();
         if (param.DistanceCardParam.Command == PortEnums.DistanceCommands.ReadACard)
         {
             if (param.DistanceCardParam.AuxiliaryCommand == PortEnums.AuxiliaryCommands.Success)
             {
                 int state = CardManager.LossLists[0].CardReportLoss;
                 by = DistanceLoss.PersonnelLoseOrRecovery(CardManager.LossLists, state == 1 ? 1 : 2);
                 bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                 if (!ret)
                 {
                     ViewCallFunction.ViewCloseLoading();
                 }
                 else
                 {
                     OverTimeManager.Start();
                 }
             }
             else
             {
                 ViewCallFunction.ViewCloseLoading();
                 ViewCallFunction.ViewMessage("未能获取到挂失卡,请重新操作。", "2");
             }
         }
         else if (param.DistanceCardParam.Command == PortEnums.DistanceCommands.WriteACard)
         {
             if (param.DistanceCardParam.AuxiliaryCommand == PortEnums.AuxiliaryCommands.Success)
             {
                 foreach (CardInfo item in CardManager.LossLists)
                 {
                     item.CardReportLoss = item.CardReportLoss == 1 ? 0 : 1;
                 }
                 CardManager.Update(CardManager.LossLists.ToArray());
                 CardManager.LossLists = null;
                 ViewCallFunction.ViewLoseOver();
             }
             else
             {
                 ViewCallFunction.ViewCloseLoading();
             }
         }
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewCloseLoading();
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 10
0
        public void DataReceived(byte[] by)
        {
            PortDataParameter param = DataParsing.Parsing(by);

            OverTimeManager.Stop();
            try
            {
                if (param.Command.DCommand == PortEnums.DCommands.Default)
                {
                    if (param.DistanceDeviceParam != null && param.DistanceDeviceParam.Command == PortEnums.DistanceCommands.InitializeDevice)
                    {
                        if (param.DistanceDeviceParam.AuxiliaryCommand == PortEnums.AuxiliaryCommands.Success)
                        {
                            if (!EncryptNewDevice)
                            {
                                byte[] bys = PortAgreement.DistanceCardEncryption(NewPwd);
                                SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys);
                                EncryptNewDevice = true;
                                OverTimeManager.Start();
                                return;
                            }
                            else
                            {
                                ViewCallFunction.ViewEncryptMessage("定距卡加密结束。");
                                ViewCallFunction.ViewEncryptOver();
                            }
                        }
                        else
                        {
                            ViewCallFunction.ViewEncryptMessage("定距卡加密失败,请重新操作。");
                            ViewCallFunction.ViewEncryptOver();
                        }
                        EncryptNewDevice = false;
                    }
                    else if (param.DistanceCardParam != null && param.DistanceCardParam.Command == PortEnums.DistanceCommands.ModifyAllCardPwd)
                    {
                        if (param.DistanceCardParam.AuxiliaryCommand == PortEnums.AuxiliaryCommands.Success)
                        {
                            DistanceCardParameter distanceParam = param.DistanceCardParam;
                            string msg = $"定距卡:{distanceParam.CardNumber} 密码(口令)加密{(distanceParam.CardTypeParameter.CardType != PortEnums.CardTypes.PwdError ? "成功" : "失败")}";
                            ViewCallFunction.ViewEncryptMessage(msg);
                        }
                        else
                        {
                            DeviceNewPwd();
                        }
                        OverTimeManager.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewEncryptOver();
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 11
0
        public void DataReceived(byte[] by)
        {
            PortDataParameter param = DataParsing.Parsing(by);

            OverTimeManager.Stop();
            try
            {
                if (param.FunctionAddress == PortEnums.DealFunctions.Ic)
                {
                    if (param.Command.ICommand == PortEnums.ICommands.EntryptIcDevice)
                    {
                        if (param.IcParam.Result)
                        {
                            EncryptNewPwd();
                        }
                        else
                        {
                            ViewCallFunction.ViewEncryptMessage("加密失败,请重新操作。");
                            ViewCallFunction.ViewEncryptOver();
                        }
                    }
                    else if (param.Command.ICommand == PortEnums.ICommands.EntryptIcCard)
                    {
                        if (param.IcParam != null)
                        {
                            string msg = $"IC 卡加密{(param.IcParam.Result ? "成功" : "失败")}";
                            ViewCallFunction.ViewEncryptMessage(msg);

                            Task.Factory.StartNew(() =>
                            {
                                for (int i = 0; i < 150; i++)
                                {
                                    Thread.Sleep(10);
                                    if (StopEncrypt)
                                    {
                                        StopEncrypt = false;
                                        OverEncrypt();
                                        return;
                                    }
                                }
                                EncryptNewPwd();
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Esempio n. 12
0
 private static void Host_PostStopReadIcCard(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         byte[] by = PortAgreement.CloseModular();
         SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 13
0
 private static void Host_PostDelAllData(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         bool ret = CardManager.Delete();
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 14
0
 private static void Host_PostDelNumberInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int index = e.Arguments[0].IntValue;
         LimitManager.Del(index);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 15
0
 private static void Host_PostConfirmInfoCount(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int count = ConfirmManager.GetCount();
         e.SetReturnValue(count);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 16
0
 private static void Host_PostHostType(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int      index = e.Arguments[0].IntValue;
         CardInfo info  = CardManager.CardInfos[index];
         e.SetReturnValue(info.CardType);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 17
0
 private static void Host_PostDrives(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         DriveInfo[] drives = DriveInfo.GetDrives();
         string      json   = Utility.JsonSerializerByArrayData(drives);
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 18
0
 private static void Host_PostClientInfoCount(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string strWhere = e.Arguments[0].StringValue;
         int    count    = UserManager.GetCount(strWhere);
         e.SetReturnValue(count);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 19
0
 private void OverEncrypt()
 {
     try
     {
         byte[] by = PortAgreement.IcDeviceEncryption(Pwd);
         SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
         ReceivedManager.SetReceivedFunction <IcDeviceEncrypt>();
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 20
0
 private static void ReplaceSerialPort(IDevice device)
 {
     try
     {
         m_SerialPort.DataReceived -= SerialPortDataReceived;
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
     }
     SerialPortManager.CompleteSerialPortConnection(m_SerialPort, device);
     m_SerialPort = null;
     m_Validation.Dispose();
 }
Esempio n. 21
0
 private static void Host_PostLimitNumberInfos(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         List <NumberLimit> infos = LimitManager.GetInfos();
         string             json  = Utility.JsonSerializerByArrayData(infos.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 22
0
 private static void Host_PostDelConfirmInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int        index = e.Arguments[0].IntValue;
         DeviceInfo info  = ConfirmManager.ConfirmInfos[index];
         ConfirmManager.Del(info.Did);
         ConfirmManager.ConfirmInfos.RemoveAt(index);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 23
0
 private static void Host_PostConfirmInfos(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int page = e.Arguments[0].IntValue;
         List <DeviceInfo> infos = ConfirmManager.GetInfos(page - 1, DefaultParams.PAGE_ROW_COUNT);
         string            json  = Utility.JsonSerializerByArrayData(infos.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 24
0
 private static void Host_PostConfirmAdd(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string     json = e.Arguments[0].StringValue;
         DeviceInfo info = ConfirmManager.Add(json);
         // json = Utility.JsonSerializerBySingleData(info);
         // e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 25
0
 private static void Host_PostViceCardList(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int             index     = e.Arguments[0].IntValue;
         List <CardInfo> viceCards = CardManager.GetViceCards(index);
         string          json      = Utility.JsonSerializerByArrayData(viceCards.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 26
0
 private static void Host_PostAddNumberInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string strNumber = e.Arguments[0].StringValue;
         int    number    = Utility.StrToInt(strNumber);
         bool   ret       = LimitManager.Add(number);
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 27
0
 private static void Host_PostLimitNumberInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int         index = e.Arguments[0].IntValue;
         NumberLimit info  = LimitManager.NumberInfos[index];
         string      json  = Utility.JsonSerializerBySingleData(info);
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 28
0
 private static void Host_PostAddUserInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string json = e.Arguments[0].StringValue;
         UserManager.Add(json);
         json = Utility.JsonSerializerByArrayData(UserManager.UserInfos.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 29
0
 private static void Host_PostStopIcCardEncrypt(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         ISerialPortDataReceived dataReceived = ReceivedManager.ReceivedFunction;
         if (dataReceived is IcCardEncrypt)
         {
             ((IcCardEncrypt)dataReceived).StopEncrypt = true;
         }
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Esempio n. 30
0
 private static void Host_PostUpdateUserInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string   json  = e.Arguments[0].StringValue;
         int      index = e.Arguments[1].IntValue;
         UserInfo info  = UserManager.Update(json, index);
         json = Utility.JsonSerializerBySingleData(info);
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }