コード例 #1
0
 private void CreateWorkItemForDelete(FolderEvaluationResult result, RuleAction.Delete action, int actionIndex)
 {
     result.ExitExecution = true;
     if (result.HasDeferredMoveOrCopy)
     {
         this.context.TraceDebug("Softly delete the message since it is moved/copied to external store");
         this.CreateWorkItemForDefer(result, action, actionIndex);
         result.TargetFolder = this.context.GetDeletedItemsFolder();
         return;
     }
     this.context.TraceDebug("Delete the message");
     result.TargetFolder = null;
     if (result.IsMessageDelegated)
     {
         this.context.TraceDebug("Message was delegated. No need to generate NRN.");
         return;
     }
     if (!this.context.Message.IsReadReceiptRequested)
     {
         this.context.TraceDebug("Read Receipt is not requested on the message.");
         return;
     }
     if (null == this.context.Message.Sender && null == this.context.Message.From && null == this.context.Message.ReadReceiptAddressee)
     {
         this.context.TraceDebug("No NRN recipient data, generation skipped.");
         return;
     }
     if (this.context.IsInternetMdnDisabled)
     {
         this.context.TraceDebug("MDNs are disabled on the mailbox, message deleted without NRN to sender.");
         return;
     }
     result.AddWorkItem(new DeleteWorkItem(this.context, actionIndex));
 }
コード例 #2
0
        internal static RuleAction ConvertRuleAction(StoreSession session, ExTimeZone timeZone, RuleAction ruleAction)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(timeZone, "timeZone");
            Util.ThrowOnNullArgument(ruleAction, "ruleAction");
            switch (ruleAction.ActionType)
            {
            case RuleAction.Type.OP_MOVE:
            {
                RuleAction.MoveCopy moveCopy = (RuleAction.MoveCopy)ruleAction;
                if (moveCopy.FolderIsInThisStore)
                {
                    return(new RuleAction.MoveAction(moveCopy.UserFlags, RuleActionConverter.EntryIdToStoreObjectId(moveCopy.FolderEntryID, StoreObjectType.Folder)));
                }
                return(new RuleAction.MoveAction(moveCopy.UserFlags, moveCopy.StoreEntryID, moveCopy.FolderEntryID));
            }

            case RuleAction.Type.OP_COPY:
            {
                RuleAction.MoveCopy moveCopy2 = (RuleAction.MoveCopy)ruleAction;
                if (moveCopy2.FolderIsInThisStore)
                {
                    return(new RuleAction.CopyAction(moveCopy2.UserFlags, RuleActionConverter.EntryIdToStoreObjectId(moveCopy2.FolderEntryID, StoreObjectType.Folder)));
                }
                return(new RuleAction.CopyAction(moveCopy2.UserFlags, moveCopy2.StoreEntryID, moveCopy2.FolderEntryID));
            }

            case RuleAction.Type.OP_REPLY:
            {
                RuleAction.Reply reply = (RuleAction.Reply)ruleAction;
                return(new RuleAction.ReplyAction(reply.UserFlags, RuleActionConverter.MapiReplyFlagsToReplyFlags(reply.Flags), RuleActionConverter.GetReplyTemplateStoreObjectId(reply.ReplyTemplateMessageEntryID), reply.ReplyTemplateGuid));
            }

            case RuleAction.Type.OP_OOF_REPLY:
            {
                RuleAction.OOFReply oofreply = (RuleAction.OOFReply)ruleAction;
                return(new RuleAction.OutOfOfficeReplyAction(oofreply.UserFlags, RuleActionConverter.GetReplyTemplateStoreObjectId(oofreply.ReplyTemplateMessageEntryID), oofreply.ReplyTemplateGuid));
            }

            case RuleAction.Type.OP_DEFER_ACTION:
            {
                RuleAction.Defer defer = (RuleAction.Defer)ruleAction;
                return(new RuleAction.DeferAction(defer.UserFlags, defer.Data));
            }

            case RuleAction.Type.OP_BOUNCE:
            {
                RuleAction.Bounce bounce = (RuleAction.Bounce)ruleAction;
                return(new RuleAction.BounceAction(bounce.UserFlags, (uint)bounce.Code));
            }

            case RuleAction.Type.OP_FORWARD:
            {
                RuleAction.Forward forward = (RuleAction.Forward)ruleAction;
                return(new RuleAction.ForwardAction(forward.UserFlags, RuleActionConverter.GetRecipients(session, timeZone, forward.Recipients), RuleActionConverter.MapiForwardFlagsToForwardFlags(forward.Flags)));
            }

            case RuleAction.Type.OP_DELEGATE:
            {
                RuleAction.Delegate @delegate = (RuleAction.Delegate)ruleAction;
                return(new RuleAction.DelegateAction(@delegate.UserFlags, RuleActionConverter.GetRecipients(session, timeZone, @delegate.Recipients)));
            }

            case RuleAction.Type.OP_TAG:
            {
                RuleAction.Tag tag = (RuleAction.Tag)ruleAction;
                NativeStorePropertyDefinition propertyDefinition = null;
                try
                {
                    propertyDefinition = PropertyTagCache.Cache.SafePropertyDefinitionsFromPropTags(session, new PropTag[]
                        {
                            tag.Value.PropTag
                        })[0];
                }
                catch (CorruptDataException)
                {
                    if (session.IsMoveUser)
                    {
                        return(new RuleAction.TagAction(tag.UserFlags, InternalSchema.RuleError, 0));
                    }
                    throw;
                }
                object valueFromPropValue = MapiPropertyBag.GetValueFromPropValue(session, timeZone, propertyDefinition, tag.Value);
                return(new RuleAction.TagAction(tag.UserFlags, propertyDefinition, valueFromPropValue));
            }

            case RuleAction.Type.OP_DELETE:
            {
                RuleAction.Delete delete = (RuleAction.Delete)ruleAction;
                return(new RuleAction.DeleteAction(delete.UserFlags));
            }

            case RuleAction.Type.OP_MARK_AS_READ:
            {
                RuleAction.MarkAsRead markAsRead = (RuleAction.MarkAsRead)ruleAction;
                return(new RuleAction.MarkAsReadAction(markAsRead.UserFlags));
            }

            default:
                throw new ArgumentException(string.Format("Invalid action type {0}.", ruleAction.ActionType));
            }
        }
