internal static ExDateTime?GetNormalizedTime(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty) { ExDateTime?valueAsNullable = propertyBag.GetValueAsNullable <ExDateTime>(utcTimeProperty); if (valueAsNullable == null) { if (legacyUtcTimeProperty != null) { valueAsNullable = propertyBag.GetValueAsNullable <ExDateTime>(legacyUtcTimeProperty); } if (valueAsNullable == null) { return(null); } } ExDateTime exDateTime = ExTimeZone.UtcTimeZone.ConvertDateTime(valueAsNullable.Value); byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionStart); ExTimeZone legacyTimeZone; if (O12TimeZoneFormatter.TryParseTimeZoneBlob(valueOrDefault, string.Empty, out legacyTimeZone)) { exDateTime = TimeZoneHelper.NormalizeUtcTime(exDateTime, legacyTimeZone); } exDateTime = StartTimeProperty.DynamicAdjustForAllDayEvent(propertyBag, exDateTime, utcTimeProperty == InternalSchema.MapiEndTime); return(new ExDateTime?(propertyBag.TimeZone.ConvertDateTime(exDateTime))); }
internal static bool CompareBlob(byte[] left, byte[] right, bool compareKeyName) { if (object.Equals(left, right)) { return(true); } if (left == null || right == null) { return(false); } bool result = false; if (compareKeyName) { result = O12TimeZoneFormatter.ByteArrayEqual(left, 0, right, 0); } else { int num = 2; if (num + 1 < left.Length && num + 1 < right.Length) { int num2 = num + (int)left[num] + ((int)left[num + 1] << 8); int num3 = num + (int)right[num] + ((int)right[num + 1] << 8); if (num2 < left.Length && num3 < right.Length) { result = O12TimeZoneFormatter.ByteArrayEqual(left, num2, right, num3); } } } return(result); }
protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value) { ExTimeZone exTimeZone = value as ExTimeZone; if (exTimeZone == ExTimeZone.UnspecifiedTimeZone) { throw new InvalidOperationException("unspecified time zone is not allowed to set"); } StartTimeZoneProperty.RecalculateNormalizedTimeProperty(propertyBag, InternalSchema.MapiStartTime, InternalSchema.MapiPRStartDate, exTimeZone); StartTimeZoneProperty.RecalculateNormalizedTimeProperty(propertyBag, InternalSchema.MapiEndTime, InternalSchema.MapiPREndDate, exTimeZone); StartTimeZoneProperty.RecalculateNormalizedTimeProperty(propertyBag, InternalSchema.ReminderNextTime, null, exTimeZone); if (exTimeZone == ExTimeZone.UtcTimeZone) { if (!(propertyBag.Context.StoreObject is CalendarItemOccurrence)) { propertyBag.Delete(InternalSchema.TimeZoneDefinitionStart); return; } } else { byte[] timeZoneBlob = O12TimeZoneFormatter.GetTimeZoneBlob(exTimeZone); propertyBag.SetValueWithFixup(InternalSchema.TimeZoneDefinitionStart, timeZoneBlob); StartTimeZoneProperty.SyncRecurringTimeZoneProperties(propertyBag, exTimeZone, timeZoneBlob); } }
private bool IsMeetingChanged(GlobalObjectId goid, Item promotedItem, object[] matchedItem) { for (int i = 0; i < InternetCalendarSchema.ImportCompare.Length; i++) { PropertyDefinition propertyDefinition = InternetCalendarSchema.ImportCompare[i]; object obj = matchedItem[i]; object obj2 = promotedItem.TryGetProperty(propertyDefinition); if (!Util.ValueEquals(obj, obj2)) { if (!(obj is PropertyError) && !(obj2 is PropertyError)) { if (propertyDefinition == CalendarItemBaseSchema.AppointmentRecurrenceBlob) { InternalRecurrence internalRecurrence = InternalRecurrence.InternalParse((byte[])obj, (VersionedId)matchedItem[this.QueryIndexId], CalendarImporter.GetRecurringTimeZoneFromQueryItem(matchedItem), promotedItem.PropertyBag.ExTimeZone, CalendarItem.DefaultCodePage); InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(promotedItem); ExTraceGlobals.SharingTracer.TraceDebug <InternalRecurrence, InternalRecurrence, GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Comparing property AppointmentRecurrenceBlob: old Recurrence is {0}; new Recurrence is {1}. GOID:{2}.", internalRecurrence, recurrenceFromItem, goid); if (Util.ValueEquals(internalRecurrence, recurrenceFromItem) && Util.ValueEquals(internalRecurrence.GetDeletedOccurrences(false), recurrenceFromItem.GetDeletedOccurrences(false))) { goto IL_214; } } if (true.Equals(promotedItem.TryGetProperty(CalendarItemBaseSchema.IsException)) && (propertyDefinition == ItemSchema.TimeZoneDefinitionStart || propertyDefinition == CalendarItemBaseSchema.TimeZoneDefinitionEnd)) { ExTimeZone exTimeZone; O12TimeZoneFormatter.TryParseTimeZoneBlob((byte[])obj, string.Empty, out exTimeZone); ExTimeZone exTimeZone2; O12TimeZoneFormatter.TryParseTimeZoneBlob((byte[])obj2, string.Empty, out exTimeZone2); ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Comparing property {0}: old TimeZone is {1}; new TimeZone is {2}. GOID:{3}.", new object[] { propertyDefinition.Name, (exTimeZone != null) ? exTimeZone.AlternativeId : "null", (exTimeZone2 != null) ? exTimeZone2.AlternativeId : "null", goid }); if (exTimeZone != null && exTimeZone2 != null) { REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone, (ExDateTime)matchedItem[CalendarImporter.QueryIndexOfProperty(CalendarItemInstanceSchema.StartTime)]); REG_TIMEZONE_INFO reg_TIMEZONE_INFO2 = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone2, (ExDateTime)promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime)); if (Util.ValueEquals(reg_TIMEZONE_INFO, reg_TIMEZONE_INFO2)) { goto IL_214; } } } } ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Change is detected on property {0}: old value is {1}; new value is {2}. GOID:{3}; Subject:{4}; StartTime:{5}.", new object[] { propertyDefinition.Name, obj, obj2, goid, promotedItem.TryGetProperty(ItemSchema.Subject), promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime) }); return(true); } IL_214 :; } return(false); }
internal static ExTimeZone FindBestMatchingTimeZone(byte[] timeZoneBlob) { ExTimeZone exTimeZone = null; if (O12TimeZoneFormatter.TryParseTimeZoneBlob(timeZoneBlob, string.Empty, out exTimeZone) && exTimeZone.IsCustomTimeZone) { exTimeZone = TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZone); } return(exTimeZone); }
internal static ExTimeZone GetExTimeZoneFromLegacyBlob(PropertyBag.BasicPropertyStore propertyBag, NativeStorePropertyDefinition propertyDefinition) { byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(propertyDefinition); ExTimeZone exTimeZone; if (O12TimeZoneFormatter.TryParseTimeZoneBlob(valueOrDefault, string.Empty, out exTimeZone)) { return(TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZone) ?? exTimeZone); } return(ExTimeZone.UtcTimeZone); }
internal static void SetCalendarTime(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty, GuidIdPropertyDefinition timeZoneDefinition, bool isEndTime, object value) { StoreObject storeObject = propertyBag.Context.StoreObject; CalendarItemBase calendarItemBase = storeObject as CalendarItemBase; if (calendarItemBase != null && calendarItemBase.PropertyBag.ExTimeZone != null && calendarItemBase.IsAllDayEventCache == null) { object obj = IsAllDayEventProperty.CalculateIsAllDayEvent(propertyBag); if (obj is bool) { calendarItemBase.IsAllDayEventCache = new bool?((bool)obj); } } propertyBag.SetValueWithFixup(utcTimeProperty, value); propertyBag.SetValueWithFixup(legacyUtcTimeProperty, value); ExTimeZone timeZone = propertyBag.TimeZone; if (value is ExDateTime && ((ExDateTime)value).TimeZone != null && ((ExDateTime)value).TimeZone != ExTimeZone.UnspecifiedTimeZone) { timeZone = ((ExDateTime)value).TimeZone; } if (timeZone == ExTimeZone.UtcTimeZone) { if (!(storeObject is CalendarItemOccurrence)) { propertyBag.Delete(timeZoneDefinition); } } else if (value is ExDateTime && timeZone != ExTimeZone.UnspecifiedTimeZone) { if (timeZoneDefinition == InternalSchema.TimeZoneDefinitionStart) { byte[] timeZoneBlob = O12TimeZoneFormatter.GetTimeZoneBlob(timeZone); StartTimeZoneProperty.RecalculateNormalizedTimeProperty(propertyBag, InternalSchema.MapiEndTime, InternalSchema.MapiPREndDate, timeZone); StartTimeZoneProperty.RecalculateNormalizedTimeProperty(propertyBag, InternalSchema.ReminderNextTime, null, timeZone); StartTimeZoneProperty.SyncRecurringTimeZoneProperties(propertyBag, timeZone, timeZoneBlob); propertyBag.SetValueWithFixup(timeZoneDefinition, timeZoneBlob); } else { byte[] timeZoneBlob2 = O12TimeZoneFormatter.GetTimeZoneBlob(timeZone, (ExDateTime)value); propertyBag.SetValueWithFixup(timeZoneDefinition, timeZoneBlob2); } } if (!isEndTime) { propertyBag.SetValueWithFixup(InternalSchema.ReminderDueByInternal, value); } if (storeObject != null) { Reminder.Adjust(storeObject); } }
internal static void SyncRecurringTimeZoneProperties(PropertyBag.BasicPropertyStore propertyBag, ExTimeZone timeZone, byte[] o12TimeZoneBlob) { if (o12TimeZoneBlob == null) { o12TimeZoneBlob = O12TimeZoneFormatter.GetTimeZoneBlob(timeZone); } if (propertyBag.GetValueOrDefault <bool>(InternalSchema.AppointmentRecurring) && timeZone != ExTimeZone.UtcTimeZone && timeZone != ExTimeZone.UnspecifiedTimeZone) { propertyBag.SetValueWithFixup(InternalSchema.TimeZone, timeZone.LocalizableDisplayName.ToString()); propertyBag.SetValueWithFixup(InternalSchema.TimeZoneBlob, O11TimeZoneFormatter.GetTimeZoneBlob(timeZone)); propertyBag.SetValueWithFixup(InternalSchema.TimeZoneDefinitionRecurring, o12TimeZoneBlob); } }
private static LocalizedString GenerateOldFashionedReportBody(MessageItem message, out CultureInfo culture) { message.Load(ReportMessageSchema.Instance.AutoloadProperties); ExDateTime? valueAsNullable = message.GetValueAsNullable <ExDateTime>(InternalSchema.ReportTime); ExTimeZone exTimeZone = ExTimeZone.CurrentTimeZone; StoreSession session = message.Session; if (session != null) { exTimeZone = session.ExTimeZone; } byte[] valueOrDefault = message.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionStart); ExTimeZone exTimeZone2; if (valueOrDefault != null && O12TimeZoneFormatter.TryParseTruncatedTimeZoneBlob(valueOrDefault, out exTimeZone2)) { exTimeZone = (TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZone2) ?? exTimeZone2); } culture = ReportMessage.GetMdnCulture(message.CoreItem); LocalizedString originalMessageInfo = ReportMessage.GetOriginalMessageInfo(message, exTimeZone, culture); LocalizedString result; if (ObjectClass.IsReport(message.ClassName, "IPNRN")) { if (valueAsNullable != null) { result = ClientStrings.MdnRead(originalMessageInfo, exTimeZone.ConvertDateTime(valueAsNullable.Value), new LocalizedString(exTimeZone.LocalizableDisplayName.ToString(culture))); } else { result = ClientStrings.MdnReadNoTime(originalMessageInfo); } } else { if (!ObjectClass.IsReport(message.ClassName, "IPNNRN")) { ExTraceGlobals.StorageTracer.TraceDebug((long)message.GetHashCode(), ServerStrings.UnsupportedReportType(message.ClassName)); return(new LocalizedString(ServerStrings.UnsupportedReportType(message.ClassName))); } if (valueAsNullable != null) { result = ClientStrings.MdnNotRead(originalMessageInfo, exTimeZone.ConvertDateTime(valueAsNullable.Value), new LocalizedString(exTimeZone.LocalizableDisplayName.ToString(culture))); } else { result = ClientStrings.MdnNotReadNoTime(originalMessageInfo); } } return(result); }
public static byte[] GetTimeZoneBlob(ExTimeZone timeZone) { if (timeZone == null) { throw new ArgumentNullException("timeZone"); } if (timeZone == ExTimeZone.UnspecifiedTimeZone) { throw new ArgumentException("timeZone should not be UnspecifiedTimeZone"); } string keyName = timeZone.IsCustomTimeZone ? timeZone.AlternativeId : timeZone.Id; return(O12TimeZoneFormatter.GenerateBlobFromRuleGroups(keyName, timeZone.TimeZoneInformation.Groups)); }
private static List <ExTimeZone> MatchCustomTimeZoneByRules(ExTimeZone customTimeZone, List <ExTimeZone> candidates) { List <ExTimeZone> list = new List <ExTimeZone>(); byte[] timeZoneBlob = O12TimeZoneFormatter.GetTimeZoneBlob(customTimeZone); foreach (ExTimeZone exTimeZone in candidates) { byte[] timeZoneBlob2 = O12TimeZoneFormatter.GetTimeZoneBlob(exTimeZone); if (O12TimeZoneFormatter.CompareBlob(timeZoneBlob, timeZoneBlob2, false)) { list.Add(exTimeZone); } } return(list); }
internal static void DenormalizeTimeProperty(PropertyBag propertyBag, ExDateTime newTime, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty) { byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionStart); ExTimeZone legacyTimeZone; if (O12TimeZoneFormatter.TryParseTimeZoneBlob(valueOrDefault, string.Empty, out legacyTimeZone)) { ExDateTime exDateTime = TimeZoneHelper.DeNormalizeToUtcTime(newTime, legacyTimeZone); propertyBag.SetProperty(utcTimeProperty, exDateTime); if (legacyUtcTimeProperty != null) { propertyBag.SetProperty(legacyUtcTimeProperty, exDateTime); } } }
internal static ExTimeZone GetTimeZoneFromProperties(string timeZoneDisplayName, byte[] o11TimeZoneBlob, byte[] o12TimeZoneBlob) { string text = timeZoneDisplayName ?? string.Empty; ExTimeZone result; if (O12TimeZoneFormatter.TryParseTimeZoneBlob(o12TimeZoneBlob, text, out result)) { return(result); } ExTimeZone result2; if (O11TimeZoneFormatter.TryParseTimeZoneBlob(o11TimeZoneBlob, text, out result2)) { return(result2); } return(null); }
public static byte[] GetTimeZoneBlob(ExTimeZone timeZone, ExDateTime time) { if (timeZone == null) { throw new ArgumentNullException("timeZone"); } if (timeZone == ExTimeZone.UnspecifiedTimeZone) { throw new ArgumentException("timeZone should not be UnspecifiedTimeZone"); } DateTime universalTime = time.UniversalTime; ExTimeZoneRule ruleForUtcTime = timeZone.TimeZoneInformation.GetRuleForUtcTime(universalTime); if (ruleForUtcTime != null && ruleForUtcTime.RuleGroup != null) { List <ExTimeZoneRuleGroup> list = new List <ExTimeZoneRuleGroup>(); list.Add(ruleForUtcTime.RuleGroup); return(O12TimeZoneFormatter.GenerateBlobFromRuleGroups(timeZone.AlternativeId, list)); } throw new ArgumentException("no time zone rule found for specified time: " + time.ToString()); }
private void AppendTimeZoneInfo() { MailboxSession mailboxSession = this.item.Session as MailboxSession; if (mailboxSession == null) { return; } ExTimeZone timeZone; byte[] timeZoneBlob; if (TimeZoneSettings.TryFindOwaTimeZone(mailboxSession, out timeZone)) { timeZoneBlob = O12TimeZoneFormatter.GetTimeZoneBlob(timeZone); this.tnefWriter.WriteProperty(InternalSchema.TimeZoneDefinitionStart, timeZoneBlob); return; } if (TimeZoneSettings.TryFindOutlookTimeZone(mailboxSession, out timeZoneBlob)) { this.tnefWriter.WriteProperty(InternalSchema.TimeZoneDefinitionStart, timeZoneBlob); } }
protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value) { ExTimeZone exTimeZone = value as ExTimeZone; if (exTimeZone == ExTimeZone.UnspecifiedTimeZone) { throw new InvalidOperationException("unspecified time zone is not allowed to set"); } if (exTimeZone == ExTimeZone.UtcTimeZone) { if (!(propertyBag.Context.StoreObject is CalendarItemOccurrence)) { propertyBag.Delete(InternalSchema.TimeZoneDefinitionStart); return; } } else { ExDateTime valueOrDefault = propertyBag.GetValueOrDefault <ExDateTime>(InternalSchema.MapiEndTime, ExDateTime.UtcNow); propertyBag.SetValueWithFixup(InternalSchema.TimeZoneDefinitionEnd, (exTimeZone != null) ? O12TimeZoneFormatter.GetTimeZoneBlob(exTimeZone, valueOrDefault) : null); } }
internal List <object[]> Expand(object[] masterValues, ExDateTime start, ExDateTime end, int codePage, PropertyDefinition[] columns, RecurrenceExpansionOption options) { List <object[]> list = new List <object[]>(); if (masterValues.Length != columns.Length) { throw new ArgumentException(ServerStrings.ExInvalidMasterValueAndColumnLength); } object[] array = null; if ((options & RecurrenceExpansionOption.TruncateMaster) == RecurrenceExpansionOption.TruncateMaster) { array = this.GetTruncatedRecurringMaster(masterValues, start, end, columns); if (array == null) { return(list); } } else { array = masterValues; } int num = Array.IndexOf <PropertyDefinition>(columns, InternalSchema.ItemId); VersionedId versionedId = (VersionedId)array[num]; Item item = null; AttachmentCollection attachmentCollection = null; bool flag; try { byte[] timeZoneBlob = O12TimeZoneFormatter.GetTimeZoneBlob(this.recurrence.CreatedExTimeZone); IList <OccurrenceInfo> occurrenceInfoList = this.recurrence.GetOccurrenceInfoList(start, end); flag = (occurrenceInfoList.Count != 0); foreach (OccurrenceInfo occurrenceInfo in occurrenceInfoList) { bool flag2 = occurrenceInfo is ExceptionInfo; if (flag2 || (options & RecurrenceExpansionOption.IncludeRegularOccurrences) == RecurrenceExpansionOption.IncludeRegularOccurrences) { object[] array2 = new object[array.Length]; array.CopyTo(array2, 0); if (flag2) { this.PopulateExceptionOccurrence(array2, columns, (ExceptionInfo)occurrenceInfo, ref attachmentCollection, ref item, occurrenceInfo.VersionedId); } this.AdjustOccurrenceColumnsForExpansion(array2, columns, occurrenceInfo, codePage, timeZoneBlob, flag2); list.Add(array2); } } } finally { if (item != null) { item.Dispose(); item = null; } } if (flag && (options & RecurrenceExpansionOption.IncludeMaster) == RecurrenceExpansionOption.IncludeMaster) { list.Insert(0, array); } return(list); }