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);
        }
Пример #2
0
        public static ExTimeZone GetPromotedTimeZoneFromItem(Item item)
        {
            ExTimeZone exTimeZoneFromItem = TimeZoneHelper.GetExTimeZoneFromItem(item);
            ExTimeZone exTimeZone         = null;

            if (exTimeZoneFromItem != null)
            {
                exTimeZone = TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZoneFromItem);
            }
            return(exTimeZone ?? exTimeZoneFromItem);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        public static ExDateTime DeNormalizeToUtcTime(ExDateTime time, ExTimeZone legacyTimeZone)
        {
            if (legacyTimeZone == null || !legacyTimeZone.IsCustomTimeZone)
            {
                return(time.ToUtc());
            }
            ExTimeZone exTimeZone = TimeZoneHelper.PromoteCustomizedTimeZone(legacyTimeZone);

            if (exTimeZone != null)
            {
                DateTime localTime = exTimeZone.ConvertDateTime(time).LocalTime;
                return(new ExDateTime(legacyTimeZone, localTime).ToUtc());
            }
            return(time);
        }
Пример #6
0
        public static ExTimeZone CreateExTimeZoneFromRegTimeZoneInfo(REG_TIMEZONE_INFO regInfo, string keyName)
        {
            ExTimeZone exTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(regInfo, keyName, keyName);

            return(TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZone) ?? exTimeZone);
        }