예제 #1
0
 internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
 {
     if (ObjectClass.IsCalendarItem((validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string) ?? string.Empty))
     {
         PersistablePropertyBag persistablePropertyBag = validatablePropertyBag as PersistablePropertyBag;
         if (persistablePropertyBag != null)
         {
             byte[] largeBinaryProperty = persistablePropertyBag.GetLargeBinaryProperty(InternalSchema.AppointmentRecurrenceBlob);
             if (largeBinaryProperty != null)
             {
                 ExTimeZone createTimeZone = TimeZoneHelper.GetRecurringTimeZoneFromPropertyBag(persistablePropertyBag) ?? ExTimeZone.CurrentTimeZone;
                 try
                 {
                     InternalRecurrence.InternalParse(largeBinaryProperty, persistablePropertyBag.TryGetProperty(InternalSchema.ItemId) as VersionedId, createTimeZone, persistablePropertyBag.ExTimeZone, CalendarItem.DefaultCodePage);
                 }
                 catch (RecurrenceCalendarTypeNotSupportedException ex)
                 {
                     ExTraceGlobals.RecurrenceTracer.TraceDebug <CalendarType>((long)this.GetHashCode(), "RecurrenceBlobConstraint::Validate. Not supported calendar type found. CalendarType:{0}", ex.CalendarType);
                 }
                 catch (RecurrenceFormatException)
                 {
                     return(new StoreObjectValidationError(context, InternalSchema.AppointmentRecurrenceBlob, largeBinaryProperty, this));
                 }
             }
         }
     }
     return(null);
 }
예제 #2
0
		internal static RecurrenceInfo GetInfo(Recurrence recurrenceObject)
		{
			RecurrenceInfo recurrenceInfo = null;
			InternalRecurrence internalRecurrence = recurrenceObject as InternalRecurrence;
			if (internalRecurrence != null)
			{
				recurrenceInfo = new RecurrenceInfo();
				recurrenceInfo.StartDate = internalRecurrence.Range.StartDate;
				recurrenceInfo.EndDate = internalRecurrence.EndDate;
				if (internalRecurrence.Range is EndDateRecurrenceRange)
				{
					recurrenceInfo.Range = RecurrenceRangeType.End;
					recurrenceInfo.EndDate = ((EndDateRecurrenceRange)internalRecurrence.Range).EndDate;
				}
				else if (internalRecurrence.Range is NumberedRecurrenceRange)
				{
					recurrenceInfo.Range = RecurrenceRangeType.AfterNOccur;
					recurrenceInfo.NumberOfOccurrences = ((NumberedRecurrenceRange)internalRecurrence.Range).NumberOfOccurrences;
				}
				else
				{
					recurrenceInfo.Range = RecurrenceRangeType.NoEnd;
				}
				recurrenceInfo.SetPatternSpecificProperties(internalRecurrence.Pattern);
				recurrenceInfo.Anomalies = internalRecurrence.Anomalies;
				recurrenceInfo.ModifiedOccurrences = internalRecurrence.GetModifiedOccurrences();
				recurrenceInfo.DeletedOccurrences = internalRecurrence.GetDeletedOccurrences();
			}
			return recurrenceInfo;
		}
