private List <CardPaymentInfo> GetCardPaymentRecordsFromDeviceRecords(List <DevicePaymentRecord> deviceRecords, string entranceName) { if (deviceRecords != null) { List <CardPaymentInfo> records = new List <CardPaymentInfo>(); CardInfo card = null; CardInfo operatorCard = null; foreach (DevicePaymentRecord deviceRecord in deviceRecords) { CardPaymentInfo record = new CardPaymentInfo(); record.PaymentCode = deviceRecord.PaymentCode == DevicePaymentCode.Computer ? PaymentCode.Computer : PaymentCode.FunctionCard; record.ChargeDateTime = deviceRecord.PaymentDateTime; record.CardID = deviceRecord.CardID; record.Accounts = deviceRecord.Amount; record.Paid = deviceRecord.Amount; record.OperatorCardID = deviceRecord.FunctionCardID; record.StationID = entranceName; //缴费卡片相关信息 CardBll _CardBll = new CardBll(AppSettings.CurrentSetting.ParkConnect); if (card == null || card.CardID != record.CardID) { card = _CardBll.GetCardByID(record.CardID).QueryObject; } if (card != null) { record.OwnerName = card.OwnerName; record.CarPlate = card.CarPlate; record.CardType = card.CardType; record.CarType = card.CarType; } //收费功能卡相关信息 if (operatorCard == null || operatorCard.CardID != record.OperatorCardID) { operatorCard = _CardBll.GetCardByID(record.OperatorCardID).QueryObject; } if (operatorCard != null) { record.OperatorID = operatorCard.OwnerName; OperatorSettleBLL osbll = new OperatorSettleBLL(AppSettings.CurrentSetting.ParkConnect); //查找与收费时间最近的结算时间为记录结算时间,如没有找到,则该记录还没结算 record.SettleDateTime = osbll.GetRecentSettleDateTime(operatorCard.OwnerName, deviceRecord.PaymentDateTime); } record.Memo = string.Format("上传时间:{0} ;硬件记录索引:{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), deviceRecord.RecordIndex); records.Add(record); } return(records); } return(null); }
private void ExecuteWaitingCommand_Thread() { CardBll cb = new CardBll(AppSettings.CurrentSetting.ParkConnect); WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); while (true) { List <WaitingCommandInfo> wcs = wb.GetCommands(this.ParkID).QueryObjects; foreach (var wc in wcs) { CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; if (card != null) { if (SaveCard(card, ActionType.Upate)) { wb.Delete(wc); } } else { wb.Delete(wc); } } Thread.Sleep(60000); } }
private void txtCardID_TextChanged(object sender, EventArgs e) { string cardID = this.txtCardID.Text.Trim(); #region 如果扫描枪使用模拟键盘输入 if (AppSettings.CurrentSetting.TicketReaderCOMPort == 0) { if (cardID.Length == 8) { string ck = Ralid.GeneralLibrary.ITFCheckCreater.Create(cardID.Substring(0, cardID.Length - 1)); if (!string.IsNullOrEmpty(ck) && ck == cardID.Substring(cardID.Length - 1, 1)) { cardID = cardID.Substring(0, cardID.Length - 1); this.txtCardID.TextChanged -= txtCardID_TextChanged; this.txtCardID.Text = cardID; this.txtCardID.TextChanged += txtCardID_TextChanged; } } } #endregion if (!string.IsNullOrEmpty(cardID)) { CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = bll.GetCardByID(cardID).QueryObject; ShowCardInfo(card); } }
private void ShowSpeedingDetail(CardInvalidEventReport info) { ClearDetail(); CardBll cbll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = cbll.GetCardByID(info.CardID).QueryObject; if (card == null) { return; //没找到卡片,返回 } this.lblCardID.Text = card.CardID; this.lblCarPlate.Text = card.CarPlate; this.lblOwner.Text = card.OwnerName; this.lblDepartment.Text = card.Department; if (!string.IsNullOrEmpty(card.CarPlate)) { SpeedingRecordBll sbll = new SpeedingRecordBll(AppSettings.CurrentSetting.ParkConnect); List <SpeedingRecord> records = sbll.GetRecordsByCarPlate(card.CarPlate).QueryObjects; ShowSpeedingRecords(records); } ucVideoes.ShowVideoes(ParkBuffer.Current.GetEntrance(info.EntranceID).VideoSources); }
private void txtCardID_TextChanged(object sender, EventArgs e) { //卡片名单时才检查 if (this.ucCard1.rdbCardList.Checked) { string cardID = this.ucCard1.txtCardID.Text.Trim(' ', '\n'); if (!string.IsNullOrEmpty(cardID)) { CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); QueryResult <CardInfo> result = bll.GetCardByID(cardID); if (result.Result == ResultCode.Successful) { CardInfo info = result.QueryObject; if (!info.ReleasAble) { MessageBox.Show(string.Format(Resources.Resource1.UcCard_CannotRelease, cardID)); this.ucCard1.txtCardID.Focus(); btnOk.Enabled = false; } else { ReleasingCard = info; this.ucCard1.Card = ReleasingCard; this._isAdding = false; btnOk.Enabled = true; } } else { this._isAdding = true; btnOk.Enabled = true; } } } }
private List <CardPaymentInfo> GetCardPaymentRecordsFromDeviceRecords(List <DevicePaymentRecord> deviceRecords, string entranceName) { if (deviceRecords != null) { List <CardPaymentInfo> records = new List <CardPaymentInfo>(); CardInfo card = null; CardInfo operatorCard = null; foreach (DevicePaymentRecord deviceRecord in deviceRecords) { CardPaymentInfo record = new CardPaymentInfo(); record.PaymentCode = deviceRecord.PaymentCode == DevicePaymentCode.Computer ? PaymentCode.Computer : PaymentCode.FunctionCard; record.ChargeDateTime = deviceRecord.PaymentDateTime; record.CardID = deviceRecord.CardID; record.Accounts = deviceRecord.Amount; record.Paid = deviceRecord.Amount; record.OperatorCardID = deviceRecord.FunctionCardID; record.StationID = entranceName; //缴费卡片相关信息 if (card == null || card.CardID != record.CardID) { card = _CardBll.GetCardByID(record.CardID).QueryObject; } if (card != null) { record.OwnerName = card.OwnerName; record.CarPlate = card.CarPlate; record.CardType = card.CardType; record.CarType = card.CarType; } //收费功能卡相关信息 if (operatorCard == null || operatorCard.CardID != record.OperatorCardID) { operatorCard = _CardBll.GetCardByID(record.OperatorCardID).QueryObject; } if (operatorCard != null) { record.OperatorID = operatorCard.OwnerName; } records.Add(record); } return(records); } return(null); }
/// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardIDHandler(string cardID, CardInfo info) { this.txtCardID.Text = cardID; CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = bll.GetCardByID(cardID).QueryObject; ShowCardInfo(card, cardID); }
private void ReadCardSuccess_Handler(string cardID) { CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); if (bll.GetCardByID(cardID).Result == ResultCode.Successful) { lblAlarm.Text = string.Format(Resources.Resource1.FrmAddCards_CardExists, cardID); lblAlarm.ForeColor = Color.Red; return; //如果卡片已经存在什么也不做 } if (cardView.IndexOfCard(cardID) == -1) { CardInfo card = new CardInfo(); card.CardID = cardID; card.CardType = this.comCardType.SelectedCardType; card.AccessID = (byte)this.comAccessLevel.AccesslevelID; card.Balance = this.txtBalance.DecimalValue; card.ValidDate = this.dtValidDate.Value; card.CarType = this.comChargeType.SelectedCarType; card.Status = CardStatus.Enabled; card.CanRepeatIn = this.chkRepeatIn.Checked; card.CanRepeatOut = this.chkRepeatOut.Checked; card.HolidayEnabled = this.chkHoliday.Checked; card.WithCount = this.chkWithCount.Checked; card.CanEnterWhenFull = this.chkCanEnterWhenFull.Checked; card.EnableWhenExpired = this.chkEnableWhenExpired.Checked; card.OnlineHandleWhenOfflineMode = this.chkOnlineHandleWhenOfflineMode.Checked; card.OwnerName = string.Format("{0}{1}{2}", this.txtPrefix.Text.Trim(), chkAutoIncrement.Checked ? (txtAutoIncrement.IntergerValue + cardView.Rows.Count).ToString() : string.Empty, txtSuffix.Text.Trim()); //如果是写卡模式,这里需将信息写入卡片成功后才能继续 if (this.chkWriteCard.Checked) { lblAlarm.Text = string.Format(Resources.Resource1.FrmAddCards_WritingCard, cardID); lblAlarm.ForeColor = Color.Blue; lblAlarm.Refresh(); //密钥不正确的,需要初始化密钥 if (CardOperationManager.Instance.WriteCardLoop(card, true) != CardOperationResultCode.Success) { lblAlarm.Text = string.Format(Resources.Resource1.FrmAddCards_WriteCardFail, cardID); lblAlarm.ForeColor = Color.Red; return;//如果卡片信息写入失败什么也不做 } } cardView.AddCardInfo(card); cardView.SelectedCard(card.CardID); lblAlarm.Text = string.Format(Resources.Resource1.FrmAddCards_CardCount, cardView.Rows.Count); lblAlarm.ForeColor = Color.Blue; } else { cardView.SelectedCard(cardID); } }
/// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardIDHandler(string cardID, CardInfo info) { this.txtCardID.Text = cardID; CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = bll.GetCardByID(cardID).QueryObject; this.lbl_HasHour.Text = string.Empty;//每次读卡都清空已录入优惠时数 ShowCardInfo(card); }
private void txtCardID_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtCardID.Text)) { CardInfo card = _CardBll.GetCardByID(this.txtCardID.Text).QueryObject; if (card != null) { ReadCardIDHandler(txtCardID.Text, card); } } }
private void txtCardID_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtCardID.Text)) { CardBll _CardBll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = _CardBll.GetCardByID(this.txtCardID.Text).QueryObject; if (card != null) { ReadCardIDHandler(txtCardID.Text, null); } } }
private void CardReadHandler(object sender, CardReadEventArgs e) { Action action = delegate() { if (!string.IsNullOrEmpty(e.CardID)) { CardInfo card = CardDateResolver.Instance.GetCardInfoFromData(e.CardID, e.ParkingDate); string msg = string.Empty; if (card == null) { msg = Resources.Resource1.FrmOperatorCardCashComfirm_InvalidCard; } else if (!card.CardType.IsOperatorCard) { msg = Resources.Resource1.FrmOperatorCardCashComfirm_NotOperatorCard; } else { CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo info = bll.GetCardByID(e.CardID).QueryObject; if (info == null) { msg = Resources.Resource1.FrmOperatorCardCashComfirm_InvalidCard; } else if (Operator == null || info.OwnerName != Operator.OperatorName) { msg = Resources.Resource1.FrmOperatorCardCashComfirm_NotCurrentOperatorCard; } } if (!string.IsNullOrEmpty(msg)) { ShowMsg(msg); return; } this.OperatorCard = card; this.DialogResult = DialogResult.OK; } }; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }
/// <summary> /// 删除卡片 /// </summary> public CommandResult DeleteCard(string cardID) { CardBll bll = new CardBll(AppConifg.Current.ParkingConnection); CardInfo card = bll.GetCardByID(cardID).QueryObject; if (card != null) { return(bll.DeleteCard(card)); } else { return(null); } }
private void FrmCardCharge_Load(object sender, EventArgs e) { this.chkWriteCard.Checked = AppSettings.CurrentSetting.EnableWriteCard; //写卡模式时默认选中 this.chkWriteCard.Visible = AppSettings.CurrentSetting.EnableWriteCard; //写卡模式时显示 this.ucCardInfo.Init(); this.ucCardInfo.UseToShow(); this.comPaymentMode.Init(); this.comPaymentMode.SelectedPaymentMode = PaymentMode.Cash; if (ChargingCard != null) { //获取最新的卡片信息,这是为了防止用户一直打开卡片管理,而使用的卡片信息是缓存信息,导致充值的卡片信息不是最新的 CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = bll.GetCardByID(ChargingCard.CardID).QueryObject; if (card != null) { ChargingCard = card; this.ucCardInfo.Card = ChargingCard; if (ChargingCard.ValidDate > this.dtValidDate.MaxDate) { this.dtValidDate.Value = this.dtValidDate.MaxDate; } else if (ChargingCard.ValidDate < this.dtValidDate.MinDate) { this.dtValidDate.Value = this.dtValidDate.MinDate; } else { this.dtValidDate.Value = ChargingCard.ValidDate; } if (!ChargingCard.IsCardList) { //不是卡片名单时,不需要进行写卡 this.chkWriteCard.Checked = false; this.chkWriteCard.Enabled = false; } } else { this.btnOk.Enabled = false; MessageBox.Show(Resource1.FrmMain_NoCard); } } if (AppSettings.CurrentSetting.EnableWriteCard) { CardReaderManager.GetInstance(UserSetting.Current.WegenType).PushCardReadRequest(CardReadHandler); } }
public void HandleCardEvent(CardEventReport report) { GlobalSettings.Current.Get <Dictionary <int, CardEventReport> >()[report.EntranceID] = report; // if (report.EventStatus != CardEventStatus.Valid) { return; } if (report.CardType != null && (report.CardType.Name == YiTingShanFuSetting.CardType || report.CardType.Name == YCT.YCTSetting.CardTyte || report.CardType.Name == ETC.ETCSetting.CardTyte)) // { if (report.IsExitEvent) //出场后,将开放卡片从系统中删除 { CardBll bll = new CardBll(AppSettings.CurrentSetting.MasterParkConnect); CardInfo card = bll.GetCardByID(report.CardID).QueryObject; if (card != null && (card.ParkingStatus & ParkingStatus.Out) == ParkingStatus.Out) //只有在卡片已经出场的情况下才删除它 { bll.DeleteCardAtAll(card); } } } }
private void txtCardID_TextChanged(object sender, EventArgs e) { string cardID = this.txtCardID.Text.Trim(' ', '\n'); if (!string.IsNullOrEmpty(cardID)) { CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); QueryResult <CardInfo> result = bll.GetCardByID(cardID); if (result.Result == ResultCode.Successful) { CardInfo info = result.QueryObject; if (_ReadCard != null) { CardDateResolver.Instance.CopyCardDataToCard(info, _ReadCard); } if (!info.CardType.IsManagedCard) { MessageBox.Show(string.Format(Resource1.FrmManageCardDetail_NotManagement, cardID)); this.txtCardID.Focus(); btnOk.Enabled = false; } else { UpdatingItem = info; this.IsAdding = false; btnOk.Enabled = true; ShowCardInfo(info); } } else { if (_ReadCard != null) { ShowCardInfo(_ReadCard); } this.IsAdding = true; btnOk.Enabled = true; } } }
private void ReadCardHandler(string cardID, CardInfo info) { CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = bll.GetCardByID(cardID).QueryObject; string msg = string.Empty; if (card == null) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_UnRegister); } else if (AppSettings.CurrentSetting.EnableWriteCard && !card.OnlineHandleWhenOfflineMode && !CardDateResolver.Instance.CopyPaidDataToCard(card, info)) { //写卡模式时,卡片收费信息从扇区数据中获取 msg = Resource1.FrmCardCenterCharge_CardDataErr; } else if (!card.IsInPark) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_StillOut); } else if (!card.IsTempCard) { msg = Resource1.FrmCardOut_NoTempCard; } else { msg = CardOut(bll, card); } if (!string.IsNullOrEmpty(msg)) { this.listMsg.InsertMessage(msg); } }
/// <summary> /// 验证输入的合法性 /// </summary> /// <returns></returns> private bool CheckInput() { if (string.IsNullOrEmpty(this.txtCardID.Text.Trim())) { MessageBox.Show("没有卡片!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (this.lblCardWarning.Text.Length > 0) { MessageBox.Show(this.lblCardWarning.Text, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (this.cmbPreferentialHour.Text.Length == 0) { MessageBox.Show("必须输入优惠时数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.cmbPreferentialHour.Focus(); return(false); } int temp = 0; if (!string.IsNullOrEmpty(this.cmbPreferentialHour.Text.Trim()) && !int.TryParse(this.cmbPreferentialHour.Text, out temp)) { MessageBox.Show("请输入正确的优惠时数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.cmbPreferentialHour.Focus(); return(false); } if (!string.IsNullOrEmpty(this.txtCost1.Text.Trim()) && !int.TryParse(this.txtCost1.Text, out temp)) { MessageBox.Show("请输入正确的消费金额", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtCost1.Focus(); return(false); } if (!string.IsNullOrEmpty(this.txtCost2.Text.Trim()) && !int.TryParse(this.txtCost2.Text, out temp)) { MessageBox.Show("请输入正确的消费金额", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtCost1.Focus(); return(false); } if (!string.IsNullOrEmpty(this.txtCost3.Text.Trim()) && !int.TryParse(this.txtCost3.Text, out temp)) { MessageBox.Show("请输入正确的消费金额", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtCost1.Focus(); return(false); } if (!string.IsNullOrEmpty(this.cmbPreferentialHour.Text.Trim()) && PRESysOptionSetting.Current.PRESysOption.IsAllowDefineHour == 1) {//当手动输入优惠时数时,阻止其超过当前最大可优惠时数 int currentInputHour = Convert.ToInt32(this.cmbPreferentialHour.Text.Trim()); CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = bll.GetCardByID(this.txtCardID.Text.Trim()).QueryObject; if (card != null) { int hasPreferentialHour = card.DiscountHour; if (currentInputHour + hasPreferentialHour > PRESysOptionSetting.Current.PRESysOption.MaxHour) { MessageBox.Show("当前优惠时数和已优惠时数之和已超过系统最大优惠时数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } } } return(true); }
/// <summary> /// 获取某卡号的停车收费信息接口 /// </summary> /// <param name="cardID">卡号</param> /// <param name="discountHour">优惠时长</param> /// <param name="discountAmount">优惠金额</param> /// <param name="reserve1">预留1</param> /// <param name="reserve2">预留2</param> /// <returns>Result 0:成功,其他:失败;QueryObject:返回收费信息对象</returns> public QueryResult <WSCardPaymentInfo> GetCardPayment(string cardID, string discountHour, string discountAmount, string reserve1, string reserve2) { try { #region 先验证输入参数 if (string.IsNullOrEmpty(cardID.Trim())) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.ParameterError, "参数卡号错误", null)); } int discountHourInt = 0; if (!string.IsNullOrEmpty(discountHour.Trim())) { if (!int.TryParse(discountHour, out discountHourInt)) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.ParameterError, "参数优惠时长错误", null)); } } decimal discountAmountD = 0; if (!string.IsNullOrEmpty(discountAmount.Trim())) { if (!decimal.TryParse(discountAmount, out discountAmountD)) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.ParameterError, "参数优惠金额错误", null)); } } #endregion #region 接口日志记录 if (AppConifg.Current.Log) { try { string log = string.Format("卡号:{0} 优惠时长:{1} 优惠金额:{2} 预留1:{3} 预留2:{4}" , cardID , discountHour , discountAmount , reserve1 , reserve2); Ralid.GeneralLibrary.LOG.FileLog.Log(AppConifg.Current.LogPath, "GetCardPayment", log); } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } } #endregion #region 验证卡片信息 //查找该卡号的卡片 CardBll cardBll = new CardBll(AppConifg.Current.ParkingConnection); QueryResult <CardInfo> cResult = cardBll.GetCardByID(cardID); if (cResult.Result != ResultCode.Successful) { return(new QueryResult <WSCardPaymentInfo>(cResult.Result, "获取卡片信息失败", null)); } CardInfo card = cResult.QueryObject; if (card == null) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.NoRecord, "此卡未登记", null)); } if (!card.IsInPark) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "此卡已出场", null)); } string msg = string.Empty; if (!ValidateCard(card, out msg)) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, msg, null)); } DateTime chargeDateTime = DateTime.Now; if (card.LastDateTime > chargeDateTime) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "入场时间晚于计费时间", null)); } //获取卡片所在停车场信息 EntranceBll entranceBll = new EntranceBll(AppConifg.Current.ParkingConnection); EntranceInfo entrance = entranceBll.GetEntranceInfo(card.LastEntrance).QueryObject; if (entrance == null) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.NoRecord, "没有找到入场通道信息", null)); } ParkBll parkBll = new ParkBll(AppConifg.Current.ParkingConnection); ParkInfo park = parkBll.GetParkInfoByID(entrance.ParkID).QueryObject; if (park == null) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.NoRecord, "没有找到停车场信息", null)); } //判断卡片合法性 if (card.IsCardList && park.IsWriteCardMode && !card.OnlineHandleWhenOfflineMode) { //写卡模式时,脱机处理的卡片名单不能缴费 return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "该卡片为写卡处理卡片,不能进行在线缴费", null)); } #endregion #region 获取费率和节假日 SysParaSettingsBll ssb = new SysParaSettingsBll(AppConifg.Current.ParkingConnection); TariffSetting tariff = ssb.GetSetting <TariffSetting>(); if (tariff == null) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "获取费率失败", null)); } TariffSetting.Current = tariff; HolidaySetting holiday = ssb.GetSetting <HolidaySetting>(); if (holiday == null) { return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "获取节假日失败", null)); } HolidaySetting.Current = holiday; #endregion #region 判断是否已缴过费 if (card.IsCompletedPaid && tariff.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime)) { //已缴费,并且未过免费时间,不允许缴费 msg = string.Format("已缴费,请在{0}分钟内离场!", tariff.FreeTimeRemaining(card.PaidDateTime.Value, chargeDateTime)); return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, msg, null)); } #endregion //重设卡片优惠时长 card.DiscountHour += discountHourInt; if (card.DiscountHour > 0xFF) { card.DiscountHour = 0xFF; } //生成卡片缴费记录 CardPaymentInfo chargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(park.ParkID, card, tariff, card.CarType, chargeDateTime); //计算优惠后的缴费费用 chargeRecord.Discount += discountAmountD; if (chargeRecord.Discount > chargeRecord.Accounts) { //如果优惠金额比应收费用多,优惠金额为应收费用,这是为了防止实际支付费用为负数的情况出现 chargeRecord.Discount = chargeRecord.Accounts; } WSCardPaymentInfo wsRecord = new WSCardPaymentInfo(); wsRecord.SetWSCardPaymentInfo(chargeRecord); wsRecord.EntranceName = entrance.EntranceName; return(new QueryResult <WSCardPaymentInfo>(ResultCode.Successful, wsRecord)); } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); string msg = string.Format("接口发生异常,异常信息:{0}", ex.Message); return(new QueryResult <WSCardPaymentInfo>(ResultCode.InterfaceException, msg, null)); } }
/// <summary> /// 停车收费接口 /// </summary> /// <param name="cardID">卡号</param> /// <param name="chargeDateTime">计费时间(格式:yyyy-MM-dd HH:mm:ss.fff)</param> /// <param name="paid">实付金额</param> /// <param name="payMode">支付方式[0代表现金,1代表微信,…]</param> /// <param name="memo">费用说明</param> /// <param name="reserve1">预留1</param> /// <param name="reserve2">预留2</param> /// <returns>Result 0:成功,其他:失败</returns> public CommandResult CardFeePay(string cardID, string chargeDateTime, string paid, string payMode, string memo, string reserve1, string reserve2) { try { #region 先验证输入参数 if (string.IsNullOrEmpty(cardID.Trim())) { return(new CommandResult(ResultCode.ParameterError, "参数卡号错误")); } DateTime chargeTime = new DateTime(2011, 1, 1); if (!DateTime.TryParse(chargeDateTime, out chargeTime)) { return(new CommandResult(ResultCode.ParameterError, "参数计费时间错误")); } if (chargeTime > DateTime.Now) { return(new CommandResult(ResultCode.ParameterError, "计费时间大于系统当前时间")); } decimal paidD = 0; if (!decimal.TryParse(paid, out paidD)) { return(new CommandResult(ResultCode.ParameterError, "参数实付金额错误")); } int payModeI = 0; if (!int.TryParse(payMode, out payModeI)) { return(new CommandResult(ResultCode.ParameterError, "参数支付方式错误")); } #endregion #region 接口日志记录 if (AppConifg.Current.Log) { try { string log = string.Format("卡号:{0} 计费时间:{1} 实付金额:{2} 支付方式:{3} 费用说明:{4} 预留1:{5} 预留2:{6}" , cardID , chargeDateTime , paid , payMode , memo , reserve1 , reserve2); Ralid.GeneralLibrary.LOG.FileLog.Log(AppConifg.Current.LogPath, "CardFeePay", log); } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } } #endregion #region 验证卡片信息 //查找该卡号的卡片 CardBll cardBll = new CardBll(AppConifg.Current.ParkingConnection); QueryResult <CardInfo> cResult = cardBll.GetCardByID(cardID); if (cResult.Result != ResultCode.Successful) { return(new CommandResult(cResult.Result, "获取卡片信息失败")); } CardInfo card = cResult.QueryObject; if (card == null) { return(new CommandResult(ResultCode.NoRecord, "此卡未登记")); } if (!card.IsInPark) { return(new CommandResult(ResultCode.Fail, "此卡已出场")); } string msg = string.Empty; if (!ValidateCard(card, out msg)) { return(new CommandResult(ResultCode.Fail, msg)); } if (card.LastDateTime > chargeTime) { return(new CommandResult(ResultCode.ParameterError, "入场时间晚于计费时间")); } //获取卡片所在停车场信息 EntranceBll entranceBll = new EntranceBll(AppConifg.Current.ParkingConnection); EntranceInfo entrance = entranceBll.GetEntranceInfo(card.LastEntrance).QueryObject; if (entrance == null) { return(new CommandResult(ResultCode.NoRecord, "没有找到入场通道信息")); } ParkBll parkBll = new ParkBll(AppConifg.Current.ParkingConnection); ParkInfo park = parkBll.GetParkInfoByID(entrance.ParkID).QueryObject; if (park == null) { return(new CommandResult(ResultCode.NoRecord, "没有找到停车场信息")); } //判断卡片合法性 if (card.IsCardList && park.IsWriteCardMode && !card.OnlineHandleWhenOfflineMode) { //写卡模式时,脱机处理的卡片名单不能缴费 return(new CommandResult(ResultCode.Fail, "该卡片为写卡处理卡片,不能进行在线收费")); } #endregion #region 获取费率和节假日 SysParaSettingsBll ssb = new SysParaSettingsBll(AppConifg.Current.ParkingConnection); TariffSetting tariff = ssb.GetSetting <TariffSetting>(); if (tariff == null) { return(new CommandResult(ResultCode.Fail, "获取费率失败")); } TariffSetting.Current = tariff; HolidaySetting holiday = ssb.GetSetting <HolidaySetting>(); if (holiday == null) { return(new CommandResult(ResultCode.Fail, "获取节假日失败")); } HolidaySetting.Current = holiday; #endregion #region 判断是否已缴过费 if (card.IsCompletedPaid && tariff.IsInFreeTime(card.PaidDateTime.Value, chargeTime)) { //已缴费,并且未过免费时间,不允许缴费 msg = string.Format("已缴费,请在{0}分钟内离场!", tariff.FreeTimeRemaining(card.PaidDateTime.Value, chargeTime)); return(new CommandResult(ResultCode.Fail, msg)); } #endregion //生成卡片缴费记录 CardPaymentInfo chargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(park.ParkID, card, tariff, card.CarType, chargeTime); //将收费信息重新赋值 chargeRecord.Paid = paidD; chargeRecord.Discount = chargeRecord.Accounts - paidD; if (chargeRecord.Discount < 0) { chargeRecord.Discount = 0; } chargeRecord.PaymentCode = PaymentCode.Internet; chargeRecord.PaymentMode = payModeI == 1 ? PaymentMode.WeChat : PaymentMode.Cash; chargeRecord.IsCenterCharge = true; chargeRecord.StationID = string.Empty; chargeRecord.OperatorID = string.Empty; if (!string.IsNullOrEmpty(memo)) { chargeRecord.Memo = memo; } if (chargeRecord.Memo == null) { chargeRecord.Memo = string.Empty; } CommandResult result = cardBll.PayParkFee(chargeRecord); if (result.Result == ResultCode.Successful) { //缴费成功,返回缴费后离场提示信息 msg = string.Format("缴费成功,请在{0}分钟内离场!", tariff.FreeTimeRemaining(chargeTime, DateTime.Now)); } return(result); } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); string msg = string.Format("接口发生异常,异常信息:{0}", ex.Message); return(new CommandResult(ResultCode.InterfaceException, msg)); } }
//private void SyncTime_Thread() //{ // while (true) // { // Thread.Sleep(5 * 60 * 1000); // try // { // foreach (EntranceBase entrance in _Entrances) // { // entrance.SyncTime(); // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // } // } //} //private void ExecuteWaitingCommand_Thread() //{ // try // { // ClearInvalidWaitingCommand();//清除已删除的控制器的等待命令 // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); // while (true) // { // try // { // if (!_WaitingCommandPause && DataBaseConnectionsManager.Current.MasterConnected) // { // WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); // List<WaitingCommandInfo> wcs = wb.GetAllCommands().QueryObjects; // EntranceBase entrance = null; // int entranceID = -1; // foreach (var wc in wcs) // { // if (entranceID != wc.EntranceID) // { // entrance = GetEntrance(wc.EntranceID); // entranceID = wc.EntranceID; // } // if (entrance != null) // { // bool ret = false; // if (wc.Command == CommandType.DownloadAccesses) // { // ret = entrance.ApplyAccessSetting(AccessSetting.Current); // } // else if (wc.Command == CommandType.DownloadHolidays) // { // ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); // } // else if (wc.Command == CommandType.DownloadTariffs) // { // ret = entrance.ApplyTariffSetting(TariffSetting.Current); // } // else if (wc.Command == CommandType.ClearCard) // { // ret = entrance.ClearCard(); // } // else if (wc.Command == CommandType.DeleteCard) // { // CardInfo card = new CardInfo(); // card.CardID = wc.CardID; // ret = entrance.SaveCard(card, ActionType.Delete); // } // else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) // { // CardBll cb = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); // CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; // if (card != null) // { // ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate, false); // } // else // { // ret = true; // } // } // if (ret) // { // CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); // if (DataBaseConnectionsManager.Current.MasterConnected) // { // dresult = wb.Delete(wc); // } // if (AppSettings.CurrentSetting.Debug) // { // if (dresult.Result == ResultCode.Successful) // { // string msg = string.Format("控制器{0}[{1}] 命令 {2} {3} 成功,删除命令 {4}", entrance.EntranceName, entrance.EntranceID, wc.Command, wc.CardID, dresult.Result == ResultCode.Successful ? "成功" : dresult.Result.ToString()); // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", msg); // } // } // } // } // } // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); // } // Thread.Sleep(60 * 1000); // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); // } //} private void ExecuteWaitingCommand_Thread() { try { //开始前先等待10分钟,用于等待硬件设备连接状态检测完成 Thread.Sleep(10 * 60 * 1000); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); while (true) { try { if (!_WaitingCommandPause && DataBaseConnectionsManager.Current.MasterConnected) { WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); List <WaitingCommandInfo> wcs = wb.GetWaitingCommands().QueryObjects; EntranceBase entrance = null; int entranceID = -1; foreach (var wc in wcs) { if (entranceID != wc.EntranceID) { entrance = GetEntrance(wc.EntranceID); entranceID = wc.EntranceID; } if (entrance != null && entrance.Status != EntranceStatus.OffLine) { bool ret = false; if (wc.Command == CommandType.DownloadAccesses) { ret = entrance.ApplyAccessSetting(AccessSetting.Current); } else if (wc.Command == CommandType.DownloadHolidays) { ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); } else if (wc.Command == CommandType.DownloadTariffs) { ret = entrance.ApplyTariffSetting(TariffSetting.Current); } else if (wc.Command == CommandType.DownloadKeySetting) { ret = entrance.ApplyKeySetting(KeySetting.Current); } else if (wc.Command == CommandType.ClearCard) { ret = entrance.ClearCard(); } else if (wc.Command == CommandType.DeleteCard) { //由于命令执行前已删除了卡片信息,所以如果是车牌名单时,cardid保存的是车牌名单的车牌号 CardInfo card = new CardInfo(); card.ListType = wc.CardIDType.HasValue && wc.CardIDType.Value == 1 ? CardListType.CarPlate : CardListType.Card; if (card.IsCardList) { card.CardID = wc.CardID; } else { card.CarPlate = wc.CardID; } ret = entrance.SaveCard(card, ActionType.Delete); } else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) { CardBll cb = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; if (card != null) { ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate); } else { ret = true; } } if (ret) { CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); if (DataBaseConnectionsManager.Current.MasterConnected) { dresult = wb.Delete(wc); } if (AppSettings.CurrentSetting.Debug) { if (dresult.Result == ResultCode.Successful) { string msg = string.Format("控制器{0}[{1}] 命令 {2} {3} 成功,删除命令 {4}", entrance.EntranceName, entrance.EntranceID, wc.Command, wc.CardID, dresult.Result == ResultCode.Successful ? "成功" : dresult.Result.ToString()); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", msg); } } } else { CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); if (DataBaseConnectionsManager.Current.MasterConnected) { wc.Status = WaitingCommandStatus.Fail; dresult = wb.Update(wc); } } } } } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } Thread.Sleep(5 * 60 * 1000); } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "WaitingCommand服务异常终止"); } }
private void ExecuteWaitingCommand_Thread() { ClearInvalidWaitingCommand();//清除已删除的控制器的等待命令 WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); while (true) { List <WaitingCommandInfo> wcs = wb.GetAllCommands().QueryObjects; EntranceBase entrance = null; int entranceID = -1; foreach (var wc in wcs) { if (entranceID != wc.EntranceID) { entrance = GetEntrance(wc.EntranceID); entranceID = wc.EntranceID; } if (entrance != null) { bool ret = false; if (wc.Command == CommandType.DownloadAccesses) { ret = entrance.ApplyAccessSetting(AccessSetting.Current); } else if (wc.Command == CommandType.DownloadHolidays) { ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); } else if (wc.Command == CommandType.DownloadTariffs) { ret = entrance.ApplyTariffSetting(TariffSetting.Current); } else if (wc.Command == CommandType.ClearCard) { ret = entrance.ClearCard(); } else if (wc.Command == CommandType.DeleteCard) { CardInfo card = new CardInfo(); card.CardID = wc.CardID; ret = entrance.DeleteCard(card); } else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) { CardBll cb = new CardBll(AppSettings.CurrentSetting.ParkConnect); CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; if (card != null) { ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate); } else { ret = true; } } if (ret) { wb.Delete(wc); } } } Thread.Sleep(60 * 1000); } }
//private void SyncTime_Thread() //{ // while (true) // { // Thread.Sleep(5 * 60 * 1000); // try // { // foreach (EntranceBase entrance in _Entrances) // { // entrance.SyncTime(); // } // } // catch (Exception ex) // { // Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); // } // } //} private void ExecuteWaitingCommand_Thread() { try { ClearInvalidWaitingCommand();//清除已删除的控制器的等待命令 Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); while (true) { try { if (!_WaitingCommandPause && DataBaseConnectionsManager.Current.MasterConnected) { WaitingCommandBLL wb = new WaitingCommandBLL(AppSettings.CurrentSetting.ParkConnect); List <WaitingCommandInfo> wcs = wb.GetAllCommands().QueryObjects; EntranceBase entrance = null; int entranceID = -1; foreach (var wc in wcs) { if (entranceID != wc.EntranceID) { entrance = GetEntrance(wc.EntranceID); entranceID = wc.EntranceID; } if (entrance != null) { bool ret = false; if (wc.Command == CommandType.DownloadAccesses) { ret = entrance.ApplyAccessSetting(AccessSetting.Current); } else if (wc.Command == CommandType.DownloadHolidays) { ret = entrance.ApplyHolidaySetting(HolidaySetting.Current); } else if (wc.Command == CommandType.DownloadTariffs) { ret = entrance.ApplyTariffSetting(TariffSetting.Current); } else if (wc.Command == CommandType.ClearCard) { ret = entrance.ClearCard(); } else if (wc.Command == CommandType.DeleteCard) { CardInfo card = new CardInfo(); card.CardID = wc.CardID; ret = entrance.SaveCard(card, ActionType.Delete); } else if (wc.Command == CommandType.AddCard || wc.Command == CommandType.UpateCard) { CardBll cb = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); CardInfo card = cb.GetCardByID(wc.CardID).QueryObject; if (card != null) { ret = entrance.SaveCard(card, wc.Command == CommandType.AddCard ? ActionType.Add : ActionType.Upate, false); } else { ret = true; } } if (ret) { CommandResult dresult = new CommandResult(ResultCode.CannotConnectServer); if (DataBaseConnectionsManager.Current.MasterConnected) { dresult = wb.Delete(wc); } if (AppSettings.CurrentSetting.Debug) { if (dresult.Result == ResultCode.Successful) { string msg = string.Format("控制器{0}[{1}] 命令 {2} {3} 成功,删除命令 {4}", entrance.EntranceName, entrance.EntranceID, wc.Command, wc.CardID, dresult.Result == ResultCode.Successful ? "成功" : dresult.Result.ToString()); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", msg); } } } } } } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); } Thread.Sleep(60 * 1000); } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); Ralid.GeneralLibrary.LOG.FileLog.Log("WaitingCommand", "开始WaitingCommand服务"); } }