Esempio n. 1
0
        public static ExTimeZone GetRecurringTimeZoneFromPropertyBag(IStorePropertyBag propertyBag)
        {
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.TimeZone, null);

            byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneBlob, null);
            byte[] valueOrDefault3 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionRecurring, null);
            return(TimeZoneHelper.GetTimeZoneFromProperties(valueOrDefault, valueOrDefault2, valueOrDefault3));
        }
Esempio n. 2
0
        private static ExTimeZone GetRecurringTimeZoneFromQueryItem(object[] matchedItem)
        {
            string timeZoneDisplayName = matchedItem[CalendarImporter.QueryIndexOfProperty(CalendarItemBaseSchema.TimeZone)] as string;

            byte[] o11TimeZoneBlob = matchedItem[CalendarImporter.QueryIndexOfProperty(CalendarItemBaseSchema.TimeZoneBlob)] as byte[];
            byte[] o12TimeZoneBlob = matchedItem[CalendarImporter.QueryIndexOfProperty(CalendarItemBaseSchema.TimeZoneDefinitionRecurring)] as byte[];
            return(TimeZoneHelper.GetTimeZoneFromProperties(timeZoneDisplayName, o11TimeZoneBlob, o12TimeZoneBlob));
        }
Esempio n. 3
0
        public static ExTimeZone GetExTimeZoneFromItem(Item item)
        {
            ExTimeZone exTimeZone = TimeZoneHelper.GetRecurringTimeZoneFromPropertyBag(item.PropertyBag);

            if (exTimeZone == null)
            {
                exTimeZone = TimeZoneHelper.GetTimeZoneFromProperties("Customized Time Zone", null, item.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionStart));
            }
            if (exTimeZone == null)
            {
                if (item.Session != null && item.Session.ExTimeZone != ExTimeZone.UtcTimeZone)
                {
                    exTimeZone = item.Session.ExTimeZone;
                }
                else
                {
                    ExTimeZoneHelperForMigrationOnly.CheckValidationLevel(false, ExTimeZoneHelperForMigrationOnly.ValidationLevel.Low, "TimeZoneHelper.GetTimeZoneFromItem: no time zone", new object[0]);
                    exTimeZone = ExTimeZone.CurrentTimeZone;
                }
            }
            return(exTimeZone);
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            StoreSession session = propertyBag.Context.Session;

            if (session == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug((long)propertyBag.GetHashCode(), "ReminderDueByProperty: StoreObject is not present and the property bag is not a QueryResultsPropertyBag. First should be present when accessing a property on an object, and the second one - when called from a view. All other cases are wrong.");
                return(propertyBag.GetValue(InternalSchema.ReminderDueByInternal));
            }
            PropertyError      result             = new PropertyError(InternalSchema.ReminderDueBy, PropertyErrorCode.GetCalculatedPropertyError);
            CalendarItem       calendarItem       = propertyBag.Context.StoreObject as CalendarItem;
            InternalRecurrence internalRecurrence = null;

            if (calendarItem != null)
            {
                try
                {
                    internalRecurrence = (InternalRecurrence)calendarItem.Recurrence;
                    goto IL_206;
                }
                catch (RecurrenceFormatException ex)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse recurrence info. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex.Message, (calendarItem.Id != null) ? calendarItem.Id.ObjectId : null);
                    return(result);
                }
                catch (CorruptDataException ex2)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse the organizer timezone. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex2.Message, (calendarItem.Id != null) ? calendarItem.Id.ObjectId : null);
                    return(result);
                }
            }
            byte[] entryId;
            if (Util.TryConvertTo <byte[]>(propertyBag.GetValue(InternalSchema.EntryId), out entryId))
            {
                VersionedId versionedId = new VersionedId(StoreObjectId.FromProviderSpecificId(entryId), Array <byte> .Empty);
                byte[]      array       = propertyBag.GetValue(InternalSchema.AppointmentRecurrenceBlob) as byte[];
                if (array != null)
                {
                    string     valueOrDefault         = propertyBag.GetValueOrDefault <string>(InternalSchema.TimeZone, string.Empty);
                    byte[]     valueOrDefault2        = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneBlob);
                    byte[]     valueOrDefault3        = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionRecurring);
                    ExTimeZone timeZoneFromProperties = TimeZoneHelper.GetTimeZoneFromProperties(valueOrDefault, valueOrDefault2, valueOrDefault3);
                    if (timeZoneFromProperties == null)
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse the organizer timezone. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", "organizerTimeZone is null", versionedId.ObjectId);
                        return(result);
                    }
                    try
                    {
                        internalRecurrence = InternalRecurrence.GetRecurrence(versionedId, session, array, timeZoneFromProperties, CalendarItem.DefaultCodePage);
                    }
                    catch (RecurrenceFormatException ex3)
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse recurrence info. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex3.Message, versionedId.ObjectId);
                        return(result);
                    }
                    catch (CorruptDataException ex4)
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <string, StoreObjectId>((long)session.GetHashCode(), "Unable to parse the organizer timezone. Using the stored value for DueBy.\r\n\tError: {0}\r\n\tID:{1}", ex4.Message, versionedId.ObjectId);
                        return(result);
                    }
                }
            }
IL_206:
            bool defaultIsSet;
            int        defaultMinutesBeforeStart;
            ExDateTime value;

            if (internalRecurrence == null || !Util.TryConvertTo <bool>(propertyBag.GetValue(InternalSchema.ReminderIsSetInternal), out defaultIsSet) || !Util.TryConvertTo <int>(propertyBag.GetValue(InternalSchema.ReminderMinutesBeforeStartInternal), out defaultMinutesBeforeStart) || !Util.TryConvertTo <ExDateTime>(propertyBag.GetValue(InternalSchema.ReminderNextTime), out value))
            {
                return(propertyBag.GetValue(InternalSchema.ReminderDueByInternal));
            }
            ExDateTime     probeTime = Reminder.GetProbeTime(Reminder.GetTimeNow(session.ExTimeZone), new ExDateTime?(value));
            OccurrenceInfo mostRecentOccurrence;

            try
            {
                mostRecentOccurrence = CalendarItem.CustomReminder.GetMostRecentOccurrence(internalRecurrence, probeTime, defaultIsSet, defaultMinutesBeforeStart);
            }
            catch (CorruptDataException)
            {
                return(result);
            }
            if (mostRecentOccurrence == null)
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            return(mostRecentOccurrence.StartTime);
        }