예제 #3
0
 private bool IsMeetingChanged(GlobalObjectId goid, Item promotedItem, object[] matchedItem)
 {
     for (int i = 0; i < InternetCalendarSchema.ImportCompare.Length; i++)
     {
         PropertyDefinition propertyDefinition = InternetCalendarSchema.ImportCompare[i];
         object             obj  = matchedItem[i];
         object             obj2 = promotedItem.TryGetProperty(propertyDefinition);
         if (!Util.ValueEquals(obj, obj2))
         {
             if (!(obj is PropertyError) && !(obj2 is PropertyError))
             {
                 if (propertyDefinition == CalendarItemBaseSchema.AppointmentRecurrenceBlob)
                 {
                     InternalRecurrence internalRecurrence = InternalRecurrence.InternalParse((byte[])obj, (VersionedId)matchedItem[this.QueryIndexId], CalendarImporter.GetRecurringTimeZoneFromQueryItem(matchedItem), promotedItem.PropertyBag.ExTimeZone, CalendarItem.DefaultCodePage);
                     InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(promotedItem);
                     ExTraceGlobals.SharingTracer.TraceDebug <InternalRecurrence, InternalRecurrence, GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Comparing property AppointmentRecurrenceBlob: old Recurrence is {0}; new Recurrence is {1}. GOID:{2}.", internalRecurrence, recurrenceFromItem, goid);
                     if (Util.ValueEquals(internalRecurrence, recurrenceFromItem) && Util.ValueEquals(internalRecurrence.GetDeletedOccurrences(false), recurrenceFromItem.GetDeletedOccurrences(false)))
                     {
                         goto IL_214;
                     }
                 }
                 if (true.Equals(promotedItem.TryGetProperty(CalendarItemBaseSchema.IsException)) && (propertyDefinition == ItemSchema.TimeZoneDefinitionStart || propertyDefinition == CalendarItemBaseSchema.TimeZoneDefinitionEnd))
                 {
                     ExTimeZone exTimeZone;
                     O12TimeZoneFormatter.TryParseTimeZoneBlob((byte[])obj, string.Empty, out exTimeZone);
                     ExTimeZone exTimeZone2;
                     O12TimeZoneFormatter.TryParseTimeZoneBlob((byte[])obj2, string.Empty, out exTimeZone2);
                     ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Comparing property {0}: old TimeZone is {1}; new TimeZone is {2}. GOID:{3}.", new object[]
                     {
                         propertyDefinition.Name,
                         (exTimeZone != null) ? exTimeZone.AlternativeId : "null",
                         (exTimeZone2 != null) ? exTimeZone2.AlternativeId : "null",
                         goid
                     });
                     if (exTimeZone != null && exTimeZone2 != null)
                     {
                         REG_TIMEZONE_INFO reg_TIMEZONE_INFO  = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone, (ExDateTime)matchedItem[CalendarImporter.QueryIndexOfProperty(CalendarItemInstanceSchema.StartTime)]);
                         REG_TIMEZONE_INFO reg_TIMEZONE_INFO2 = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone2, (ExDateTime)promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime));
                         if (Util.ValueEquals(reg_TIMEZONE_INFO, reg_TIMEZONE_INFO2))
                         {
                             goto IL_214;
                         }
                     }
                 }
             }
             ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Change is detected on property {0}: old value is {1}; new value is {2}. GOID:{3}; Subject:{4}; StartTime:{5}.", new object[]
             {
                 propertyDefinition.Name,
                 obj,
                 obj2,
                 goid,
                 promotedItem.TryGetProperty(ItemSchema.Subject),
                 promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime)
             });
             return(true);
         }
         IL_214 :;
     }
     return(false);
 }
