Пример #1
0
        /// <summary>
        /// btnSubmit click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            IList <EyouSoft.Model.SmsStructure.MSmsPriceInfo> items = new List <EyouSoft.Model.SmsStructure.MSmsPriceInfo>();

            #region get and validate form values
            string[] channels = Utils.GetFormValues("txtChannel");
            string[] prices   = Utils.GetFormValues("txtPrice");

            if (channels == null || channels.Length == 0 || prices == null || prices.Length == 0 || channels.Length != prices.Length)
            {
                RegisterAlertAndReloadScript("表单提交数据错误。");
                return;
            }

            IList <int> _exists  = new List <int>();
            bool        isexists = false;
            for (int i = 0; i < channels.Length; i++)
            {
                var item = new EyouSoft.Model.SmsStructure.MSmsPriceInfo();
                item.ChannelIndex = Utils.GetInt(channels[i]);
                item.Price        = Utils.GetDecimal(prices[i]);

                if (item.Price <= 0)
                {
                    item.Price = 0.1M;
                }

                items.Add(item);

                if (_exists.Contains(item.ChannelIndex))
                {
                    isexists = true; break;
                }

                _exists.Add(item.ChannelIndex);
            }

            if (items.Count == 0)
            {
                RegisterAlertAndReloadScript("表单提交数据错误(未提交任何通道价格信息)。");
                return;
            }

            if (isexists)
            {
                RegisterAlertAndReloadScript("表单提交数据错误(通道有重复)。");
                return;
            }
            #endregion

            if (new EyouSoft.BLL.SmsStructure.BSmsAccount().SetSmsPrices(CompanyId, items))
            {
                this.RegisterAlertAndReloadScript("短信通道价格设置成功");
            }
            else
            {
                this.RegisterAlertAndReloadScript("短信通道价格设置失败");
            }
        }
Пример #2
0
        /// <summary>
        /// 获取短信账户信息
        /// </summary>
        /// <param name="companyId">公司编号</param>
        /// <returns></returns>
        public EyouSoft.Model.SmsStructure.MSmsAccountInfo GetAccountInfo(string companyId)
        {
            if (string.IsNullOrEmpty(companyId))
            {
                return(null);
            }
            var setting = new EyouSoft.BLL.ComStructure.BComSetting().GetModel(companyId);

            if (setting == null || setting.SmsConfig == null || !setting.SmsConfig.IsEnabled)
            {
                return(null);
            }

            var api = GetSmsCenterApi();

            var account = new EyouSoft.BLL.SmsCenter.MSmsAccountBase();

            account.AccountId = setting.SmsConfig.Account;
            account.AppKey    = setting.SmsConfig.AppKey;
            account.AppSecret = setting.SmsConfig.AppSecret;

            var apiRetInfo = api.GetSmsAccount(account);

            if (apiRetInfo != null)
            {
                var info = new EyouSoft.Model.SmsStructure.MSmsAccountInfo();

                info.Account   = apiRetInfo.AccountId;
                info.AppKey    = apiRetInfo.AppKey;
                info.AppSecret = apiRetInfo.AppSecret;
                info.YuE       = apiRetInfo.Amount;


                if (apiRetInfo.SmsUnitPrice != null && apiRetInfo.SmsUnitPrice.Length > 0)
                {
                    info.Prices = new List <EyouSoft.Model.SmsStructure.MSmsPriceInfo>();
                    foreach (var item in apiRetInfo.SmsUnitPrice)
                    {
                        var tmp = new EyouSoft.Model.SmsStructure.MSmsPriceInfo();
                        tmp.ChannelIndex = (int)item.Cnannel;
                        tmp.Price        = item.Price;
                        tmp.ChannelName  = item.Name;

                        info.Prices.Add(tmp);
                    }
                }

                return(info);
            }

            return(null);
        }