private Microsoft.Office.Interop.Outlook.TimeZone WindowsTimeZone(string ianaZoneId) { Microsoft.Office.Interop.Outlook.TimeZones tzs = oApp.TimeZones; var utcZones = new[] { "Etc/UTC", "Etc/UCT" }; if (utcZones.Contains(ianaZoneId, StringComparer.OrdinalIgnoreCase)) { log.Fine("Timezone \"" + ianaZoneId + "\" mapped to \"UTC\""); return tzs["UTC"]; } var tzdbSource = NodaTime.TimeZones.TzdbDateTimeZoneSource.Default; // resolve any link, since the CLDR doesn't necessarily use canonical IDs var links = tzdbSource.CanonicalIdMap .Where(x => x.Value.Equals(ianaZoneId, StringComparison.OrdinalIgnoreCase)) .Select(x => x.Key); var mappings = tzdbSource.WindowsMapping.MapZones; var item = mappings.FirstOrDefault(x => x.TzdbIds.Any(links.Contains)); if (item == null) { log.Warn("Timezone \"" + ianaZoneId + "\" could not find a mapping"); return null; } log.Fine("Timezone \"" + ianaZoneId + "\" mapped to \"" + item.WindowsId + "\""); return tzs[item.WindowsId]; }
// // GET: /PeopleContact/ /// <summary> /// Indexes the specified sort order. /// </summary> /// <param name="sortOrder">The sort order.</param> /// <param name="currentFilter">The current filter.</param> /// <param name="currentFilterAccording">The current filter according.</param> /// <param name="searchString">The search string.</param> /// <param name="searchStringAccording">The search string according.</param> /// <param name="page">The page.</param> /// <param name="commandArgument">The command argument.</param> /// <param name="pageSize">Size of the page.</param> /// <param name="filteredUserId">The filtered user id.</param> /// <returns>ActionResult.</returns> /// <exception cref="System.ArgumentOutOfRangeException"></exception> public ActionResult Index(string sortOrder, string currentFilter, string currentFilterAccording, string searchString, string searchStringAccording, int? page, string commandArgument, int filteredUserId = 0, int pageSize = PageSize) { if (!CheckFilteredUserId(ref filteredUserId)) { return RedirectToAccessDenied(); } int pageNumber; ProcessSearchFilterAndPaging(currentFilter, currentFilterAccording, ref searchString, ref searchStringAccording, ref page, out pageNumber); CommandArgument argument; bool showFormating = Cookie.GetCookie(Request, Cookie.ShowFormattingCookieKey) == Cookie.CookieTrue; bool hideDeathContacts = Cookie.GetCookie(Request, Cookie.HideDeathContactsCookieKey) == Cookie.CookieTrue; if (!String.IsNullOrEmpty(commandArgument) && Enum.TryParse(commandArgument, out argument)) { switch (argument) { case CommandArgument.ShowFormatting: showFormating = true; Cookie.SetNewCookie(Cookie.ShowFormattingCookieKey, Cookie.CookieTrue, Response); break; case CommandArgument.HideFormatting: showFormating = false; Cookie.SetNewCookie(Cookie.ShowFormattingCookieKey, Cookie.CookieFalse, Response); break; case CommandArgument.ShowDeathContacts: hideDeathContacts = false; Cookie.SetNewCookie(Cookie.HideDeathContactsCookieKey, Cookie.CookieFalse, Response); break; case CommandArgument.HideDeathContacts: hideDeathContacts = true; Cookie.SetNewCookie(Cookie.HideDeathContactsCookieKey, Cookie.CookieTrue, Response); break; default: throw new ArgumentOutOfRangeException(); } } IQueryable<PeopleContact> peopleContacts = PeopleContactCache.GetIndex(Db, searchString, searchStringAccording, sortOrder, filteredUserId, hideDeathContacts); ViewBag.ShowFormatting = showFormating; ViewBag.HideDeathContacts = hideDeathContacts; ViewBag.IsRegistrar = filteredUserId == UserId; ViewBag.ShowImportExport = filteredUserId == UserId; var sortingNames = new[] { BaseCache.LastNameField, BaseCache.FirstNameField, BaseCache.CityField, BaseCache.PhoneNumber1Field, BaseCache.Email1Field, BaseCache.SkypeField, BaseCache.PotentialField }; ProcessSorting(sortOrder, sortingNames); PopulateSearchStringAccording(searchString, searchStringAccording); PopulateFilteredUserId(filteredUserId); PopulatePageSize(pageSize); PeopleContactIndex[] peopleContactIndices = PeopleContactIndex.GetModelView(peopleContacts.ToArray()); return View(peopleContactIndices.ToPagedList(pageNumber, pageSize)); }