Exemplo n.º 1
0
        /// <summary>
        /// 获取配置
        /// </summary>
        /// <returns></returns>
        public static ParkOutDoorLedManager Get(int parkID)
        {
            SysParaSettingsBll    bll = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect);
            ParkOutDoorLedManager man = bll.GetSetting <ParkOutDoorLedManager>("OutdoorLed_Park" + parkID.ToString());

            return(man);
        }
 private void FrmMain_Load(object sender, EventArgs e)
 {
     //ReadSoftDog();
     DoLogIn();
     UserSettings.Current = SysParaSettingsBll.GetOrCreateSetting <UserSettings>(AppSettings.Current.ConnStr);
     //mnu_Home.PerformClick();
 }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            _ETC.ReadSameCardInterval = txtReadSameCardInterval.IntergerValue;
            CommandResult ret = (new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect)).SaveSetting <ETCSetting>(_ETC);

            if (CustomCardTypeSetting.Current.GetCardType(ETCSetting.CardTyte) == null) //增加自定义卡片类型
            {
                CustomCardTypeSetting.Current.AddCardType(ETCSetting.CardTyte, (byte)Ralid.Park.BusinessModel.Enum.CardType.MonthRentCard);
                ret = new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect).SaveSetting <CustomCardTypeSetting>(CustomCardTypeSetting.Current);
            }
            if (ret.Result == ResultCode.Successful)
            {
                AppSettings.CurrentSetting.SaveConfig("EnableETC", chkEnable.Checked.ToString());
                OpenCardMessageHandler handler = GlobalSettings.Current.Get <OpenCardMessageHandler>();
                if (chkEnable.Checked)
                {
                    handler.InitService(_ETC);
                }
                else
                {
                    handler.CloseService <ETCSetting>();
                }
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(ret.Message);
            }
        }
Exemplo n.º 4
0
 private void FrmMain_Load(object sender, EventArgs e)
 {
     this.Text += string.Format(" [{0}]", Application.ProductVersion);
     DoLogIn();
     WXManager.Current = new WXManager(AppSettings.Current.ConnStr);
     WXManager.Current.Init();
     UserSettings.Current = SysParaSettingsBll.GetOrCreateSetting<UserSettings>(AppSettings.Current.ConnStr);
     SelfHostServer.StartWebApiService();
 }
Exemplo n.º 5
0
        private void InitSystemParameters()
        {
            //初始化系统设置
            SysParaSettingsBll ssb = new SysParaSettingsBll(AppSettings.CurrentSetting.AvailableParkConnect);

            UserSetting.Current           = ssb.GetOrCreateSetting <UserSetting>();
            TariffSetting.Current         = ssb.GetOrCreateSetting <TariffSetting>();
            CustomCardTypeSetting.Current = ssb.GetOrCreateSetting <CustomCardTypeSetting>();
        }
Exemplo n.º 6
0
 private void FrmMain_Load(object sender, EventArgs e)
 {
     //ReadSoftDog();
     DoLogIn();
     UserSettings.Current = SysParaSettingsBll.GetOrCreateSetting <UserSettings>(AppSettings.Current.ConnStr);
     //启动同步时间服务
     _DatetimeSyncService = new DatetimeSyncService(AppSettings.Current.ConnStr);
     _DatetimeSyncService.Start();
 }
Exemplo n.º 7
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (CheckTariffInput())
     {
         SysParaSettingsBll ssb = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect);
         TariffSetting.Current = GetTariffSettingFromInput();
         //TariffSetting.Current.TariffOption = GetTollOptionFromInput();
         ssb.SaveSetting <TariffSetting>(TariffSetting.Current);
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
Exemplo n.º 8
0
        public ServiceHelper()
        {
            SysParaSettingsBll ssb = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect);

            AccessSetting.Current         = ssb.GetOrCreateSetting <AccessSetting>();
            TariffSetting.Current         = ssb.GetOrCreateSetting <TariffSetting>();
            UserSetting.Current           = ssb.GetOrCreateSetting <UserSetting>();
            HolidaySetting.Current        = ssb.GetOrCreateSetting <HolidaySetting>();
            CarTypeSetting.Current        = ssb.GetOrCreateSetting <CarTypeSetting>();
            CustomCardTypeSetting.Current = ssb.GetSetting <CustomCardTypeSetting>();
            ParkBuffer.Current            = new ParkBuffer(AppSettings.CurrentSetting.ParkConnect);
            ParkBuffer.Current.InValid();
        }
