Example #1
0
 internal List <MeetingValidationResult> Run()
 {
     CalendarValidator.< > c__DisplayClass6 CS$ < > 8__locals1 = new CalendarValidator.< > c__DisplayClass6();
     CS$ < > 8__locals1.< > 4__this = this;
     CS$ < > 8__locals1.results     = new List <MeetingValidationResult>();
     using (SessionManager sessionManager = this.independentSession ? new SessionManager(this.mailboxUser.ExchangePrincipal, "Client=ResourceHealth;Action=Meeting Validator") : new SessionManager(this.mailboxSession))
     {
         if (sessionManager.PrimarySession.Session.GetDefaultFolderId(DefaultFolderType.Calendar) == null)
         {
             CS$ < > 8__locals1.meetings = new List <MeetingData>();
         }
         else
         {
             using (CalendarFolder calendarFolder = CalendarFolder.Bind(sessionManager.PrimarySession.Session, DefaultFolderType.Calendar))
             {
                 if (this.validatingRange)
                 {
                     CS$ < > 8__locals1.meetings = CalendarQuery.GetMeetingsInRange(sessionManager.PrimarySession.Session, this.mailboxUser, calendarFolder, this.rangeStart, this.rangeEnd, this.locationToFilterWith, this.subjectToFilterWith, CS$ < > 8__locals1.results);
                 }
                 else
                 {
                     CS$ < > 8__locals1.meetings = CalendarQuery.GetCorrelatedMeetings(sessionManager.PrimarySession.Session, this.mailboxUser, this.meetingToValidate);
                 }
                 if (CS$ < > 8__locals1.meetings.Count > 0)
                 {
                     try
                     {
                         CS$ < > 8__locals1.meetings.Sort();
                         if (CS$ < > 8__locals1.meetings.Count > Configuration.MaxMeetingsToProcessIncludingDuplicates)
                         {
                             CS$ < > 8__locals1.meetings = CS$ < > 8__locals1.meetings.GetRange(0, Configuration.MaxMeetingsToProcessIncludingDuplicates);
                         }
                         Util.CoreCatchMeIfYouCan(delegate
                         {
                             CS$ < > 8__locals1.results.AddRange(CS$ < > 8__locals1.< > 4__this.RemoveDuplicates(sessionManager.PrimarySession.Session, CS$ < > 8__locals1.meetings));
                         }, "CalendarValidator");
                     }
Example #2
0
        internal static List <MeetingData> GetMeetingsInRange(MailboxSession session, UserObject mailboxUser, CalendarFolder calendarFolder, ExDateTime rangeStart, ExDateTime rangeEnd, string locationToFilterWith, string subjectToFilterWith, List <MeetingValidationResult> results)
        {
            object[][]         array   = null;
            List <MeetingData> list    = new List <MeetingData>();
            HashSet <StoreId>  hashSet = new HashSet <StoreId>();

            if (results == null)
            {
                return(list);
            }
            array = CalendarQuery.GetRecurringMasters(calendarFolder, CalendarQuery.CalendarQueryProps);
            foreach (object[] array3 in array)
            {
                if (!ObjectClass.IsCalendarItemSeries((string)array3[29]))
                {
                    string text;
                    if (!CalendarQuery.ArePropertiesValid(array3, out text))
                    {
                        StoreId     storeId     = (StoreId)array3[0];
                        MeetingData meetingData = MeetingData.CreateInstance(mailboxUser, storeId);
                        results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData, false, text));
                    }
                    else
                    {
                        string location = (string)array3[8];
                        string text2    = (string)array3[9];
                        if (CalendarQuery.ShouldContinueLocationSubjectFilters(locationToFilterWith, subjectToFilterWith, location, text2))
                        {
                            StoreId storeId = (StoreId)array3[0];
                            bool    flag    = (bool)array3[3];
                            if (flag)
                            {
                                CalendarItem calendarItem = null;
                                string       empty        = string.Empty;
                                try
                                {
                                    calendarItem = CalendarItem.Bind(session, storeId, CalendarQuery.CalendarQueryProps);
                                    if (calendarItem.Recurrence != null)
                                    {
                                        IList <OccurrenceInfo> modifiedOccurrences = calendarItem.Recurrence.GetModifiedOccurrences();
                                        foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences)
                                        {
                                            StoreId versionedId = occurrenceInfo.VersionedId;
                                            hashSet.Add(versionedId);
                                        }
                                        OccurrenceInfo firstOccurrence;
                                        OccurrenceInfo occurrenceInfo2;
                                        try
                                        {
                                            firstOccurrence = calendarItem.Recurrence.GetFirstOccurrence();
                                            if (calendarItem.Recurrence.Range is NoEndRecurrenceRange)
                                            {
                                                occurrenceInfo2 = null;
                                            }
                                            else
                                            {
                                                occurrenceInfo2 = calendarItem.Recurrence.GetLastOccurrence();
                                            }
                                        }
                                        catch (RecurrenceHasNoOccurrenceException)
                                        {
                                            goto IL_350;
                                        }
                                        catch (InvalidOperationException)
                                        {
                                            MeetingData meetingData2 = MeetingData.CreateInstance(mailboxUser, storeId);
                                            results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData2, false, string.Format("GetMeetingsInRange: InvalidOperationException: no end occurence, Subject=\"{0}\"", text2)));
                                            goto IL_350;
                                        }
                                        if ((occurrenceInfo2 == null || !(occurrenceInfo2.StartTime < rangeStart)) && !(firstOccurrence.EndTime >= rangeEnd))
                                        {
                                            QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(session, CalendarQuery.CalendarQueryProps);
                                            queryResultPropertyBag.SetQueryResultRow(array3);
                                            MeetingData item = MeetingData.CreateInstance(mailboxUser, calendarItem);
                                            list.Add(item);
                                            foreach (OccurrenceInfo occurrenceInfo3 in modifiedOccurrences)
                                            {
                                                if (!(occurrenceInfo3.StartTime > rangeEnd) && !(occurrenceInfo3.StartTime < rangeStart))
                                                {
                                                    MeetingData item2 = MeetingData.CreateInstance(mailboxUser, occurrenceInfo3.VersionedId, calendarItem.GlobalObjectId, CalendarItemType.Exception);
                                                    list.Add(item2);
                                                }
                                            }
                                        }
                                    }
                                }
                                catch (RecurrenceFormatException exception)
                                {
                                    MeetingData item3 = MeetingData.CreateInstance(mailboxUser, storeId, null, exception);
                                    list.Add(item3);
                                }
                                catch (ObjectNotFoundException exception2)
                                {
                                    MeetingData meetingData3 = MeetingData.CreateInstance(mailboxUser, storeId, null, exception2);
                                    list.Add(meetingData3);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData3, false, string.Format("GetMeetingsInRange: ObjectNotFoundException - could not find this meeting, Subject=\"{0}\"", text2)));
                                }
                                catch (CorruptDataException arg)
                                {
                                    text = string.Format("GetMeetingsInRange: Subject=\"{0}\", CorruptDataException: {1}", text2, arg);
                                    MeetingValidationResult mvresultWithMoreCalItemData = CalendarQuery.GetMVResultWithMoreCalItemData(session, mailboxUser, storeId, text, text2, rangeStart, rangeEnd);
                                    results.Add(mvresultWithMoreCalItemData);
                                }
                                catch (ArgumentException exception3)
                                {
                                    MeetingData meetingData4 = MeetingData.CreateInstance(mailboxUser, storeId, null, exception3);
                                    list.Add(meetingData4);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData4, false, string.Format("GetMeetingsInRange: ArgumentException - could not bind this meeting, Subject=\"{0}\"", text2)));
                                }
                                catch (AccessDeniedException arg2)
                                {
                                    MeetingData meetingData5 = MeetingData.CreateInstance(mailboxUser, storeId);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData5, false, string.Format("GetMeetingsInRange:  AccessDeniedException: {0}", arg2)));
                                }
                                finally
                                {
                                    if (calendarItem != null)
                                    {
                                        calendarItem.Dispose();
                                    }
                                }
                            }
                        }
                    }
                }
                IL_350 :;
            }
            try
            {
                array = calendarFolder.GetCalendarView(rangeStart, rangeEnd, CalendarQuery.CalendarQueryProps);
            }
            catch (Exception arg3)
            {
                MeetingData meetingData6 = MeetingData.CreateInstance(mailboxUser, null);
                results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData6, false, string.Format("GetMeetingsInRange:  Exception: {0}", arg3)));
                return(list);
            }
            foreach (object[] array5 in array)
            {
                if (!ObjectClass.IsCalendarItemSeries((string)array5[29]))
                {
                    string errorDescription;
                    if (!CalendarQuery.ArePropertiesValid(array5, out errorDescription))
                    {
                        StoreId     storeId2     = (StoreId)array5[0];
                        MeetingData meetingData7 = MeetingData.CreateInstance(mailboxUser, storeId2);
                        results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData7, false, errorDescription));
                    }
                    else
                    {
                        string location2 = (string)array5[8];
                        string subject   = (string)array5[9];
                        if (CalendarQuery.ShouldContinueLocationSubjectFilters(locationToFilterWith, subjectToFilterWith, location2, subject))
                        {
                            StoreId storeId2 = (StoreId)array5[0];
                            bool    flag2    = (bool)array5[3];
                            if (flag2)
                            {
                                byte[]         array6 = (byte[])array5[1];
                                GlobalObjectId globalObjectId;
                                try
                                {
                                    globalObjectId = new GlobalObjectId(array6);
                                }
                                catch (CorruptDataException arg4)
                                {
                                    MeetingData meetingData8 = MeetingData.CreateInstance(mailboxUser, storeId2);
                                    results.Add(new MeetingValidationResult(rangeStart, rangeEnd, mailboxUser, meetingData8, false, string.Format("GetMeetingsInRange: CorruptDataException: The Global Object ID is invalid ({0}). Error: {1}", GlobalObjectId.ByteArrayToHexString(array6), arg4)));
                                    goto IL_54A;
                                }
                                int value = (int)array5[30];
                                CalendarItemType calendarItemType = (CalendarItemType)array5[5];
                                if (calendarItemType == CalendarItemType.Single)
                                {
                                    int         appointmentSequenceNumber = (int)array5[15];
                                    ExDateTime  lastModifiedTime          = (ExDateTime)array5[14];
                                    ExDateTime  ownerCriticalChangeTime   = (ExDateTime)array5[17];
                                    int         documentId = (int)array5[33];
                                    MeetingData item4      = MeetingData.CreateInstance(mailboxUser, storeId2, globalObjectId, appointmentSequenceNumber, lastModifiedTime, ownerCriticalChangeTime, CalendarItemType.Single, subject, new int?(value), documentId);
                                    list.Add(item4);
                                }
                                else if (calendarItemType == CalendarItemType.Exception)
                                {
                                    if (!hashSet.Contains(storeId2))
                                    {
                                        MeetingData item5 = MeetingData.CreateInstance(mailboxUser, storeId2, globalObjectId, CalendarItemType.Exception);
                                        list.Add(item5);
                                    }
                                }
                                else if (calendarItemType == CalendarItemType.Occurrence)
                                {
                                    MeetingData item6 = MeetingData.CreateInstance(mailboxUser, storeId2, globalObjectId, CalendarItemType.Occurrence);
                                    list.Add(item6);
                                }
                            }
                        }
                    }
                }
                IL_54A :;
            }
            return(list);
        }
