Пример #1
0
 public static string GetRedirectUrl(ESmsProviderType providerType)
 {
     return(PageUtils.GetSettingsUrl(nameof(PageSmsTemplates), new NameValueCollection
     {
         { "providerType", ESmsProviderTypeUtils.GetValue(providerType) }
     }));
 }
Пример #2
0
 public static string GetOpenWindowStringToEdit(ESmsProviderType providerType, ESmsTemplateType templateType)
 {
     return(PageUtils.GetOpenWindowString("设置短信模板", PageUtils.GetSettingsUrl(nameof(ModalSmsTemplateAdd), new NameValueCollection
     {
         { "providerType", ESmsProviderTypeUtils.GetValue(providerType) },
         { "templateType", ESmsTemplateTypeUtils.GetValue(templateType) }
     }), 460, 360));
 }
Пример #3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }
            if (IsPostBack)
            {
                return;
            }

            BreadCrumbSettings(AppManager.Settings.LeftMenu.Config, "短信服务商设置", AppManager.Settings.Permission.SettingsConfig);

            ESmsProviderTypeUtils.AddListItems(DdlProviderType);
            ControlUtils.SelectListItemsIgnoreCase(DdlProviderType, ESmsProviderTypeUtils.GetValue(ConfigManager.SystemConfigInfo.SmsProviderType));

            TbAppKey.Text    = ConfigManager.SystemConfigInfo.SmsAppKey;
            TbAppSecret.Text = ConfigManager.SystemConfigInfo.SmsAppSecret;
            TbSignName.Text  = ConfigManager.SystemConfigInfo.SmsSignName;

            DdlProviderType_SelectedIndexChanged(null, EventArgs.Empty);
        }
Пример #4
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>";
                }
            }
        }