예제 #4
0
        public static byte[] ToRecurrenceBlob(Properties easCalendarItem, ExDateTime start, ExDateTime end, ExTimeZone targetTimeZone)
        {
            Microsoft.Exchange.Connections.Eas.Model.Response.Calendar.Recurrence recurrence = easCalendarItem.Recurrence;
            RecurrencePattern  pattern            = SyncCalendarUtils.CreateRecurrencePattern(recurrence);
            RecurrenceRange    range              = SyncCalendarUtils.CreateRecurrenceRange(start, recurrence);
            ExDateTime         dt                 = targetTimeZone.ConvertDateTime(start);
            ExDateTime         dt2                = targetTimeZone.ConvertDateTime(end);
            TimeSpan           startOffset        = dt - dt.Date;
            TimeSpan           endOffset          = dt2 - dt2.Date;
            InternalRecurrence internalRecurrence = new InternalRecurrence(pattern, range, null, targetTimeZone, ExTimeZone.UtcTimeZone, startOffset, endOffset);

            if (easCalendarItem.Exceptions != null)
            {
                foreach (Microsoft.Exchange.Connections.Eas.Model.Response.Calendar.Exception ex in easCalendarItem.Exceptions)
                {
                    ExDateTime originalStartTime = SyncCalendarUtils.ToUtcExDateTime(ex.ExceptionStartTime);
                    ExDateTime date = originalStartTime.Date;
                    if (ex.Deleted)
                    {
                        internalRecurrence.TryDeleteOccurrence(date);
                    }
                    else
                    {
                        ModificationType  modificationType  = (ModificationType)0;
                        MemoryPropertyBag memoryPropertyBag = new MemoryPropertyBag();
                        memoryPropertyBag.SetAllPropertiesLoaded();
                        if (ex.Subject != easCalendarItem.CalendarSubject)
                        {
                            modificationType |= ModificationType.Subject;
                            memoryPropertyBag[ItemSchema.Subject] = ex.Subject;
                        }
                        if (ex.Reminder != easCalendarItem.Reminder)
                        {
                            modificationType |= ModificationType.ReminderDelta;
                            memoryPropertyBag[ItemSchema.ReminderMinutesBeforeStartInternal] = ex.Reminder;
                        }
                        if (ex.Location != easCalendarItem.Location)
                        {
                            modificationType |= ModificationType.Location;
                            memoryPropertyBag[CalendarItemBaseSchema.Location] = ex.Location;
                        }
                        if (ex.BusyStatus != easCalendarItem.BusyStatus)
                        {
                            modificationType |= ModificationType.BusyStatus;
                            memoryPropertyBag[CalendarItemBaseSchema.FreeBusyStatus] = ex.BusyStatus;
                        }
                        if (ex.AllDayEvent != easCalendarItem.AllDayEvent)
                        {
                            modificationType |= ModificationType.SubType;
                            memoryPropertyBag[CalendarItemBaseSchema.MapiIsAllDayEvent] = ex.AllDayEvent;
                        }
                        ExDateTime    startTime     = targetTimeZone.ConvertDateTime(SyncCalendarUtils.ToUtcExDateTime(ex.StartTime));
                        ExDateTime    endTime       = targetTimeZone.ConvertDateTime(SyncCalendarUtils.ToUtcExDateTime(ex.EndTime));
                        ExceptionInfo exceptionInfo = new ExceptionInfo(null, date, originalStartTime, startTime, endTime, modificationType, memoryPropertyBag);
                        internalRecurrence.ModifyOccurrence(exceptionInfo);
                    }
                }
            }
            return(internalRecurrence.ToByteArray());
        }
        // Token: 0x0600157B RID: 5499 RVA: 0x0007EA98 File Offset: 0x0007CC98
        internal bool IsResponseMessageToSingleMeeting(IMessageItem message)
        {
            string className = message.ClassName;

            if (ObjectClass.IsMeetingResponse(className))
            {
                bool flag = InternalRecurrence.HasRecurrenceBlob(message.CoreItem.PropertyBag);
                return(!flag);
            }
            return(false);
        }
예제 #6
0
        internal InternalRecurrence GetTruncatedRecurrence(ExDateTime firstOccurrenceId, ExDateTime lastOccurrenceId, bool keepNoEndDateRange)
        {
            RecurrenceRange recurrenceRange = (keepNoEndDateRange && this.recurrence.Range is NoEndRecurrenceRange) ? new NoEndRecurrenceRange(firstOccurrenceId) : new EndDateRecurrenceRange(firstOccurrenceId, lastOccurrenceId);

            if (!recurrenceRange.Equals(this.recurrence.Range))
            {
                InternalRecurrence internalRecurrence = new InternalRecurrence(this.recurrence.Pattern, recurrenceRange, this.recurrence.MasterItem as CalendarItem, this.recurrence.CreatedExTimeZone, this.recurrence.ReadExTimeZone, this.recurrence.StartOffset, this.recurrence.EndOffset);
                RecurrenceBlobMerger.Merge(this.storeSession, null, null, this.recurrence, internalRecurrence);
                return(internalRecurrence);
            }
            return(null);
        }