Example #3
0
 internal static bool ArePropertiesValid(CalendarItemBase item, out string errorString)
 {
     return(CalendarQuery.ArePropertiesValid(item.GetProperties(CalendarQuery.CalendarQueryProps), out errorString));
 }
        internal override void ValidateMeetings(ref Dictionary <GlobalObjectId, List <Attendee> > organizerRumsSent, Action <long> onItemRepaired)
        {
            bool shouldProcessMailbox = CalendarParticipant.InternalShouldProcessMailbox(this.ExchangePrincipal);

            SessionManager.SessionData sessionData = this.sessionManager[this.ExchangePrincipal];
            foreach (CalendarInstanceContext calendarInstanceContext in base.ItemList.Values)
            {
                string            empty             = string.Empty;
                CalendarLocalItem calendarLocalItem = new CalendarLocalItem(this.ExchangePrincipal, sessionData.Session);
                calendarInstanceContext.ValidationContext.CalendarInstance = calendarLocalItem;
                calendarInstanceContext.ValidationContext.CalendarInstance.ShouldProcessMailbox = shouldProcessMailbox;
                try
                {
                    using (CalendarFolder calendarFolder = CalendarFolder.Bind(sessionData.Session, DefaultFolderType.Calendar, null))
                    {
                        calendarLocalItem.CalendarFolderId = calendarFolder.Id.ObjectId.ProviderLevelItemId;
                        CalendarItemBase calendarItemBase = CalendarQuery.FindMatchingItem(sessionData.Session, calendarFolder, calendarInstanceContext.ValidationContext.BaseItem.CalendarItemType, calendarInstanceContext.ValidationContext.BaseItem.GlobalObjectId.Bytes, ref empty);
                        if (calendarInstanceContext.ValidationContext.OppositeRole == RoleType.Organizer)
                        {
                            if (calendarItemBase != null)
                            {
                                calendarInstanceContext.ValidationContext.OppositeRoleOrganizerIsValid = calendarItemBase.IsOrganizer();
                            }
                            else
                            {
                                calendarInstanceContext.ValidationContext.OppositeRoleOrganizerIsValid = this.IsOrganizerValid(sessionData.Session, calendarInstanceContext);
                            }
                            calendarInstanceContext.ValidationContext.OppositeItem = (calendarInstanceContext.ValidationContext.OppositeRoleOrganizerIsValid ? calendarItemBase : null);
                        }
                        else
                        {
                            calendarInstanceContext.ValidationContext.OppositeItem = calendarItemBase;
                        }
                        calendarInstanceContext.ValidationContext.ErrorString = empty;
                    }
                }
                catch (StorageTransientException ex)
                {
                    string text = string.Format("Could not open item store session or calendar, exception = {0}", ex.GetType());
                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text);
                    calendarInstanceContext.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(calendarInstanceContext.ValidationContext.OppositeRole, text, CalendarInconsistencyFlag.StorageException, calendarInstanceContext.ValidationContext);
                }
                catch (RecurrenceFormatException ex2)
                {
                    string text2 = string.Format("Could not open item store session or calendar due recurrence format error, exception = {0}", ex2.GetType());
                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text2);
                    calendarInstanceContext.ValidationContext.CalendarInstance.LoadInconsistency = ((calendarInstanceContext.ValidationContext.OppositeRole == RoleType.Attendee) ? Inconsistency.CreateInstance(calendarInstanceContext.ValidationContext.OppositeRole, text2, CalendarInconsistencyFlag.RecurrenceBlob, calendarInstanceContext.ValidationContext) : null);
                }
                catch (StoragePermanentException ex3)
                {
                    string text3 = string.Format("Could not open item store session or calendar, exception = {0}", ex3.GetType());
                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text3);
                    calendarInstanceContext.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(calendarInstanceContext.ValidationContext.OppositeRole, text3, CalendarInconsistencyFlag.StorageException, calendarInstanceContext.ValidationContext);
                }
                catch (ArgumentException arg)
                {
                    Globals.ConsistencyChecksTracer.TraceError <RoleType, ArgumentException>((long)this.GetHashCode(), "Could not open item store session or calendar for {0}, exception = {1}", calendarInstanceContext.ValidationContext.OppositeRole, arg);
                }
                finally
                {
                    base.ValidateInstance(calendarInstanceContext, organizerRumsSent, onItemRepaired);
                    if (calendarInstanceContext.ValidationContext.OppositeItem != null)
                    {
                        calendarInstanceContext.ValidationContext.OppositeItem.Dispose();
                        calendarInstanceContext.ValidationContext.OppositeItem = null;
                    }
                }
            }
        }