Exemple #1
0
        protected void DemoteReminder()
        {
            if (base.Context.Method != CalendarMethod.Request && base.Context.Method != CalendarMethod.Publish)
            {
                return;
            }
            if (!this.item.GetValueOrDefault <bool>(InternalSchema.ReminderIsSetInternal))
            {
                return;
            }
            int?valueAsNullable = this.item.GetValueAsNullable <int>(InternalSchema.ReminderMinutesBeforeStartInternal);

            if (valueAsNullable == null)
            {
                return;
            }
            valueAsNullable = new int?(Reminder.NormalizeMinutesBeforeStart(valueAsNullable.Value, 15));
            TimeSpan minutes = ((double)valueAsNullable.Value != TimeSpan.MinValue.TotalMinutes) ? TimeSpan.FromMinutes((double)valueAsNullable.Value).Negate() : TimeSpan.FromMinutes(-15.0);

            VAlarm.Demote(base.OutboundContext.Writer, minutes, "REMINDER", null);
        }
Exemple #2
0
        protected static ExDateTime?GetDefaultReminderNextTime(ExDateTime?dueBy, int minutesBeforeStart)
        {
            if (dueBy == null)
            {
                return(null);
            }
            int        num = Reminder.NormalizeMinutesBeforeStart(minutesBeforeStart, 15);
            ExDateTime?result;

            try
            {
                if (dueBy <= ExDateTime.MinValue.AddMinutes((double)num))
                {
                    num = 15;
                }
                result = new ExDateTime?(dueBy.Value.AddMinutes((double)(-(double)num)));
            }
            catch (ArgumentOutOfRangeException)
            {
                result = new ExDateTime?(dueBy.Value);
            }
            return(result);
        }
        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);
        }
 protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
 {
     propertyBag.SetValueWithFixup(this.nativeProp, value);
     Reminder.Adjust(propertyBag.Context.StoreObject);
 }
Exemple #5
0
 private ExDateTime GetProbeTime(ExDateTime actualizationTime)
 {
     return(Reminder.GetProbeTime(actualizationTime, this.ReminderNextTime));
 }
Exemple #6
0
 protected static void Adjust(Reminder reminder, ExDateTime actualizationTime)
 {
     reminder.Adjust(actualizationTime);
 }
Exemple #7
0
 internal static void EnsureMinutesBeforeStartIsInRange(Item item)
 {
     Reminder.EnsureMinutesBeforeStartIsInRange(item, 15);
 }