예제 #7
0
        private bool PromoteRecurrence()
        {
            if (this.xsoRecurrence == null)
            {
                return(true);
            }
            ExDateTime         dt = (ExDateTime)this.dueTime.Value;
            InternalRecurrence internalRecurrence = new InternalRecurrence(this.xsoRecurrence.Pattern, this.xsoRecurrence.Range, this.item, this.xsoRecurrence.CreatedExTimeZone, this.xsoRecurrence.ReadExTimeZone, dt - dt.Date, dt - dt.Date, new ExDateTime?(this.xsoRecurrence.EndDate));

            byte[] propertyValue = internalRecurrence.ToByteArray();
            base.SetProperty(InternalSchema.TaskRecurrence, propertyValue);
            return(true);
        }
 protected internal override CalendarItemOccurrence RecoverDeletedOccurrence()
 {
     if (this.possibleDeletedOccurrenceId != null)
     {
         MailboxSession calendarMailboxSession = MeetingMessage.GetCalendarMailboxSession(this);
         for (int i = 0; i < 2; i++)
         {
             CalendarItem calendarItem = CalendarItem.Bind(calendarMailboxSession, StoreObjectId.FromProviderSpecificId(this.possibleDeletedOccurrenceId.ProviderLevelItemId, StoreObjectType.CalendarItem));
             try
             {
                 calendarItem.OpenAsReadWrite();
                 if (calendarItem.Recurrence != null)
                 {
                     InternalRecurrence internalRecurrence = (InternalRecurrence)calendarItem.Recurrence;
                     ExDateTime         occurrenceId       = ((OccurrenceStoreObjectId)this.possibleDeletedOccurrenceId).OccurrenceId;
                     if (internalRecurrence.IsValidOccurrenceId(occurrenceId))
                     {
                         if (internalRecurrence.IsOccurrenceDeleted(occurrenceId))
                         {
                             base.LocationIdentifierHelperInstance.SetLocationIdentifier(39541U, LastChangeAction.RecoverDeletedOccurance);
                             calendarItem.RecoverDeletedOccurrence(this.possibleDeletedOccurrenceId);
                             if (calendarItem.Save(SaveMode.ResolveConflicts).SaveStatus == SaveResult.IrresolvableConflict)
                             {
                                 goto IL_136;
                             }
                         }
                         CalendarItemOccurrence calendarItemOccurrence = CalendarItemOccurrence.Bind(calendarMailboxSession, this.possibleDeletedOccurrenceId, MeetingMessageSchema.Instance.AutoloadProperties);
                         calendarItemOccurrence.OpenAsReadWrite();
                         ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence recovered.", this.GlobalObjectId);
                         return(calendarItemOccurrence);
                     }
                     ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence id is invalid.", this.GlobalObjectId);
                     return(null);
                 }
             }
             catch (OccurrenceNotFoundException)
             {
                 ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence not found.", this.GlobalObjectId);
                 return(null);
             }
             finally
             {
                 calendarItem.Dispose();
             }
             IL_136 :;
         }
     }
     ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingMessage.RecoverDeletedOccurrence: GOID={0}; occurrence not recovered.", this.GlobalObjectId);
     return(null);
 }
