/// <summary>
 ///     Changes setting for a Tenant.
 /// </summary>
 /// <param name="settingManager">Setting manager</param>
 /// <param name="tenantId">TenantId</param>
 /// <param name="name">Unique name of the setting</param>
 /// <param name="value">Value of the setting</param>
 public static void ChangeSettingForTenant <TTenantId, TUserId>(
     this ISettingManager <TTenantId, TUserId> settingManager, TTenantId tenantId, string name, string value)
     where TTenantId : struct
     where TUserId : struct
 {
     AsyncHelper.RunSync(() => settingManager.ChangeSettingForTenantAsync(tenantId, name, value));
 }
Esempio n. 2
0
 public async Task SetMaxUserMembershipCountAsync(int?tenantId, int value)
 {
     if (tenantId.HasValue)
     {
         await _settingManager.ChangeSettingForTenantAsync(tenantId.Value, HozaruIdentitySettingNames.OrganizationUnits.MaxUserMembershipCount, value.ToString());
     }
     else
     {
         await _settingManager.ChangeSettingForApplicationAsync(HozaruIdentitySettingNames.OrganizationUnits.MaxUserMembershipCount, value.ToString());
     }
 }
 /// <summary>
 /// Changes setting for tenant with fallback to application
 /// </summary>
 /// <param name="name">Setting name</param>
 /// <param name="value">Setting value</param>
 protected async Task ChangeSettingAsync(string name, string value)
 {
     // todo: move to IShaProjectNameSettings
     if (AbpSession.TenantId.HasValue)
     {
         await _settingManager.ChangeSettingForTenantAsync(AbpSession.TenantId.Value, name, value);
     }
     else
     {
         await _settingManager.ChangeSettingForApplicationAsync(name, value);
     }
 }
        /// <summary>
        /// Sets the default language for a tenant or the host.
        /// </summary>
        /// <param name="tenantId">Tenant Id of null for host</param>
        /// <param name="languageName">Name of the language.</param>
        public virtual async Task SetDefaultLanguageAsync(int?tenantId, string languageName)
        {
            var cultureInfo = CultureInfoHelper.Get(languageName);

            if (tenantId.HasValue)
            {
                await _settingManager.ChangeSettingForTenantAsync(tenantId.Value, LocalizationSettingNames.DefaultLanguage, cultureInfo.Name);
            }
            else
            {
                await _settingManager.ChangeSettingForApplicationAsync(LocalizationSettingNames.DefaultLanguage, cultureInfo.Name);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Changes setting for tenant with fallback to application
        /// </summary>
        /// <param name="name">Setting name</param>
        /// <param name="value">Setting value</param>
        public static async Task ChangeSettingAsync(this ISettingManager manager, string name, string value)
        {
            var session = StaticContext.IocManager.Resolve <IAbpSession>();

            if (session.TenantId.HasValue)
            {
                await manager.ChangeSettingForTenantAsync(session.TenantId.Value, name, value);
            }
            else
            {
                await manager.ChangeSettingForApplicationAsync(name, value);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Changes setting for a Tenant.
 /// </summary>
 /// <param name="settingManager">Setting manager</param>
 /// <param name="tenantId">TenantId</param>
 /// <param name="name">Unique name of the setting</param>
 /// <param name="value">Value of the setting</param>
 public static void ChangeSettingForTenant(this ISettingManager settingManager, int tenantId, string name, string value)
 {
     AsyncHelper.RunSync(() => settingManager.ChangeSettingForTenantAsync(tenantId, name, value));
 }
 protected async Task ChangeSettingForTenantAsync(int tenantId, string name, string value)
 {
     await SettingManager.ChangeSettingForTenantAsync(tenantId, ThemeName + "." + name, value);
 }
        public async Task UpdateAllSettings(TenantSettingsEditDto input)
        {
            string          domain;
            string          userName;
            string          password;
            ISettingManager settingManager        = this.SettingManager;
            int             tenantId              = this.AbpSession.GetTenantId();
            bool            allowSelfRegistration = input.UserManagement.AllowSelfRegistration;
            await settingManager.ChangeSettingForTenantAsync(tenantId, "App.UserManagement.AllowSelfRegistration", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            ISettingManager settingManager1 = this.SettingManager;
            int             num             = this.AbpSession.GetTenantId();

            allowSelfRegistration = input.UserManagement.IsNewRegisteredUserActiveByDefault;
            await settingManager1.ChangeSettingForTenantAsync(num, "App.UserManagement.IsNewRegisteredUserActiveByDefault", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            ISettingManager settingManager2 = this.SettingManager;
            int             tenantId1       = this.AbpSession.GetTenantId();

            allowSelfRegistration = input.UserManagement.IsEmailConfirmationRequiredForLogin;
            await settingManager2.ChangeSettingForTenantAsync(tenantId1, "Abp.Zero.UserManagement.IsEmailConfirmationRequiredForLogin", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            ISettingManager settingManager3 = this.SettingManager;
            int             num1            = this.AbpSession.GetTenantId();

            allowSelfRegistration = input.UserManagement.UseCaptchaOnRegistration;
            await settingManager3.ChangeSettingForTenantAsync(num1, "App.UserManagement.UseCaptchaOnRegistration", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            ISettingManager settingManager4 = this.SettingManager;
            int             tenantId2       = this.AbpSession.GetTenantId();

            allowSelfRegistration = input.UserManagement.RequireOnePhoneNumberForRegistration;
            await settingManager4.ChangeSettingForTenantAsync(tenantId2, "App.UserManagement.RequireOnePhoneNumberForRegistration", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            ISettingManager settingManager5 = this.SettingManager;
            int             num2            = this.AbpSession.GetTenantId();

            allowSelfRegistration = input.UserManagement.SendEmailAfterRegistration;
            await settingManager5.ChangeSettingForTenantAsync(num2, "App.UserManagement.SendEmailAfterRegistration", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            await this.SettingManager.ChangeSettingForTenantAsync(this.AbpSession.GetTenantId(), "App.UserManagement.SendEmailAfterRegistrationMessage", input.UserManagement.SendEmailAfterRegistrationMessage.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            ISettingManager settingManager6 = this.SettingManager;
            int             tenantId3       = this.AbpSession.GetTenantId();

            allowSelfRegistration = input.UserManagement.EnableEmergencyDeliveryFees;
            await settingManager6.ChangeSettingForTenantAsync(tenantId3, "App.UserManagment.EnableEmergencyDeliveryFees", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

            if (!this._multiTenancyConfig.IsEnabled)
            {
                input.ValidateHostSettings();
                await this.SettingManager.ChangeSettingForApplicationAsync("App.General.WebSiteRootAddress", input.General.WebSiteRootAddress.EnsureEndsWith('/'));

                await this.SettingManager.ChangeSettingForApplicationAsync("Abp.Net.Mail.DefaultFromAddress", input.Email.DefaultFromAddress);

                await this.SettingManager.ChangeSettingForApplicationAsync("Abp.Net.Mail.DefaultFromDisplayName", input.Email.DefaultFromDisplayName);

                await this.SettingManager.ChangeSettingForApplicationAsync("Abp.Net.Mail.Smtp.Host", input.Email.SmtpHost);

                ISettingManager settingManager7 = this.SettingManager;
                int             smtpPort        = input.Email.SmtpPort;
                await settingManager7.ChangeSettingForApplicationAsync("Abp.Net.Mail.Smtp.Port", smtpPort.ToString(CultureInfo.InvariantCulture));

                await this.SettingManager.ChangeSettingForApplicationAsync("Abp.Net.Mail.Smtp.UserName", input.Email.SmtpUserName);

                await this.SettingManager.ChangeSettingForApplicationAsync("Abp.Net.Mail.Smtp.Password", input.Email.SmtpPassword);

                await this.SettingManager.ChangeSettingForApplicationAsync("Abp.Net.Mail.Smtp.Domain", input.Email.SmtpDomain);

                ISettingManager settingManager8 = this.SettingManager;
                allowSelfRegistration = input.Email.SmtpEnableSsl;
                await settingManager8.ChangeSettingForApplicationAsync("Abp.Net.Mail.Smtp.EnableSsl", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

                ISettingManager settingManager9 = this.SettingManager;
                allowSelfRegistration = input.Email.SmtpUseDefaultCredentials;
                await settingManager9.ChangeSettingForApplicationAsync("Abp.Net.Mail.Smtp.UseDefaultCredentials", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

                if (this._ldapModuleConfig.IsEnabled)
                {
                    ISettingManager settingManager10 = this.SettingManager;
                    int             num3             = this.AbpSession.GetTenantId();
                    allowSelfRegistration = input.Ldap.IsEnabled;
                    await settingManager10.ChangeSettingForTenantAsync(num3, "Abp.Zero.Ldap.IsEnabled", allowSelfRegistration.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));

                    ISettingManager settingManager11 = this.SettingManager;
                    int             tenantId4        = this.AbpSession.GetTenantId();
                    if (input.Ldap.Domain.IsNullOrWhiteSpace())
                    {
                        domain = null;
                    }
                    else
                    {
                        domain = input.Ldap.Domain;
                    }
                    await settingManager11.ChangeSettingForTenantAsync(tenantId4, "Abp.Zero.Ldap.Domain", domain);

                    ISettingManager settingManager12 = this.SettingManager;
                    int             num4             = this.AbpSession.GetTenantId();
                    if (input.Ldap.UserName.IsNullOrWhiteSpace())
                    {
                        userName = null;
                    }
                    else
                    {
                        userName = input.Ldap.UserName;
                    }
                    await settingManager12.ChangeSettingForTenantAsync(num4, "Abp.Zero.Ldap.UserName", userName);

                    ISettingManager settingManager13 = this.SettingManager;
                    int             tenantId5        = this.AbpSession.GetTenantId();
                    if (input.Ldap.Password.IsNullOrWhiteSpace())
                    {
                        password = null;
                    }
                    else
                    {
                        password = input.Ldap.Password;
                    }
                    await settingManager13.ChangeSettingForTenantAsync(tenantId5, "Abp.Zero.Ldap.Password", password);
                }
            }
            if (input.Details != null)
            {
                if (input.Details.TenantId == 0)
                {
                    input.Details.TenantId = this.AbpSession.GetTenantId();
                }
                TenantDetail nullable  = input.Details.MapTo <TenantDetail>();
                double?      longitude = nullable.Longitude;
                if (longitude.HasValue)
                {
                    longitude = nullable.Latitude;
                    if (longitude.HasValue)
                    {
                        goto Label0;
                    }
                }
                string empty = string.Empty;
                if (nullable.CountryRegionId.HasValue)
                {
                    IRepository <CountryRegion> repository = this._countryRegionRepository;
                    int?countryRegionId = nullable.CountryRegionId;
                    empty = (await repository.GetAsync(countryRegionId.Value)).Code;
                }
                string[]  address   = new string[] { nullable.Address, ",", nullable.City, ",", empty, ",", nullable.PostalCode };
                string    str       = string.Concat(address);
                XDocument xDocument = XDocument.Load(WebRequest.Create(string.Format("http://maps.google.com/maps/api/geocode/xml?address={0}&sensor=false", str.Replace(",,", ",").Replace(" ", "+"))).GetResponse().GetResponseStream());
                if (!xDocument.ToString().Contains("<GeocodeResponse>") || xDocument.ToString().Contains("ZERO_RESULTS"))
                {
                    longitude          = null;
                    nullable.Longitude = longitude;
                    longitude          = null;
                    nullable.Latitude  = longitude;
                    nullable.Location  = null;
                }
                else
                {
                    XElement xElement = xDocument.Element("GeocodeResponse").Element("result").Element("geometry").Element("location");
                    nullable.Latitude  = new double?(double.Parse(xElement.Element("lat").Value));
                    nullable.Longitude = new double?(double.Parse(xElement.Element("lng").Value));
                }
                xDocument = null;
Label0:
                TenantDetail tenantDetail = nullable;
                longitude = nullable.Longitude;
                object value = longitude.Value;
                longitude             = nullable.Latitude;
                tenantDetail.Location = DbGeography.PointFromText(string.Format("POINT({0} {1})", value, longitude.Value), 4326);
                await this._tenantDetailRepository.InsertOrUpdateAsync(nullable);

                nullable = null;
            }
            if (input.CustomerService != null)
            {
                if (input.CustomerService.TenantId == 0)
                {
                    input.CustomerService.TenantId = this.AbpSession.GetTenantId();
                }
                await this._tenantCustomerServicesRepository.InsertOrUpdateAsync(input.CustomerService.MapTo <TenantCustomerService>());
            }
            if (input.Hours != null)
            {
                if (input.CustomerService.TenantId == 0)
                {
                    input.CustomerService.TenantId = this.AbpSession.GetTenantId();
                }
                await this._tenantHoursRepository.InsertOrUpdateAsync(input.Hours.MapTo <TenantHour>());
            }
            if (input.Notifications != null)
            {
                input.ValidateEmailLists();
                if (input.Notifications.TenantId == 0)
                {
                    input.Notifications.TenantId = this.AbpSession.GetTenantId();
                }
                await this._tenantNotificationsRepository.InsertOrUpdateAsync(input.Notifications.MapTo <TenantNotifications>());
            }
            if (input.PaymentSettings != null)
            {
                if (input.PaymentSettings.TenantId == 0)
                {
                    input.PaymentSettings.TenantId = this.AbpSession.GetTenantId();
                }
                await this._tenantPaymentSettingsRepository.InsertOrUpdateAsync(input.PaymentSettings.MapTo <TenantPaymentSettings>());
            }
            if (input.PaymentGatewaySettings != null)
            {
                if (input.PaymentGatewaySettings.TenantId == 0)
                {
                    input.PaymentGatewaySettings.TenantId = this.AbpSession.GetTenantId();
                }
                await this._tenantPaymentGatewaySettingsRepository.InsertOrUpdateAsync(input.PaymentGatewaySettings.MapTo <TenantPaymentGatewaySettings>());
            }
            if (input.DateTimeSettings != null)
            {
                if (input.DateTimeSettings.TenantId == 0)
                {
                    input.DateTimeSettings.TenantId = this.AbpSession.GetTenantId();
                }
                await this._tenantDateTimeSettingsRepository.InsertOrUpdateAsync(input.DateTimeSettings.MapTo <TenantDateTimeSettings>());
            }
        }