Exemplo n.º 1
0
        // Token: 0x06001427 RID: 5159 RVA: 0x00074578 File Offset: 0x00072778
        internal bool ShouldProcessUnseenEmailEvent(IMailboxSession session, IXSOFactory xsoFactory, IMapiEvent mapiEvent)
        {
            if (!this.IsEmailSubscriptionEnabled(mapiEvent.MailboxGuid))
            {
                return(false);
            }
            if (PushNotificationMapiEventAnalyzer.IsIpmFolderContentChangeEvent(mapiEvent))
            {
                return(true);
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(session.MailboxGuid);

            using (new PushNotificationDataHandler.CachedStateReadLock(cachedState))
            {
                if (!(cachedState.State[9] is MailboxData))
                {
                    using (new PushNotificationDataHandler.CachedStateUpgradeWriteLock(cachedState))
                    {
                        if (!(cachedState.State[9] is MailboxData))
                        {
                            MailboxData mailboxData = new MailboxData(session.MailboxGuid);
                            if (!mailboxData.LoadData(session, xsoFactory))
                            {
                                return(false);
                            }
                            cachedState.State[9] = mailboxData;
                            return(ArrayComparer <byte> .Comparer.Equals(mapiEvent.ParentEntryId, mailboxData.InboxFolderId));
                        }
                    }
                }
            }
            return(false);
        }
        // Token: 0x060004A0 RID: 1184 RVA: 0x00021E6C File Offset: 0x0002006C
        private void ManageCache(Guid mbxGuid)
        {
            int num = Array.IndexOf <Guid>(this.mbxGuidFifo, mbxGuid);

            if (num >= 0 && num != this.mbxGuidFifoStart)
            {
                int num2 = (num == 0) ? (ElcEventBasedAssistant.mbxFifoCacheSize - 1) : (num - 1);
                this.mbxGuidFifo[num]  = this.mbxGuidFifo[num2];
                this.mbxGuidFifo[num2] = mbxGuid;
            }
            if (num < 0)
            {
                this.mbxGuidFifoStart = ((this.mbxGuidFifoStart == 0) ? (ElcEventBasedAssistant.mbxFifoCacheSize - 1) : (this.mbxGuidFifoStart - 1));
                Guid mbxGuid2 = this.mbxGuidFifo[this.mbxGuidFifoStart];
                if (!Guid.Empty.Equals(this.mbxGuidFifoStart))
                {
                    CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mbxGuid2);
                    if (cachedState != null)
                    {
                        cachedState.LockForWrite();
                        UserRetentionPolicyCache userRetentionPolicyCache = cachedState.State[5] as UserRetentionPolicyCache;
                        if (userRetentionPolicyCache != null && !userRetentionPolicyCache.ReadOnlyCache)
                        {
                            cachedState.State[5] = null;
                        }
                        cachedState.ReleaseWriterLock();
                    }
                }
                this.mbxGuidFifo[this.mbxGuidFifoStart] = mbxGuid;
            }
        }
Exemplo n.º 3
0
        // Token: 0x06001426 RID: 5158 RVA: 0x00074498 File Offset: 0x00072698
        internal bool IsValidFolderMessageForEmailSubscription(IMapiEvent mapiEvent)
        {
            if (!this.IsEmailSubscriptionEnabled(mapiEvent.MailboxGuid))
            {
                return(false);
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);

            byte[] y;
            if (!this.TryGetInboxFolderIdFromCache(mapiEvent.MailboxGuid, out y))
            {
                return(false);
            }
            if (!ArrayComparer <byte> .Comparer.Equals(mapiEvent.ItemEntryId, y))
            {
                return(false);
            }
            long inboxItemCount;

            using (new PushNotificationDataHandler.CachedStateReadLock(cachedState))
            {
                MailboxData mailboxData = cachedState.State[9] as MailboxData;
                inboxItemCount = mailboxData.InboxItemCount;
                if (inboxItemCount != mapiEvent.ItemCount)
                {
                    using (new PushNotificationDataHandler.CachedStateUpgradeWriteLock(cachedState))
                    {
                        mailboxData.InboxItemCount = mapiEvent.ItemCount;
                    }
                }
            }
            return(inboxItemCount < mapiEvent.ItemCount && mapiEvent.UnreadItemCount > 0L);
        }
        // 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);
        }
        // Token: 0x060000FE RID: 254 RVA: 0x00005BE0 File Offset: 0x00003DE0
        public bool IsEventInteresting(MapiEvent mapiEvent)
        {
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);
            MailboxData mailboxData = (MailboxData)cachedState.State[3];

            return(BodyTagProcessor.IsEventInteresting(mapiEvent) || ActionsProcessor.IsEventInteresting(mapiEvent) || SentItemsProcessor.IsEventInteresting(mapiEvent, mailboxData) || LicensingProcessor.IsEventInteresting(mapiEvent, mailboxData) || InferenceProcessor.IsEventInteresting(mapiEvent, mailboxData));
        }
        // 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);
        }