コード例 #3
0
        internal static RuleAction ConvertRuleAction(StoreSession session, ExTimeZone timeZone, RuleAction ruleAction)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(timeZone, "timeZone");
            Util.ThrowOnNullArgument(ruleAction, "ruleAction");
            RuleAction ruleAction2;

            switch (ruleAction.ActionType)
            {
            case RuleActionType.Move:
            {
                RuleAction.MoveAction moveAction = (RuleAction.MoveAction)ruleAction;
                if (moveAction.ExternalDestinationFolderId != null)
                {
                    ruleAction2 = new RuleAction.ExternalMove(moveAction.DestinationStoreEntryId, moveAction.ExternalDestinationFolderId);
                }
                else
                {
                    ruleAction2 = new RuleAction.InMailboxMove(moveAction.DestinationFolderId.ProviderLevelItemId);
                }
                break;
            }

            case RuleActionType.Copy:
            {
                RuleAction.CopyAction copyAction = (RuleAction.CopyAction)ruleAction;
                if (copyAction.ExternalDestinationFolderId != null)
                {
                    ruleAction2 = new RuleAction.ExternalCopy(copyAction.DestinationStoreEntryId, copyAction.ExternalDestinationFolderId);
                }
                else
                {
                    ruleAction2 = new RuleAction.InMailboxCopy(copyAction.DestinationFolderId.ProviderLevelItemId);
                }
                break;
            }

            case RuleActionType.Reply:
            {
                RuleAction.ReplyAction replyAction = (RuleAction.ReplyAction)ruleAction;
                ruleAction2 = new RuleAction.Reply(RuleActionConverter.GetReplyTemplateMessageEntryId(replyAction.ReplyTemplateMessageId), replyAction.ReplyTemplateGuid, RuleActionConverter.ReplyFlagsToMapiReplyFlags(replyAction.Flags));
                break;
            }

            case RuleActionType.OutOfOfficeReply:
            {
                RuleAction.OutOfOfficeReplyAction outOfOfficeReplyAction = (RuleAction.OutOfOfficeReplyAction)ruleAction;
                ruleAction2 = new RuleAction.OOFReply(RuleActionConverter.GetReplyTemplateMessageEntryId(outOfOfficeReplyAction.ReplyTemplateMessageId), outOfOfficeReplyAction.ReplyTemplateGuid);
                break;
            }

            case RuleActionType.DeferAction:
            {
                RuleAction.DeferAction deferAction = (RuleAction.DeferAction)ruleAction;
                ruleAction2 = new RuleAction.Defer(deferAction.Data);
                break;
            }

            case RuleActionType.Bounce:
            {
                RuleAction.BounceAction bounceAction = (RuleAction.BounceAction)ruleAction;
                ruleAction2 = new RuleAction.Bounce((RuleAction.Bounce.BounceCode)bounceAction.BounceCode);
                break;
            }

            case RuleActionType.Forward:
            {
                RuleAction.ForwardAction forwardAction = (RuleAction.ForwardAction)ruleAction;
                ruleAction2 = new RuleAction.Forward(RuleActionConverter.GetAdrEntries(session, timeZone, forwardAction.Recipients), RuleActionConverter.ForwardFlagsToMapiForwardFlags(forwardAction.Flags));
                break;
            }

            case RuleActionType.Delegate:
            {
                RuleAction.DelegateAction delegateAction = (RuleAction.DelegateAction)ruleAction;
                ruleAction2 = new RuleAction.Delegate(RuleActionConverter.GetAdrEntries(session, timeZone, delegateAction.Recipients));
                break;
            }

            case RuleActionType.Tag:
            {
                RuleAction.TagAction tagAction = (RuleAction.TagAction)ruleAction;
                PropTag propTag = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(session.Mailbox.MapiStore, session, new NativeStorePropertyDefinition[]
                    {
                        tagAction.PropertyDefinition
                    }).First <PropTag>();
                ruleAction2 = new RuleAction.Tag(MapiPropertyBag.GetPropValueFromValue(session, timeZone, propTag, tagAction.PropertyValue));
                break;
            }

            case RuleActionType.Delete:
            {
                RuleAction.DeleteAction deleteAction = (RuleAction.DeleteAction)ruleAction;
                ruleAction2 = new RuleAction.Delete();
                break;
            }

            case RuleActionType.MarkAsRead:
            {
                RuleAction.MarkAsReadAction markAsReadAction = (RuleAction.MarkAsReadAction)ruleAction;
                ruleAction2 = new RuleAction.MarkAsRead();
                break;
            }

            default:
                throw new ArgumentException(string.Format("Invalid action type {0}.", ruleAction.ActionType));
            }
            ruleAction2.UserFlags = ruleAction.UserFlags;
            return(ruleAction2);
        }
コード例 #4
0
 public RuleActionDeleteData(RuleAction.Delete ruleAction) : base(ruleAction)
 {
 }