コード例 #1
0
        ///// <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);
        }