public static QueryResultList <CardEvent> GetCardEvents(CardEventSearchCondition con) { System.Threading.Thread.Sleep(_Random.Next(1, 5) * 1000); List <CardEvent> ret = new List <CardEvent>(); DateTime dt = DateTime.Now; for (int i = 0; i < 10; i++) { var userid = _Random.Next(1, 300); var doorID = _Random.Next(1, 10); var door = _Doors.Single(it => it.ID == doorID.ToString()); var ce = new CardEvent() { ID = Guid.NewGuid().ToString(), UserID = userid.ToString(), UserName = $"用户{userid}", Department = $"电力部门{Math.Floor((double)userid / 30)}", DoorID = door.ID, DoorName = door.Name, EventTime = dt, Permitted = true, Photo = null, }; ret.Add(ce); } return(new QueryResultList <CardEvent>(ResultCode.Successful, String.Empty, ret)); }
private void UploadCardEvent() { CommandResult result = null; CardEventSearchCondition search = new CardEventSearchCondition(); search.UpdateFlag = false; List <CardEventRecord> sRecords = _StandbyCardEventBll.GetCardEvents(search).QueryObjects; if (sRecords != null && sRecords.Count > 0) { foreach (CardEventRecord sRecord in sRecords) { if (_SyncDataPause) { break; } CardEventRecord ceInfo = sRecord.Clone(); ceInfo.UpdateFlag = true; result = _MasterCardEventBll.InsertRecordWithCheck(ceInfo); if (result.Result == ResultCode.Successful) { sRecord.UpdateFlag = true; _StandbyCardEventBll.Update(sRecord); } } } }
protected override void OnItemSearching(EventArgs e) { this.customDataGridView1.Rows.Clear(); CardEventSearchCondition con = new CardEventSearchCondition(); con.RecordDateTimeRange = new DateTimeRange(); con.RecordDateTimeRange.Begin = this.ucDateTimeInterval1.StartDateTime; con.RecordDateTimeRange.End = this.ucDateTimeInterval1.EndDateTime; con.Source = this.ucEntrance1.SelectedEntrances; if (this.carTypeComboBox1.SelectedIndex >= 0) { con.CarType = this.carTypeComboBox1.SelectedCarType; } CarFlowStatisticsType cType; if (this.rdPerHour.Checked) { cType = CarFlowStatisticsType.perHour; } else if (this.rdPerDay.Checked) { cType = CarFlowStatisticsType.perDay; } else { cType = CarFlowStatisticsType.perMonth; } CarFlowStaticstics(con, cType); }
protected override List <object> GetDataSource() { CardEventSearchCondition con = new CardEventSearchCondition(); con.EventTime = new GeneralLibrary.DateTimeRange(ucDateTimeInterval1.StartDateTime, ucDateTimeInterval1.EndDateTime); var record = new CardEventClient(AppSettings.Current.ConnStr).GetItems(con, true).QueryObjects; if (record != null && record.Count > 0) { return((from it in record orderby it.EventTime descending select(object) it).ToList()); } return(null); }
/// <summary> /// 检查有无该记录,无则插入 /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult InsertRecordWithCheck(CardEventRecord info) { CardEventSearchCondition searchCondition = new CardEventSearchCondition(); searchCondition.CardID = info.CardID; searchCondition.RecordDateTimeRange = new DateTimeRange(info.EventDateTime, info.EventDateTime); List <CardEventRecord> check = provider.GetItems(searchCondition).QueryObjects; if (check == null || check.Count == 0) { return(provider.Insert(info)); } //已存在该记录,可认为插入成功 return(new CommandResult(ResultCode.Successful, string.Empty)); }
private void ItemSearching_Handler(object sender, EventArgs e) { CardEventSearchCondition con = new CardEventSearchCondition(); con.RecordDateTimeRange = new DateTimeRange(); con.RecordDateTimeRange.Begin = this.ucDateTimeInterval1.StartDateTime; con.RecordDateTimeRange.End = this.ucDateTimeInterval1.EndDateTime; con.CardType = this.comCardType.SelectedCardType; con.CardCertificate = this.txtCertificate.Text; if (carTypeComboBox1.SelectedIndex > 0) { con.CarType = this.carTypeComboBox1.SelectedCarType; } con.OwnerName = txtOwnerName.Text; con.CardID = this.txtCardID.Text.Trim(); OperatorInfo opt = this.comOperator.SelectecOperator; if (opt != null) { con.Operator = opt; } con.Source = this.ucEntrance1.SelectedEntrances; con.CarPlate = this.txtCarPlate.Text; con.Department = this.txtDepartment.Text; CardEventBll bll = null; if (this.rdbMaster.Checked) { bll = new CardEventBll(AppSettings.CurrentSetting.ParkConnect); } else { bll = new CardEventBll(AppSettings.CurrentSetting.CurrentStandbyConnect); } QueryResultList <CardEventRecord> result = bll.GetCardEvents(con); if (result.Result == ResultCode.Successful) { ShowReportsOnGrid(result.QueryObjects); } else { MessageBox.Show(result.Message); } }
private void FreshRegion_Thread() { while (true) { try { Thread.Sleep(1000); if (_CurrentRegion == null) { continue; } var con = new CardEventSearchCondition() { EventTime = new DateTimeRange() { Begin = _LastDateTime, End = DateTime.Now } }; List <CardEvent> events = new CardEventClient(AppSettings.Current.ConnStr).GetItems(con, true).QueryObjects; if (events != null && events.Count > 0) { events = (from it in events orderby it.EventTime ascending select it).ToList(); foreach (var item in events) { _CurrentRegion.HandleCardEvent(item); } _LastDateTime = events.Max(it => it.EventTime); } } catch (ThreadAbortException) { break; } catch (Exception) { } } }
/// <summary> /// 生成操作员结算汇总,如果不指定工作站,则表示汇总结果中包括操作员在所有工作站上的收费情况 /// </summary> /// <param name="opt"></param> /// <param name="station"></param> /// <returns></returns> public OperatorSettleLog CreateOperatorLog(OperatorInfo opt, WorkStationInfo station) { if (opt != null) { OperatorSettleLog log = new OperatorSettleLog(); log.OperatorID = opt.OperatorName; log.SettleDateTime = DateTime.Now; if (station != null) { log.StationID = station.StationName; } //查询条件 RecordSearchCondition recordCon = new RecordSearchCondition(); recordCon.RecordDateTimeRange = new DateTimeRange(log.SettleFrom == null ? new DateTime(1753, 1, 1, 12, 0, 0) : log.SettleFrom.Value, log.SettleDateTime); recordCon.Operator = opt; recordCon.IsUnSettled = true; if (station != null) { recordCon.StationID = station.StationName; } //查询收费记录 CardPaymentRecordBll paymentBll = new CardPaymentRecordBll(_RepoUri); List <CardPaymentInfo> paymentRecords = paymentBll.GetItems(recordCon).QueryObjects; log.PaymentRecords = paymentRecords; log.CashParkFact = CashParkFactSum(paymentRecords); log.CashOperatorCard = CashOperatorCardSum(paymentRecords); log.CashParkDiscount = CashParkDiscountSum(paymentRecords); log.NonCashParkFact = NoCashParkFactSum(paymentRecords); log.NonCashParkDiscount = NoCashParkDiscountSum(paymentRecords); //查询卡片发行记录 CardBll cbll = new CardBll(_RepoUri); List <CardReleaseRecord> cardReleaseRecords = cbll.GetCardReleaseRecords(recordCon).QueryObjects; log.ReleaseRecords = cardReleaseRecords; log.CashOfCard += CashCardReleaseSum(cardReleaseRecords); log.CashOfDeposit += CashDepositSum(cardReleaseRecords); log.NonCashOfDeposit += NonCashDepositSum(cardReleaseRecords); log.NonCashOfCard += NonCashCardReleaseSum(cardReleaseRecords); //查询卡片延期记录 List <CardDeferRecord> cardDeferRecords = cbll.GetCardDeferRecords(recordCon).QueryObjects; log.DeferRecords = cardDeferRecords; log.CashOfCard += CashCardDeferSum(cardDeferRecords); log.NonCashOfCard += NonCashCardDeferSum(cardDeferRecords); //查询卡片充值记录 List <CardChargeRecord> cardChargeRecords = cbll.GetCardChargeRecords(recordCon).QueryObjects; log.ChargeRecords = cardChargeRecords; log.CashOfCard += CashCardChargeSum(cardChargeRecords); log.NonCashOfCard += NonCashCardChargeSum(cardChargeRecords); //卡片挂失记录 List <CardLostRestoreRecord> cardLostRecords = cbll.GetCardLostRestoreRecords(recordCon).QueryObjects; log.CardLostRecords = cardLostRecords; log.CashOfCardLost = CashCardLostSum(cardLostRecords); log.NonCashOfCardLost = NonCashCardLostSum(cardLostRecords); //查询卡片回收记录 List <CardRecycleRecord> cardRecycleRecords = cbll.GetCardRecycleRecords(recordCon).QueryObjects; log.RecycleRecords = cardRecycleRecords; log.CashOfCardRecycle += CashCardRecycleSum(cardRecycleRecords); //查询报警记录 AlarmSearchCondition alarmCon = new AlarmSearchCondition(); alarmCon.RecordDateTimeRange = new DateTimeRange(log.SettleFrom == null ? new DateTime(1753, 1, 1, 12, 0, 0) : log.SettleFrom.Value, log.SettleDateTime); alarmCon.Operator = opt; alarmCon.IsUnSettled = true; alarmCon.AlarmType = AlarmType.Opendoor; if (station != null) { alarmCon.StationID = station.StationName; } List <AlarmInfo> alarmReocrds = (new AlarmBll(_RepoUri)).GetAlarms(alarmCon).QueryObjects; log.OpenDoorCount = alarmReocrds.Count; log.AlarmRecords = alarmReocrds; //查询事件 CardEventSearchCondition eventCon = new CardEventSearchCondition(); eventCon.RecordDateTimeRange = new DateTimeRange(log.SettleFrom == null ? new DateTime(1753, 1, 1, 12, 0, 0) : log.SettleFrom.Value, log.SettleDateTime); eventCon.Operator = opt; eventCon.IsUnSettled = true; eventCon.OnlyExitEvent = true; eventCon.CardType = CardType.TempCard; //只获取临时卡事件 if (station != null) { eventCon.StationID = station.StationName; } List <CardEventRecord> handledEvents = (new CardEventBll(_RepoUri)).GetCardEvents(eventCon).QueryObjects; log.EventRecords = handledEvents; log.TempCardRecycle = TempCardRecycleSum(handledEvents); return(log); } else { throw new InvalidOperationException(Resource1.OperatorSettleBLL_noOperator); } }
protected override List <CardEventRecord> GetingItems(ParkDataContext parking, SearchCondition search) { List <CardEventRecord> items = new List <CardEventRecord>(); IQueryable <CardEventRecord> result = parking.CardEvent; if (search is RecordSearchCondition) { RecordSearchCondition condition = search as RecordSearchCondition; if (condition.RecordDateTimeRange != null) { result = result.Where(c => c.EventDateTime >= condition.RecordDateTimeRange.Begin).AsQueryable(); result = result.Where(c => c.EventDateTime <= condition.RecordDateTimeRange.End).AsQueryable(); } if (!string.IsNullOrEmpty(condition.CardID)) { result = result.Where(c => c.CardID == condition.CardID); } if (condition.Operator != null) { result = result.Where(c => c.OperatorID == condition.Operator.OperatorName); } if (!string.IsNullOrEmpty(condition.StationID)) { result = result.Where(c => c.StationID == condition.StationID); } if (!string.IsNullOrEmpty(condition.OwnerName)) { result = result.Where(c => c.OwnerName.Contains(condition.OwnerName)); } if (!string.IsNullOrEmpty(condition.Department)) { result = result.Where(c => c.Department == condition.Department); } if (condition.IsUnSettled != null) { if (condition.IsUnSettled.Value) { result = result.Where(c => c.SettleDateTime == null); } else { result = result.Where(c => c.SettleDateTime != null); } } if (condition.SettleDateTime != null) { result = result.Where(c => c.SettleDateTime == condition.SettleDateTime.Value); } if (condition.CarType != null) { result = result.Where(c => c.CarType == condition.CarType); } if (!string.IsNullOrEmpty(condition.CardCertificate)) { result = result.Where(c => c.CardCertificate.Contains(condition.CardCertificate)); } if (condition.UpdateFlag != null) { result = result.Where(c => c.UpdateFlag == condition.UpdateFlag); } if (search is CardEventSearchCondition) { CardEventSearchCondition s = search as CardEventSearchCondition; if (s.CarType != null) { result = result.Where(item => item.CarType == s.CarType); } if (!string.IsNullOrEmpty(s.CarPlate)) { result = result.Where(c => c.CarPlate.Contains(s.CarPlate)); } if (s.OnlyExitEvent) { result = result.Where(item => item.IsExitEvent == true); } if (s.OnlyEnterEvent) { result = result.Where(item => item.IsExitEvent == false); } } items = result.ToList(); if (condition.CardType != null) { items = items.Where(c => c.CardType == condition.CardType).ToList(); } if (search is CardEventSearchCondition) { CardEventSearchCondition s = search as CardEventSearchCondition; if (s.Source != null && s.Source.Count > 0) { items = (from c in items join e in s.Source on c.EntranceID equals e.EntranceID select c).ToList(); } } } return(items); }
private void FreshRegion_Thread() { while (true) { try { Thread.Sleep(1000); if (_CurrentRegion == null) { continue; } var con = new CardEventSearchCondition() { EventTime = new DateTimeRange() { Begin = _FirstTime ? DateTime.Now.AddDays(-2) : DateTime.Now.AddMinutes(-30), //第一次获取两天之前的记录 End = DateTime.Now.AddMinutes(30) //这里获取事件的时间为当前时间再往前半个小时 } }; _LastCardEvent = null; List <CardEvent> events = new CardEventClient(_Url).GetItems(con, true).QueryObjects; if (events != null && events.Count > 0) { events = (from it in events orderby it.EventTime ascending select it).ToList(); foreach (var item in events) { if (!_CurrentRegion.IsMyDoor(item.DoorID)) { continue; } if (!_LastEvents.Exists(it => it.EventTime == item.EventTime && it.UserID == item.UserID)) { _LastEvents.Add(item); if (!_FirstTime && IsMyDoor(item.DoorName)) { _LastCardEvent = item; } _CurrentRegion.HandleCardEvent(item); } } if (_LastCardEvent != null) { GetPersonDetail(_LastCardEvent.UserID); } } if (_FirstTime) { _FirstTime = false; } _LastEvents.RemoveAll(it => it.EventTime < con.EventTime.Begin); if (_CurrentRegion.PersonChanged) { _CurrentRegion.PersonChanged = false; this.RunOnUiThread(() => FreshRegion()); } } catch (ThreadAbortException) { break; } catch (Exception) { } } }
/// <summary> /// 获取车牌号码所在停车场 /// </summary> /// <param name="carPlate"></param> /// <returns></returns> public QueryResult <ParkInfo> GetParkInfoCarPlate(string carPlate) { QueryResult <ParkInfo> result = new QueryResult <ParkInfo>(ResultCode.Fail, null); //先根据车牌查找卡片 ICardProvider cardProvider = ProviderFactory.Create <ICardProvider>(this._repoUri); CardSearchCondition cardCondition = new CardSearchCondition(); cardCondition.CarPlateOrLast = carPlate; QueryResultList <CardInfo> cardResult = cardProvider.GetItems(cardCondition); if (cardResult.Result == ResultCode.Successful) { CardInfo card = null; if (cardResult.QueryObjects != null && cardResult.QueryObjects.Count > 0) { //查找第一个符合条件的已入场卡片 card = cardResult.QueryObjects.FirstOrDefault(c => c.IsInPark); } if (card == null) { result = new QueryResult <ParkInfo>(ResultCode.NoRecord, null); } else { //根据卡号和入场时间查找入场事件 ICardEventProvider eventProvider = ProviderFactory.Create <ICardEventProvider>(this._repoUri); CardEventSearchCondition eventCondition = new CardEventSearchCondition(); eventCondition.RecordDateTimeRange = new DateTimeRange(card.LastDateTime, card.LastDateTime); eventCondition.CardID = card.CardID; eventCondition.OnlyEnterEvent = true; QueryResultList <CardEventRecord> eventResult = eventProvider.GetItems(eventCondition); if (eventResult.Result == ResultCode.Successful) { CardEventRecord eventRecord = null; if (eventResult.QueryObjects != null && eventResult.QueryObjects.Count > 0) { //查找到多条记录时,取第一条记录 eventRecord = eventResult.QueryObjects[0]; } if (eventRecord == null) { result = new QueryResult <ParkInfo>(ResultCode.NoRecord, null); } else { ParkInfo park = provider.GetByID(eventRecord.ParkID).QueryObject; if (park == null) { result = new QueryResult <ParkInfo>(ResultCode.NoRecord, null); } else { result = new QueryResult <ParkInfo>(ResultCode.Successful, park); } } } } } return(result); }
protected override List <CardEventRecord> GetingItems(ParkDataContext parking, SearchCondition search) { List <CardEventRecord> items = new List <CardEventRecord>(); IQueryable <CardEventRecord> result = parking.CardEvent; if (search is CardEventSearchCondition) { CardEventSearchCondition s = search as CardEventSearchCondition; if (s.RecordDateTimeRange != null) { result = result.Where(c => c.EventDateTime >= s.RecordDateTimeRange.Begin).AsQueryable(); result = result.Where(c => c.EventDateTime <= s.RecordDateTimeRange.End).AsQueryable(); } if (!string.IsNullOrEmpty(s.CardID)) { result = result.Where(c => c.CardID == s.CardID); } if (s.Operator != null) { result = result.Where(c => c.OperatorID == s.Operator.OperatorID); } if (!string.IsNullOrEmpty(s.StationID)) { result = result.Where(c => c.StationID == s.StationID); } if (!string.IsNullOrEmpty(s.CarPlate)) { result = result.Where(c => c.CarPlate.Contains(s.CarPlate)); } if (s.OnlyExitEvent) { result = result.Where(c => c.IsExitEvent == true); } items = result.ToList(); if (s.CardType != null) { items = items.Where(c => c.CardType == s.CardType).ToList(); } if (s.Source != null && s.Source.Count > 0) { items = (from c in items join e in s.Source on c.EntranceID equals e.EntranceID select c).ToList(); } } else if (search is RecordSearchCondition) { RecordSearchCondition s = search as RecordSearchCondition; if (s.RecordDateTimeRange != null) { result = result.Where(c => c.EventDateTime >= s.RecordDateTimeRange.Begin).AsQueryable(); result = result.Where(c => c.EventDateTime <= s.RecordDateTimeRange.End).AsQueryable(); } if (!string.IsNullOrEmpty(s.CardID)) { result = result.Where(c => c.CardID == s.CardID); } if (s.Operator != null) { result = result.Where(c => c.OperatorID == s.Operator.OperatorID); } if (!string.IsNullOrEmpty(s.StationID)) { result = result.Where(c => c.StationID == s.StationID); } items = result.ToList(); if (s.CardType != null) { items = items.Where(c => c.CardType == s.CardType).ToList(); } } return(items); }