public static bool TryParseTimeZoneBlob(byte[] bytes, string displayName, out ExTimeZone timeZone) { timeZone = null; if (bytes == null || displayName == null) { ExTraceGlobals.StorageTracer.TraceError(0L, "O11TimeZoneParser, time zone blob or display name is null"); return(false); } if (bytes.Length < O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.Size) { ExTraceGlobals.StorageTracer.TraceError <int>(0L, "O11TimeZoneParser, corrupted TimeZoneBlob. Length {0} less than standard blob", bytes.Length); return(false); } if (bytes.Length > O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.Size) { ExTraceGlobals.StorageTracer.TraceWarning <int>(0L, "O11TimeZoneParser, corrupted TimeZoneBlob Length {0}, going to trim extra bytes", bytes.Length); } REG_TIMEZONE_INFO regInfo = O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.ParseToRegistryFormat(bytes); try { timeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(regInfo, string.Empty, displayName); } catch (InvalidTimeZoneException ex) { ExTraceGlobals.StorageTracer.TraceError <string>(0L, "O11TimeZoneParser, corrupted time zone, blob is not valid registry format. Inner message is {0}", ex.Message); } return(timeZone != null); }
public static StorageWorkingHours LoadFrom(MailboxSession session, StoreId folderId) { WorkHoursInCalendar fromCalendar = WorkHoursInCalendar.GetFromCalendar(session, folderId); if (fromCalendar == null || fromCalendar.WorkHoursVersion1 == null) { return(null); } if (fromCalendar.WorkHoursVersion1.TimeSlot == null) { throw new WorkingHoursXmlMalformedException(ServerStrings.NullWorkHours); } ExTimeZone exTimeZone = null; try { if (!string.IsNullOrEmpty(fromCalendar.WorkHoursVersion1.TimeZone.Name)) { if (ExTimeZoneEnumerator.Instance.TryGetTimeZoneByName(fromCalendar.WorkHoursVersion1.TimeZone.Name, out exTimeZone)) { WorkHoursTimeZone workHoursTimeZone = fromCalendar.WorkHoursVersion1.TimeZone; if (!workHoursTimeZone.IsSameTimeZoneInfo(TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone))) { exTimeZone = null; } } else { exTimeZone = null; } } if (exTimeZone == null) { exTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(fromCalendar.WorkHoursVersion1.TimeZone.TimeZoneInfo, "tzone://Microsoft/Custom", "Customized Time Zone"); } } catch (InvalidTimeZoneException ex) { throw new WorkingHoursXmlMalformedException(ServerStrings.MalformedTimeZoneWorkingHours(session.MailboxOwner.MailboxInfo.DisplayName, ex.ToString()), ex); } return(new StorageWorkingHours(exTimeZone, fromCalendar.WorkHoursVersion1.WorkDays, fromCalendar.WorkHoursVersion1.TimeSlot.StartTimeInMinutes, fromCalendar.WorkHoursVersion1.TimeSlot.EndTimeInMinutes)); }
private void DemoteVEvents(IList <Item> items) { foreach (Item item in items) { ExTimeZone exTimeZone = item.PropertyBag.ExTimeZone; try { REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(TimeZoneHelper.GetExTimeZoneFromItem(item)); string text = this.demotingTimeZones[reg_TIMEZONE_INFO]; item.PropertyBag.ExTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(reg_TIMEZONE_INFO, text, text); VEvent vevent = new VEvent(this); vevent.Demote(item); if (!base.OutboundContext.SuppressExceptionAndAttachmentDemotion && (base.Context.Method == CalendarMethod.Request || base.Context.Method == CalendarMethod.Cancel || base.Context.Method == CalendarMethod.Publish)) { InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(item); if (recurrenceFromItem != null) { IList <OccurrenceInfo> modifiedOccurrences = recurrenceFromItem.GetModifiedOccurrences(); foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences) { ExceptionInfo exceptionInfo = (ExceptionInfo)occurrenceInfo; VEvent vevent2 = new VEvent(this); vevent2.DemoteException(exceptionInfo, vevent); } } } } catch (Exception ex) { ExTraceGlobals.ICalTracer.TraceError <Exception>((long)this.GetHashCode(), "VCalendar::DemoteVEvents. Skipping item due to {0}", ex); base.Context.AddError(ServerStrings.InvalidICalElement(ex.ToString())); } finally { item.PropertyBag.ExTimeZone = exTimeZone; } } }
public static ExTimeZone CreateExTimeZoneFromRegTimeZoneInfo(REG_TIMEZONE_INFO regInfo, string keyName) { ExTimeZone exTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(regInfo, keyName, keyName); return(TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZone) ?? exTimeZone); }