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); } }
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); } }); }
private static void Host_PostStartIcCardEncrypt(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { string oldpwd = e.Arguments[0].StringValue; string pwd = e.Arguments[1].StringValue; byte[] bys = PortAgreement.IcDeviceEncryption(oldpwd); SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys); ReceivedManager.SetReceivedFunction <IcCardEncrypt>(); IcCardEncrypt received = ReceivedManager.GetReceivedFun <IcCardEncrypt>(); received.Pwd = pwd; } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }
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); } }
private static SettingModule SettingReceived() { ReceivedManager.SetReceivedFunction <SettingModule>(); return(ReceivedManager.GetReceivedFun <SettingModule>()); }
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); } }
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); } }