Ejemplo n.º 1
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            Util.ThrowOnNullArgument(item, "item");
            MailboxSession mailboxSession = session as MailboxSession;
            ExDateTime     now            = ExDateTime.Now;

            try
            {
                item.PropertyBag.Load(COWSiteMailboxMessageDedup.PropsForMessageRemoval);
                if (item.Id != null && item.Id.ObjectId != null)
                {
                    StoreObjectId storeObjectId = item.PropertyBag.TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId;
                    if (storeObjectId != null)
                    {
                        using (CoreFolder coreFolder = CoreFolder.Bind(session, storeObjectId))
                        {
                            DeleteItemFlags deleteItemFlags = DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt;
                            coreFolder.DeleteItems(deleteItemFlags, new StoreObjectId[]
                            {
                                item.Id.ObjectId
                            });
                        }
                        COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId, string, double>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: deleting message {0} from site mailbox {1} used {2} milliseconds", itemId, mailboxSession.DisplayName, (ExDateTime.Now - now).TotalMilliseconds);
                    }
                }
            }
            catch (StoragePermanentException arg)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: got store permanent exception: {0}", arg);
            }
            catch (StorageTransientException arg2)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: got store transient exception: {0}", arg2);
            }
            callbackContext.SiteMailboxMessageDedupState = COWProcessorState.Processed;
        }