예제 #9
0
        internal object[] GetTruncatedRecurringMaster(object[] masterRow, ExDateTime windowStart, ExDateTime windowEnd, PropertyDefinition[] columns)
        {
            if (masterRow.Length != columns.Length)
            {
                throw new ArgumentException(ServerStrings.ExInvalidMasterValueAndColumnLength);
            }
            IList <OccurrenceInfo> occurrenceInfoList = this.recurrence.GetOccurrenceInfoList(windowStart, windowEnd);

            if (occurrenceInfoList.Count > 0)
            {
                OccurrenceInfo occurrenceInfo  = occurrenceInfoList[0];
                OccurrenceInfo occurrenceInfo2 = occurrenceInfoList[occurrenceInfoList.Count - 1];
                int            num             = Array.IndexOf <PropertyDefinition>(columns, InternalSchema.MapiStartTime);
                int            num2            = Array.IndexOf <PropertyDefinition>(columns, InternalSchema.MapiEndTime);
                if (num > 0)
                {
                    masterRow[num] = occurrenceInfo.OccurrenceDateId + this.recurrence.StartOffset;
                }
                if (num2 > 0)
                {
                    masterRow[num2] = occurrenceInfo.OccurrenceDateId + this.recurrence.EndOffset;
                }
                int num3 = Array.IndexOf <PropertyDefinition>(columns, InternalSchema.AppointmentRecurrenceBlob);
                if (num3 > 0)
                {
                    int num4 = Array.IndexOf <PropertyDefinition>(columns, InternalSchema.GlobalObjectId);
                    if (num4 > 0)
                    {
                        try
                        {
                            new GlobalObjectId(masterRow[num4] as byte[]);
                        }
                        catch (CorruptDataException)
                        {
                        }
                    }
                    InternalRecurrence truncatedRecurrence = this.GetTruncatedRecurrence(occurrenceInfo.OccurrenceDateId, occurrenceInfo2.OccurrenceDateId, windowEnd == ExDateTime.MaxValue);
                    if (truncatedRecurrence != null)
                    {
                        masterRow[num3] = truncatedRecurrence.ToByteArray();
                    }
                }
                return(masterRow);
            }
            return(null);
        }
        private bool ValidateCorrelatedItem(CalendarItemBase calendarItem)
        {
            byte[] largeBinaryProperty = calendarItem.PropertyBag.GetLargeBinaryProperty(InternalSchema.AppointmentRecurrenceBlob);
            bool   valueOrDefault      = calendarItem.GetValueOrDefault <bool>(InternalSchema.AppointmentRecurring);
            bool   flag = this is MeetingResponse;

            if (flag && valueOrDefault)
            {
                bool valueOrDefault2 = base.GetValueOrDefault <bool>(InternalSchema.AppointmentCounterProposal);
                if (valueOrDefault2)
                {
                    return(false);
                }
            }
            if (largeBinaryProperty == null || !valueOrDefault)
            {
                return(true);
            }
            bool valueOrDefault3 = base.GetValueOrDefault <bool>(InternalSchema.IsException);

            if (valueOrDefault3)
            {
                return(false);
            }
            int valueOrDefault4 = base.GetValueOrDefault <int>(InternalSchema.AppointmentSequenceNumber);
            int valueOrDefault5 = calendarItem.GetValueOrDefault <int>(InternalSchema.AppointmentSequenceNumber);

            if (valueOrDefault4 > valueOrDefault5)
            {
                return(true);
            }
            bool flag2           = InternalRecurrence.HasRecurrenceBlob(base.PropertyBag);
            bool valueOrDefault6 = base.GetValueOrDefault <bool>(InternalSchema.IsRecurring);
            bool?valueAsNullable = base.GetValueAsNullable <bool>(InternalSchema.AppointmentRecurring);
            bool flag3           = flag2 && valueOrDefault6 && (valueAsNullable == null || valueAsNullable.Value);

            if (flag3)
            {
                return(true);
            }
            bool flag4 = this is MeetingForwardNotification;
            bool flag5 = this is MeetingCancellation && new GlobalObjectId(this).IsForeignUid();

            return(flag || flag5 || flag4);
        }
예제 #11
0
        private bool ShouldPreserveLocalExceptions(CalendarItem calendarItem)
        {
            InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(this);
            Recurrence         recurrence         = null;

            try
            {
                recurrence = calendarItem.Recurrence;
            }
            catch (RecurrenceFormatException ex)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <string, GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.ShouldPreserveLocalExceptions encountered a recurrence format exception ({0}). Local exceptions will not be preserved: GOID={1}", ex.Message, this.GlobalObjectId);
            }
            catch (CorruptDataException ex2)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <string, GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.ShouldPreserveLocalExceptions encountered a corrupt data exception ({0}). Local exceptions will not be preserved: GOID={1}", ex2.Message, this.GlobalObjectId);
            }
            return(recurrence != null && recurrenceFromItem != null && recurrence.Equals(recurrenceFromItem) && MeetingRequest.ArePropsEqual(calendarItem.TryGetProperty(InternalSchema.StartTime), base.TryGetProperty(InternalSchema.StartTime)) && MeetingRequest.ArePropsEqual(calendarItem.TryGetProperty(InternalSchema.EndTime), base.TryGetProperty(InternalSchema.EndTime)));
        }
