Esempio n. 1
0
        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);
            }
        }
        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);
            }
        }