internal static StoreObjectId GetReplyTemplateStoreObjectId(byte[] entryId) { if (entryId == null) { return(null); } return(RuleActionConverter.EntryIdToStoreObjectId(entryId, StoreObjectType.Message)); }
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)); } }