/// <summary> /// 免费授权 /// </summary> private void FreeAuthorization(CardInfo cardinfo) { bool offlineHandleCard = AppSettings.CurrentSetting.EnableWriteCard && cardinfo != null && !cardinfo.OnlineHandleWhenOfflineMode; CardBll _CardBll = new CardBll(AppSettings.CurrentSetting.ParkConnect); bool success = _CardBll.CardFreeAuthorizationWithStandby(_cardInfo, WorkStationInfo.CurrentStation.HasStandbyDatabase, AppSettings.CurrentSetting.CurrentStandbyConnect).Result == ResultCode.Successful; //写卡模式时需要将授权信息写入卡片扇区,并且只需要写入卡片成功就可以了 if (offlineHandleCard) { success = CardOperationManager.Instance.WriteCardLoop(cardinfo) == CardOperationResultCode.Success; if (!success) { //写入失败时,将数据库的卡片授权信息还原 _CardBll.CardFreeAuthorization(_OriginalCard); if (!string.IsNullOrEmpty(AppSettings.CurrentSetting.CurrentStandbyConnect)) { //还原备用数据库 CardBll standbyCardBll = new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect); standbyCardBll.CardFreeAuthorization(_OriginalCard); } } } if (success) { //插入授权记录 FreeAuthorizationLog log = CreateFreeAuthorizationLog(_cardInfo); FreeAuthorizationLogBll logBll = new FreeAuthorizationLogBll(AppSettings.CurrentSetting.ParkConnect); logBll.Insert(log); MessageBox.Show(Resource1.FrmHotelAuthorization_Authe + Resource1.Form_Success); ClearInput(); } else { MessageBox.Show(Resource1.FrmHotelAuthorization_Authe + Resource1.Form_Fail); } }