Exemple #1
0
        protected virtual async Task <ListResultDto <SettingGroupDto> > GetAllForProviderAsync(string providerName, string providerKey)
        {
            var settingGroups = new List <SettingGroupDto>();

            // 无权限返回空结果,直接报错的话,网关聚合会抛出异常
            if (await PermissionChecker.IsGrantedAsync(AbpOssManagementPermissions.OssObject.Default))
            {
                var ossSettingGroup = new SettingGroupDto(L["DisplayName:OssManagement"], L["Description:OssManagement"]);

                var ossObjectSetting = ossSettingGroup.AddSetting(L["DisplayName:OssObject"], L["Description:OssObject"]);

                ossObjectSetting.AddDetail(
                    SettingDefinitionManager.Get(AbpOssManagementSettingNames.FileLimitLength),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AbpOssManagementSettingNames.FileLimitLength, providerName, providerKey),
                    ValueType.Number);
                ossObjectSetting.AddDetail(
                    SettingDefinitionManager.Get(AbpOssManagementSettingNames.AllowFileExtensions),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AbpOssManagementSettingNames.AllowFileExtensions, providerName, providerKey),
                    ValueType.String);

                settingGroups.Add(ossSettingGroup);
            }

            return(new ListResultDto <SettingGroupDto>(settingGroups));
        }
Exemple #2
0
        protected virtual async Task <ListResultDto <SettingGroupDto> > GetAllForProviderAsync(string providerName, string providerKey)
        {
            var settingGroups      = new List <SettingGroupDto>();
            var wechatSettingGroup = new SettingGroupDto(L["DisplayName:WeChat"], L["Description:WeChat"]);

            // 无权限返回空结果,直接报错的话,网关聚合会抛出异常
            if (await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.Official))
            {
                #region 公众号

                var officialSetting = wechatSettingGroup.AddSetting(L["DisplayName:WeChat.Official"], L["Description:WeChat.Official"]);
                officialSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatOfficialSettingNames.AppId),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatOfficialSettingNames.AppId, providerName, providerKey),
                    ValueType.String);
                officialSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatOfficialSettingNames.AppSecret),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatOfficialSettingNames.AppSecret, providerName, providerKey),
                    ValueType.String);
                officialSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatOfficialSettingNames.Url),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatOfficialSettingNames.Url, providerName, providerKey),
                    ValueType.String);
                officialSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatOfficialSettingNames.Token),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatOfficialSettingNames.Token, providerName, providerKey),
                    ValueType.String);
                officialSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatOfficialSettingNames.EncodingAESKey),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatOfficialSettingNames.EncodingAESKey, providerName, providerKey),
                    ValueType.String);

                #endregion
            }

            if (await PermissionChecker.IsGrantedAsync(WeChatSettingPermissionNames.MiniProgram))
            {
                #region 小程序

                var miniProgramSetting = wechatSettingGroup.AddSetting(L["DisplayName:WeChat.MiniProgram"], L["Description:WeChat.MiniProgram"]);
                miniProgramSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatMiniProgramSettingNames.AppId),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatMiniProgramSettingNames.AppId, providerName, providerKey),
                    ValueType.String);
                miniProgramSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatMiniProgramSettingNames.AppSecret),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatMiniProgramSettingNames.AppSecret, providerName, providerKey),
                    ValueType.String);
                miniProgramSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatMiniProgramSettingNames.Token),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatMiniProgramSettingNames.Token, providerName, providerKey),
                    ValueType.String);
                miniProgramSetting.AddDetail(
                    SettingDefinitionManager.Get(WeChatMiniProgramSettingNames.EncodingAESKey),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(WeChatMiniProgramSettingNames.EncodingAESKey, providerName, providerKey),
                    ValueType.String);

                #endregion
            }

            settingGroups.Add(wechatSettingGroup);
            return(new ListResultDto <SettingGroupDto>(settingGroups));
        }
        protected virtual async Task <ListResultDto <SettingGroupDto> > GetAllForProviderAsync(string providerName, string providerKey)
        {
            var settingGroups = new List <SettingGroupDto>();

            // 无权限返回空结果,直接报错的话,网关聚合会抛出异常
            if (await PermissionChecker.IsGrantedAsync(AliyunSettingPermissionNames.Settings))
            {
                var aliyunSettingGroup = new SettingGroupDto(L["DisplayName:Aliyun"], L["Description:Aliyun"]);
                #region 访问控制

                var ramSetting = aliyunSettingGroup.AddSetting(L["DisplayName:Aliyun.RAM"], L["Description:Aliyun.RAM"]);

                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.RegionId),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.RegionId, providerName, providerKey),
                    ValueType.String);
                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.AccessKeyId),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.AccessKeyId, providerName, providerKey),
                    ValueType.String);
                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.AccessKeySecret),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.AccessKeySecret, providerName, providerKey),
                    ValueType.String);
                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.RamRoleArn),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.RamRoleArn, providerName, providerKey),
                    ValueType.String);
                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.RoleSessionName),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.RoleSessionName, providerName, providerKey),
                    ValueType.String);
                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.Policy),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.Policy, providerName, providerKey),
                    ValueType.String);
                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.UseSecurityTokenService),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.UseSecurityTokenService, providerName, providerKey),
                    ValueType.Boolean);
                ramSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSettingNames.Authorization.DurationSeconds),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSettingNames.Authorization.DurationSeconds, providerName, providerKey),
                    ValueType.Number);

                #endregion

                #region 短信

                var smsSetting = aliyunSettingGroup.AddSetting(L["DisplayName:Aliyun.Sms"], L["Description:Aliyun.Sms"]);
                smsSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.Domain),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.Domain, providerName, providerKey),
                    ValueType.String);
                smsSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.Version),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.Version, providerName, providerKey),
                    ValueType.String);
                smsSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.ActionName),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.ActionName, providerName, providerKey),
                    ValueType.String);
                smsSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.DefaultPhoneNumber),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultPhoneNumber, providerName, providerKey),
                    ValueType.String);
                smsSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.DefaultSignName),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultSignName, providerName, providerKey),
                    ValueType.String);
                smsSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.DefaultTemplateCode),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultTemplateCode, providerName, providerKey),
                    ValueType.String);
                smsSetting.AddDetail(
                    SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.VisableErrorToClient),
                    StringLocalizerFactory,
                    await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.VisableErrorToClient, providerName, providerKey),
                    ValueType.Boolean);

                #endregion

                settingGroups.Add(aliyunSettingGroup);
            }

            return(new ListResultDto <SettingGroupDto>(settingGroups));
        }