private void CreateWorkItemForBounce(FolderEvaluationResult result, RuleAction.Bounce action) { if (ObjectClass.IsDsn(this.context.Message.ClassName)) { this.context.TraceDebug("DSN message can not be bounced"); return; } result.ClearWorkItems(); result.TargetFolder = null; result.ExitExecution = true; result.BounceCode = new RuleAction.Bounce.BounceCode?(action.Code); this.context.TraceDebug <RuleAction.Bounce.BounceCode?>("Message will be bounced with code {0}", result.BounceCode); }
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)); } }
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 void WriteAction(RuleAction action) { this.CheckDisposed(null); this.writer.WriteStartElement("Action"); if (action == null) { this.writer.WriteAttributeString("Type", ServerStrings.Null); } else { this.writer.WriteAttributeString("Type", action.ActionType.ToString()); this.writer.WriteAttributeString("UserFlags", action.UserFlags.ToString("X08")); switch (action.ActionType) { case RuleAction.Type.OP_MOVE: case RuleAction.Type.OP_COPY: this.WriteMoveCopyAction((RuleAction.MoveCopy)action); break; case RuleAction.Type.OP_REPLY: { RuleAction.Reply reply = (RuleAction.Reply)action; this.writer.WriteAttributeString("ActionFlags", reply.Flags.ToString()); byte[] replyTemplateMessageEntryID = reply.ReplyTemplateMessageEntryID; Guid replyTemplateGuid = reply.ReplyTemplateGuid; this.WriteReplyAction(replyTemplateMessageEntryID, replyTemplateGuid, true); break; } case RuleAction.Type.OP_OOF_REPLY: { RuleAction.OOFReply oofreply = (RuleAction.OOFReply)action; byte[] replyTemplateMessageEntryID = oofreply.ReplyTemplateMessageEntryID; Guid replyTemplateGuid = oofreply.ReplyTemplateGuid; this.WriteReplyAction(replyTemplateMessageEntryID, replyTemplateGuid, false); break; } case RuleAction.Type.OP_DEFER_ACTION: { RuleAction.Defer defer = (RuleAction.Defer)action; this.WriteBinaryData("Defer", defer.Data); break; } case RuleAction.Type.OP_BOUNCE: { RuleAction.Bounce bounce = (RuleAction.Bounce)action; this.writer.WriteAttributeString("BounceCode", bounce.Code.ToString()); break; } case RuleAction.Type.OP_FORWARD: { RuleAction.Forward forward = (RuleAction.Forward)action; this.writer.WriteAttributeString("ForwardFlags", forward.Flags.ToString()); this.WriteForwardRecipients(forward.Recipients); break; } case RuleAction.Type.OP_DELEGATE: { RuleAction.Delegate @delegate = (RuleAction.Delegate)action; this.WriteForwardRecipients(@delegate.Recipients); break; } case RuleAction.Type.OP_TAG: { RuleAction.Tag tag = (RuleAction.Tag)action; this.WritePropValue(tag.Value); break; } } } this.writer.WriteEndElement(); }
public RuleActionBounceData(RuleAction.Bounce ruleAction) : base(ruleAction) { this.Code = (uint)ruleAction.Code; }