Exemplo n.º 7
0
 // Token: 0x0600142E RID: 5166 RVA: 0x000747CF File Offset: 0x000729CF
 public CachedStateWriteLock(CachedState state)
 {
     if (state == null)
     {
         throw new ArgumentNullException("state");
     }
     this.state = state;
     this.state.LockForWrite();
 }
Exemplo n.º 8
0
 // Token: 0x06001430 RID: 5168 RVA: 0x00074813 File Offset: 0x00072A13
 public CachedStateUpgradeWriteLock(CachedState state)
 {
     if (state == null)
     {
         throw new ArgumentNullException("state");
     }
     this.state  = state;
     this.cookie = this.state.UpgradeToWriterLock();
 }
        // Token: 0x060004A2 RID: 1186 RVA: 0x00021FA8 File Offset: 0x000201A8
        public bool IsEventInteresting(MapiEvent mapiEvent)
        {
            ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "MapiEvent is dispatched: {0}", mapiEvent);
            if (!this.IsEventRelevant(mapiEvent))
            {
                return(false);
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);
            UserRetentionPolicyCache userRetentionPolicyCache = RetentionPolicyCheck.QuickCheckForRetentionPolicy(mapiEvent, cachedState);

            if (userRetentionPolicyCache == null || userRetentionPolicyCache.UnderRetentionPolicy)
            {
                bool flag = RetentionPolicyCheck.IsEventConfigChange(mapiEvent);
                if (flag)
                {
                    RetentionPolicyCheck.UpdateStateForPendingFaiEvent(mapiEvent.EventCounter, cachedState);
                    ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: this event is interesting because it is a change to our FAI: {1}", TraceContext.Get(), mapiEvent);
                    return(true);
                }
                if (RetentionPolicyCheck.IsAutoTagFai(mapiEvent))
                {
                    ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: this event is interesting because it is a change to an Autotag FAI: {1}", TraceContext.Get(), mapiEvent);
                    return(true);
                }
                MapiEventTypeFlags mapiEventTypeFlags = MapiEventTypeFlags.ObjectCreated | MapiEventTypeFlags.ObjectModified | MapiEventTypeFlags.ObjectMoved | MapiEventTypeFlags.ObjectCopied;
                if ((mapiEvent.EventMask & mapiEventTypeFlags) != (MapiEventTypeFlags)0)
                {
                    if (mapiEvent.ClientType == MapiEventClientTypes.Transport && userRetentionPolicyCache != null && !this.InSentItems(userRetentionPolicyCache, mapiEvent))
                    {
                        ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Event is from transport and item not in SentItems. Ignoring from IsEventInteresting. Mapievent: {0}", mapiEvent);
                        return(false);
                    }
                    if (userRetentionPolicyCache != null && !this.IsEventOnRelevantFolder(userRetentionPolicyCache, mapiEvent))
                    {
                        return(false);
                    }
                    if (userRetentionPolicyCache != null && TagAssistantHelper.IsConflictableItem(mapiEvent.ObjectClass, mapiEvent.ParentEntryId, userRetentionPolicyCache.DeletedItemsId))
                    {
                        return(false);
                    }
                    MapiEventTypeFlags mapiEventTypeFlags2 = MapiEventTypeFlags.ObjectMoved | MapiEventTypeFlags.ObjectCopied;
                    if (mapiEvent.ItemType == ObjectType.MAPI_FOLDER && (mapiEvent.EventMask & mapiEventTypeFlags2) != (MapiEventTypeFlags)0)
                    {
                        ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: this event is interesting because is a moved folder: {1}", TraceContext.Get(), mapiEvent);
                        return(true);
                    }
                    if (mapiEvent.ItemType == ObjectType.MAPI_MESSAGE)
                    {
                        ElcEventBasedAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: this event is interesting because is a message: {1}", TraceContext.Get(), mapiEvent);
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 10
0
        // Token: 0x06001429 RID: 5161 RVA: 0x000746BC File Offset: 0x000728BC
        internal void UpdateEmailWatermarkToCache(Guid mailboxGuid, long updatedValue)
        {
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mailboxGuid);

            using (new PushNotificationDataHandler.CachedStateWriteLock(cachedState))
            {
                MailboxData mailboxData = cachedState.State[9] as MailboxData;
                if (mailboxData == null)
                {
                    throw new FailedToResolveInMemoryCacheException(mailboxGuid);
                }
                mailboxData.InboxUnreadCount = updatedValue;
            }
        }
Exemplo n.º 11
0
        // Token: 0x0600141E RID: 5150 RVA: 0x000742A4 File Offset: 0x000724A4
        internal void RemoveSubscriptions(Guid mailboxGuid)
        {
            byte b;

            if (!this.subscribedMailboxes.TryRemove(mailboxGuid, out b))
            {
                ExTraceGlobals.PushNotificationAssistantTracer.TraceError <Guid>((long)this.GetHashCode(), "PushNotificationAssistantAdapter.CleanupSubscription: Failed to clean-up subscription type entry on in-memory dictionary for='{0}'.", mailboxGuid);
            }
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mailboxGuid);

            using (new PushNotificationDataHandler.CachedStateWriteLock(cachedState))
            {
                cachedState.State[9] = null;
            }
        }
Exemplo n.º 12
0
        // Token: 0x06001428 RID: 5160 RVA: 0x0007465C File Offset: 0x0007285C
        internal long ReadEmailWatermarkFromCache(Guid mailboxGuid)
        {
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mailboxGuid);
            long        inboxUnreadCount;

            using (new PushNotificationDataHandler.CachedStateReadLock(cachedState))
            {
                MailboxData mailboxData = cachedState.State[9] as MailboxData;
                if (mailboxData == null)
                {
                    throw new FailedToResolveInMemoryCacheException(mailboxGuid);
                }
                inboxUnreadCount = mailboxData.InboxUnreadCount;
            }
            return(inboxUnreadCount);
        }