Exemple #8
0
        private void CopyMeetingRequestProperties(CalendarItemBase calendarItem, bool preserveLocalExceptions)
        {
            long size = calendarItem.Body.Size;

            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(42101U);
            if (!base.IsRepairUpdateMessage || (this.ChangeHighlight & ChangeHighlightProperties.BodyProps) == ChangeHighlightProperties.BodyProps)
            {
                Body.CopyBody(this, calendarItem, false);
                this.CopyNlgPropertiesTo(calendarItem);
            }
            ChangeHighlightProperties changeHighlight = this.ChangeHighlight;

            this.ProcessChangeHighlights(calendarItem, calendarItem.Body.Size, size);
            MeetingMessageType meetingMessageType = base.GetValueOrDefault <MeetingMessageType>(InternalSchema.MeetingRequestType, MeetingMessageType.NewMeetingRequest);

            if (meetingMessageType == MeetingMessageType.PrincipalWantsCopy)
            {
                if (calendarItem.IsNew)
                {
                    meetingMessageType = MeetingMessageType.NewMeetingRequest;
                    ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; Meeting type is PrincipalWantsCopy and calendar item just created.", this.GlobalObjectId);
                }
                else
                {
                    meetingMessageType = base.GetValueOrDefault <MeetingMessageType>(InternalSchema.OriginalMeetingType, MeetingMessageType.NewMeetingRequest);
                    ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, MeetingMessageType>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; Meeting type is PrincipalWantsCopy. Will use OriginalMeetingType {1}", this.GlobalObjectId, meetingMessageType);
                }
            }
            base.LocationIdentifierHelperInstance.SetLocationIdentifier(60533U, LastChangeAction.CopyMeetingRequestProperties);
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(35957U, LastChangeAction.CopyMeetingRequestProperties);
            if (MeetingMessageType.NewMeetingRequest == meetingMessageType || calendarItem.IsNew)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Copying WriteOnCreate properties onto calendar item.");
                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(52341U);
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.WriteOnCreateProperties);
                if (base.IsSeriesMessage)
                {
                    CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.WriteOnCreateSeriesProperties);
                }
                Reminder.EnsureMinutesBeforeStartIsInRange(calendarItem, this.consumerDefaultMinutesBeforeStart);
                if (base.IsRepairUpdateMessage)
                {
                    int?valueAsNullable = base.GetValueAsNullable <int>(CalendarItemBaseSchema.ItemVersion);
                    if (valueAsNullable != null)
                    {
                        calendarItem[CalendarItemBaseSchema.ItemVersion] = valueAsNullable;
                    }
                }
            }
            if (meetingMessageType == MeetingMessageType.NewMeetingRequest || (!base.IsRepairUpdateMessage && meetingMessageType == MeetingMessageType.FullUpdate))
            {
                calendarItem.ResponseType = ResponseType.NotResponded;
                BusyType valueOrDefault  = base.GetValueOrDefault <BusyType>(InternalSchema.IntendedFreeBusyStatus, BusyType.Busy);
                BusyType valueOrDefault2 = base.GetValueOrDefault <BusyType>(InternalSchema.FreeBusyStatus, BusyType.Tentative);
                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(58485U);
                calendarItem[InternalSchema.IntendedFreeBusyStatus] = valueOrDefault;
                calendarItem[InternalSchema.FreeBusyStatus]         = ((valueOrDefault != BusyType.Free) ? valueOrDefault2 : BusyType.Free);
            }
            ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Copying properties onto calendar item.");
            byte[]       largeBinaryProperty = base.PropertyBag.GetLargeBinaryProperty(InternalSchema.AppointmentRecurrenceBlob);
            CalendarItem calendarItem2       = calendarItem as CalendarItem;
            bool         flag = false;

            if (largeBinaryProperty != null && calendarItem2 != null)
            {
                calendarItem2.SuppressUpdateRecurrenceTimeOffset = true;
                this.CopyRecurrenceBlob(calendarItem2, largeBinaryProperty, preserveLocalExceptions);
                flag = true;
            }
            else if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster)
            {
                CalendarItem calendarItem3 = calendarItem as CalendarItem;
                if (calendarItem3 != null)
                {
                    calendarItem3.Recurrence = null;
                }
            }
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(62581U);
            if (calendarItem is CalendarItem)
            {
                PropertyChangeMetadataProcessingFlags propertyChangeMetadataProcessingFlags = calendarItem.GetValueOrDefault <PropertyChangeMetadataProcessingFlags>(CalendarItemSchema.PropertyChangeMetadataProcessingFlags, PropertyChangeMetadataProcessingFlags.None);
                propertyChangeMetadataProcessingFlags |= PropertyChangeMetadataProcessingFlags.OverrideMetadata;
                calendarItem[CalendarItemSchema.PropertyChangeMetadataProcessingFlags] = propertyChangeMetadataProcessingFlags;
            }
            if (this.ShouldPreserveAttendeesChanges(calendarItem))
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Will copy properties trying to preserve attendee's changes.");
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, CalendarItemProperties.NonPreservableMeetingMessageProperties);
                PreservableMeetingMessageProperty.CopyPreserving(new PreservablePropertyContext(this, calendarItem, changeHighlight));
                if (calendarItem is CalendarItem)
                {
                    PropertyChangeMetadata valueOrDefault3        = calendarItem.GetValueOrDefault <PropertyChangeMetadata>(InternalSchema.PropertyChangeMetadata);
                    PropertyChangeMetadata valueOrDefault4        = base.GetValueOrDefault <PropertyChangeMetadata>(InternalSchema.PropertyChangeMetadata);
                    PropertyChangeMetadata propertyChangeMetadata = PropertyChangeMetadata.Merge(valueOrDefault3, valueOrDefault4);
                    if (propertyChangeMetadata != null)
                    {
                        calendarItem[InternalSchema.PropertyChangeMetadata] = propertyChangeMetadata;
                    }
                }
            }
            else
            {
                if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster || calendarItem.CalendarItemType == CalendarItemType.Single)
                {
                    calendarItem.DeleteProperties(MeetingMessage.DisplayTimeZoneProperties);
                }
                if (calendarItem is CalendarItem)
                {
                    CalendarItemBase.CopyPropertiesTo(this, calendarItem, new PropertyDefinition[]
                    {
                        InternalSchema.PropertyChangeMetadataRaw
                    });
                }
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.MeetingMessageProperties);
            }
            string valueOrDefault5 = base.GetValueOrDefault <string>(InternalSchema.AppointmentClass);

            if (valueOrDefault5 != null && ObjectClass.IsDerivedClass(valueOrDefault5, "IPM.Appointment"))
            {
                calendarItem.ClassName = valueOrDefault5;
            }
            Microsoft.Exchange.Data.Storage.Item.CopyCustomPublicStrings(this, calendarItem);
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(54389U);
            CalendarItemBase.CopyPropertiesTo(this, calendarItem, new PropertyDefinition[]
            {
                InternalSchema.TimeZoneDefinitionRecurring
            });
            if (meetingMessageType == MeetingMessageType.InformationalUpdate && !calendarItem.IsCalendarItemTypeOccurrenceOrException)
            {
                Sensitivity?valueAsNullable2 = base.GetValueAsNullable <Sensitivity>(InternalSchema.Sensitivity);
                if (valueAsNullable2 != null && calendarItem.Sensitivity != Sensitivity.Private && Enum.IsDefined(typeof(Sensitivity), valueAsNullable2.Value))
                {
                    calendarItem.Sensitivity = valueAsNullable2.Value;
                }
            }
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(50293U);
            calendarItem.Reminder.Adjust();
            if (flag && calendarItem2 != null)
            {
                calendarItem2.ReloadRecurrence();
            }
        }