Exemplo n.º 9
0
        /// <summary>
        /// 保存配置
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static bool Save(ParkOutDoorLedManager setting)
        {
            try
            {
                SysParaSettingsBll bll = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect);
                CommandResult      ret = bll.SaveSetting <ParkOutDoorLedManager>(setting, "OutdoorLed_Park" + setting.ParkID.ToString());

                ParkCarPortSearchCondition con = new ParkCarPortSearchCondition()
                {
                    ParkID = setting.ParkID
                };
                IUnitWork          unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect);
                List <ParkCarPort> items    = ProviderFactory.Create <IParkCarPortProvider>(AppSettings.CurrentSetting.ParkConnect).GetItems(con).QueryObjects;
                //foreach (OutDoorLedArea area in setting.Areas)
                //{
                //    if (area.CardType != null)
                //    {
                //        ParkCarPort item = items.FirstOrDefault(it => it.CardType.Value == area.CardType && it.CarType.Value == area.CarType);
                //        if (item == null)
                //        {
                //            ParkCarPort pcp = new ParkCarPort()
                //            {
                //                ParkID = setting.ParkID,
                //                CardType = area.CardType,
                //                CarType = area.CarType,
                //                CarPort = (short)area.CarPort,
                //                Vacant = (short)area.Vacant
                //            };
                //            ProviderFactory.Create<IParkCarPortProvider>(AppSettings.CurrentSetting.ParkConnect).Insert(pcp, unitWork);
                //        }
                //        else
                //        {
                //            ParkCarPort pcp = item.Clone();
                //            item.CarPort = (short)area.CarPort;
                //            item.Vacant = (short)area.Vacant;
                //            ProviderFactory.Create<IParkCarPortProvider>(AppSettings.CurrentSetting.ParkConnect).Update(item, pcp, unitWork);
                //        }
                //    }
                //}
                ret = unitWork.Commit();
                return(ret.Result == ResultCode.Successful);
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                return(false);
            }
        }
Exemplo n.º 10
0
        private void InitSystemParameters()
        {
            AppSettings.CurrentSetting = new AppSettings(Application.StartupPath + @"\PreferentialSystem.exe.config");
            SysParaSettingsBll ssb = new SysParaSettingsBll(AppSettings.CurrentSetting.AvailableParkConnect);

            UserSetting.Current           = ssb.GetOrCreateSetting <UserSetting>();
            PREWorkstationSetting.Current = ssb.GetOrCreateSetting <PREWorkstationSetting>();
            PRESysOptionSetting.Current   = ssb.GetOrCreateSetting <PRESysOptionSetting>();
            //从本地获取当前工作站
            string temp = AppSettings.CurrentSetting.GetConfigContent("CurrentWorkstationID");
            Guid   guidValue;

            if (Guid.TryParse(temp, out guidValue) && guidValue != null)
            {
                PRESysOptionSetting.Current.PRESysOption.CurrentWorkstationID = guidValue;
                temp = AppSettings.CurrentSetting.GetConfigContent("CurrentWorkstation");
                PRESysOptionSetting.Current.PRESysOption.CurrentWorkstation = temp;
            }
        }
Exemplo n.º 11
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                AppSettings.CurrentSetting.TicketReaderCOMPort = this.comTicketReader.ComPort;

                PRESysOptionSetting pss = PRESysOptionSetting.Current;

                Guid   currentWorkstationID = Guid.Empty;
                string currentWorkstation   = string.Empty;
                if (this.cmbWorkstations.SelectedItem != null)
                {
                    currentWorkstationID = (this.cmbWorkstations.SelectedItem as PREWorkstation).WorkstationID;
                    currentWorkstation   = (this.cmbWorkstations.SelectedItem as PREWorkstation).WorkstationName;
                }
                byte isAllowDeHour = this.chkAllowDefine.Checked == true ? (byte)1 : (byte)0;
                int  maxHour       = 0;
                try
                {
                    maxHour = Convert.ToInt32(this.txtMaxHour.Text);
                }
                catch { }
                //当前工作站保存到本地
                AppSettings.CurrentSetting.SaveConfig("CurrentWorkstationID", currentWorkstationID != null ? currentWorkstationID.ToString() : string.Empty);
                AppSettings.CurrentSetting.SaveConfig("CurrentWorkstation", currentWorkstation);

                pss.PRESysOption = new PRESysOption {
                    CurrentWorkstationID = currentWorkstationID, CurrentWorkstation = currentWorkstation, IsAllowDefineHour = isAllowDeHour, MaxHour = maxHour
                };
                SysParaSettingsBll bll    = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect);
                CommandResult      result = bll.SaveSetting <PRESysOptionSetting>(pss, "PRESysOptionSetting");
                if (result.Result == ResultCode.Successful)
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show(result.Message);
                }
            }
        }
