/// <summary> /// 保存卡片以及嵌套车场进出事件 /// </summary> /// <param name="card"></param> /// <param name="report"></param> /// <returns></returns> public CommandResult SaveCardAndNestedEvent(CardInfo card, CardEventReport report) { //内嵌车场事件只改变卡片的停车状态 IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); CardInfo info = card.Clone(); //卡片状态保持用数据库中的状态 info.ParkingStatus = report.ParkingStatus; if (!report.IsExitEvent) { info.LastNestParkDateTime = report.EventDateTime; //如果是入场事件,则更新卡片的最后进入内车场时间 } _Provider.Update(info, card, unitWork); ICardEventProvider icp = ProviderFactory.Create <ICardEventProvider>(_RepoUri); if (report.IsExitEvent) //如果是入内车场,则不记录最后刷卡时间,如果是出内车场,则保存上次时间 { report.LastDateTime = card.LastNestParkDateTime; } else { report.LastDateTime = null; } icp.Insert((new CardEventRecord(report)), unitWork); CommandResult ret = unitWork.Commit(); if (ret.Result == ResultCode.Successful) //如果成功,则改变卡片状态 { //卡片状态保持用数据库中的状态 card.ParkingStatus = report.ParkingStatus; } return(ret); }
/// <summary> /// 保存卡片与卡片事件信息(用于停车场产生事件时更新卡片状态并保存事件) /// </summary> /// <param name="card"></param> /// <param name="report"></param> /// <returns></returns> public CommandResult SaveCardAndEvent(CardInfo card, CardEventReport report) { IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); if (card.CardType == CardType.Ticket && report.IsExitEvent) ////纸票出场后将其删除 { _Provider.Delete(card, unitWork); } else { CardInfo info = card.Clone(); //卡片状态保持用数据库中的状态 info.ParkingStatus = report.ParkingStatus; info.LastDateTime = report.EventDateTime; info.LastEntrance = report.EntranceID; info.LastCarPlate = report.CarPlate; if (report.LimitationRemain != info.LimitationRemain) { info.LimitationRemain = report.LimitationRemain; info.LimitationTimestamp = report.EventDateTime; } //入口刷卡事件时,将缴费时间,停车费用,累计停车费用清空 if (!report.IsExitEvent) { info.ClearPaidData(); } _Provider.Update(info, card, unitWork); } ICardEventProvider icp = ProviderFactory.Create <ICardEventProvider>(_RepoUri); icp.Insert((new CardEventRecord(report)), unitWork); if (report.IsExitEvent && report.Limitation > 0) //出场事件且有限时停车的记录才要记录到上传表中。 { ECardRecord ecr = new ECardRecord() { SheetID = card.SheetID, Carplate = report.CarPlate, CardID = report.CardID, EventDt = report.EventDateTime, EnterDt = report.LastDateTime, Limitation = report.Limitation, LimitationRemain = report.LimitationRemain }; IECardRecordProvider iecr = ProviderFactory.Create <IECardRecordProvider>(_RepoUri); iecr.Insert(ecr, unitWork); } CommandResult ret = unitWork.Commit(); if (ret.Result == ResultCode.Successful) //如果成功,则改变卡片状态 { //卡片状态保持用数据库中的状态 card.ParkingStatus = report.ParkingStatus; card.LastDateTime = report.EventDateTime; card.LastEntrance = report.EntranceID; card.LastCarPlate = report.CarPlate; card.LimitationRemain = report.LimitationRemain; //入口刷卡事件时,将缴费时间,停车费用,累计停车费用清空 if (!report.IsExitEvent) { card.ClearPaidData(); } } return(ret); }
/// <summary> /// 插入卡片事件 /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult Insert(CardEventRecord info) { return(provider.Insert(info)); }