///// <summary> ///// 脱机模式时按在线模式处理的检验 ///// </summary> ///// <param name="card"></param> ///// <param name="msg"></param> ///// <returns></returns> //private bool OnlineHandleWhenOfflineModeCheck(CardInfo card, out string msg) //{ // if (AppSettings.CurrentSetting.EnableWriteCard // && !card.OnlineHandleWhenOfflineMode)//脱机模式时,按脱机模式处理 // { // if (!DataBaseConnectionsManager.Current.BothCconnectedOrNoStandby) // { // msg = "与主数据库或备用数据库连接失败!"; // return false; // } // if (DataBaseConnectionsManager.Current.StandbyConnected) // { // //与备用数据库连接上时,检查主数据库与备用数据库的数据是否一致 // CardBll scbll = new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect); // CardInfo scard = scbll.GetCardByID(card.CardID).QueryObject; // if (scard == null // || scard.ParkingStatus != card.ParkingStatus //停车状态 // || scard.LastDateTime != card.LastDateTime //最近一次刷卡时间 // ||scard.PaidDateTime!=card.PaidDateTime //缴费时间 // ||scard.TotalPaidFee!=card.TotalPaidFee) //已缴费用 // { // msg = "主数据库与备用数据库信息不一致!"; // return false; // } // } // } // msg = string.Empty; // return true; //} /// <summary> /// 获取卡片详细信息 /// </summary> /// <param name="offlineHandleCard">是否脱机处理的卡片</param> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> /// <param name="card">返回的卡片</param> /// <param name="msg">返回的错误信息</param> /// <returns></returns> private bool GetCardDetail(bool offlineHandleCard, string cardID, CardInfo info, out CardInfo card, out string msg) { card = null; if (DataBaseConnectionsManager.Current.MasterConnected || DataBaseConnectionsManager.Current.StandbyConnected) { CardInfo mastercard = null; CardInfo standbycard = null; if (DataBaseConnectionsManager.Current.MasterConnected) { CardBll mcbll = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); mastercard = mcbll.GetCardDetail(cardID); } if (DataBaseConnectionsManager.Current.StandbyConnected) { //需要获取备用数据库的卡片信息进行比对 //通信工作站如果没有连接上主数据库,需要从备用数据库中获取卡片信息 CardBll scbll = new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect); standbycard = scbll.GetCardDetail(cardID); } //在线处理的卡片,主数据库连上,有备份数据库的,需要与获取备用数据库的卡片信息进行比对 if (!offlineHandleCard && DataBaseConnectionsManager.Current.MasterConnected && WorkStationInfo.CurrentStation.HasStandbyDatabase) { if (mastercard == null && standbycard == null) { //没有该卡片 } else if (mastercard == null || standbycard == null || !mastercard.CompareChargeInfo(standbycard)) { msg = "主数据库与备用数据库信息不一致!"; return(false); } } if (mastercard != null) { card = mastercard; } else if (WorkStationInfo.CurrentStation.IsHostWorkstation || offlineHandleCard) { card = standbycard; } } else if (offlineHandleCard) { //与主数据库和备用连接断开时,如果是脱机处理的卡片,获取的为读到的卡片信息 card = info.Clone(); } msg = string.Empty; return(true); }
/// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardIDHandler(string cardID, CardInfo info) { txtCardID.TextChanged -= txtCardID_TextChanged; this.txtCardID.Text = cardID; this.txtCardID.ReadOnly = true; string msg = string.Empty; CardInfo card = _CardBll.GetCardDetail(this.txtCardID.Text); if (card == null) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_UnRegister); } else if (AppSettings.CurrentSetting.EnableWriteCard && !card.OnlineHandleWhenOfflineMode && !CardDateResolver.Instance.CopyCardDataToCard(card, info)) { //写卡模式时,卡片信息从扇区数据中获取 msg = Resource1.FrmCardCenterCharge_CardDataErr; } else if (!ValidateCard(card, out msg)) { //卡片无效 } else if (TariffSetting.Current.GetTariff(card.CardType.ID, card.CarType) == null) { //msg = Resource1.FrmCardPaying_NotTempCard; msg = Resource1.FrmCardCenterCharge_NotPaymentCard; } else if (!card.IsInPark) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_StillOut); } else if (card.LastDateTime > DateTime.Now) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_WrongInTime); } else { _cardInfo = card; _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(_cardInfo, TariffSetting.Current, _cardInfo.CarType, DateTime.Now); ShowCardPaymentInfo(_ChargeRecord); } if (!string.IsNullOrEmpty(msg)) { if (_ChargeLed != null) { _ChargeLed.DisplayMsg(msg); } if (AppSettings.CurrentSetting.EnableTTS) { TTSSpeech.Instance.Speek(msg); } ClearInput(); this.txtCardID.Text = cardID; this.txtMemo.Text = msg; } txtCardID.TextChanged += txtCardID_TextChanged; }
private CardInfo _OriginalCard; //卡片原始信息 #region 私有方法 /// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardIDHandler(string cardID, CardInfo info) { txtCardID.TextChanged -= txtCardID_TextChanged; this.txtCardID.Text = cardID; this.txtCardID.ReadOnly = true; string msg = string.Empty; bool offlineHandleCard = AppSettings.CurrentSetting.EnableWriteCard && info != null && !info.OnlineHandleWhenOfflineMode; CardBll bll = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); //如果只是免费授权,卡片信息只要从主数据库获取就可以了 CardInfo card = bll.GetCardDetail(cardID); if (card == null && offlineHandleCard) { card = info.Clone(); } if (!WorkStationInfo.CurrentStation.CanFreeAuthorization(offlineHandleCard, out msg)) { //该工作站不能进行授权 } else if (card == null) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_UnRegister); } else if (AppSettings.CurrentSetting.EnableWriteCard && !card.OnlineHandleWhenOfflineMode && !CardDateResolver.Instance.CopyPaidDataToCard(card, info))//只复制缴费相关的信息,如果复制了所有的信息,会覆盖数据库内的卡片状态,如挂失,禁用等状态 //&& !CardDateResolver.Instance.CopyCardDataToCard(card, info)) { //写卡模式时,卡片信息从扇区数据中获取 msg = Resource1.FrmCardCenterCharge_CardDataErr; } else if (!ValidateCard(card, out msg)) { //卡片无效 } else { _cardInfo = card; _OriginalCard = card.Clone(); ShowCardInfo(_cardInfo); } if (!string.IsNullOrEmpty(msg)) { if (AppSettings.CurrentSetting.EnableTTS) { TTSSpeech.Instance.Speek(msg); } ClearInput(); this.txtCardID.Text = cardID; MessageBox.Show(msg); } txtCardID.TextChanged += txtCardID_TextChanged; }