예제 #12
0
        private static RecurrenceType GetTaskRecurrenceTypeFromBlob(byte[] blob)
        {
            if (blob == null)
            {
                return(RecurrenceType.None);
            }
            RecurrenceType result;

            try
            {
                TaskRecurrence taskRecurrence = InternalRecurrence.InternalParseTask(blob, null, null, null);
                result = RecurrenceTypeProperty.TaskRecurrencePatternToRecurrenceType(taskRecurrence);
            }
            catch (RecurrenceFormatException)
            {
                result = RecurrenceType.None;
            }
            return(result);
        }
예제 #13
0
        private void CopyRecurrenceBlob(CalendarItem calendarItem, byte[] recurrenceBlob, bool preserveLocalExceptions)
        {
            InternalRecurrence originalRecurrence = preserveLocalExceptions ? CalendarItem.GetRecurrenceFromItem(calendarItem) : null;

            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(46197U);
            calendarItem[InternalSchema.AppointmentRecurrenceBlob] = recurrenceBlob;
            if (preserveLocalExceptions)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Will merge the recurrence blob.");
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, new PropertyDefinition[]
                {
                    CalendarItemBaseSchema.TimeZone,
                    CalendarItemBaseSchema.TimeZoneBlob,
                    CalendarItemBaseSchema.TimeZoneDefinitionRecurring
                });
                InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(calendarItem);
                if (RecurrenceBlobMerger.Merge(base.Session, calendarItem, this.GlobalObjectId, originalRecurrence, recurrenceFromItem))
                {
                    calendarItem[InternalSchema.AppointmentRecurrenceBlob] = recurrenceFromItem.ToByteArray();
                }
            }
        }
예제 #14
0
 private bool PromoteReminders()
 {
     if (base.Context.Method == CalendarMethod.Request || base.Context.Method == CalendarMethod.Publish)
     {
         ExDateTime valueOrDefault = base.GetValueOrDefault <ExDateTime>(InternalSchema.DueDate, ExDateTime.MinValue);
         bool       flag           = false;
         if (this.item != null && this.item.Session != null && this.item.Session.IsOlcMoveDestination)
         {
             InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(this.item);
             ExDateTime         exDateTime;
             if (recurrenceFromItem != null)
             {
                 exDateTime = recurrenceFromItem.EndDate + recurrenceFromItem.EndOffset;
             }
             else
             {
                 exDateTime = valueOrDefault;
             }
             flag = (exDateTime.CompareTo(ExDateTime.UtcNow) < 0);
         }
         if (this.displayVAlarm != null && this.displayVAlarm.Validate() && !flag && (this.dueTime != null || this.displayVAlarm.ValueType == CalendarValueType.DateTime))
         {
             int num = VAlarm.CalculateReminderMinutesBeforeStart(this.displayVAlarm, valueOrDefault, valueOrDefault);
             base.SetProperty(InternalSchema.ReminderIsSetInternal, true);
             base.SetProperty(InternalSchema.ReminderDueBy, valueOrDefault.AddMinutes((double)(-(double)num)));
         }
         else
         {
             base.SetProperty(InternalSchema.ReminderMinutesBeforeStart, 0);
             base.SetProperty(InternalSchema.ReminderIsSetInternal, false);
         }
         if (!flag)
         {
             VAlarm.PromoteEmailReminders(this.item, this.emailVAlarms, valueOrDefault, valueOrDefault, false);
         }
     }
     return(true);
 }