Exemplo n.º 13
0
        // Token: 0x06000B70 RID: 2928 RVA: 0x0004999C File Offset: 0x00047B9C
        public bool IsEventInteresting(MapiEvent mapiEvent)
        {
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);
            bool?       flag        = ResourceCheck.QuickCheckForAutomatedBooking(mapiEvent, cachedState);

            if (flag != null && !(flag == true))
            {
                return(false);
            }
            if (mapiEvent.ItemType == ObjectType.MAPI_MESSAGE && (mapiEvent.EventMask & MapiEventTypeFlags.NewMail) != (MapiEventTypeFlags)0)
            {
                ResourceBookingAssistant.Tracer.TraceDebug <object, MapiEvent>((long)this.GetHashCode(), "{0}: this event is interesting because is a new message: {1}", TraceContext.Get(), mapiEvent);
                return(true);
            }
            return(ResourceCheck.IsEventConfigChange(mapiEvent));
        }
Exemplo n.º 14
0
 // Token: 0x060004EA RID: 1258 RVA: 0x0002570C File Offset: 0x0002390C
 internal static void UpdateStateForPendingFaiEvent(long eventCounter, CachedState cachedState)
 {
     cachedState.LockForWrite();
     try
     {
         UserRetentionPolicyCache userRetentionPolicyCache = cachedState.State[5] as UserRetentionPolicyCache;
         if (userRetentionPolicyCache == null || userRetentionPolicyCache.ReadOnlyCache)
         {
             userRetentionPolicyCache = new UserRetentionPolicyCache();
         }
         userRetentionPolicyCache.HasPendingFaiEvent     = true;
         userRetentionPolicyCache.PendingFaiEventCounter = eventCounter;
         cachedState.State[5] = userRetentionPolicyCache;
     }
     finally
     {
         cachedState.ReleaseWriterLock();
     }
 }