Exemplo n.º 12
0
 public static ETCSetting GetSetting()
 {
     try
     {
         if (_CurSetting == null)
         {
             var items = ETCDevice.GetAllDevices();
             if (items != null && items.Length > 0)
             {
                 _CurSetting         = new ETCSetting();
                 _CurSetting.Devices = new List <ETCDeviceInfo>();
                 _CurSetting.Devices.AddRange(items);
                 var original = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect).GetSetting <ETCSetting>();
                 if (original != null && original.Devices != null)
                 {
                     if (original.ReadSameCardInterval > 0)
                     {
                         _CurSetting.ReadSameCardInterval = original.ReadSameCardInterval;
                     }
                     foreach (var item in items)
                     {
                         var o = original.Devices.SingleOrDefault(it => it.LaneNo == item.LaneNo);
                         item.EntranceID    = o != null ? o.EntranceID : 0;
                         item.DisableReader = o != null ? o.DisableReader : true;
                         item.DisableRSU    = o != null ? o.DisableRSU : true;
                     }
                 }
             }
             else
             {
                 _CurSetting = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect).GetSetting <ETCSetting>();
             }
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     return(_CurSetting);
 }
Exemplo n.º 13
0
        /// <summary>
        /// 通过权限组名称获取权限组ID,权限组名称为空时表示所有权限,返回0,没有找到的返回-1
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private int GetAccessID(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(0);
            }

            SysParaSettingsBll sbll          = new SysParaSettingsBll(AppConifg.Current.ParkingConnection);
            AccessSetting      accessSetting = sbll.GetOrCreateSetting <AccessSetting>();
            AccessInfo         access        = null;

            if (accessSetting.Accesses != null)
            {
                access = accessSetting.Accesses.FirstOrDefault(item => item.Name == name);
            }
            if (access != null)
            {
                return(access.ID);
            }

            return(-1);
        }
Exemplo n.º 14
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            //初始化系统设置

            SysParaSettingsBll ssb = new SysParaSettingsBll(AppSettings.CurrentSetting.AvailableParkConnect);

            //UserSetting.Current = ssb.GetOrCreateSetting<UserSetting>();
            //HolidaySetting.Current = ssb.GetOrCreateSetting<HolidaySetting>();
            //AccessSetting.Current = ssb.GetOrCreateSetting<AccessSetting>();
            //TariffSetting.Current = ssb.GetOrCreateSetting<TariffSetting>();
            CarTypeSetting.Current = ssb.GetOrCreateSetting <CarTypeSetting>();
            //CustomCardTypeSetting.Current = ssb.GetOrCreateSetting<CustomCardTypeSetting>();
            //BaseCardTypeSetting.Current = ssb.GetOrCreateSetting<BaseCardTypeSetting>();
            //KeySetting.Current = ssb.GetOrCreateSetting<KeySetting>();

            //GlobalVariables.SetCardReaderKeysetting();

            this.ucCard1.Init();
            this.ucCard1.UseToShow();

            ClearCardFeePayInterface();
            this.cbbPayMode.SelectedIndex = 0;
        }
Exemplo n.º 15
0
        private void btnDownLoad_Click(object sender, EventArgs e)
        {
            FrmDownLoadBase    frm = null;
            SysParaSettingsBll ssb = new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect);

            if (CheckTariffInput())
            {
                TariffSetting.Current = GetTariffSettingFromInput();
                ssb.SaveSetting <TariffSetting>(TariffSetting.Current);
                foreach (IParkingAdapter ad in ParkingAdapterManager.Instance.ParkAdapters)
                {
                    ad.DownloadTariffSetting(TariffSetting.Current);
                }

                frm = new FrmDownLoadTariffSetting();
            }


            if (frm != null)
            {
                frm.ParkID = ParkID;
                frm.ShowDialog();
            }
        }
Exemplo n.º 16
0
        /// <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));
            }
        }
Exemplo n.º 17
0
        /// <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));
            }
        }
Exemplo n.º 18
0
 private void FrmSystemOptions_Load(object sender, EventArgs e)
 {
     UserSettings.Current = SysParaSettingsBll.GetOrCreateSetting <UserSettings>(AppSettings.Current.ConnStr);
     ShowSetting(UserSettings.Current);
     btnOk.Enabled = Operator.Current.Permit(Permission.SystemOptions, PermissionActions.Edit);
 }
