internal static void ResolveAndFilterPropertyValues(NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, StoreSession storeSession, MapiProp mapiProp, ExTimeZone exTimeZone, PropValue[] mapiPropValues, out NativeStorePropertyDefinition[] propertyDefinitions, out PropTag[] mapiPropTags, out object[] propertyValues)
        {
            PropTag[] array = new PropTag[mapiPropValues.Length];
            for (int i = 0; i < mapiPropValues.Length; i++)
            {
                array[i] = mapiPropValues[i].PropTag;
            }
            int num;

            NativeStorePropertyDefinition[] array2 = PropertyTagCache.Cache.InternalPropertyDefinitionsFromPropTags(typeCheckingFlag, mapiProp, storeSession, array, out num);
            propertyDefinitions = new NativeStorePropertyDefinition[num];
            mapiPropTags        = new PropTag[num];
            propertyValues      = new object[num];
            int num2 = 0;

            for (int j = 0; j < array2.Length; j++)
            {
                if (array2[j] != null)
                {
                    object valueFromPropValue = MapiPropertyBag.GetValueFromPropValue(storeSession, exTimeZone, array2[j], mapiPropValues[j]);
                    propertyDefinitions[num2] = array2[j];
                    mapiPropTags[num2]        = PropTagHelper.PropTagFromIdAndType(array[j].Id(), array2[j].MapiPropertyType);
                    propertyValues[num2]      = valueFromPropValue;
                    num2++;
                }
            }
        }
示例#2
0
 internal void SetQueryResultRow(PropValue[] row)
 {
     if (row.Length != this.propertyPositions.Count)
     {
         throw new ArgumentException("An array of values is different in size from an array of columns");
     }
     this.currentRowValues = new object[row.Length];
     foreach (KeyValuePair <StorePropertyDefinition, int> keyValuePair in this.propertyPositions)
     {
         StorePropertyDefinition key = keyValuePair.Key;
         int value = keyValuePair.Value;
         this.currentRowValues[value] = MapiPropertyBag.GetValueFromPropValue(this.Context.Session, this.timeZone, key, row[value]);
     }
 }
示例#3
0
 private static RuleAction.ForwardActionBase.ActionRecipient GetRecipient(StoreSession session, ExTimeZone timeZone, AdrEntry adrEntry)
 {
     Util.ThrowOnNullArgument(adrEntry, "adrEntry");
     PropTag[] array = new PropTag[adrEntry.Values.Length];
     for (int i = 0; i < array.Length; i++)
     {
         array[i] = adrEntry.Values[i].PropTag;
     }
     NativeStorePropertyDefinition[] array2 = PropertyTagCache.Cache.SafePropertyDefinitionsFromPropTags(session, array);
     object[] array3 = new object[adrEntry.Values.Length];
     for (int j = 0; j < array3.Length; j++)
     {
         array3[j] = MapiPropertyBag.GetValueFromPropValue(session, timeZone, array2[j], adrEntry.Values[j]);
     }
     return(new RuleAction.ForwardActionBase.ActionRecipient(array2, array3));
 }
 protected PropValue[] FromMapiPropValueToXsoPropValue(PropValue[] propValues)
 {
     PropTag[] array = new PropTag[propValues.Length];
     for (int i = 0; i < propValues.Length; i++)
     {
         array[i] = propValues[i].PropTag;
     }
     NativeStorePropertyDefinition[] array2 = PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, this.MapiFolder, this.Session, array);
     PropValue[] array3 = new PropValue[propValues.Length];
     for (int j = 0; j < array2.Length; j++)
     {
         if (array2[j] == null)
         {
             throw new NotSupportedException(string.Format("The property tag cannot be resolved to a property definition. PropertyTag = {0}", array[j]));
         }
         object valueFromPropValue = MapiPropertyBag.GetValueFromPropValue(this.Session, CoreObject.GetPersistablePropertyBag(this.folder).ExTimeZone, array2[j], propValues[j]);
         array3[j] = new PropValue(array2[j], valueFromPropValue);
     }
     return(array3);
 }
示例#5
0
        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));
            }
        }
示例#6
0
        private void RetryBigProperties(IList <NativeStorePropertyDefinition> allPropDefs, ICollection <PropTag> allPropTags, object[] allValues)
        {
            List <int> list  = null;
            int        count = allPropDefs.Count;

            for (int i = 0; i < count; i++)
            {
                if (PropertyError.IsPropertyValueTooBig(allValues[i]) && MapiPropertyBag.IsPropertyRetriable(allPropDefs[i]))
                {
                    if (list == null)
                    {
                        list = new List <int>(10);
                    }
                    list.Add(i);
                }
            }
            if (list == null)
            {
                return;
            }
            PropTag[] array = new PropTag[count];
            allPropTags.CopyTo(array, 0);
            bool flag = true;

            while (flag && list.Count > 0)
            {
                flag = false;
                PropTag[] array2 = new PropTag[list.Count];
                for (int j = 0; j < array2.Length; j++)
                {
                    array2[j] = array[list[j]];
                }
                PropValue[]  array3       = null;
                StoreSession storeSession = this.StoreSession;
                bool         flag2        = false;
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.BeginMapiCall();
                        storeSession.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    array3 = this.mapiProp.GetProps(array2);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiPropertyBag::RetryBigProperties. MapiProp = {0}.", this.MapiProp),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiPropertyBag::RetryBigProperties. MapiProp = {0}.", this.MapiProp),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (storeSession != null)
                        {
                            storeSession.EndMapiCall();
                            if (flag2)
                            {
                                storeSession.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                for (int k = array3.Length - 1; k >= 0; k--)
                {
                    int    num = list[k];
                    object valueFromPropValue = MapiPropertyBag.GetValueFromPropValue(this.storeSession, this.ExTimeZone, InternalSchema.ToStorePropertyDefinition(allPropDefs[num]), array3[k]);
                    if (!PropertyError.IsPropertyValueTooBig(valueFromPropValue))
                    {
                        allValues[num] = valueFromPropValue;
                        list.RemoveAt(k);
                        flag = true;
                    }
                }
            }
        }
示例#7
0
        internal object[] GetProperties(IList <NativeStorePropertyDefinition> propertyDefinitions)
        {
            this.CheckDisposed("GetProperties");
            if (propertyDefinitions == null)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "MapiPropertyBag::GetProperties. {0} == null.", "propertyDefinitions");
                throw new ArgumentNullException("propertyDefinitions");
            }
            int count = propertyDefinitions.Count;

            if (count == 0)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "MapiPropertyBag::GetProperties. {0} contain zero elements.", "propertyDefinitions");
                throw new ArgumentException(ServerStrings.ExEmptyCollection("propertyDefinitions"), "propertyDefinitions");
            }
            object[] array = new object[count];
            ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(this.MapiProp, this.storeSession, true, !this.storeSession.Capabilities.IsReadOnly, !this.storeSession.Capabilities.IsReadOnly, propertyDefinitions);

            PropValue[]  array2       = 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());
                }
                array2 = this.MapiProp.GetProps(collection);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::GetProperties. MapiProp = {0}.", this.MapiProp),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::GetProperties. MapiProp = {0}.", this.MapiProp),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            for (int i = 0; i < count; i++)
            {
                array[i] = MapiPropertyBag.GetValueFromPropValue(this.storeSession, this.ExTimeZone, InternalSchema.ToStorePropertyDefinition(propertyDefinitions[i]), array2[i]);
            }
            this.RetryBigProperties(propertyDefinitions, collection, array);
            return(array);
        }