예제 #15
0
 private void DemoteVEvents(IList <Item> items)
 {
     foreach (Item item in items)
     {
         ExTimeZone exTimeZone = item.PropertyBag.ExTimeZone;
         try
         {
             REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(TimeZoneHelper.GetExTimeZoneFromItem(item));
             string            text = this.demotingTimeZones[reg_TIMEZONE_INFO];
             item.PropertyBag.ExTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(reg_TIMEZONE_INFO, text, text);
             VEvent vevent = new VEvent(this);
             vevent.Demote(item);
             if (!base.OutboundContext.SuppressExceptionAndAttachmentDemotion && (base.Context.Method == CalendarMethod.Request || base.Context.Method == CalendarMethod.Cancel || base.Context.Method == CalendarMethod.Publish))
             {
                 InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(item);
                 if (recurrenceFromItem != null)
                 {
                     IList <OccurrenceInfo> modifiedOccurrences = recurrenceFromItem.GetModifiedOccurrences();
                     foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences)
                     {
                         ExceptionInfo exceptionInfo = (ExceptionInfo)occurrenceInfo;
                         VEvent        vevent2       = new VEvent(this);
                         vevent2.DemoteException(exceptionInfo, vevent);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             ExTraceGlobals.ICalTracer.TraceError <Exception>((long)this.GetHashCode(), "VCalendar::DemoteVEvents. Skipping item due to {0}", ex);
             base.Context.AddError(ServerStrings.InvalidICalElement(ex.ToString()));
         }
         finally
         {
             item.PropertyBag.ExTimeZone = exTimeZone;
         }
     }
 }
예제 #16
0
 private void CopyToCalendarItem(Item promotedItem, CalendarItemBase calendarItem, bool itemCreated)
 {
     foreach (PropertyDefinition propertyDefinition in InternetCalendarSchema.ImportUpdate)
     {
         object obj = promotedItem.TryGetProperty(propertyDefinition);
         if (obj != null && !PropertyError.IsPropertyNotFound(obj))
         {
             if (propertyDefinition == CalendarItemBaseSchema.AppointmentRecurrenceBlob && !itemCreated)
             {
                 CalendarItem calendarItem2 = calendarItem as CalendarItem;
                 if (calendarItem2 != null)
                 {
                     InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(promotedItem);
                     InternalRecurrence internalRecurrence = new InternalRecurrence(recurrenceFromItem.Pattern, recurrenceFromItem.Range, calendarItem2, recurrenceFromItem.CreatedExTimeZone, recurrenceFromItem.ReadExTimeZone, recurrenceFromItem.StartOffset, recurrenceFromItem.EndOffset);
                     RecurrenceBlobMerger.Merge(null, null, calendarItem.GlobalObjectId, recurrenceFromItem, internalRecurrence);
                     calendarItem2.Recurrence = internalRecurrence;
                     goto IL_9C;
                 }
             }
             calendarItem[propertyDefinition] = obj;
         }
         else
         {
             calendarItem.Delete(propertyDefinition);
         }
         IL_9C :;
     }
     using (TextReader textReader = promotedItem.Body.OpenTextReader(BodyFormat.ApplicationRtf))
     {
         using (TextWriter textWriter = calendarItem.Body.OpenTextWriter(BodyFormat.ApplicationRtf))
         {
             Util.StreamHandler.CopyText(textReader, textWriter);
         }
     }
     calendarItem.CoreItem.Recipients.CopyRecipientsFrom(promotedItem.CoreItem.Recipients);
 }
        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);
        }
예제 #18
0
 internal RecurrenceManager(StoreSession storeSession, InternalRecurrence recurrence)
 {
     this.recurrence   = recurrence;
     this.storeSession = storeSession;
 }
예제 #19
0
 private RecurrenceBlobMerger(StoreSession session, CalendarItem calendarItem, GlobalObjectId globalObjectId, InternalRecurrence originalRecurrence, InternalRecurrence newRecurrence)
 {
     this.Session            = session;
     this.CalendarItem       = calendarItem;
     this.GlobalObjectId     = ((globalObjectId == null) ? string.Empty : globalObjectId.ToString());
     this.OriginalRecurrence = originalRecurrence;
     this.NewRecurrence      = newRecurrence;
 }
예제 #20
0
 public static bool Merge(StoreSession session, CalendarItem calendarItem, GlobalObjectId globalObjectId, InternalRecurrence originalRecurrence, InternalRecurrence newRecurrence)
 {
     return(new RecurrenceBlobMerger(session, calendarItem, globalObjectId, originalRecurrence, newRecurrence).Merge());
 }