Exemplo n.º 19
0
        private void InitOpenCardServices(object obj)
        {
            OpenCardMessageHandler handler = new OpenCardMessageHandler();

            GlobalSettings.Current.Set <OpenCardMessageHandler>(handler);
            GlobalSettings.Current.Set <Dictionary <int, CardEventReport> >(new Dictionary <int, CardEventReport>());
            handler.Debug       = this.chkDebug.Checked;
            handler.OnReadCard += new EventHandler <OpenCardEventArgs>(handler_OnReadCard);
            handler.OnPaying   += new EventHandler <OpenCardEventArgs>(handler_OnPaying);
            handler.OnPaidOk   += new EventHandler <OpenCardEventArgs>(handler_OnPaidOk);
            handler.OnPaidFail += new EventHandler <OpenCardEventArgs>(handler_OnPaidFail);
            handler.OnError    += new EventHandler <OpenCardEventArgs>(handler_OnError);

            SysParaSettingsBll ssb  = new SysParaSettingsBll(AppSettings.CurrentSetting.AvailableParkConnect);
            string             temp = AppSettings.CurrentSetting.GetConfigContent("EnableZST");
            bool enabled            = false;

            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                ZSTSettings zst = ssb.GetSetting <ZSTSettings>();
                if (zst != null)
                {
                    handler.InitService(zst);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableYiTingShanFu");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                YiTingShanFuSetting yt = ssb.GetSetting <YiTingShanFuSetting>();
                if (yt != null)
                {
                    AppSettings.CurrentSetting.GetYiTingConfig(yt);
                    handler.InitService(yt);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableYCT");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                YCTSetting yct = ssb.GetSetting <YCTSetting>();
                if (yct != null)
                {
                    handler.InitService(yct);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableETC");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                ETCSetting etc = ETCSetting.GetSetting();
                if (etc != null)
                {
                    handler.InitService(etc);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableLR280");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                Ralid.OpenCard.OpenCardService.LR280.LR280Setting lr280 = ssb.GetSetting <OpenCardService.LR280.LR280Setting>();
                if (lr280 != null)
                {
                    handler.InitService(lr280);
                }
            }
            this.Invoke((Action)(() => { ShowServiceState(); }));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 同步系统设置
        /// </summary>
        private bool SyncSystemOptions()
        {
            NotifyMsg(Resources.Resource1.FrmSyncDataToStandby_SynchronizingOptions);
            NotifyProgress(8, 0);

            bool          success = true;
            CommandResult result  = null;

            SysParaSettingsBll masterssb  = new SysParaSettingsBll(AppSettings.CurrentSetting.CurrentMasterConnect);
            SysParaSettingsBll standbyssb = new SysParaSettingsBll(AppSettings.CurrentSetting.CurrentStandbyConnect);

            UserSetting us = masterssb.GetSetting <UserSetting>();

            success = us != null ? success : false;
            if (us != null)
            {
                result  = standbyssb.SaveSetting <UserSetting>(us);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (us != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_UserSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_UserSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            HolidaySetting hs = masterssb.GetSetting <HolidaySetting>();

            success = hs != null ? success : false;
            if (hs != null)
            {
                result  = standbyssb.SaveSetting <HolidaySetting>(hs);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (hs != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_HolidaySetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_HolidaySetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            AccessSetting acs = masterssb.GetSetting <AccessSetting>();

            success = acs != null ? success : false;
            if (acs != null)
            {
                result  = standbyssb.SaveSetting <AccessSetting>(acs);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (acs != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_AccessSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_AccessSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            TariffSetting ts = masterssb.GetSetting <TariffSetting>();

            success = ts != null ? success : false;
            if (ts != null)
            {
                result  = standbyssb.SaveSetting <TariffSetting>(ts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (ts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_TariffSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_TariffSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            CarTypeSetting cts = masterssb.GetSetting <CarTypeSetting>();

            success = cts != null ? success : false;
            if (cts != null)
            {
                result  = standbyssb.SaveSetting <CarTypeSetting>(cts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (cts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CarTypeSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CarTypeSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            CustomCardTypeSetting ccts = masterssb.GetSetting <CustomCardTypeSetting>();

            success = ccts != null ? success : false;
            if (ccts != null)
            {
                result  = standbyssb.SaveSetting <CustomCardTypeSetting>(ccts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (ccts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CustomCardTypeSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CustomCardTypeSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            BaseCardTypeSetting bcts = masterssb.GetSetting <BaseCardTypeSetting>();

            success = bcts != null ? success : false;
            if (bcts != null)
            {
                result  = standbyssb.SaveSetting <BaseCardTypeSetting>(bcts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (bcts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_BaseCardTypeSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_BaseCardTypeSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            KeySetting ks = masterssb.GetSetting <KeySetting>();

            success = ks != null ? success : false;
            if (ks != null)
            {
                result  = standbyssb.SaveSetting <KeySetting>(ks);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (ks != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_KeySetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_KeySetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            NotifyMsg(Resources.Resource1.FrmSyncDataToStandby_OptionsFinish);

            return(success);
        }
Exemplo n.º 21
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     UserSettings.Current = GetSettingFromInput();
     SysParaSettingsBll.SaveSetting <UserSettings>(UserSettings.Current, AppSettings.Current.ConnStr);
     this.Close();
 }