public void UpdateRegionalSettings(RegionalSettingsConfiguration settings) { this.DateFormat = settings.DateFormat; this.TimeFormat = settings.TimeFormat; base.UserCulture = RoleBasedStringMapping.GetRoleBasedCultureInfo(settings.UserCulture, base.RbacConfiguration.RoleTypes); this.UpdateUserTimeZone(settings.TimeZone); }
private RegionalSettingsConfiguration GetDefaultRegionalSettings(RegionalSettingsConfiguration executingUserSettings) { return(new RegionalSettingsConfiguration(new MailboxRegionalConfiguration { Language = (executingUserSettings.UserCulture ?? Culture.GetDefaultCulture(HttpContext.Current)), TimeZone = executingUserSettings.MailboxRegionalConfiguration.TimeZone })); }
private void WaitingForCmdlet() { if (this.regionalCmdletStatus == LocalSession.RegionalCmdletStatus.Waiting) { this.regionalCmdletStatus = LocalSession.RegionalCmdletStatus.Running; RegionalSettingsConfiguration settings = new RegionalSettingsConfiguration(new MailboxRegionalConfiguration()); RegionalSettings regionalSettings = new RegionalSettings(); PowerShellResults <RegionalSettingsConfiguration> settings2 = regionalSettings.GetSettings(Microsoft.Exchange.Management.ControlPanel.Identity.FromExecutingUserId(), false); if (settings2.SucceededWithValue) { settings = settings2.Value; this.AddRegionalSettingsToCache(settings); this.InitializeRegionalSettings(); } } }
private void InitializeRegionalSettings() { RegionalSettingsConfiguration regionalSettingsConfiguration = null; this.HasRegionalSettings = false; RegionalSettingsConfiguration regionalSettingsConfiguration2 = new RegionalSettingsConfiguration(new MailboxRegionalConfiguration()); if (base.IsInRole("Get-MailboxRegionalConfiguration?Identity@R:Self") && base.IsInRole("!DelegatedAdmin")) { if (HttpRuntime.Cache[this.RegionalCacheKey] != null) { regionalSettingsConfiguration2 = (RegionalSettingsConfiguration)HttpRuntime.Cache[this.RegionalCacheKey]; this.regionalCmdletStatus = LocalSession.RegionalCmdletStatus.Finished; } else { this.regionalCmdletStatus = LocalSession.RegionalCmdletStatus.Waiting; regionalSettingsConfiguration2 = new RegionalSettingsConfiguration(new MailboxRegionalConfiguration { Language = base.UserCulture }); } if (base.IsInRole("MailboxFullAccess")) { regionalSettingsConfiguration = regionalSettingsConfiguration2; this.HasRegionalSettings = (regionalSettingsConfiguration != null && regionalSettingsConfiguration.UserCulture != null); if (this.regionalCmdletStatus == LocalSession.RegionalCmdletStatus.Finished) { this.HasRegionalSettings = (this.HasRegionalSettings && regionalSettingsConfiguration.TimeZone != null); } } } else { this.regionalCmdletStatus = LocalSession.RegionalCmdletStatus.NotNeeded; } bool flag = !this.HasRegionalSettings; HttpContext httpContext = HttpContext.Current; CultureInfo cultureInfo = (regionalSettingsConfiguration == null) ? null : regionalSettingsConfiguration.UserCulture; if (regionalSettingsConfiguration == null || (!this.CanRedirectToOwa(httpContext) && !this.HasRegionalSettings) || (cultureInfo == null && httpContext.TargetServerOrVersionSpecifiedInUrlOrCookie())) { if (regionalSettingsConfiguration != null && cultureInfo == null && regionalSettingsConfiguration.MailboxRegionalConfiguration.Language != null) { EcpEventLogConstants.Tuple_LanguagePackIsNotInstalled.LogEvent(new object[] { EcpEventLogExtensions.GetUserNameToLog(), regionalSettingsConfiguration.MailboxRegionalConfiguration.Language.IetfLanguageTag }); } regionalSettingsConfiguration = this.GetDefaultRegionalSettings(regionalSettingsConfiguration2); this.HasRegionalSettings = true; } string text = httpContext.Request.QueryString["mkt"]; if (flag && string.IsNullOrEmpty(text)) { text = httpContext.Request.QueryString["mkt2"]; } if (!string.IsNullOrEmpty(text)) { httpContext.Response.Cookies.Add(new HttpCookie("mkt", text)); } else { HttpCookie httpCookie = httpContext.Request.Cookies["mkt"]; if (httpCookie != null) { text = httpCookie.Value; } } if (!string.IsNullOrEmpty(text)) { try { CultureInfo cultureInfoByIetfLanguageTag = CultureInfo.GetCultureInfoByIetfLanguageTag(text); if (Culture.IsSupportedCulture(cultureInfoByIetfLanguageTag)) { MailboxRegionalConfiguration mailboxRegionalConfiguration = new MailboxRegionalConfiguration(); mailboxRegionalConfiguration.Language = Culture.GetCultureInfoInstance(cultureInfoByIetfLanguageTag.LCID); mailboxRegionalConfiguration.TimeZone = regionalSettingsConfiguration.MailboxRegionalConfiguration.TimeZone; if (regionalSettingsConfiguration.UserCulture != null && regionalSettingsConfiguration.UserCulture.DateTimeFormat != null) { mailboxRegionalConfiguration.DateFormat = regionalSettingsConfiguration.DateFormat; mailboxRegionalConfiguration.TimeFormat = regionalSettingsConfiguration.TimeFormat; } regionalSettingsConfiguration = new RegionalSettingsConfiguration(mailboxRegionalConfiguration); this.HasRegionalSettings = true; } } catch (ArgumentException) { } } if (this.HasRegionalSettings) { this.UpdateRegionalSettings(regionalSettingsConfiguration); } }
internal void AddRegionalSettingsToCache(RegionalSettingsConfiguration settings) { HttpRuntime.Cache.Insert(this.RegionalCacheKey, settings, null, (DateTime)ExDateTime.UtcNow.Add(TimeSpan.FromHours(24.0)), Cache.NoSlidingExpiration, CacheItemPriority.High, null); }