Пример #1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var mobile = TbMobile.Text;

            if (StringUtils.IsMobile(mobile))
            {
                var errorMessage = string.Empty;
                var isSuccess    = false;
                if (_providerType == ESmsProviderType.AliDaYu)
                {
                    if (_templateType == ESmsTemplateType.Code)
                    {
                        isSuccess = SmsManager.SendCodeByAliDaYu(mobile, 6856, out errorMessage);
                    }
                }
                else if (_providerType == ESmsProviderType.YunPian)
                {
                    if (_templateType == ESmsTemplateType.Code)
                    {
                        isSuccess = SmsManager.SendCodeByYunPian(mobile, 6856, out errorMessage);
                    }
                }

                if (isSuccess)
                {
                    SuccessMessage("短信发送成功!");
                    isChanged = true;
                }
                else
                {
                    FailMessage("短信发送失败:" + errorMessage + "!");
                }
            }

            if (!isChanged)
            {
                return;
            }

            PageUtils.CloseModalPageAndRedirect(Page, PageSmsTemplates.GetRedirectUrl(_providerType));
        }
Пример #2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                var tplId = this.TbTplId.Text;
                if (_templateType == ESmsTemplateType.Code)
                {
                    if (_providerType == ESmsProviderType.AliDaYu)
                    {
                        ConfigManager.SystemConfigInfo.SmsAliDaYuCodeTplId = tplId;
                    }
                    else if (_providerType == ESmsProviderType.YunPian)
                    {
                        ConfigManager.SystemConfigInfo.SmsYunPianCodeTplId = tplId;
                    }
                }
                BaiRongDataProvider.ConfigDao.Update(ConfigManager.Instance);

                Body.AddAdminLog("设置短信模板");

                SuccessMessage("短信模板设置成功!");
                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, "短信模板设置失败!");
            }

            if (!isChanged)
            {
                return;
            }

            PageUtils.CloseModalPageAndRedirect(Page, PageSmsTemplates.GetRedirectUrl(_providerType));
        }
Пример #3
0
        private void rptInstalled_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var providerType = (ESmsProviderType)e.Item.DataItem;

                var isEnabled = false;
                if (providerType == ESmsProviderType.AliDaYu)
                {
                    isEnabled = ConfigManager.SystemConfigInfo.IsSmsAliDaYu;
                }
                else if (providerType == ESmsProviderType.YunPian)
                {
                    isEnabled = ConfigManager.SystemConfigInfo.IsSmsYunPian;
                }

                var ltlName         = e.Item.FindControl("ltlName") as Literal;
                var ltlIsEnabled    = e.Item.FindControl("ltlIsEnabled") as Literal;
                var ltlTemplates    = e.Item.FindControl("ltlTemplates") as Literal;
                var ltlConfigUrl    = e.Item.FindControl("ltlConfigUrl") as Literal;
                var ltlIsEnabledUrl = e.Item.FindControl("ltlIsEnabledUrl") as Literal;

                if (ltlName != null)
                {
                    ltlName.Text = $@"{ESmsProviderTypeUtils.GetText(providerType)}(<a href=""{ESmsProviderTypeUtils.GetUrl(providerType)}"" target=""_blank"">{ESmsProviderTypeUtils.GetUrl(providerType)}</a>)";
                }
                if (ltlIsEnabled != null)
                {
                    ltlIsEnabled.Text = StringUtils.GetTrueOrFalseImageHtml(isEnabled);
                }

                if (isEnabled)
                {
                    var urlConfig  = string.Empty;
                    var isConfig   = false;
                    var isTemplate = false;
                    if (providerType == ESmsProviderType.AliDaYu)
                    {
                        urlConfig = PageSmsProviderAliDaYu.GetRedirectUrl();
                        isConfig  = !string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.SmsAliDaYuAppKey) &&
                                    !string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.SmsAliDaYuAppSecret) &&
                                    !string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.SmsAliDaYuSignName);
                        isTemplate = !string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.SmsAliDaYuCodeTplId);
                    }
                    else if (providerType == ESmsProviderType.YunPian)
                    {
                        urlConfig  = PageSmsProviderYunPian.GetRedirectUrl();
                        isConfig   = !string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.SmsYunPianApiKey);
                        isTemplate = !string.IsNullOrEmpty(ConfigManager.SystemConfigInfo.SmsYunPianCodeTplId);
                    }
                    if (ltlConfigUrl != null)
                    {
                        ltlConfigUrl.Text = isConfig ? $@"<a href=""{urlConfig}"">设置</a>" : $@"<a href=""{urlConfig}"" style=""color:red"">设置</a>";
                    }
                    if (ltlTemplates != null)
                    {
                        ltlTemplates.Text = isTemplate ? $@"<a href=""{PageSmsTemplates.GetRedirectUrl(providerType)}"">短信模板管理</a>" : $@"<a href=""{PageSmsTemplates.GetRedirectUrl(providerType)}"" style=""color:red"">短信模板管理</a>";
                    }
                }

                var urlIsEnabled = GetRedirectUrl() + $"?isEnabled=True&providerType={ESmsProviderTypeUtils.GetValue(providerType)}";
                var action       = isEnabled ? "禁用" : "启用";
                if (ltlIsEnabledUrl != null)
                {
                    ltlIsEnabledUrl.Text = $@"<a href=""{urlIsEnabled}"">{action}</a>";
                }
            }
        }