// Token: 0x06000798 RID: 1944 RVA: 0x00039E40 File Offset: 0x00038040
        public static int GetCancelRecurrenceCount(CalendarItem calendarItem, ExDateTime endRange)
        {
            if (calendarItem == null)
            {
                throw new ArgumentNullException("calendarItem");
            }
            if (endRange <= calendarItem.Recurrence.Range.StartDate)
            {
                return(0);
            }
            if (!(calendarItem.Recurrence.Range is NoEndRecurrenceRange))
            {
                OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                if (lastOccurrence != null && lastOccurrence.EndTime < endRange)
                {
                    return(int.MinValue);
                }
            }
            EndDateRecurrenceRange endDateRecurrenceRange = calendarItem.Recurrence.Range as EndDateRecurrenceRange;

            if (endDateRecurrenceRange != null && endDateRecurrenceRange.EndDate < endRange)
            {
                return(int.MinValue);
            }
            IList <OccurrenceInfo> occurrenceInfoList = calendarItem.Recurrence.GetOccurrenceInfoList(calendarItem.Recurrence.Range.StartDate, endRange);

            if (0 <= occurrenceInfoList.Count && (!(calendarItem.Recurrence.Range is NumberedRecurrenceRange) || occurrenceInfoList.Count < ((NumberedRecurrenceRange)calendarItem.Recurrence.Range).NumberOfOccurrences))
            {
                return(occurrenceInfoList.Count);
            }
            return(int.MinValue);
        }
Example #2
0
        internal static bool IsCalendarItemEndTimeInPast(CalendarItemBase calendarItemBase)
        {
            if (calendarItemBase == null)
            {
                throw new ArgumentNullException("calendarItemBase");
            }
            ExDateTime localTime = DateTimeUtilities.GetLocalTime();
            bool       result    = false;

            if (calendarItemBase.CalendarItemType == CalendarItemType.RecurringMaster)
            {
                CalendarItem calendarItem = (CalendarItem)calendarItemBase;
                if (!(calendarItem.Recurrence.Range is NoEndRecurrenceRange))
                {
                    OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                    if (lastOccurrence != null && lastOccurrence.EndTime < localTime)
                    {
                        result = true;
                    }
                }
            }
            else if (calendarItemBase.EndTime < localTime)
            {
                result = true;
            }
            return(result);
        }
        public string GetValue(object ownerInstance, PropertyInfo propInfo)
        {
            string text = string.Empty;

            OccurrenceInfo occur = propInfo.GetValue(ownerInstance, null) as OccurrenceInfo;

            return(GetValue(occur, false));
        }
        internal static string GetValue(OccurrenceInfo occur, bool singleLine)
        {
            string text = string.Format(System.Globalization.CultureInfo.CurrentCulture, "Original Start: {0}\nStart: {1}\nEnd: {2}\nItemId: {3}",
                                        occur.OriginalStart,
                                        occur.Start,
                                        occur.End,
                                        ItemIdTypeValue.GetValue(occur.ItemId, true));

            if (singleLine)
            {
                return(text.Replace("\n", ""));
            }

            return(text);
        }
        // Token: 0x06000B9F RID: 2975 RVA: 0x0004D740 File Offset: 0x0004B940
        internal void GenerateRecurringInPolicyResponse(RecurringAcceptType type, OccurrenceInfo last, ExDateTime bookingWindowLocal)
        {
            bookingWindowLocal = bookingWindowLocal.AddSeconds(-1.0);
            ExDateTime exDateTime;

            if (last == null || last.EndTime > bookingWindowLocal)
            {
                exDateTime = this.CalendarItemTz.ConvertDateTime(bookingWindowLocal);
            }
            else
            {
                exDateTime = this.CalendarItemTz.ConvertDateTime(last.EndTime);
            }
            string date = exDateTime.ToString(this.CultureInfo.DateTimeFormat.ShortDatePattern);

            this.GetResponseBody = delegate()
            {
                string result;
                if (type == RecurringAcceptType.Free)
                {
                    result = this.GenerateResponseWithTimeZoneInfo(Strings.descRecurringAccepted(date).ToString(this.CultureInfo));
                }
                else
                {
                    result = this.GenerateResponseWithTimeZoneInfo(Strings.descRecurringAccepted(date).ToString(this.CultureInfo) + this.GeneratingConflictingMeetingTable(Strings.descRecurringSomeAccepted));
                }
                return(result);
            };
            this.GetResponseSubjectPrefix = delegate()
            {
                string result;
                if (last == null || last.EndTime > bookingWindowLocal)
                {
                    result = Strings.descAcceptedThrough(date).ToString(this.CultureInfo);
                }
                else if (type == RecurringAcceptType.Free)
                {
                    result = Strings.descAcceptedAll.ToString(this.CultureInfo);
                }
                else
                {
                    result = Strings.descAccepted.ToString(this.CultureInfo);
                }
                return(result);
            };
            this.GetDelegateBody = (() => this.GenerateInPolicyDelegateResponse(Strings.descDelegateNoPerm.ToString(this.DelegateCultureInfo)));
        }
