コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        // Token: 0x060004A4 RID: 1188 RVA: 0x00022330 File Offset: 0x00020530
        private bool IsEventRelevant(MapiEvent mapiEvent)
        {
            if ((mapiEvent.ExtendedEventFlags & MapiExtendedEventFlags.NonIPMFolder) == MapiExtendedEventFlags.NonIPMFolder)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Non IPM Folder events are not relevant. MapiEvent: {0}", mapiEvent);
                return(false);
            }
            if ((mapiEvent.EventFlags & MapiEventFlags.SearchFolder) == MapiEventFlags.SearchFolder)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "SearchFolder events are not relevant. MapiEvent: {0}", mapiEvent);
                return(false);
            }
            if ((mapiEvent.EventFlags & MapiEventFlags.ContentOnly) == MapiEventFlags.ContentOnly)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "ContentOnly events are not relevant. MapiEvent: {0}", mapiEvent);
                return(false);
            }
            if (ObjectClass.IsCalendarItem(mapiEvent.ObjectClass) || ObjectClass.IsTask(mapiEvent.ObjectClass))
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Calendar and task items are not relevent. Mapievent: {0}", mapiEvent);
                return(false);
            }
            if (mapiEvent.ClientType == MapiEventClientTypes.Transport)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Skip events from Transport. Mapievent: {0}", mapiEvent);
                return(false);
            }
            MapiEventTypeFlags mapiEventTypeFlags = MapiEventTypeFlags.ObjectCreated | MapiEventTypeFlags.ObjectModified | MapiEventTypeFlags.ObjectMoved | MapiEventTypeFlags.ObjectCopied;

            if ((mapiEvent.EventMask & mapiEventTypeFlags) == (MapiEventTypeFlags)0)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "No interesting MapiEventTypeFlags. Skip. Mapievent: {0}", mapiEvent);
                return(false);
            }
            if ((mapiEvent.EventMask & MapiEventTypeFlags.ObjectModified) != (MapiEventTypeFlags)0 && (mapiEvent.EventFlags & MapiEventFlags.FolderAssociated) == MapiEventFlags.None && mapiEvent.ItemType == ObjectType.MAPI_MESSAGE && (mapiEvent.ExtendedEventFlags & MapiExtendedEventFlags.RetentionTagModified) == MapiExtendedEventFlags.None && (mapiEvent.ExtendedEventFlags & MapiExtendedEventFlags.RetentionPropertiesModified) == MapiExtendedEventFlags.None)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Item was modified. Either the property modified is not relevent to us . Mapievent: {0}", mapiEvent);
                return(false);
            }
            if (mapiEvent.ClientType == MapiEventClientTypes.TimeBasedAssistants && !RetentionPolicyCheck.IsEventConfigChange(mapiEvent) && !RetentionPolicyCheck.IsAutoTagFai(mapiEvent))
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Event is from Time Based Assistant and not FAI related. Ignoring. Mapievent: {0}", mapiEvent);
                return(false);
            }
            if (mapiEvent.ClientType == MapiEventClientTypes.EventBasedAssistants)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Event is from this assistant. Ignoring. Mapievent: {0}", mapiEvent);
                return(false);
            }
            if ((mapiEvent.EventFlags & MapiEventFlags.FolderAssociated) != MapiEventFlags.None && !RetentionPolicyCheck.IsEventConfigChange(mapiEvent) && !RetentionPolicyCheck.IsAutoTagFai(mapiEvent))
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "FAI we don't care about. Ignoring. Mapievent: {0}", mapiEvent);
                return(false);
            }
            if (mapiEvent.ItemType != ObjectType.MAPI_MESSAGE && mapiEvent.ItemType != ObjectType.MAPI_FOLDER)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Not a message or a folder. Ignoring. Mapievent: {0}", mapiEvent);
                return(false);
            }
            if ((mapiEvent.EventMask & MapiEventTypeFlags.ObjectDeleted) != (MapiEventTypeFlags)0)
            {
                ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "Item Deleted. Ignoring. Mapievent: {0}", mapiEvent);
                return(false);
            }
            ElcEventBasedAssistant.Tracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "IsEventRelevant is true. Mapievent: {0}", mapiEvent);
            return(true);
        }
コード例 #5
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();
                    }
                }
            }
        }