private void CreateWorkItemForInMailboxCopy(FolderEvaluationResult result, RuleAction.InMailboxCopy action, int actionIndex) { Folder folder; if (!this.context.TryOpenLocalStore(action.FolderEntryID, out folder)) { this.context.TraceError <byte[]>("Could not bind to local folder {0}", action.FolderEntryID); this.context.MarkRuleInError(this.context.CurrentRule, action.ActionType, actionIndex, DeferredError.RuleError.NoFolder); return; } this.context.TraceDebug <string>("Copy to local folder {0}", folder.DisplayName); if (!result.HasCopyWorkItemTo(folder.Id)) { result.AddWorkItem(new CopyWorkItem(this.context, folder, actionIndex)); return; } this.context.TraceDebug("Duplicate copy to a folder will be ignored"); }
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); }
public RuleActionInMailboxCopyData(RuleAction.InMailboxCopy ruleAction) : base(ruleAction) { }