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); } }
private static void Host_PostUpdateViceCardInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e) { try { int index = e.Arguments[0].IntValue; int viceIndex = e.Arguments[1].IntValue; string strNumber = e.Arguments[2].StringValue; int type = e.Arguments[3].IntValue; Chromium.Remote.CfrTime cTime = e.Arguments[4].DateValue; DateTime time = new DateTime(cTime.Year, cTime.Month, cTime.DayOfMonth); int partition = e.Arguments[5].IntValue; CardInfo info = CardManager.CardInfos[index]; if (viceIndex > -1) { CardInfo viceInfo = info.ViceCardInfos[viceIndex]; viceInfo.CardNumber = strNumber; viceInfo.CardTime = time; viceInfo.CardPartition = partition; viceInfo.CardCount = DistanceIssue.SetCount(viceInfo.CardCount); CardManager.Update(viceInfo); } else { if (info.ViceCardInfos == null) { info.ViceCardInfos = new List <CardInfo>(); } List <BundledInfo> bundledInfos = new List <BundledInfo>(); string[] strNumbers = strNumber.Split(','); if (type == (int)PortEnums.CardTypes.Card2)//车卡 { List <CardInfo> viceInfos = CardManager.CardInfos.Where(c => c.Id == 0 && c.CardType == (int)PortEnums.CardTypes.Card4).ToList(); if (viceInfos.Count > 0) { foreach (CardInfo item in viceInfos) { foreach (string number in strNumbers) { if (item.CardNumber != number) { continue; } item.CardTime = time; item.CardPartition = partition; item.CardCount = DistanceIssue.SetCount(item.CardCount); item.Id = CardManager.Insert(item); info.ViceCardInfos.Add(item); bundledInfos.Add(new BundledInfo() { //Cid = info.Id, HostCardNumber = info.CardNumber, Vid = item.Id, ViceCardNumber = item.CardNumber }); break; } } } viceInfos = CardManager.GetViceCards(strNumbers); if (viceInfos.Count > 0) { foreach (CardInfo item in viceInfos) { item.CardTime = time; item.CardPartition = partition; item.CardCount = DistanceIssue.SetCount(item.CardCount); bundledInfos.Add(new BundledInfo() { //Cid = info.Id, HostCardNumber = info.CardNumber, Vid = item.Id, ViceCardNumber = item.CardNumber }); } info.ViceCardInfos.AddRange(viceInfos); CardManager.Update(viceInfos.ToArray()); } } else if (type == (int)PortEnums.CardTypes.Card3)//车牌号码 { CardInfo licensePlateInfo = CardManager.GetLicensePlateInfo(strNumber); if (licensePlateInfo != null) { licensePlateInfo.CardTime = time; licensePlateInfo.CardPartition = partition; CardManager.Update(licensePlateInfo); } else { licensePlateInfo = new CardInfo() { CardNumber = strNumber, CardTime = time, CardPartition = partition, CardType = -1, }; licensePlateInfo.Id = CardManager.Insert(licensePlateInfo); } info.ViceCardInfos.Add(licensePlateInfo); bundledInfos.Add(new BundledInfo() { //Cid = info.Id, HostCardNumber = info.CardNumber, Vid = licensePlateInfo.Id, ViceCardNumber = licensePlateInfo.CardNumber, }); } if (bundledInfos.Count > 0) { BundledInfoManager.Insert(bundledInfos.ToArray()); } } string json = Utility.JsonSerializerByArrayData(info.ViceCardInfos.ToArray()); e.SetReturnValue(json); } catch (Exception ex) { Log4Helper.ErrorInfo(ex.Message, ex); ViewCallFunction.ViewAlert(ex.Message); } }