Exemplo n.º 15
0
 public AsyncTask Cache(Func <Action <T>, Action <Exception>, AsyncTask> cacheProcess, System.Action <T> onSuccess = null, System.Action <Exception> onFail = null)
 {
     state       = CachedState.Caching;
     asyncResult = cacheProcess(
         value => {
         Cached(value);
         if (onSuccess != null)
         {
             onSuccess(value);
         }
     },
         ex => {
         Failed(ex);
         if (onFail != null)
         {
             onFail(ex);
         }
     }
         );
     return(asyncResult);
 }
Exemplo n.º 16
0
        // Token: 0x0600141D RID: 5149 RVA: 0x000741BC File Offset: 0x000723BC
        internal void UpdateSubscriptionData(Guid mailboxGuid, PushNotificationSubscription subscriptionContract)
        {
            PushNotificationSubscriptionOption subscriptionOption = subscriptionContract.GetSubscriptionOption();

            this.subscribedMailboxes.AddOrUpdate(mailboxGuid, (byte)subscriptionOption, (Guid key, byte oldValue) => (byte)subscriptionOption);
            if (subscriptionContract.InboxUnreadCount != null && subscriptionContract.InboxUnreadCount > 0L)
            {
                CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mailboxGuid);
                using (new PushNotificationDataHandler.CachedStateReadLock(cachedState))
                {
                    MailboxData mailboxData = (MailboxData)cachedState.State[9];
                    if (mailboxData != null)
                    {
                        using (new PushNotificationDataHandler.CachedStateUpgradeWriteLock(cachedState))
                        {
                            mailboxData.InboxUnreadCount = subscriptionContract.InboxUnreadCount.Value;
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
        // Token: 0x0600142A RID: 5162 RVA: 0x00074718 File Offset: 0x00072918
        private bool TryGetInboxFolderIdFromCache(Guid mailboxGuid, out byte[] inboxId)
        {
            inboxId = null;
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mailboxGuid);
            bool        result;

            using (new PushNotificationDataHandler.CachedStateReadLock(cachedState))
            {
                MailboxData mailboxData = cachedState.State[9] as MailboxData;
                if (mailboxData == null)
                {
                    result = false;
                }
                else
                {
                    inboxId = mailboxData.InboxFolderId;
                    result  = true;
                }
            }
            return(result);
        }
        // Token: 0x060000FF RID: 255 RVA: 0x00005C38 File Offset: 0x00003E38
        protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession session, StoreObject item, List <KeyValuePair <string, object> > customDataToLog)
        {
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mapiEvent.MailboxGuid);
            MailboxData mailboxData = (MailboxData)cachedState.State[3];

            if (mailboxData == null)
            {
                mailboxData = new MailboxData(session);
                Interlocked.Exchange(ref cachedState.State[3], mailboxData);
            }
            if (BodyTagProcessor.IsEventInteresting(mapiEvent))
            {
                BodyTagProcessor.HandleEventInternal(session, item);
                return;
            }
            if (ActionsProcessor.IsEventInteresting(mapiEvent))
            {
                ActionsProcessor.HandleEventInternal(mapiEvent, session, item, mailboxData);
                Interlocked.Exchange(ref cachedState.State[3], mailboxData);
                return;
            }
            if (SentItemsProcessor.IsEventInteresting(mapiEvent, mailboxData))
            {
                SentItemsProcessor.HandleEventInternal(mapiEvent, session, item, mailboxData);
                Interlocked.Exchange(ref cachedState.State[3], mailboxData);
                return;
            }
            if (LicensingProcessor.IsEventInteresting(mapiEvent, mailboxData))
            {
                LicensingProcessor.HandleEventInternal(session, item);
                return;
            }
            if (InferenceProcessor.IsEventInteresting(mapiEvent, mailboxData))
            {
                InferenceProcessor.HandleEventInternal(mapiEvent, session, item, mailboxData, customDataToLog);
            }
        }
        // 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();
                    }
                }
            }
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
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());
            }
        }
