示例#1
0
            internal RowEntry ToRowEntry(StoreSession session, MapiProp propertyMappingReference)
            {
                PropertyTable.Operation.MapiRowFactory mapiRowFactory = null;
                switch (base.Operation)
                {
                case ModifyTableOperationType.Add:
                    mapiRowFactory = new PropertyTable.Operation.MapiRowFactory(RowEntry.Add);
                    break;

                case ModifyTableOperationType.Modify:
                    mapiRowFactory = new PropertyTable.Operation.MapiRowFactory(RowEntry.Modify);
                    break;

                case ModifyTableOperationType.Remove:
                    mapiRowFactory = new PropertyTable.Operation.MapiRowFactory(RowEntry.Remove);
                    break;
                }
                ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(propertyMappingReference, session, from propValue in base.Properties
                                                                                                          select(NativeStorePropertyDefinition) propValue.Property);

                PropValue[] array = new PropValue[base.Properties.Length];
                int         num   = 0;

                foreach (PropTag propTag in collection)
                {
                    array[num] = MapiPropertyBag.GetPropValueFromValue(session, session.ExTimeZone, propTag, base.Properties[num].Value);
                    num++;
                }
                return(mapiRowFactory(array));
            }
示例#2
0
        internal static PropValue[] MapiPropValuesFromXsoProperties(StoreSession storeSession, MapiProp mapiProp, PropertyDefinition[] propertyDefinitions, object[] propertyValues)
        {
            PropValue[]           array      = new PropValue[propertyValues.Length];
            ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(mapiProp, storeSession, false, propertyDefinitions);
            int num = 0;

            foreach (PropTag propTag in collection)
            {
                array[num] = MapiPropertyBag.GetPropValueFromValue(storeSession, storeSession.ExTimeZone, propTag, propertyValues[num]);
                num++;
            }
            return(array);
        }
        protected List <PropValue> GetPropValuesFromValues(ExTimeZone exTimeZone, IList <PropertyDefinition> propertyDefinitions, IList <object> propertyValues)
        {
            ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.Session.Mailbox.MapiStore, this.Session, false, propertyDefinitions);
            List <PropValue>      list       = new List <PropValue>(propertyDefinitions.Count);
            int num = 0;

            foreach (PropTag propTag in collection)
            {
                InternalSchema.CheckPropertyValueType(propertyDefinitions[num], propertyValues[num]);
                list.Add(MapiPropertyBag.GetPropValueFromValue(this.Session, exTimeZone, propTag, propertyValues[num]));
                num++;
            }
            return(list);
        }
示例#4
0
        private static AdrEntry GetAdrEntry(StoreSession session, ExTimeZone timeZone, RuleAction.ForwardActionBase.ActionRecipient recipient)
        {
            Util.ThrowOnNullArgument(recipient, "recipient");
            ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(session.Mailbox.MapiStore, session, recipient.PropertyDefinitions);

            PropValue[] array = new PropValue[recipient.PropertyDefinitions.Count];
            int         num   = 0;

            foreach (PropTag propTag in collection)
            {
                array[num] = MapiPropertyBag.GetPropValueFromValue(session, timeZone, propTag, recipient.PropertyValues[num]);
                num++;
            }
            return(new AdrEntry(array));
        }
示例#5
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);
        }
示例#6
0
        private PropertyError[] InternalSetProperties(PropertyDefinition[] propertyDefinitions, object[] propertyValues, MapiPropertyBag.MapiSetProps mapiSetProps)
        {
            this.CheckDisposed("SetProperties");
            if (propertyDefinitions == null)
            {
                throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinitions", 1));
            }
            if (propertyValues == null)
            {
                throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyValues", 2));
            }
            if (propertyDefinitions.Length == 0)
            {
                return(MapiPropertyBag.EmptyPropertyErrorArray);
            }
            ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiProp, this.storeSession, (this.saveFlags & PropertyBagSaveFlags.IgnoreUnresolvedHeaders) == PropertyBagSaveFlags.IgnoreUnresolvedHeaders, true, (this.saveFlags & PropertyBagSaveFlags.DisableNewXHeaderMapping) != PropertyBagSaveFlags.DisableNewXHeaderMapping, propertyDefinitions);
            List <PropValue>      list       = new List <PropValue>(propertyDefinitions.Length);
            int num = 0;

            foreach (PropTag propTag in collection)
            {
                if (propTag != PropTag.Unresolved)
                {
                    InternalSchema.CheckPropertyValueType(propertyDefinitions[num], propertyValues[num]);
                    list.Add(MapiPropertyBag.GetPropValueFromValue(this.storeSession, this.ExTimeZone, propTag, propertyValues[num]));
                }
                num++;
            }
            PropProblem[] array        = null;
            StoreSession  storeSession = this.StoreSession;
            bool          flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                try
                {
                    array = mapiSetProps(list.ToArray());
                }
                catch (MapiExceptionNotEnoughMemory mapiExceptionNotEnoughMemory)
                {
                    ExTraceGlobals.StorageTracer.TraceError <MapiExceptionNotEnoughMemory>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed to SetProps due to MapiException {0}.", mapiExceptionNotEnoughMemory);
                    string errorDescription    = mapiExceptionNotEnoughMemory.ToString();
                    List <PropertyError> list2 = new List <PropertyError>();
                    foreach (PropertyDefinition propertyDefinition in propertyDefinitions)
                    {
                        list2.Add(new PropertyError(propertyDefinition, PropertyErrorCode.NotEnoughMemory, errorDescription));
                    }
                    throw PropertyError.ToException(list2.ToArray());
                }
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            PropertyError[] array2 = MapiPropertyBag.EmptyPropertyErrorArray;
            if (array != null)
            {
                array2 = new PropertyError[array.Length];
                for (int j = 0; j < array.Length; j++)
                {
                    int scode = array[j].Scode;
                    PropertyDefinition propertyDefinition2 = null;
                    int num2 = 0;
                    foreach (PropTag propTag2 in collection)
                    {
                        if (array[j].PropTag == propTag2)
                        {
                            propertyDefinition2 = propertyDefinitions[num2];
                            break;
                        }
                        num2++;
                    }
                    string            errorDescription2;
                    PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(scode, out errorDescription2);
                    array2[j] = new PropertyError(propertyDefinition2, error, errorDescription2);
                    ExTraceGlobals.StorageTracer.TraceError <string, MapiProp, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed. PropDef display name= {0}, MapiProp = {1}, Error = {2}.", propertyDefinition2.Name, this.MapiProp, array2[j]);
                }
            }
            return(array2);
        }