コード例 #1
0
        // Token: 0x06000B77 RID: 2935 RVA: 0x0004A378 File Offset: 0x00048578
        public static bool?QuickCheckForAutomatedBooking(MapiEvent mapiEvent, CachedState cachedState)
        {
            bool?result = new bool?(false);

            cachedState.LockForRead();
            CalendarConfiguration calendarConfiguration;

            try
            {
                calendarConfiguration = (cachedState.State[0] as CalendarConfiguration);
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            if (calendarConfiguration == null || ResourceCheck.IsEventConfigChange(mapiEvent))
            {
                result = null;
            }
            else
            {
                result = new bool?(calendarConfiguration.AutomateProcessing == CalendarProcessingFlags.AutoAccept);
            }
            return(result);
        }
コード例 #2
0
        // Token: 0x06000774 RID: 1908 RVA: 0x00034760 File Offset: 0x00032960
        private bool IsMessageInteresting(MapiEvent mapiEvent)
        {
            bool flag = ResourceCheck.IsEventConfigChange(mapiEvent);

            if (ObjectClass.IsMiddleTierRulesMessage(mapiEvent.ObjectClass) && !flag)
            {
                return(true);
            }
            if (!CalendarAssistant.ShouldProcessMessageClass(mapiEvent) && !flag)
            {
                return(false);
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);
            bool?       flag2       = ResourceCheck.QuickCheckForAutomatedBooking(mapiEvent, cachedState);

            if (flag2 == null)
            {
                return(true);
            }
            if (flag2 == false)
            {
                cachedState.LockForRead();
                CalendarConfiguration calendarConfiguration;
                try
                {
                    calendarConfiguration = (cachedState.State[0] as CalendarConfiguration);
                }
                finally
                {
                    cachedState.ReleaseReaderLock();
                }
                return(!calendarConfiguration.SkipProcessing);
            }
            return(false);
        }
コード例 #3
0
        // Token: 0x06000B7A RID: 2938 RVA: 0x0004A418 File Offset: 0x00048618
        private static bool InternalCheckForAutomaticBooking(bool isEventForConfigObject, MailboxSession itemStore, CachedState cachedState)
        {
            cachedState.LockForRead();
            CalendarConfiguration calendarConfiguration;

            try
            {
                calendarConfiguration = (cachedState.State[0] as CalendarConfiguration);
                if (calendarConfiguration == null || isEventForConfigObject)
                {
                    LockCookie lockCookie = cachedState.UpgradeToWriterLock();
                    try
                    {
                        using (CalendarConfigurationDataProvider calendarConfigurationDataProvider = new CalendarConfigurationDataProvider(itemStore))
                        {
                            calendarConfiguration = (CalendarConfiguration)calendarConfigurationDataProvider.Read <CalendarConfiguration>(null);
                            if (calendarConfiguration == null)
                            {
                                Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_CorruptCalendarConfiguration, null, new object[]
                                {
                                    itemStore.MailboxOwner.LegacyDn
                                });
                                calendarConfigurationDataProvider.Delete(new CalendarConfiguration());
                                calendarConfiguration = new CalendarConfiguration();
                            }
                        }
                        if (calendarConfiguration.AutomateProcessing == CalendarProcessingFlags.AutoAccept)
                        {
                            calendarConfiguration.AddNewRequestsTentatively = true;
                        }
                        cachedState.State[0] = calendarConfiguration;
                        ResourceCheck.Tracer.TraceDebug((long)itemStore.GetHashCode(), "{0}: The calendar settings object was new or has been changed - (re)reading contents.", new object[]
                        {
                            TraceContext.Get()
                        });
                    }
                    catch (ObjectNotFoundException innerException)
                    {
                        ResourceCheck.Tracer.TraceError((long)itemStore.GetHashCode(), "{0}: The calendar configuration was deleted while we were looking at it. Back off and retry.", new object[]
                        {
                            TraceContext.Get()
                        });
                        throw new TransientMailboxException(innerException);
                    }
                    finally
                    {
                        cachedState.DowngradeFromWriterLock(ref lockCookie);
                    }
                }
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            ResourceCheck.Tracer.TraceDebug <object, CalendarProcessingFlags>((long)itemStore.GetHashCode(), "{0}: MailboxType {1}", TraceContext.Get(), calendarConfiguration.AutomateProcessing);
            ResourceCheck.TracerPfd.TracePfd <int, object, CalendarProcessingFlags>((long)itemStore.GetHashCode(), "PFD IWR {0} {1}: ResourceMailbox: {2}", 19223, TraceContext.Get(), calendarConfiguration.AutomateProcessing);
            return(calendarConfiguration.AutomateProcessing == CalendarProcessingFlags.AutoAccept);
        }
コード例 #4
0
        // Token: 0x060004ED RID: 1261 RVA: 0x000257D4 File Offset: 0x000239D4
        internal static UserRetentionPolicyCache QuickCheckForRetentionPolicy(MapiEvent mapiEvent, CachedState cachedState)
        {
            UserRetentionPolicyCache userRetentionPolicyCache = null;

            cachedState.LockForRead();
            try
            {
                userRetentionPolicyCache = (cachedState.State[5] as UserRetentionPolicyCache);
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            if (userRetentionPolicyCache == null || RetentionPolicyCheck.IsEventConfigChange(mapiEvent) || userRetentionPolicyCache.HasPendingFaiEvent)
            {
                userRetentionPolicyCache = null;
            }
            return(userRetentionPolicyCache);
        }
コード例 #5
0
        // Token: 0x060004EE RID: 1262 RVA: 0x00025828 File Offset: 0x00023A28
        internal static UserRetentionPolicyCache DetailedCheckForRetentionPolicy(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, CachedState cachedState)
        {
            UserRetentionPolicyCache userRetentionPolicyCache = null;

            cachedState.LockForRead();
            try
            {
                userRetentionPolicyCache = (cachedState.State[5] as UserRetentionPolicyCache);
                if (userRetentionPolicyCache == null || (item != null && RetentionPolicyCheck.IsEventConfigChange(mapiEvent)) || (userRetentionPolicyCache.HasPendingFaiEvent && userRetentionPolicyCache.PendingFaiEventCounter <= mapiEvent.EventCounter))
                {
                    LockCookie lockCookie = cachedState.UpgradeToWriterLock();
                    try
                    {
                        if (userRetentionPolicyCache == null || !userRetentionPolicyCache.UnderRetentionPolicy)
                        {
                            userRetentionPolicyCache = new UserRetentionPolicyCache();
                        }
                        userRetentionPolicyCache.LoadStoreTagDataFromStore(itemStore);
                        if (!userRetentionPolicyCache.UnderRetentionPolicy)
                        {
                            userRetentionPolicyCache = RetentionPolicyCheck.CachedOffState;
                        }
                        cachedState.State[5] = userRetentionPolicyCache;
                        RetentionPolicyCheck.Tracer.TraceDebug((long)itemStore.GetHashCode(), "{0}: The MRM settings object was new or has been changed - (re)reading contents.", new object[]
                        {
                            TraceContext.Get()
                        });
                    }
                    finally
                    {
                        cachedState.DowngradeFromWriterLock(ref lockCookie);
                    }
                }
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            RetentionPolicyCheck.Tracer.TraceDebug <object, bool>((long)itemStore.GetHashCode(), "{0}: Mailbox under retention policy: {1}", TraceContext.Get(), userRetentionPolicyCache.UnderRetentionPolicy);
            RetentionPolicyCheck.TracerPfd.TracePfd <int, object, bool>((long)itemStore.GetHashCode(), "PFD IWR {0} {1}: Mailbox under retention policy: {2}", 19223, TraceContext.Get(), userRetentionPolicyCache.UnderRetentionPolicy);
            return(userRetentionPolicyCache);
        }
コード例 #6
0
        // Token: 0x060004A3 RID: 1187 RVA: 0x00022124 File Offset: 0x00020324
        protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog)
        {
            ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "MapiEvent is handled: {0}", mapiEvent);
            this.ManageCache(mapiEvent.MailboxGuid);
            if (this.IsIgnorableDraft(mapiEvent, item))
            {
                return;
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);

            cachedState.LockForRead();
            UserRetentionPolicyCache userRetentionPolicyCache = null;

            try
            {
                userRetentionPolicyCache = RetentionPolicyCheck.DetailedCheckForRetentionPolicy(mapiEvent, itemStore, item, cachedState);
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            if (RetentionPolicyCheck.IsEventConfigChange(mapiEvent))
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: updated configuration {1}", TraceContext.Get(), mapiEvent);
                return;
            }
            if (userRetentionPolicyCache != null && userRetentionPolicyCache.UnderRetentionPolicy)
            {
                bool flag = false;
                if (!this.IsEventOnRelevantFolder(userRetentionPolicyCache, mapiEvent))
                {
                    return;
                }
                if (mapiEvent.ClientType == MapiEventClientTypes.Transport && !this.InSentItems(userRetentionPolicyCache, mapiEvent))
                {
                    ElcEventBasedAssistant.Tracer.TraceDebug <ElcEventBasedAssistant, MapiEvent>((long)this.GetHashCode(), "{0} Event is from transport and item not in SentItems. Ignoring from HandleEvent. Mapievent: {1}", this, mapiEvent);
                    return;
                }
                if (TagAssistantHelper.IsConflictableItem(mapiEvent.ObjectClass, mapiEvent.ParentEntryId, userRetentionPolicyCache.DeletedItemsId))
                {
                    return;
                }
                if ((mapiEvent.EventMask & MapiEventTypeFlags.ObjectMoved) != (MapiEventTypeFlags)0 && mapiEvent.ItemType == ObjectType.MAPI_FOLDER)
                {
                    userRetentionPolicyCache.ResetFolderCaches();
                }
                StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(mapiEvent.ItemEntryId);
                if (mapiEvent.ItemType == ObjectType.MAPI_FOLDER && item == null && mapiEvent.ItemEntryId != null && (mapiEvent.EventMask & MapiEventTypeFlags.ObjectDeleted) == (MapiEventTypeFlags)0)
                {
                    Exception ex = null;
                    try
                    {
                        ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: A folder was changed and needs to be manually loaded {1}", TraceContext.Get(), mapiEvent);
                        item = Folder.Bind(itemStore, storeObjectId, ElcEventBasedAssistantType.InternalPreloadItemProperties);
                        flag = true;
                    }
                    catch (ObjectNotFoundException ex2)
                    {
                        ex = ex2;
                    }
                    catch (ConversionFailedException ex3)
                    {
                        ex = ex3;
                    }
                    catch (VirusMessageDeletedException ex4)
                    {
                        ex = ex4;
                    }
                    if (ex != null)
                    {
                        ElcEventBasedAssistant.Tracer.TraceDebug <ElcEventBasedAssistant, Exception>((long)this.GetHashCode(), "{0}: Problems loading a folder. It will not be processed. Exception: {1}", this, ex);
                        return;
                    }
                }
                try
                {
                    StoreObjectId     parentId          = StoreObjectId.FromProviderSpecificId(mapiEvent.ParentEntryId);
                    ElcEventProcessor elcEventProcessor = ElcEventProcessor.GetElcEventProcessor();
                    elcEventProcessor.ValidateStoreObject(userRetentionPolicyCache, itemStore, parentId, storeObjectId, item, mapiEvent);
                }
                finally
                {
                    if (flag)
                    {
                        item.Dispose();
                    }
                }
            }
        }
コード例 #7
0
        // Token: 0x06000779 RID: 1913 RVA: 0x00034A3C File Offset: 0x00032C3C
        private void HandleMeetingMessage(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog)
        {
            if (item == null)
            {
                string objectClass = mapiEvent.ObjectClass;
            }
            else
            {
                string className = item.ClassName;
            }
            if (itemStore.GetDefaultFolderId(DefaultFolderType.Calendar) == null)
            {
                CalendarAssistant.GeneralTracer.TraceDebug((long)this.GetHashCode(), "{0}: Calendar folder does not exist. Skipping processing.", new object[]
                {
                    TraceContext.Get()
                });
                CalendarAssistantLog.LogEntry(itemStore, "Could not get default folder id", new object[0]);
                return;
            }
            if (item == null)
            {
                return;
            }
            MeetingMessage meetingMessage = item as MeetingMessage;

            if (meetingMessage != null && meetingMessage.IsArchiveMigratedMessage)
            {
                CalendarAssistant.CachedStateTracer.TraceDebug((long)this.GetHashCode(), "{0}: Skipping the processing of the meeting item as this is an EHA migration traffic.", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);
            bool        flag        = ResourceCheck.DetailedCheckForAutomatedBooking(mapiEvent, itemStore, item, cachedState);

            if (itemStore != null)
            {
                string legacyDn = itemStore.MailboxOwner.LegacyDn;
            }
            if (flag)
            {
                CalendarAssistant.CachedStateTracer.TraceDebug((long)this.GetHashCode(), "{0}: Updated the cachedState object, but this is a resource mailbox.", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            cachedState.LockForRead();
            CalendarConfiguration calendarConfiguration;

            try
            {
                calendarConfiguration = (cachedState.State[0] as CalendarConfiguration);
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            if (calendarConfiguration.SkipProcessing)
            {
                CalendarAssistant.CachedStateTracer.TraceDebug((long)this.GetHashCode(), "{0}: SkipProcessing is set.", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            if (CalendarAssistant.ShouldIgnoreMessage(itemStore, item.ParentId, meetingMessage))
            {
                return;
            }
            string text = (string)Utils.SafeGetProperty(item, ItemSchema.InternetMessageId, "<null>");

            if (CalendarAssistant.ShouldProcessMessageClass(mapiEvent) && CalendarAssistant.ShouldProcessSeriesMessages(mapiEvent, itemStore))
            {
                bool     flag2  = false;
                DateTime utcNow = DateTime.UtcNow;
                if (meetingMessage != null)
                {
                    CalendarItemBase calendarItemBase = null;
                    try
                    {
                        if (meetingMessage.IsDelegated())
                        {
                            this.calProcessor.OldMessageDeletion.PerformCleanUp(itemStore, item, calendarConfiguration, calendarItemBase, null);
                        }
                        else
                        {
                            IEnumerable <VersionedId> duplicates;
                            bool calendarItem = CalendarAssistant.GetCalendarItem(meetingMessage, CalendarAssistant.UnexpectedPathTracer, ref calendarItemBase, true, out duplicates);
                            if (calendarItem)
                            {
                                this.calProcessor.ProcessMeetingMessage(itemStore, meetingMessage, ref calendarItemBase, calendarConfiguration, duplicates, true, itemStore.MailboxOwner.IsResource.Value);
                            }
                        }
                    }
                    catch (OccurrenceCrossingBoundaryException ex)
                    {
                        CalendarAssistant.ProcessingTracer.TraceDebug <object, VersionedId>((long)meetingMessage.GetHashCode(), "{0}: Found an overlapping occurrence while processing message ID={1}. Cleaning things up and retrying", TraceContext.Get(), meetingMessage.Id);
                        StringBuilder stringBuilder = new StringBuilder(1024);
                        stringBuilder.AppendFormat("Found an overlapping occurrence while processing message ID={0}.", meetingMessage.Id);
                        if (ex.OccurrenceInfo == null)
                        {
                            CalendarAssistant.UnexpectedPathTracer.TraceError((long)this.GetHashCode(), "{0}: Unexpected: Handling OccurrenceCrossingBoundaryException, the OccurrenceInfo is null.", new object[]
                            {
                                TraceContext.Get()
                            });
                            stringBuilder.Append("Unexpected: Handling OccurrenceCrossingBoundaryException, the OccurrenceInfo is null.");
                        }
                        else
                        {
                            VersionedId versionedId = ex.OccurrenceInfo.VersionedId;
                            AggregateOperationResult aggregateOperationResult = meetingMessage.Session.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                            {
                                versionedId
                            });
                            CalendarAssistant.ProcessingTracer.TraceDebug <object, OperationResult>((long)this.GetHashCode(), "{0}: Deleting the occurrence when handling an OccurrenceCrossingBoundaryException, returned:{1}", TraceContext.Get(), aggregateOperationResult.OperationResult);
                            stringBuilder.AppendFormat("Deleting the occurrence when handling an OccurrenceCrossingBoundaryException, returned: {0}", aggregateOperationResult.OperationResult);
                        }
                        CalendarAssistantLog.LogEntry(itemStore, ex, false, stringBuilder.ToString(), new object[0]);
                    }
                    catch (CorruptDataException ex2)
                    {
                        CalendarAssistant.ProcessingTracer.TraceDebug <object, CorruptDataException>((long)this.GetHashCode(), "{0}: Got a corrupt message, exception data:{1}", TraceContext.Get(), ex2);
                        CalendarAssistantLog.LogEntry(itemStore, ex2, false, "Got a corrupt message ID = {0}.", new object[]
                        {
                            meetingMessage.Id
                        });
                    }
                    finally
                    {
                        if (calendarItemBase != null)
                        {
                            calendarItemBase.Dispose();
                            calendarItemBase = null;
                        }
                    }
                    flag2 = true;
                }
                else if (item is MeetingInquiryMessage)
                {
                    MeetingInquiryMessage meetingInquiryMessage = (MeetingInquiryMessage)item;
                    try
                    {
                        this.calProcessor.ProcessMeetingInquiryMessage(this.cvsGateway, itemStore, meetingInquiryMessage);
                    }
                    catch (CalendarVersionStoreNotPopulatedException ex3)
                    {
                        CalendarAssistant.ProcessingTracer.TraceWarning <object, CalendarVersionStoreNotPopulatedException>((long)this.GetHashCode(), "{0}: Failed to process an inquiry message, because the CVS is not populated yet. {1}", TraceContext.Get(), ex3);
                        CalendarAssistantLog.LogEntry(itemStore, ex3, false, "Failed to process an inquiry message ID = {0}, because the CVS is not populated yet.", new object[]
                        {
                            meetingInquiryMessage.Id
                        });
                    }
                    this.calProcessor.OldMessageDeletion.DeleteMessage(itemStore, item);
                    flag2 = true;
                }
                else
                {
                    CalendarAssistant.UnexpectedPathTracer.TraceError((long)this.GetHashCode(), "{0}: Unexpected: Message class matched, but is not the correct object type. Ignoring message.", new object[]
                    {
                        TraceContext.Get()
                    });
                    CalendarAssistantLog.LogEntry(itemStore, "Unexpected: Message class matched, but is not the correct object type. Ignoring message ID = {0}.", new object[]
                    {
                        item.Id
                    });
                }
                if (flag2)
                {
                    TimeSpan timeSpan = DateTime.UtcNow.Subtract(utcNow);
                    CalendarAssistantPerformanceCounters.LastCalAssistantProcessingTime.RawValue = (long)timeSpan.TotalMilliseconds;
                    CalendarAssistantPerformanceCounters.AverageCalAssistantProcessingTime.IncrementBy((long)timeSpan.TotalMilliseconds);
                    CalendarAssistantPerformanceCounters.AverageCalAssistantProcessingTimeBase.Increment();
                    CalendarAssistantPerformanceCounters.MeetingMessagesProcessed.Increment();
                }
                CalendarAssistant.GeneralTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Finished processing message. InternetMessgeID = {1}", TraceContext.Get(), text);
                CalendarAssistant.TracerPfd.TracePfd <int, object, string>((long)this.GetHashCode(), "PFD IWC {0} {1}: Finished processing message. InternetMessgeID = {2}", 21655, TraceContext.Get(), text);
            }
        }
コード例 #8
0
        // Token: 0x06000B71 RID: 2929 RVA: 0x00049A1C File Offset: 0x00047C1C
        protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog)
        {
            ResourceBookingAssistantLogEntry resourceBookingAssistantLogEntry = new ResourceBookingAssistantLogEntry
            {
                MapiEventFlag = mapiEvent.EventMask.ToString(),
                MailboxGuid   = itemStore.MailboxGuid,
                TenantGuid    = itemStore.MailboxOwner.MailboxInfo.OrganizationId.GetTenantGuid(),
                DatabaseGuid  = itemStore.MailboxOwner.MailboxInfo.GetDatabaseGuid()
            };

            try
            {
                string text = (item != null) ? item.ClassName : mapiEvent.ObjectClass;
                resourceBookingAssistantLogEntry.ObjectClass = text;
                if (itemStore.GetDefaultFolderId(DefaultFolderType.Calendar) == null)
                {
                    ResourceBookingAssistant.Tracer.TraceDebug <object, Guid>((long)this.GetHashCode(), "{0}: Mailbox: {1} - Calendar folder does not exist. Skipping processing.", TraceContext.Get(), mapiEvent.MailboxGuid);
                    resourceBookingAssistantLogEntry.IsCalendarFolderNotAvailable = true;
                }
                else
                {
                    CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);
                    bool        flag        = ResourceCheck.DetailedCheckForAutomatedBooking(mapiEvent, itemStore, item, cachedState);
                    resourceBookingAssistantLogEntry.IsAutomatedBooking = flag;
                    if (flag)
                    {
                        if (item == null)
                        {
                            ResourceBookingAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: HandleEvent was passed a null item.", new object[]
                            {
                                TraceContext.Get()
                            });
                        }
                        else
                        {
                            ResourceBookingAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Automatic Booking is on.", new object[]
                            {
                                TraceContext.Get()
                            });
                            if (item is MeetingMessage)
                            {
                                MeetingMessage meetingMessage = item as MeetingMessage;
                                resourceBookingAssistantLogEntry.MeetingSender            = meetingMessage.Sender.EmailAddress;
                                resourceBookingAssistantLogEntry.MeetingInternetMessageId = meetingMessage.InternetMessageId;
                                if (meetingMessage.IsDelegated())
                                {
                                    ResourceBookingAssistant.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Deleting delegated meeting message: ID={1}", TraceContext.Get(), item.Id.ToString());
                                    itemStore.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                                    {
                                        meetingMessage.Id
                                    });
                                    RbaLog.LogEntry(itemStore, meetingMessage, EvaluationResults.Delete);
                                    resourceBookingAssistantLogEntry.IsDelegatedMeetingRequest = true;
                                    return;
                                }
                            }
                            cachedState.LockForRead();
                            CalendarConfiguration calendarConfiguration;
                            try
                            {
                                calendarConfiguration = (cachedState.State[0] as CalendarConfiguration);
                            }
                            finally
                            {
                                cachedState.ReleaseReaderLock();
                            }
                            bool flag2 = false;
                            try
                            {
                                if (item is MeetingRequest)
                                {
                                    flag2 = (item as MeetingRequest).IsOrganizer();
                                }
                                else if (item is MeetingCancellation)
                                {
                                    flag2 = (item as MeetingCancellation).IsOrganizer();
                                }
                            }
                            catch (ObjectNotFoundException innerException)
                            {
                                ResourceBookingAssistant.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Object Not Found. ID={1}", TraceContext.Get(), item.Id.ToString());
                                throw new TransientMailboxException(innerException);
                            }
                            resourceBookingAssistantLogEntry.IsOrganizer = flag2;
                            if (!ObjectClass.IsOfClass(text, "IPM.Schedule.Meeting") || flag2)
                            {
                                if (calendarConfiguration.DeleteNonCalendarItems && (mapiEvent.EventMask & MapiEventTypeFlags.NewMail) != (MapiEventTypeFlags)0)
                                {
                                    ResourceBookingAssistant.Tracer.TraceError((long)this.GetHashCode(), "{0}: Deleting a non-meeting message", new object[]
                                    {
                                        TraceContext.Get()
                                    });
                                    if (item is MessageItem)
                                    {
                                        RbaLog.LogEntry(itemStore, item as MessageItem, EvaluationResults.Delete);
                                    }
                                    itemStore.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                                    {
                                        item.Id
                                    });
                                    resourceBookingAssistantLogEntry.DeleteNonMeetingMessage = true;
                                }
                            }
                            else
                            {
                                ResourceBookingAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Message is the right class", new object[]
                                {
                                    TraceContext.Get()
                                });
                                if (!(item is MeetingMessage))
                                {
                                    ResourceBookingAssistant.Tracer.TraceError((long)this.GetHashCode(), "{0}: Unexpected: Message class matched, but is not the correct object type. Ignoring message.", new object[]
                                    {
                                        TraceContext.Get()
                                    });
                                }
                                else
                                {
                                    ResourceBookingAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Message is MeetingMessage", new object[]
                                    {
                                        TraceContext.Get()
                                    });
                                    resourceBookingAssistantLogEntry.IsMeetingMessage = true;
                                    MeetingMessage   meetingMessage   = item as MeetingMessage;
                                    CalendarItemBase calendarItemBase = null;
                                    DateTime         utcNow           = DateTime.UtcNow;
                                    resourceBookingAssistantLogEntry.StartProcessingTime = utcNow;
                                    for (int i = 0; i < 2; i++)
                                    {
                                        IEnumerable <VersionedId> duplicates;
                                        Exception ex;
                                        bool      calendarItem = CalendarAssistant.GetCalendarItem(meetingMessage, ResourceBookingAssistant.Tracer, ref calendarItemBase, false, out duplicates, out ex);
                                        resourceBookingAssistantLogEntry.AddExceptionToLog(ex);
                                        if (!calendarItem)
                                        {
                                            break;
                                        }
                                        if (calendarItemBase == null)
                                        {
                                            ResourceBookingAssistant.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: Original CalendarItem for message {1} is null", TraceContext.Get(), meetingMessage.Id);
                                        }
                                        StoreObjectValidationError[] array = meetingMessage.Validate();
                                        if (array != null && array.Length > 0)
                                        {
                                            ResourceBookingAssistant.Tracer.TraceError <object, StoreObjectValidationError>((long)this.GetHashCode(), "{0}: mtgMessage did not validate, {1}", TraceContext.Get(), array[0]);
                                            resourceBookingAssistantLogEntry.IsMeetingMessageInvalid = true;
                                            throw new SkipException(Strings.descSkipExceptionFailedValidateCalItem);
                                        }
                                        string text2 = string.Empty;
                                        try
                                        {
                                            this.calProcessor.ProcessMeetingMessage(itemStore, meetingMessage, ref calendarItemBase, calendarConfiguration, duplicates, false);
                                            text2 = meetingMessage.Id.ToString();
                                            resourceBookingAssistantLogEntry.IsMeetingMessageProcessed = true;
                                            resourceBookingAssistantLogEntry.MeetingMessageId          = text2;
                                            bool flag3 = false;
                                            if (meetingMessage is MeetingRequest)
                                            {
                                                flag3 = (meetingMessage as MeetingRequest).IsOrganizer();
                                            }
                                            else if (meetingMessage is MeetingCancellation)
                                            {
                                                flag3 = (meetingMessage as MeetingCancellation).IsOrganizer();
                                            }
                                            else if (meetingMessage is MeetingResponse)
                                            {
                                                flag3 = true;
                                            }
                                            resourceBookingAssistantLogEntry.IsOrganizer = flag3;
                                            resourceBookingAssistantLogEntry.IsDelegatedMeetingRequest = meetingMessage.IsDelegated();
                                            if (calendarItemBase == null)
                                            {
                                                if (flag3)
                                                {
                                                    RbaLog.LogEntry(itemStore, meetingMessage, EvaluationResults.IgnoreOrganizer);
                                                }
                                                else if (resourceBookingAssistantLogEntry.IsDelegatedMeetingRequest)
                                                {
                                                    RbaLog.LogEntry(itemStore, meetingMessage, EvaluationResults.IgnoreDelegate);
                                                }
                                            }
                                            if (calendarItemBase == null && meetingMessage is MeetingCancellation)
                                            {
                                                ResourceBookingAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Deleting a meeting cancellation without correlated calendar item found", new object[]
                                                {
                                                    TraceContext.Get()
                                                });
                                                itemStore.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                                                {
                                                    meetingMessage.Id
                                                });
                                                RbaLog.LogEntry(itemStore, meetingMessage, EvaluationResults.Delete);
                                                resourceBookingAssistantLogEntry.DeleteCanceledMeeting = true;
                                            }
                                            if (calendarItemBase != null)
                                            {
                                                StoreObjectValidationError[] array2 = calendarItemBase.Validate();
                                                if (array2 != null && array2.Length > 0)
                                                {
                                                    ResourceBookingAssistant.Tracer.TraceError <object, StoreObjectValidationError>((long)this.GetHashCode(), "{0}: calendar item did not validate, {1}", TraceContext.Get(), array2[0]);
                                                    throw new SkipException(Strings.descSkipExceptionFailedValidateCalItem);
                                                }
                                                ResourceBookingAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: About to process request", new object[]
                                                {
                                                    TraceContext.Get()
                                                });
                                                EvaluationResults evaluationResults = EvaluationResults.None;
                                                BookingRoles      bookingRoles      = BookingRoles.NoRole;
                                                ResourceBookingProcessing.ProcessRequest(mapiEvent, itemStore, meetingMessage, ref calendarItemBase, calendarConfiguration, out evaluationResults, out bookingRoles);
                                                resourceBookingAssistantLogEntry.IsResourceBookingRequestProcessed = true;
                                                resourceBookingAssistantLogEntry.EvaluationResult = evaluationResults.ToString();
                                                resourceBookingAssistantLogEntry.BookingRole      = bookingRoles.ToString();
                                            }
                                            break;
                                        }
                                        catch (CorruptDataException ex2)
                                        {
                                            ResourceBookingAssistant.Tracer.TraceDebug <object, string, CorruptDataException>((long)this.GetHashCode(), "{0}: The calendar item found was corrupted, so we could not do Resource Booking processing for message ID={1}, skipping event. Exception={2}", TraceContext.Get(), text2, ex2);
                                            throw new SkipException(ex2);
                                        }
                                        catch (ADTransientException arg)
                                        {
                                            ResourceBookingAssistant.Tracer.TraceDebug <object, string, ADTransientException>((long)this.GetHashCode(), "{0}: There was an tranisent AD error processing the calendar item during Resource Booking processing for message ID={1}, cleaning things up and retrying. Exception={2}", TraceContext.Get(), text2, arg);
                                            throw;
                                        }
                                        catch (ObjectNotFoundException innerException2)
                                        {
                                            ResourceBookingAssistant.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Object Not Found. ID={1}", TraceContext.Get(), text2);
                                            throw new TransientMailboxException(innerException2);
                                        }
                                        catch (SaveConflictException ex3)
                                        {
                                            ResourceBookingAssistant.Tracer.TraceDebug <object, string, SaveConflictException>((long)this.GetHashCode(), "{0}: There was an error saving the calendar item during Resource Booking processing for message ID={1}, cleaning things up and retrying.Exception={2}", TraceContext.Get(), text2, ex3);
                                            resourceBookingAssistantLogEntry.AddExceptionToLog(ex3);
                                        }
                                        catch (OccurrenceCrossingBoundaryException ex4)
                                        {
                                            resourceBookingAssistantLogEntry.AddExceptionToLog(ex4);
                                            ResourceBookingAssistant.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Found an overlapping occurrence while processing message ID={1}. Cleaning things up and retrying", TraceContext.Get(), text2);
                                            if (ex4.OccurrenceInfo == null)
                                            {
                                                ResourceBookingAssistant.Tracer.TraceError((long)this.GetHashCode(), "{0}: Unexpected: Handling OccurrenceCrossingBoundaryException, the OccurrenceInfo is null", new object[]
                                                {
                                                    TraceContext.Get()
                                                });
                                                break;
                                            }
                                            VersionedId versionedId = ex4.OccurrenceInfo.VersionedId;
                                            AggregateOperationResult aggregateOperationResult = meetingMessage.Session.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                                            {
                                                versionedId
                                            });
                                            ResourceBookingAssistant.Tracer.TraceDebug <object, OperationResult>((long)this.GetHashCode(), "{0}: Deleting the occurrence when handling an OccurrenceCrossingBoundaryException, returned:{2}", TraceContext.Get(), aggregateOperationResult.OperationResult);
                                        }
                                        finally
                                        {
                                            ResourceBookingAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: In finally block.", new object[]
                                            {
                                                TraceContext.Get()
                                            });
                                            if (calendarItemBase != null)
                                            {
                                                calendarItemBase.Dispose();
                                                calendarItemBase = null;
                                            }
                                            DateTime utcNow2  = DateTime.UtcNow;
                                            TimeSpan timeSpan = utcNow2.Subtract(utcNow);
                                            ResourceBookingPerfmon.AverageResourceBookingProcessingTime.IncrementBy((long)timeSpan.TotalMilliseconds);
                                            ResourceBookingPerfmon.AverageResourceBookingProcessingTimeBase.Increment();
                                            resourceBookingAssistantLogEntry.StartProcessingTime = utcNow;
                                            resourceBookingAssistantLogEntry.StopProcessingTime  = utcNow2;
                                            ResourceBookingAssistant.TracerPfd.TracePfd <int, object, string>((long)this.GetHashCode(), "PFD IWR {0} {1}: Finished processing message. MeetingMessageID = {2}", 20247, TraceContext.Get(), text2);
                                        }
                                        i++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex5)
            {
                resourceBookingAssistantLogEntry.AddExceptionToLog(ex5);
                throw ex5;
            }
            finally
            {
                customDataToLog.AddRange(resourceBookingAssistantLogEntry.FormatCustomData());
            }
        }