Example #6
0
        private CalendarItemOccurrence GetOccurrenceFromMaster(PropertyBag masterPropertyBag, ExDateTime occurrenceId, MailboxSession session, ICollection <PropertyDefinition> requiredProperties)
        {
            Recurrence recurrence;

            if (Recurrence.TryFromMasterPropertyBag(masterPropertyBag, session, out recurrence))
            {
                OccurrenceInfo occurrenceInfo = null;
                try
                {
                    occurrenceInfo = recurrence.GetOccurrenceInfoByDateId(occurrenceId);
                    return(CalendarItemOccurrence.Bind(session, occurrenceInfo.VersionedId, requiredProperties));
                }
                catch (ObjectNotFoundException)
                {
                    ExTraceGlobals.DefaultFoldersTracer.TraceDebug <string, VersionedId>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetOccurrencePropertyBagFromMaster - Could not bind to the occurrence ID (Session Display Name: {0}; VersionedId: {1}).", session.DisplayName, (occurrenceInfo == null) ? null : occurrenceInfo.VersionedId);
                    return(null);
                }
            }
            ExTraceGlobals.DefaultFoldersTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarVersionStoreGateway::GetOccurrencePropertyBagFromMaster - Could not get the recurrence object from the master (Session Display Name: {0}).", session.DisplayName);
            return(null);
        }
        // Token: 0x0600079A RID: 1946 RVA: 0x00039FA8 File Offset: 0x000381A8
        public static bool BuildSendConfirmDialogPrompt(CalendarItemBase calendarItemBase, out string prompt)
        {
            if (calendarItemBase == null)
            {
                throw new ArgumentNullException("calendarItemBase");
            }
            prompt = null;
            StringBuilder stringBuilder = null;
            ExDateTime    localTime     = DateTimeUtilities.GetLocalTime();

            if (calendarItemBase.CalendarItemType == CalendarItemType.RecurringMaster)
            {
                CalendarItem calendarItem = calendarItemBase as CalendarItem;
                if (!(calendarItem.Recurrence.Range is NoEndRecurrenceRange))
                {
                    OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                    if (lastOccurrence != null && lastOccurrence.EndTime < localTime)
                    {
                        if (stringBuilder == null)
                        {
                            stringBuilder = new StringBuilder();
                        }
                        stringBuilder.Append("\n\t");
                        stringBuilder.Append(LocalizedStrings.GetNonEncoded(2056979915));
                    }
                }
            }
            else if (calendarItemBase.EndTime < localTime)
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("\n\t");
                stringBuilder.Append(LocalizedStrings.GetNonEncoded(839442440));
            }
            if (string.IsNullOrEmpty(calendarItemBase.Subject))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("\n\t");
                stringBuilder.Append(LocalizedStrings.GetNonEncoded(-25858033));
            }
            if (string.IsNullOrEmpty(calendarItemBase.Location))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("\n\t");
                stringBuilder.Append(LocalizedStrings.GetNonEncoded(-1681723506));
            }
            if (stringBuilder != null)
            {
                stringBuilder.Insert(0, "\n");
                stringBuilder.Insert(0, LocalizedStrings.GetNonEncoded(1040416023));
                stringBuilder.Append("\n\n");
                stringBuilder.Append(LocalizedStrings.GetNonEncoded(105464887));
                prompt = stringBuilder.ToString();
                return(true);
            }
            return(false);
        }
