Ejemplo n.º 1
0
        public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
        {
            if (!COWContactLogging.COWContactLoggingConfiguration.Instance.IsLoggingEnabled())
            {
                return(true);
            }
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            if (item == null)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: Item is null");
                return(true);
            }
            if (!onBeforeNotification)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: Not onBeforeNotification");
                return(true);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            COWContactLogging.Tracer.TraceDebug <string>((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: ItemClass: {0}", valueOrDefault);
            if (ObjectClass.IsPlace(valueOrDefault))
            {
                return(true);
            }
            if (!ObjectClass.IsContact(valueOrDefault) && !ObjectClass.IsDistributionList(valueOrDefault) && !ObjectClass.IsContactsFolder(valueOrDefault))
            {
                return(true);
            }
            foreach (IContactChangeTracker contactChangeTracker in COWContactLogging.ChangeTrackers)
            {
                if (contactChangeTracker.ShouldLoadPropertiesForFurtherCheck(operation, valueOrDefault, itemId, item))
                {
                    COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: A tracker interested.");
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        private ContactLinkingProcessingState InspectNotification(COWTriggerAction operation, StoreSession session, CoreItem item, bool onBeforeNotification, bool onDumpster)
        {
            if (onDumpster)
            {
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (!onBeforeNotification)
            {
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (item == null)
            {
                return(ContactLinkingProcessingState.Unknown);
            }
            if (!(session is MailboxSession))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not a mailbox session.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (operation != COWTriggerAction.Create && operation != COWTriggerAction.Update)
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not an Create or Update operation.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            PersistablePropertyBag persistablePropertyBag = CoreObject.GetPersistablePropertyBag(item);

            switch (persistablePropertyBag.Context.AutomaticContactLinkingAction)
            {
            case AutomaticContactLinkingAction.ClientBased:
                if (!this.IsClientAllowed(session.ClientInfoString))
                {
                    COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: not allowed client session.");
                    return(ContactLinkingProcessingState.DoNotProcess);
                }
                break;

            case AutomaticContactLinkingAction.Ignore:
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: IgnoreAutomaticContactLinking=true.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (session.LogonType != LogonType.Owner && session.LogonType != LogonType.Delegated)
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: logon session is not user or delegated.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            if (string.IsNullOrEmpty(valueOrDefault))
            {
                return(ContactLinkingProcessingState.Unknown);
            }
            if (ObjectClass.IsPlace(valueOrDefault))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: place item class are not processed.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (!ObjectClass.IsContact(valueOrDefault))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: item class is not contact.");
                return(ContactLinkingProcessingState.DoNotProcess);
            }
            if (operation == COWTriggerAction.Update && !Array.Exists <StorePropertyDefinition>(COWContactLinking.NotificationProperties, (StorePropertyDefinition property) => item.PropertyBag.IsPropertyDirty(property)))
            {
                COWContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLinking.InspectNotification: no relevant properties changed");
                return(ContactLinkingProcessingState.Unknown);
            }
            if (ClientInfo.MOMT.IsMatch(session.ClientInfoString))
            {
                return(ContactLinkingProcessingState.ProcessAfterSave);
            }
            return(ContactLinkingProcessingState.ProcessBeforeSave);
        }