コード例 #1
0
        // 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;
            }
        }
コード例 #2
0
 // Token: 0x060004A5 RID: 1189 RVA: 0x00022577 File Offset: 0x00020777
 private bool IsEventOnRelevantFolder(UserRetentionPolicyCache mailboxState, MapiEvent mapiEvent)
 {
     if (mapiEvent.ItemType == ObjectType.MAPI_MESSAGE && mailboxState.IsFolderIdToSkip(mapiEvent.ParentEntryId))
     {
         ElcEventBasedAssistant.Tracer.TraceDebug <string, MapiEvent>((long)this.GetHashCode(), "Event is in non-IPM folder (entryid {0}). Ignoring. Mapievent: {1}", mapiEvent.ParentEntryIdString, mapiEvent);
         return(false);
     }
     return(true);
 }
コード例 #3
0
 // Token: 0x060004A6 RID: 1190 RVA: 0x000225B0 File Offset: 0x000207B0
 private bool InSentItems(UserRetentionPolicyCache mailboxState, MapiEvent mapiEvent)
 {
     if (mapiEvent.ItemType == ObjectType.MAPI_MESSAGE && ArrayComparer <byte> .Comparer.Equals(mapiEvent.ParentEntryId, mailboxState.SentItemsId))
     {
         ElcEventBasedAssistant.Tracer.TraceDebug <ElcEventBasedAssistant, MapiEvent>((long)this.GetHashCode(), "{0} Event is on item in SentItems folder. We must handle it. Mapievent: {1}", this, mapiEvent);
         return(true);
     }
     ElcEventBasedAssistant.Tracer.TraceDebug <ElcEventBasedAssistant, MapiEvent>((long)this.GetHashCode(), "{0} Item not in SentItems folder. Mapievent: {1}", this, mapiEvent);
     return(false);
 }
コード例 #4
0
        // 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);
        }
コード例 #5
0
        // Token: 0x06000380 RID: 896 RVA: 0x000187A0 File Offset: 0x000169A0
        internal static bool IsRetainableItem(UserRetentionPolicyCache mailboxState, MailboxSession mailboxSession, StoreObjectId parentId, StoreObject item)
        {
            DefaultFolderType parentDefaultFolderType = TagAssistantHelper.GetParentDefaultFolderType(mailboxState, mailboxSession, parentId);

            if (UserRetentionPolicyCache.IsFolderTypeToSkip(parentDefaultFolderType))
            {
                TagAssistantHelper.Tracer.TraceDebug <DefaultFolderType>(0L, "Current item is in folder {0} (or a sub-folder) that should not be processed.", parentDefaultFolderType);
                return(false);
            }
            return(TagAssistantHelper.IsRetainableItem(item.ClassName));
        }
コード例 #6
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);
        }
コード例 #7
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();
     }
 }
コード例 #8
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);
        }
コード例 #9
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();
                    }
                }
            }
        }
コード例 #10
0
        // Token: 0x06000384 RID: 900 RVA: 0x00018884 File Offset: 0x00016A84
        internal static DefaultFolderType GetParentDefaultFolderType(UserRetentionPolicyCache mailboxState, MailboxSession mailboxSession, StoreObjectId parentId)
        {
            bool              flag              = false;
            StoreObjectId     storeObjectId     = parentId;
            DefaultFolderType defaultFolderType = DefaultFolderType.None;
            Folder            folder            = null;

            try
            {
                while (!flag)
                {
                    if (!mailboxState.FolderTypeDictionary.TryGetValue(storeObjectId, out defaultFolderType))
                    {
                        defaultFolderType = mailboxSession.IsDefaultFolderType(storeObjectId);
                        if (defaultFolderType != DefaultFolderType.None || ArrayComparer <byte> .Comparer.Equals(storeObjectId.ProviderLevelItemId, mailboxState.RootFolderId))
                        {
                            break;
                        }
                        Exception ex = null;
                        try
                        {
                            folder = Folder.Bind(mailboxSession, storeObjectId);
                        }
                        catch (ObjectNotFoundException ex2)
                        {
                            ex = ex2;
                        }
                        catch (ConversionFailedException ex3)
                        {
                            ex = ex3;
                        }
                        catch (VirusMessageDeletedException ex4)
                        {
                            ex = ex4;
                        }
                        if (ex != null)
                        {
                            TagAssistantHelper.Tracer.TraceDebug <Exception>(0L, "Problems loading a folder. It will not be processed. Exception: {0}", ex);
                        }
                        if (folder == null || ArrayComparer <byte> .Comparer.Equals(storeObjectId.ProviderLevelItemId, folder.ParentId.ProviderLevelItemId))
                        {
                            break;
                        }
                        storeObjectId = folder.ParentId;
                        folder.Dispose();
                        folder = null;
                    }
                    else
                    {
                        flag = true;
                    }
                }
                if (storeObjectId != null && !ArrayComparer <byte> .Comparer.Equals(storeObjectId.ProviderLevelItemId, parentId.ProviderLevelItemId))
                {
                    mailboxState.FolderTypeDictionary.Add(parentId, defaultFolderType);
                }
            }
            finally
            {
                if (folder != null)
                {
                    folder.Dispose();
                }
            }
            return(defaultFolderType);
        }