Example #8
0
        // Token: 0x06002FD0 RID: 12240 RVA: 0x00116600 File Offset: 0x00114800
        public static void AddCalendarInfobarMessages(Infobar infobar, CalendarItemBase calendarItemBase, MeetingMessage meetingMessage, UserContext userContext)
        {
            if (infobar == null)
            {
                throw new ArgumentNullException("infobar");
            }
            if (calendarItemBase == null)
            {
                throw new ArgumentNullException("calendarItemBase");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            bool       flag      = calendarItemBase.IsOrganizer() && calendarItemBase.IsMeeting;
            ExDateTime localTime = DateTimeUtilities.GetLocalTime();
            bool       flag2     = false;

            if (calendarItemBase.IsMeeting && calendarItemBase.IsCancelled)
            {
                infobar.AddMessage(-161808760, InfobarMessageType.Informational);
            }
            if (calendarItemBase.CalendarItemType == CalendarItemType.RecurringMaster)
            {
                CalendarItem calendarItem = (CalendarItem)calendarItemBase;
                if (calendarItem.Recurrence != null && !(calendarItem.Recurrence.Range is NoEndRecurrenceRange))
                {
                    OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                    if (lastOccurrence != null && lastOccurrence.EndTime < localTime)
                    {
                        infobar.AddMessage(-2124392108, InfobarMessageType.Informational);
                        flag2 = true;
                    }
                }
            }
            else if (calendarItemBase.EndTime < localTime)
            {
                flag2 = true;
                if (calendarItemBase.CalendarItemType != CalendarItemType.RecurringMaster)
                {
                    infobar.AddMessage(-593429293, InfobarMessageType.Informational);
                }
            }
            InfobarMessageBuilder.AddFlag(infobar, calendarItemBase, userContext);
            if (flag)
            {
                if (calendarItemBase.MeetingRequestWasSent)
                {
                    CalendarUtilities.AddAttendeeResponseCountMessage(infobar, calendarItemBase);
                }
                else
                {
                    infobar.AddMessage(613373695, InfobarMessageType.Informational);
                }
            }
            if (!calendarItemBase.IsOrganizer() && calendarItemBase.IsMeeting)
            {
                bool           flag3          = false;
                MeetingRequest meetingRequest = meetingMessage as MeetingRequest;
                if (meetingRequest != null)
                {
                    flag3 = (meetingRequest.MeetingRequestType == MeetingMessageType.PrincipalWantsCopy);
                }
                if (calendarItemBase.ResponseType != ResponseType.NotResponded)
                {
                    Strings.IDs?ds  = null;
                    Strings.IDs?ds2 = null;
                    switch (calendarItemBase.ResponseType)
                    {
                    case ResponseType.Tentative:
                        ds  = new Strings.IDs?(-1859761232);
                        ds2 = new Strings.IDs?(1365345389);
                        break;

                    case ResponseType.Accept:
                        ds  = new Strings.IDs?(-700793833);
                        ds2 = new Strings.IDs?(-1153967082);
                        break;

                    case ResponseType.Decline:
                        ds  = new Strings.IDs?(-278420592);
                        ds2 = new Strings.IDs?(2009978813);
                        break;
                    }
                    if (ds != null)
                    {
                        ExDateTime property = ItemUtility.GetProperty <ExDateTime>(calendarItemBase, CalendarItemBaseSchema.AppointmentReplyTime, ExDateTime.MinValue);
                        string     text     = Strings.None;
                        string     text2    = string.Empty;
                        if (property != ExDateTime.MinValue)
                        {
                            text  = property.ToString(userContext.UserOptions.DateFormat);
                            text2 = property.ToString(userContext.UserOptions.TimeFormat);
                        }
                        string property2 = ItemUtility.GetProperty <string>(calendarItemBase, CalendarItemBaseSchema.AppointmentReplyName, string.Empty);
                        SanitizedHtmlString messageHtml;
                        if (string.Compare(property2, userContext.ExchangePrincipal.MailboxInfo.DisplayName, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            messageHtml = SanitizedHtmlString.Format(LocalizedStrings.GetHtmlEncoded(ds.Value), new object[]
                            {
                                text,
                                text2
                            });
                        }
                        else
                        {
                            messageHtml = SanitizedHtmlString.Format(LocalizedStrings.GetHtmlEncoded(ds2.Value), new object[]
                            {
                                property2,
                                text,
                                text2
                            });
                        }
                        infobar.AddMessage(messageHtml, InfobarMessageType.Informational);
                        return;
                    }
                }
                else if (!flag2 && !calendarItemBase.IsCancelled)
                {
                    if (!flag3)
                    {
                        bool property3 = ItemUtility.GetProperty <bool>(calendarItemBase, ItemSchema.IsResponseRequested, true);
                        if (property3)
                        {
                            infobar.AddMessage(919273049, InfobarMessageType.Informational);
                        }
                        else
                        {
                            infobar.AddMessage(1602295502, InfobarMessageType.Informational);
                        }
                    }
                    else
                    {
                        infobar.AddMessage(-200304859, InfobarMessageType.Informational);
                    }
                    CalendarUtilities.GetConflictingAppointments(infobar, calendarItemBase, userContext);
                }
            }
        }
 internal void Prepopulate(Folder folder)
 {
     if (folder == null)
     {
         throw new ArgumentNullException("folder");
     }
     this.prepopulate = true;
     if (this.CustomFilterState == null)
     {
         this.CustomFilterState = new Dictionary <ISyncItemId, DateTimeCustomSyncFilter.FilterState>();
     }
     using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, null, new PropertyDefinition[]
     {
         ItemSchema.Id,
         CalendarItemInstanceSchema.EndTime,
         CalendarItemBaseSchema.CalendarItemType,
         StoreObjectSchema.ItemClass,
         ItemSchema.Subject,
         CalendarItemInstanceSchema.StartTime
     }))
     {
         bool flag = false;
         while (!flag)
         {
             object[][] rows = queryResult.GetRows(10000);
             flag = (rows.Length == 0);
             for (int i = 0; i < rows.Length; i++)
             {
                 StoreObjectId storeObjectId = null;
                 DateTimeCustomSyncFilter.FilterState filterState = null;
                 ISyncItemId key = null;
                 try
                 {
                     storeObjectId = ((VersionedId)rows[i][0]).ObjectId;
                     string itemClass = rows[i][3] as string;
                     key = MailboxSyncItemId.CreateForNewItem(storeObjectId);
                     if (!this.CustomFilterState.ContainsKey(key))
                     {
                         filterState = new DateTimeCustomSyncFilter.FilterState();
                         this.CustomFilterState[key] = filterState;
                     }
                     else
                     {
                         filterState = this.CustomFilterState[key];
                     }
                     if (!ObjectClass.IsCalendarItem(itemClass))
                     {
                         filterState.IsCalendarItem = false;
                     }
                     else
                     {
                         filterState.IsCalendarItem = true;
                         if (!(rows[i][2] is CalendarItemType))
                         {
                             filterState.IsCalendarItem = false;
                         }
                         else
                         {
                             filterState.IsRecurring = (CalendarItemType.RecurringMaster == (CalendarItemType)rows[i][2]);
                             if (filterState.IsRecurring)
                             {
                                 using (CalendarItem calendarItem = CalendarItem.Bind(folder.Session, storeObjectId))
                                 {
                                     if (calendarItem.Recurrence != null)
                                     {
                                         if (calendarItem.Recurrence.Range is NoEndRecurrenceRange)
                                         {
                                             filterState.DoesRecurrenceEnd = false;
                                         }
                                         else
                                         {
                                             filterState.DoesRecurrenceEnd = true;
                                             OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                                             filterState.EndTime = lastOccurrence.EndTime;
                                         }
                                     }
                                     else
                                     {
                                         filterState.IsCalendarItem = false;
                                     }
                                     goto IL_1E6;
                                 }
                             }
                             if (!(rows[i][1] is ExDateTime))
                             {
                                 filterState.IsCalendarItem = false;
                             }
                             else
                             {
                                 filterState.EndTime = (ExDateTime)rows[i][1];
                             }
                             IL_1E6 :;
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     if (ex is ObjectNotFoundException)
                     {
                         this.CustomFilterState.Remove(key);
                     }
                     else
                     {
                         if (!SyncCommand.IsItemSyncTolerableException(ex))
                         {
                             throw;
                         }
                         string     text       = "Unknown";
                         ExDateTime exDateTime = ExDateTime.MinValue;
                         try
                         {
                             text       = (rows[i][4] as string);
                             exDateTime = (ExDateTime)rows[i][5];
                         }
                         catch
                         {
                         }
                         AirSyncUtility.ExceptionToStringHelper exceptionToStringHelper = new AirSyncUtility.ExceptionToStringHelper(ex);
                         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Exception was caught in Prepopulate. Item id=\"{0}\", subject=\"{1}\", meetingTime={2}\r\n{3}\r\nIgnoring exception and proceeding to next item.", new object[]
                         {
                             (storeObjectId != null) ? storeObjectId : "null",
                             text,
                             exDateTime,
                             exceptionToStringHelper
                         });
                         if (filterState != null)
                         {
                             filterState.IsCalendarItem = false;
                         }
                     }
                 }
             }
         }
     }
 }
        // Token: 0x06000292 RID: 658 RVA: 0x0000F230 File Offset: 0x0000D430
        private DateTime OpenCalItemToGetStartDate(VersionedId id)
        {
            Exception ex = null;

            try
            {
                this.tracer.TraceDebug <object, VersionedId, string>((long)this.GetHashCode(), "{0}: Going to open item {1} to calculate its start date in Folder: {2}.", TraceContext.Get(), id, this.folderDisplayName);
                using (Item item = Item.Bind(this.mailboxSession, id, ItemBindOption.LoadRequiredPropertiesOnly))
                {
                    if (!(item is CalendarItem))
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "{0}: Item '{1}' in folder '{2}' is supposed to be Calendar item, but is of type '{3}'. Corrupt item.", new object[]
                        {
                            TraceContext.Get(),
                            id,
                            this.folderDisplayName,
                            item.GetType()
                        });
                        return(ItemStartDateCalculator.startDateForCorruptItems);
                    }
                    CalendarItem calendarItem = (CalendarItem)item;
                    if (calendarItem.Recurrence == null)
                    {
                        return((DateTime)calendarItem.EndTime);
                    }
                    if (calendarItem.Recurrence.Range is NoEndRecurrenceRange)
                    {
                        return(DateTime.MinValue);
                    }
                    if (calendarItem.Recurrence.Range is NumberedRecurrenceRange || calendarItem.Recurrence.Range is EndDateRecurrenceRange)
                    {
                        OccurrenceInfo lastOccurrence = calendarItem.Recurrence.GetLastOccurrence();
                        return((DateTime)lastOccurrence.EndTime);
                    }
                }
            }
            catch (CorruptDataException ex2)
            {
                this.tracer.TraceError((long)this.GetHashCode(), "{0}: CorruptDataException thrown for calendar Item '{1}' in folder '{2}' - Corrupt item. Exception: {3}", new object[]
                {
                    TraceContext.Get(),
                    id,
                    this.folderDisplayName,
                    ex2
                });
                return(ItemStartDateCalculator.startDateForCorruptItems);
            }
            catch (RecurrenceException ex3)
            {
                this.tracer.TraceError((long)this.GetHashCode(), "{0}: RecurrenceException thrown for Item '{1}' in folder '{2}' - Corrupt item. Exception: {3}", new object[]
                {
                    TraceContext.Get(),
                    id,
                    this.folderDisplayName,
                    ex3
                });
                return(ItemStartDateCalculator.startDateForCorruptItems);
            }
            catch (ObjectNotFoundException ex4)
            {
                ex = ex4;
            }
            catch (VirusDetectedException ex5)
            {
                ex = ex5;
            }
            catch (VirusScanInProgressException ex6)
            {
                ex = ex6;
            }
            if (ex != null)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "{0}: Exception: {1} thrown for calendar Item '{2}' in folder '{3}' - skipping item.", new object[]
                {
                    TraceContext.Get(),
                    ex,
                    id,
                    this.folderDisplayName
                });
                return(DateTime.MinValue);
            }
            return(DateTime.MinValue);
        }
        // Token: 0x06000295 RID: 661 RVA: 0x0000F5A4 File Offset: 0x0000D7A4
        private DateTime OpenTaskItemToGetStartDate(VersionedId id, object[] itemProperties)
        {
            Exception ex = null;

            try
            {
                this.tracer.TraceDebug <object, VersionedId, string>((long)this.GetHashCode(), "{0}: Going to open item {1} to calculate its start date in Folder: {2}.", TraceContext.Get(), id, this.folderDisplayName);
                using (Item item = Item.Bind(this.mailboxSession, id, ItemBindOption.LoadRequiredPropertiesOnly))
                {
                    if (!(item is Task))
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "{0}: Item '{1}' in folder '{2}' is supposed to be Task item but is of type '{3}'. Corrupt item.", new object[]
                        {
                            TraceContext.Get(),
                            id,
                            this.folderDisplayName,
                            item.GetType()
                        });
                        return(ItemStartDateCalculator.startDateForCorruptItems);
                    }
                    Task task = (Task)item;
                    if (task.Recurrence == null)
                    {
                        return(this.GetStartDateFromCreationDate(itemProperties));
                    }
                    if (task.Recurrence.Range is NoEndRecurrenceRange)
                    {
                        return(DateTime.MinValue);
                    }
                    if (task.Recurrence.Pattern is RegeneratingPattern)
                    {
                        this.tracer.TraceDebug <object, VersionedId, string>((long)this.GetHashCode(), "{0}: Task item '{1}' in folder '{2}' will be skipped because it is a Regenerating task.", TraceContext.Get(), id, this.folderDisplayName);
                        return(DateTime.MinValue);
                    }
                    if (task.Recurrence.Range is NumberedRecurrenceRange || task.Recurrence.Range is EndDateRecurrenceRange)
                    {
                        OccurrenceInfo lastOccurrence = task.Recurrence.GetLastOccurrence();
                        return((DateTime)lastOccurrence.EndTime);
                    }
                }
            }
            catch (CorruptDataException)
            {
                this.tracer.TraceError <object, VersionedId, string>((long)this.GetHashCode(), "{0}: CorruptDataException thrown for task Item '{1}' in folder '{2}' - Corrupt item.", TraceContext.Get(), id, this.folderDisplayName);
                return(ItemStartDateCalculator.startDateForCorruptItems);
            }
            catch (RecurrenceException ex2)
            {
                this.tracer.TraceError((long)this.GetHashCode(), "{0}: RecurrenceException thrown for Item '{1}' in folder '{2}' - Corrupt item. Exception: {3}", new object[]
                {
                    TraceContext.Get(),
                    id,
                    this.folderDisplayName,
                    ex2
                });
                return(ItemStartDateCalculator.startDateForCorruptItems);
            }
            catch (ObjectNotFoundException ex3)
            {
                ex = ex3;
            }
            catch (VirusDetectedException ex4)
            {
                ex = ex4;
            }
            catch (VirusScanInProgressException ex5)
            {
                ex = ex5;
            }
            if (ex != null)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "{0}: Exception: {1} thrown for task Item '{2}' in folder '{3}' - skipping item.", new object[]
                {
                    TraceContext.Get(),
                    ex,
                    id,
                    this.folderDisplayName
                });
                return(DateTime.MinValue);
            }
            return(DateTime.MinValue);
        }
        // Token: 0x060010EE RID: 4334 RVA: 0x00046958 File Offset: 0x00044B58
        private int AddNewOrChangedItems(StoreId id, IList <SyncCalendarItemType> updatedItemsList, IList <SyncCalendarItemType> recurrenceMastersWithInstances, IList <SyncCalendarItemType> recurrenceMastersWithoutInstances, IDictionary <StoreId, SyncCalendarItemType> unchangedRecurrenceMastersWithInstances, IList <StoreId> deletedItemsList, HashSet <StoreId> syncItemsHashSet, IList <KeyValuePair <StoreId, LocalizedException> > caughtExceptions)
        {
            int addedItems = 0;

            try
            {
                GrayException.MapAndReportGrayExceptions(delegate()
                {
                    using (CalendarItem calendarItem = CalendarItem.Bind(this.session, id, new PropertyDefinition[]
                    {
                        CalendarItemInstanceSchema.StartWallClock,
                        CalendarItemInstanceSchema.EndWallClock
                    }))
                    {
                        string uid;
                        try
                        {
                            uid = new GlobalObjectId(calendarItem).Uid;
                        }
                        catch (Exception arg)
                        {
                            ExTraceGlobals.SyncCalendarTracer.TraceWarning <StoreId, Exception>((long)this.GetHashCode(), "Skipping the corrupt recurring calendar GlobalObjectId (Id: '{0}'). {1}", id, arg);
                            uid = null;
                        }
                        SyncCalendarItemType typedItem = this.GetTypedItem(calendarItem.Id, uid, calendarItem.CalendarItemType, calendarItem.StartTime, calendarItem.StartWallClock, calendarItem.EndTime, calendarItem.EndWallClock);
                        if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster)
                        {
                            if (calendarItem.Recurrence == null)
                            {
                                ExTraceGlobals.SyncCalendarTracer.TraceWarning <StoreId>((long)this.GetHashCode(), "Skipping the corrupt recurring calendar item with no recurrence (Id: '{0}').", id);
                            }
                            else
                            {
                                IList <OccurrenceInfo> occurrenceInfoList = calendarItem.Recurrence.GetOccurrenceInfoList(this.windowStart, this.windowEnd);
                                if (occurrenceInfoList.Count != 0)
                                {
                                    addedItems += this.AddSyncItem(typedItem, recurrenceMastersWithInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                                    using (IEnumerator <OccurrenceInfo> enumerator = occurrenceInfoList.GetEnumerator())
                                    {
                                        while (enumerator.MoveNext())
                                        {
                                            OccurrenceInfo occurrenceInfo = enumerator.Current;
                                            CalendarItemType type;
                                            ExDateTime startWallClock;
                                            ExDateTime endWallClock;
                                            if (occurrenceInfo is ExceptionInfo)
                                            {
                                                type           = CalendarItemType.Exception;
                                                startWallClock = ExDateTime.MinValue;
                                                endWallClock   = ExDateTime.MinValue;
                                            }
                                            else
                                            {
                                                type           = CalendarItemType.Occurrence;
                                                startWallClock = calendarItem.StartWallClock.TimeZone.ConvertDateTime(occurrenceInfo.StartTime);
                                                endWallClock   = calendarItem.EndWallClock.TimeZone.ConvertDateTime(occurrenceInfo.EndTime);
                                            }
                                            SyncCalendarItemType typedItem2 = this.GetTypedItem(occurrenceInfo.VersionedId, uid, type, occurrenceInfo.StartTime, startWallClock, occurrenceInfo.EndTime, endWallClock);
                                            addedItems += this.AddSyncItem(typedItem2, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                                        }
                                        goto IL_2D1;
                                    }
                                }
                                addedItems += this.AddSyncItem(typedItem, recurrenceMastersWithoutInstances, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                            }
                        }
                        else
                        {
                            bool flag = this.windowStart <calendarItem.EndTime && this.windowEnd> calendarItem.StartTime;
                            if (flag)
                            {
                                addedItems += this.AddSyncItem(typedItem, updatedItemsList, syncItemsHashSet, unchangedRecurrenceMastersWithInstances, false);
                            }
                            else
                            {
                                addedItems += this.AddDeletedItem(id, syncItemsHashSet, deletedItemsList);
                            }
                        }
                        IL_2D1:;
                    }
                }, new GrayException.IsGrayExceptionDelegate(GrayException.IsSystemGrayException));
            }
            catch (LocalizedException ex)
            {
                ExTraceGlobals.SyncCalendarTracer.TraceWarning <string, LocalizedException>((long)this.GetHashCode(), "XsoSyncCalendar.AddNewOrChangedItems: Exception thrown while processing item {0}: {1}", id.ToBase64String(), ex);
                caughtExceptions.Add(new KeyValuePair <StoreId, LocalizedException>(id, ex));
            }
            return(addedItems);
        }
Example #13
0
        // Token: 0x06000953 RID: 2387 RVA: 0x0003E918 File Offset: 0x0003CB18
        public static CalendarInfo FromMasterCalendarItemAndOccurrenceInfo(ExDateTime creationRequestTime, ExTimeZone timeZoneAdjustment, CalendarItem masterItem, OccurrenceInfo occInfo)
        {
            CalendarInfo calendarInfo = CalendarInfo.FromCalendarItemBase(creationRequestTime, timeZoneAdjustment, masterItem);

            if (occInfo != null)
            {
                calendarInfo.CalendarItemOccurrenceIdentity = ((occInfo.VersionedId == null) ? null : occInfo.VersionedId.ObjectId);
                calendarInfo.StartTime = occInfo.StartTime;
                calendarInfo.EndTime   = occInfo.EndTime;
            }
            return(calendarInfo);
        }