internal static ExDateTime?GetWallClockTime(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty, NativeStorePropertyDefinition[] timeZoneBlobPropertyDefinitions)
        {
            ExDateTime?normalizedTime = StartTimeProperty.GetNormalizedTime(propertyBag, utcTimeProperty, legacyUtcTimeProperty);

            if (normalizedTime == null)
            {
                return(null);
            }
            byte[] array = null;
            foreach (NativeStorePropertyDefinition propertyDefinition in timeZoneBlobPropertyDefinitions)
            {
                array = propertyBag.GetValueOrDefault <byte[]>(propertyDefinition);
                if (array != null)
                {
                    break;
                }
            }
            if (array == null)
            {
                ExTraceGlobals.StorageTracer.TraceWarning(0L, "Could not determine suitable time zone");
            }
            ExTimeZone exTimeZone = StartWallClockProperty.FindBestMatchingTimeZone(array);

            if (exTimeZone != null)
            {
                return(new ExDateTime?(exTimeZone.ConvertDateTime(normalizedTime.Value)));
            }
            return(new ExDateTime?(normalizedTime.Value));
        }
        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 object InternalTryGetDateTimeValue(PropertyBag.BasicPropertyStore propertyBag, StorePropertyDefinition property, GuidIdPropertyDefinition mapiUtcTimeProperty, PropertyTagPropertyDefinition mapiLegacyUtcTimeProperty)
        {
            ExDateTime?normalizedTime = StartTimeProperty.GetNormalizedTime(propertyBag, mapiUtcTimeProperty, mapiLegacyUtcTimeProperty);

            if (normalizedTime != null)
            {
                return(normalizedTime.Value);
            }
            return(new PropertyError(property, PropertyErrorCode.NotFound));
        }
Exemple #4
0
        internal static void RecalculateNormalizedTimeProperty(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty, ExTimeZone newTimeZone)
        {
            if (newTimeZone == null || newTimeZone == ExTimeZone.UtcTimeZone || newTimeZone == ExTimeZone.UnspecifiedTimeZone)
            {
                return;
            }
            ExDateTime?normalizedTime = StartTimeProperty.GetNormalizedTime(propertyBag, utcTimeProperty, legacyUtcTimeProperty);

            if (normalizedTime != null)
            {
                ExDateTime exDateTime = newTimeZone.ConvertDateTime(normalizedTime.Value);
                propertyBag.SetValueWithFixup(utcTimeProperty, exDateTime.ToUtc());
                if (legacyUtcTimeProperty != null)
                {
                    propertyBag.SetValueWithFixup(legacyUtcTimeProperty, exDateTime.ToUtc());
                }
            }
        }
 protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
 {
     StartTimeProperty.SetCalendarTime(propertyBag, InternalSchema.MapiEndTime, InternalSchema.MapiPREndDate, InternalSchema.TimeZoneDefinitionEnd, true, value);
     EndTimeProperty.DenormalizeTimeProperty(propertyBag, (ExDateTime)propertyBag.GetValue(InternalSchema.MapiEndTime), InternalSchema.MapiEndTime, InternalSchema.MapiPREndDate);
 }
 protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
 {
     return(StartTimeProperty.InternalTryGetDateTimeValue(propertyBag, this, InternalSchema.MapiEndTime, InternalSchema.MapiPREndDate));
 }
 internal static ExDateTime?GetNormalizedTime(PropertyBag propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty)
 {
     return(StartTimeProperty.GetNormalizedTime((PropertyBag.BasicPropertyStore)propertyBag, utcTimeProperty, legacyUtcTimeProperty));
 }
 protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
 {
     StartTimeProperty.SetCalendarTime(propertyBag, InternalSchema.MapiStartTime, InternalSchema.MapiPRStartDate, InternalSchema.TimeZoneDefinitionStart, false, value);
 }