private static object GetMapiValueFromValue(StoreSession session, ExTimeZone timeZone, object value) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(timeZone, "timeZone"); if (value is PropertyError) { throw new ArgumentException(string.Format("We should never need to translate a PropertyError into mapi.net, because it makes no sense to set an error. PropertyError found = {0}.", value)); } QueryFilter queryFilter = value as QueryFilter; if (queryFilter != null) { return(FilterRestrictionConverter.CreateRestriction(session, timeZone, session.Mailbox.MapiStore, queryFilter)); } RuleAction[] array = value as RuleAction[]; if (array != null) { RuleAction[] array2 = new RuleAction[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = RuleActionConverter.ConvertRuleAction(session, timeZone, array[i]); } return(array2); } return(ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(timeZone, value)); }
internal static StoreObjectId GetReplyTemplateStoreObjectId(byte[] entryId) { if (entryId == null) { return(null); } return(RuleActionConverter.EntryIdToStoreObjectId(entryId, StoreObjectType.Message)); }
private static RuleAction.ForwardActionBase.ActionRecipient[] GetRecipients(StoreSession session, ExTimeZone timeZone, IList <AdrEntry> adrEntries) { Util.ThrowOnNullArgument(adrEntries, "adrEntries"); RuleAction.ForwardActionBase.ActionRecipient[] array = new RuleAction.ForwardActionBase.ActionRecipient[adrEntries.Count]; for (int i = 0; i < array.Length; i++) { array[i] = RuleActionConverter.GetRecipient(session, timeZone, adrEntries[i]); } return(array); }
private static AdrEntry[] GetAdrEntries(StoreSession session, ExTimeZone timeZone, IList <RuleAction.ForwardActionBase.ActionRecipient> recipients) { Util.ThrowOnNullArgument(recipients, "recipients"); AdrEntry[] array = new AdrEntry[recipients.Count]; for (int i = 0; i < array.Length; i++) { array[i] = RuleActionConverter.GetAdrEntry(session, timeZone, recipients[i]); } return(array); }
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); }
internal static object GetValueFromPropValue(StoreSession storeSession, ExTimeZone exTimeZone, StorePropertyDefinition propertyDefinition, PropValue propertyValue) { if (propertyValue.IsError()) { int num = propertyValue.GetErrorValue(); if (num == -2147220732 && (propertyDefinition.SpecifiedWith == PropertyTypeSpecifier.GuidId || propertyDefinition.SpecifiedWith == PropertyTypeSpecifier.GuidString)) { num = -2147221233; } return(MapiPropertyBag.CreatePropertyError(num, propertyDefinition)); } PropType propType = propertyValue.PropTag.ValueType(); if (propType == PropType.Restriction) { if (storeSession == null) { throw new NotSupportedException("PT_RESTRICTION is not supported when we do not have a session. This very likely is an attachment."); } return(FilterRestrictionConverter.CreateFilter(storeSession, storeSession.Mailbox.MapiStore, (Restriction)propertyValue.Value, false)); } else { if (propertyValue.Value == null) { return(MapiPropertyBag.CreatePropertyError(-2147221233, propertyDefinition)); } if (propType == PropType.Actions) { if (storeSession == null) { throw new NotSupportedException("RuleAction type not supported without a session."); } RuleAction[] array = (RuleAction[])propertyValue.Value; RuleAction[] array2 = new RuleAction[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = RuleActionConverter.ConvertRuleAction(storeSession, exTimeZone, array[i]); } return(array2); } else if (propType == PropType.SysTime) { DateTime dateTime = (DateTime)propertyValue.Value; if (ExDateTime.IsValidDateTime(dateTime)) { return(new ExDateTime(exTimeZone, dateTime)); } return(MapiPropertyBag.CreatePropertyError(-2147221221, propertyDefinition)); } else { if (propType == PropType.SysTimeArray) { DateTime[] array3 = (DateTime[])propertyValue.Value; foreach (DateTime dateTime2 in array3) { if (!ExDateTime.IsValidDateTime(dateTime2)) { return(MapiPropertyBag.CreatePropertyError(-2147221221, propertyDefinition)); } } return(ExTimeZoneHelperForMigrationOnly.ToExDateTimeArray(exTimeZone, array3)); } return(propertyValue.Value); } } }