Exemplo n.º 24
0
 // Token: 0x06000B79 RID: 2937 RVA: 0x0004A40D File Offset: 0x0004860D
 public static bool DetailedCheckForAutomatedBooking(MailboxSession itemStore, CachedState cachedState)
 {
     return(ResourceCheck.InternalCheckForAutomaticBooking(false, itemStore, cachedState));
 }
Exemplo n.º 25
0
        // Token: 0x06000B78 RID: 2936 RVA: 0x0004A3E0 File Offset: 0x000485E0
        public static bool DetailedCheckForAutomatedBooking(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, CachedState cachedState)
        {
            bool isEventForConfigObject = CalendarConfigurationDataProvider.IsCalendarConfigurationClass(mapiEvent.ObjectClass) && item != null;

            return(ResourceCheck.InternalCheckForAutomaticBooking(isEventForConfigObject, itemStore, cachedState));
        }
Exemplo n.º 26
0
 private void Failed(System.Exception exception)
 {
     this.state     = CachedState.Fail;
     this.exception = exception;
 }
        // 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);
            }
        }
Exemplo n.º 28
0
 private void Cached(T value)
 {
     this.state = CachedState.Cached;
     this.t     = value;
 }
Exemplo n.º 29
0
        // Token: 0x06000E0C RID: 3596 RVA: 0x00054E78 File Offset: 0x00053078
        protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession;

            if (mailboxSession == null)
            {
                return;
            }
            if (mailboxSession.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.UserMailbox && mailboxSession.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.LinkedMailbox && mailboxSession.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox)
            {
                CalendarRepairAssistant.CachedStateTracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "Skipping mailbox with guid {0} and display name {1} since this is a {2} and not a UserMailbox or a LinkedMailbox", mailboxSession.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.RecipientTypeDetails.ToString());
                return;
            }
            ExDateTime  now         = ExDateTime.Now;
            ExDateTime  rangeStart  = now.AddDays((double)(-(double)this.RepairPolicy.DaysInWindowBackward));
            ExDateTime  rangeEnd    = now.AddDays((double)this.RepairPolicy.DaysInWindowForward);
            CachedState cachedState = AssistantsService.CachedObjectsList.GetCachedState(mailboxSession.MailboxGuid);
            bool        flag        = ResourceCheck.DetailedCheckForAutomatedBooking(mailboxSession, cachedState);

            if (flag)
            {
                CalendarRepairAssistant.CachedStateTracer.TraceDebug((long)this.GetHashCode(), "{0}: Calendar Repair Assistant is skipping resource mailbox.", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            CalendarRepairAssistantLogEntry calendarRepairAssistantLogEntry = new CalendarRepairAssistantLogEntry
            {
                DatabaseGuid   = mailboxSession.MailboxOwner.MailboxInfo.GetDatabaseGuid(),
                MailboxGuid    = mailboxSession.MailboxGuid,
                TenantGuid     = mailboxSession.MailboxOwner.MailboxInfo.OrganizationId.GetTenantGuid(),
                RepairMode     = this.RepairPolicy.RepairMode.ToString(),
                RangeStartTime = string.Format("{0:O}", rangeStart.ToUtc()),
                RangeEndTime   = string.Format("{0:O}", rangeEnd.ToUtc())
            };

            this.MarkMailboxForUpgrade(mailboxSession, calendarRepairAssistantLogEntry);
            try
            {
                CalendarRepairAssistant.CachedStateTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Calendar Repair Assistant starting to validate mailbox: {1}.", TraceContext.Get(), mailboxSession.MailboxOwner.MailboxInfo.DisplayName);
                CalendarValidator calendarValidator = CalendarValidator.CreateRepairingInstance(mailboxSession, rangeStart, rangeEnd, this.RepairPolicy, CalendarRepairAssistant.cvsPopulationTimeout);
                calendarValidator.OnItemInspected += this.incrementTotalItemsInspected;
                calendarValidator.OnItemRepaired  += this.incrementTotalItemsRepaired;
                List <MeetingValidationResult> validationResults = calendarValidator.Run();
                calendarValidator.OnItemInspected -= this.incrementTotalItemsInspected;
                calendarValidator.OnItemRepaired  -= this.incrementTotalItemsRepaired;
                calendarRepairAssistantLogEntry.AddValidationResults(validationResults);
                CalendarRepairLogger.Instance.Log(validationResults, mailboxSession.MailboxOwner, rangeStart, rangeEnd);
                if (CalendarRepairAssistant.IsCRAReliabilityLoggerEnabled(mailboxSession))
                {
                    CalendarReliabilityInsigntLogger.Instance.Log(calendarRepairAssistantLogEntry, validationResults);
                }
                CalendarRepairAssistant.CachedStateTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Calendar Repair Assistant completed validating mailbox: {1}.", TraceContext.Get(), mailboxSession.MailboxOwner.MailboxInfo.DisplayName);
            }
            catch (WrongServerException ex)
            {
                string message = string.Format("Could not access the mailbox (ExchangePrincipal:'{0}'). Exception: {1}.", mailboxSession.MailboxOwner, ex);
                CalendarRepairAssistant.Tracer.TraceDebug((long)this.GetHashCode(), message);
                calendarRepairAssistantLogEntry.AddExceptionToLog(ex);
            }
            catch (MailboxUserNotFoundException ex2)
            {
                CalendarRepairAssistant.Tracer.TraceDebug <MailboxUserNotFoundException>((long)this.GetHashCode(), "MailboxUserNotFoundException:{0}", ex2);
                calendarRepairAssistantLogEntry.AddExceptionToLog(ex2);
            }
            catch (CorruptDataException ex3)
            {
                CalendarRepairAssistant.Tracer.TraceDebug <CorruptDataException>((long)this.GetHashCode(), "CorruptDataException:{0}", ex3);
                calendarRepairAssistantLogEntry.AddExceptionToLog(ex3);
            }
            catch (SubmissionQuotaExceededException ex4)
            {
                CalendarRepairAssistant.Tracer.TraceDebug <SubmissionQuotaExceededException>((long)this.GetHashCode(), "SubmissionQuotaExceededException:{0}", ex4);
                calendarRepairAssistantLogEntry.AddExceptionToLog(ex4);
            }
            catch (StoragePermanentException ex5)
            {
                CalendarRepairAssistant.Tracer.TraceDebug <StoragePermanentException>((long)this.GetHashCode(), "StoragePermanentException:{0}", ex5);
                calendarRepairAssistantLogEntry.AddExceptionToLog(ex5);
            }
            catch (Exception ex6)
            {
                CalendarRepairAssistant.Tracer.TraceDebug <Exception>((long)this.GetHashCode(), "Exception:{0}", ex6);
                calendarRepairAssistantLogEntry.AddExceptionToLog(ex6);
                throw ex6;
            }
            finally
            {
                stopwatch.Stop();
                calendarRepairAssistantLogEntry.TotalProcessingTime = stopwatch.Elapsed.TotalMilliseconds.ToString();
                customDataToLog.AddRange(calendarRepairAssistantLogEntry.FormatCustomData());
            }
        }
Exemplo n.º 30
0
 public CachedProperty()
 {
     this.state = CachedState.NotCached;
 }