Esempio n. 1
0
        internal static MapiEntryId GetEntryIdentity(MapiProp mapiObject)
        {
            MapiEntryId result;

            try
            {
                if (mapiObject == null)
                {
                    throw new ArgumentNullException("mapiObject");
                }
                PropValue prop = mapiObject.GetProp(PropTag.EntryId);
                if (PropType.Error == prop.PropType)
                {
                    result = null;
                }
                else
                {
                    result = new MapiEntryId(prop.GetBytes());
                }
            }
            catch (MapiPermanentException)
            {
                result = null;
            }
            catch (MapiRetryableException)
            {
                result = null;
            }
            return(result);
        }
Esempio n. 2
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));
            }
Esempio n. 3
0
        internal static string GetName(MapiProp mapiObject)
        {
            string result;

            try
            {
                if (mapiObject == null)
                {
                    throw new ArgumentNullException("mapiObject");
                }
                PropValue prop = mapiObject.GetProp(PropTag.DisplayName);
                if (PropType.Error == prop.PropType)
                {
                    result = null;
                }
                else
                {
                    result = prop.GetString();
                }
            }
            catch (MapiPermanentException)
            {
                result = null;
            }
            catch (MapiRetryableException)
            {
                result = null;
            }
            return(result);
        }
Esempio n. 4
0
        internal StoreObjectPropertyBag(StoreSession session, MapiProp mapiProp, ICollection <PropertyDefinition> autoloadProperties, bool canSaveOrDisposeMapiProp)
        {
            this.trackingPropertyExistence = autoloadProperties.Contains(InternalSchema.PropertyExistenceTracker);
            bool flag = false;

            try
            {
                this.canSaveOrDisposeMapiProp = canSaveOrDisposeMapiProp;
                if (mapiProp != null)
                {
                    this.MapiPropertyBag = new MapiPropertyBag(session, mapiProp);
                    if (this.mapiPropertyBag != null && this.mapiPropertyBag.DisposeTracker != null)
                    {
                        this.mapiPropertyBag.DisposeTracker.AddExtraDataWithStackTrace("StoreObjectPropertyBag owns mapiPropertyBag at");
                    }
                }
                this.ExTimeZone            = session.ExTimeZone;
                this.PrefetchPropertyArray = autoloadProperties;
                this.Load(null);
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    base.Dispose();
                }
            }
        }
Esempio n. 5
0
 internal static void SetTableFilter(StoreSession session, MapiProp propertyReference, MapiTable mapiTable, QueryFilter queryFilter)
 {
     if (queryFilter != null)
     {
         Restriction restriction = FilterRestrictionConverter.CreateRestriction(session, session.ExTimeZone, propertyReference, queryFilter);
         object      thisObject  = null;
         bool        flag        = false;
         try
         {
             if (session != null)
             {
                 session.BeginMapiCall();
                 session.BeginServerHealthCall();
                 flag = true;
             }
             if (StorageGlobals.MapiTestHookBeforeCall != null)
             {
                 StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
             }
             mapiTable.Restrict(restriction);
         }
         catch (MapiPermanentException ex)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]),
                 ex
             });
         }
         catch (MapiRetryableException ex2)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]),
                 ex2
             });
         }
         finally
         {
             try
             {
                 if (session != null)
                 {
                     session.EndMapiCall();
                     if (flag)
                     {
                         session.EndServerHealthCall();
                     }
                 }
             }
             finally
             {
                 if (StorageGlobals.MapiTestHookAfterCall != null)
                 {
                     StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                 }
             }
         }
     }
 }
Esempio n. 6
0
        internal static StoreObjectPropertyBag CreatePropertyBag(StoreSession storeSession, StoreObjectId id, ICollection <PropertyDefinition> prefetchPropertyArray)
        {
            Util.ThrowOnNullArgument(id, "id");
            MapiProp mapiProp = null;
            StoreObjectPropertyBag storeObjectPropertyBag = null;
            bool flag = false;
            StoreObjectPropertyBag result;

            try
            {
                mapiProp = storeSession.GetMapiProp(id);
                storeObjectPropertyBag = new StoreObjectPropertyBag(storeSession, mapiProp, prefetchPropertyArray);
                flag   = true;
                result = storeObjectPropertyBag;
            }
            finally
            {
                if (!flag)
                {
                    Util.DisposeIfPresent(storeObjectPropertyBag);
                    Util.DisposeIfPresent(mapiProp);
                }
            }
            return(result);
        }
Esempio n. 7
0
        internal static StoreObjectPropertyBag CreatePropertyBag(StoreSession storeSession, StoreObjectId id, ICollection <PropertyDefinition> prefetchPropertyArray)
        {
            MapiProp mapiProp = null;
            StoreObjectPropertyBag storeObjectPropertyBag = null;
            bool flag = false;
            StoreObjectPropertyBag result;

            try
            {
                mapiProp = storeSession.GetMapiProp(id);
                storeObjectPropertyBag = new StoreObjectPropertyBag(storeSession, mapiProp, prefetchPropertyArray);
                flag   = true;
                result = storeObjectPropertyBag;
            }
            finally
            {
                if (!flag)
                {
                    if (storeObjectPropertyBag != null)
                    {
                        storeObjectPropertyBag.Dispose();
                        storeObjectPropertyBag = null;
                    }
                    if (mapiProp != null)
                    {
                        mapiProp.Dispose();
                        mapiProp = null;
                    }
                }
            }
            return(result);
        }
Esempio n. 8
0
        internal static MapiPropertyBag CreateMapiPropertyBag(StoreSession storeSession, StoreObjectId id)
        {
            Util.ThrowOnNullArgument(storeSession, "storeSession");
            Util.ThrowOnNullArgument(id, "id");
            MapiProp        disposable      = null;
            MapiPropertyBag mapiPropertyBag = null;
            bool            flag            = false;
            MapiPropertyBag result;

            try
            {
                disposable      = storeSession.GetMapiProp(id);
                mapiPropertyBag = new MapiPropertyBag(storeSession, disposable);
                flag            = true;
                result          = mapiPropertyBag;
            }
            finally
            {
                if (!flag)
                {
                    Util.DisposeIfPresent(mapiPropertyBag);
                    Util.DisposeIfPresent(disposable);
                }
            }
            return(result);
        }
Esempio n. 9
0
        private static PropTag[] MapiGetIdsFromNames(StoreSession session, MapiProp mapiProp, bool createNamedProperties, ICollection <NamedProp> namedProperties)
        {
            object thisObject = null;
            bool   flag       = false;

            PropTag[] idsFromNames;
            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                idsFromNames = mapiProp.GetIDsFromNames(createNamedProperties, namedProperties);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetIDFromNames, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PropertyTagCache.MapiResolveProps failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetIDFromNames, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PropertyTagCache.MapiResolveProps failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(idsFromNames);
        }
 public PropertyDefinitionToPropTagCollection(MapiProp mapiProp, StoreSession storeSession, bool allowUnresolvedHeaders, bool allowCreate, bool allowCreateHeaders, IEnumerable <NativeStorePropertyDefinition> propertyDefinitions)
 {
     this.mapiProp               = mapiProp;
     this.storeSession           = storeSession;
     this.allowUnresolvedHeaders = allowUnresolvedHeaders;
     this.allowCreate            = allowCreate;
     this.allowCreateHeaders     = allowCreateHeaders;
     this.properties             = propertyDefinitions;
 }
Esempio n. 11
0
 internal MapiPropertyBag(StoreSession storeSession, MapiProp mapiProp)
 {
     StorageGlobals.TraceConstructIDisposable(this);
     this.disposeTracker = this.GetDisposeTracker();
     this.mapiProp       = mapiProp;
     this.exTimeZone     = storeSession.ExTimeZone;
     this.storeSession   = storeSession;
     if (mapiProp.DisposeTracker != null)
     {
         mapiProp.DisposeTracker.AddExtraDataWithStackTrace("MapiPropertyBag owns mapiProp at");
     }
 }
Esempio n. 12
0
        internal MapiProp DetachMapiProp()
        {
            MapiProp mapiProp = this.mapiProp;

            if (mapiProp.DisposeTracker != null)
            {
                mapiProp.DisposeTracker.AddExtraDataWithStackTrace("MapiPropertyBag detached mapiProp at");
            }
            this.mapiProp = null;
            this.Dispose();
            return(mapiProp);
        }
Esempio n. 13
0
        public static NamedProp[] GetNamedPropsFromIds(StoreSession session, MapiProp mapiProp, ICollection <ushort> propIds)
        {
            int count = propIds.Count;

            NamedProp[]   array   = new NamedProp[count];
            List <ushort> list    = new List <ushort>();
            List <int>    list2   = new List <int>();
            NamedPropMap  mapping = NamedPropMapCache.Default.GetMapping(session);
            int           num     = 0;

            foreach (ushort num2 in propIds)
            {
                if (num2 < 32768)
                {
                    throw new ArgumentOutOfRangeException(string.Format("PropId is not in the range of named props.  PropId = 0x{0:x}.", num2));
                }
                NamedProp namedProp = null;
                if (mapping != null && mapping.TryGetNamedPropFromPropId(num2, out namedProp))
                {
                    array[num] = namedProp;
                }
                else
                {
                    list.Add(num2);
                    list2.Add(num);
                }
                num++;
            }
            int num3 = 0;

            while (list.Count > 0)
            {
                int           count2 = Math.Min(list.Count, 256);
                List <ushort> range  = list.GetRange(0, count2);
                NamedProp[]   array2 = NamedPropConverter.MapiGetNamesFromIds(session, mapiProp, range);
                if (mapping != null)
                {
                    mapping.AddMapping(false, range, array2);
                }
                for (int i = 0; i < array2.Length; i++)
                {
                    int num4 = list2[i + num3 * 256];
                    array[num4] = array2[i];
                }
                list.RemoveRange(0, count2);
                num3++;
            }
            return(array);
        }
Esempio n. 14
0
        internal PropTag PropTagFromPropertyDefinition(MapiProp mapiProp, StoreSession storeSession, bool allowUnresolvedHeaders, bool allowCreate, NativeStorePropertyDefinition propertyDefinition)
        {
            PropertyTagPropertyDefinition propertyTagPropertyDefinition = propertyDefinition as PropertyTagPropertyDefinition;

            if (propertyTagPropertyDefinition != null)
            {
                return((PropTag)propertyTagPropertyDefinition.PropertyTag);
            }
            ICollection <PropTag> source = this.PropTagsFromPropertyDefinitions(mapiProp, storeSession, allowUnresolvedHeaders, allowCreate, true, new NativeStorePropertyDefinition[]
            {
                propertyDefinition
            });

            return(source.First <PropTag>());
        }
Esempio n. 15
0
 internal ICollection <PropTag> PropTagsFromPropertyDefinitions(MapiProp mapiProp, StoreSession storeSession, bool allowUnresolvedHeaders, bool allowCreate, bool allowCreateInternet, IEnumerable <NativeStorePropertyDefinition> propertyDefinitions)
 {
     if (mapiProp == null)
     {
         throw new ArgumentNullException("mapiProp");
     }
     if (storeSession == null)
     {
         throw new ArgumentNullException("storeSession");
     }
     if (propertyDefinitions == null)
     {
         throw new ArgumentNullException("propertyDefinitions");
     }
     return(new PropertyDefinitionToPropTagCollection(mapiProp, storeSession, allowUnresolvedHeaders, allowCreate, allowCreateInternet, propertyDefinitions));
 }
Esempio n. 16
0
 private static PropertyError[] ToXsoPropertyErrors(StoreSession session, MapiProp destMapiProp, PropProblem[] problems)
 {
     if (problems == null || problems.Length == 0)
     {
         return(MapiPropertyBag.EmptyPropertyErrorArray);
     }
     PropTag[] array  = new PropTag[problems.Length];
     int[]     array2 = new int[problems.Length];
     for (int i = 0; i < problems.Length; i++)
     {
         array2[i] = problems[i].Scode;
         array[i]  = problems[i].PropTag;
     }
     NativeStorePropertyDefinition[] array3 = PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, destMapiProp, session, array);
     PropertyError[] array4 = new PropertyError[problems.Length];
     for (int j = 0; j < problems.Length; j++)
     {
         string            errorDescription;
         PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(array2[j], out errorDescription);
         array4[j] = new PropertyError(array3[j], error, errorDescription);
     }
     return(array4);
 }
Esempio n. 17
0
 internal StoreObjectPropertyBag(StoreSession session, MapiProp mapiProp, ICollection <PropertyDefinition> autoloadProperties) : this(session, mapiProp, autoloadProperties, true)
 {
 }
        private void CreateMapiFolder()
        {
            string valueOrDefault  = base.GetValueOrDefault <string>(FolderSchema.DisplayName);
            string valueOrDefault2 = base.GetValueOrDefault <string>(FolderSchema.Description, string.Empty);

            byte[]          array           = base.Session.IsMoveUser ? base.GetValueOrDefault <byte[]>(StoreObjectSchema.EntryId, null) : null;
            MapiProp        mapiProp        = null;
            MapiPropertyBag mapiPropertyBag = null;
            bool            flag            = false;

            try
            {
                using (Folder folder = Folder.Bind(base.Session, this.parentFolderId, new PropertyDefinition[]
                {
                    StoreObjectSchema.EffectiveRights
                }))
                {
                    if (folder is SearchFolder)
                    {
                        throw new InvalidParentFolderException(ServerStrings.ExCannotCreateSubfolderUnderSearchFolder);
                    }
                    bool flag2 = (this.createMode & CreateMode.OpenIfExists) == CreateMode.OpenIfExists;
                    bool flag3 = (this.createMode & CreateMode.InstantSearch) == CreateMode.InstantSearch;
                    bool flag4 = (this.createMode & CreateMode.OptimizedConversationSearch) == CreateMode.OptimizedConversationSearch;
                    bool flag5 = (this.createMode & CreateMode.CreatePublicFolderDumpster) == CreateMode.CreatePublicFolderDumpster;
                    if (flag2 && flag3)
                    {
                        throw new ArgumentException("Cannot use both openIfExists and instantSearch folder creation flags");
                    }
                    if (this.isSecure && (flag3 || flag4 || flag5))
                    {
                        throw new ArgumentException("Cannot use isSecure in conjunction with instantSearch, optimizedConversationSearch or createPublicFolderDumpster");
                    }
                    StoreSession session = base.Session;
                    bool         flag6   = false;
                    try
                    {
                        if (session != null)
                        {
                            session.BeginMapiCall();
                            session.BeginServerHealthCall();
                            flag6 = true;
                        }
                        if (StorageGlobals.MapiTestHookBeforeCall != null)
                        {
                            StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                        }
                        try
                        {
                            this.OnBeforeCreateFolder(folder);
                            if (this.isSecure)
                            {
                                mapiProp = folder.MapiFolder.CreateSecureFolder(valueOrDefault, valueOrDefault2, flag2, array);
                            }
                            else
                            {
                                mapiProp = folder.MapiFolder.CreateFolder(valueOrDefault, valueOrDefault2, flag2, this.isSearchFolder, flag3, flag4, flag5, array);
                            }
                        }
                        catch (MapiExceptionNotEnoughMemory mapiExceptionNotEnoughMemory)
                        {
                            ExTraceGlobals.StorageTracer.TraceError <MapiExceptionNotEnoughMemory>((long)this.GetHashCode(), "CreateFolderPropertyBag::CreateMapiPropertyBag. Failed to create MapiFolder due to MapiException {0}.", mapiExceptionNotEnoughMemory);
                            bool            flag7            = !string.IsNullOrEmpty(valueOrDefault2);
                            string          errorDescription = mapiExceptionNotEnoughMemory.ToString();
                            PropertyError[] array2           = new PropertyError[flag7 ? 2 : 1];
                            array2[0] = new PropertyError(FolderSchema.DisplayName, PropertyErrorCode.NotEnoughMemory, errorDescription);
                            if (flag7)
                            {
                                array2[1] = new PropertyError(FolderSchema.Description, PropertyErrorCode.NotEnoughMemory, errorDescription);
                            }
                            throw PropertyError.ToException(array2);
                        }
                    }
                    catch (MapiPermanentException ex)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateFolder(valueOrDefault), ex, session, this, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("CreateFolderPropertyBag::CreateMapiPropertyBag.", new object[0]),
                            ex
                        });
                    }
                    catch (MapiRetryableException ex2)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateFolder(valueOrDefault), ex2, session, this, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("CreateFolderPropertyBag::CreateMapiPropertyBag.", new object[0]),
                            ex2
                        });
                    }
                    finally
                    {
                        try
                        {
                            if (session != null)
                            {
                                session.EndMapiCall();
                                if (flag6)
                                {
                                    session.EndServerHealthCall();
                                }
                            }
                        }
                        finally
                        {
                            if (StorageGlobals.MapiTestHookAfterCall != null)
                            {
                                StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                            }
                        }
                    }
                }
                this.Context.CoreState.Origin = Origin.Existing;
                base.MemoryPropertyBag.ClearChangeInfo(FolderSchema.DisplayName);
                if (array != null)
                {
                    base.MemoryPropertyBag.ClearChangeInfo(StoreObjectSchema.EntryId);
                }
                if (this.createMode == CreateMode.CreateNew)
                {
                    base.MemoryPropertyBag.ClearChangeInfo(FolderSchema.Description);
                }
                mapiPropertyBag      = new MapiPropertyBag(base.Session, mapiProp);
                base.MapiPropertyBag = mapiPropertyBag;
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    Util.DisposeIfPresent(mapiPropertyBag);
                    Util.DisposeIfPresent(mapiProp);
                }
            }
        }
Esempio n. 19
0
 internal ICollection <PropTag> PropTagsFromPropertyDefinitions <T>(MapiProp mapiProp, StoreSession storeSession, bool allowUnresolvedHeaders, bool allowCreate, bool allowCreateInternetHeaders, IEnumerable <T> propertyDefinitions) where T : PropertyDefinition
 {
     return(this.PropTagsFromPropertyDefinitions(mapiProp, storeSession, allowUnresolvedHeaders, allowCreate, allowCreateInternetHeaders, propertyDefinitions.Cast <T, NativeStorePropertyDefinition>()));
 }
Esempio n. 20
0
        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++;
                }
            }
        }
Esempio n. 21
0
        private static bool TryFixPropTagWithErrorType(StoreSession session, MapiProp mapiProp, ref PropTag[] completePropTagList, ref PropTag propTag)
        {
            if (propTag.ValueType() != PropType.Error && propTag.ValueType() != PropType.Unspecified)
            {
                return(true);
            }
            if (completePropTagList == null)
            {
                object thisObject = null;
                bool   flag       = false;
                try
                {
                    if (session != null)
                    {
                        session.BeginMapiCall();
                        session.BeginServerHealthCall();
                        flag = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    completePropTagList = mapiProp.GetPropList();
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("PropertyTagCache.IsGoodMapiPropTag failed.", new object[0]),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("PropertyTagCache.IsGoodMapiPropTag failed.", new object[0]),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (session != null)
                        {
                            session.EndMapiCall();
                            if (flag)
                            {
                                session.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
            }
            int num = propTag.Id();

            for (int i = 0; i < completePropTagList.Length; i++)
            {
                if (completePropTagList[i].Id() == num)
                {
                    propTag = completePropTagList[i];
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 22
0
        internal NativeStorePropertyDefinition[] InternalPropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag propertyTypeCheckingFlag, MapiProp mapiProp, StoreSession storeSession, PropTag[] propTags, out int resolvedPropertyCount)
        {
            EnumValidator.ThrowIfInvalid <NativeStorePropertyDefinition.TypeCheckingFlag>(propertyTypeCheckingFlag, "propertyTypeCheckingFlag");
            resolvedPropertyCount = 0;
            NativeStorePropertyDefinition[] array = new NativeStorePropertyDefinition[propTags.Length];
            List <PropertyTagCache.NamedPropertyToResolve> list = null;

            PropTag[] array2 = null;
            for (int i = 0; i < propTags.Length; i++)
            {
                PropTag propTag = propTags[i];
                if (!PropertyTagCache.TryFixPropTagWithErrorType(storeSession, mapiProp, ref array2, ref propTag))
                {
                    ExTraceGlobals.PropertyMappingTracer.TraceError <PropTag>((long)storeSession.GetHashCode(), "Failed to infer the property type for PropertyTag {0:X}", propTag);
                }
                else
                {
                    PropertyTagCache.ChangeStringPropTagTypeToUnicode(ref propTag);
                    int num = propTag.Id();
                    if (num < 32768)
                    {
                        NativeStorePropertyDefinition nativeStorePropertyDefinition = PropertyTagPropertyDefinition.InternalCreateCustom(string.Empty, propTag, PropertyFlags.None, propertyTypeCheckingFlag);
                        array[i] = nativeStorePropertyDefinition;
                        if (nativeStorePropertyDefinition != null)
                        {
                            resolvedPropertyCount++;
                        }
                    }
                    else
                    {
                        if (list == null)
                        {
                            list = new List <PropertyTagCache.NamedPropertyToResolve>();
                        }
                        list.Add(new PropertyTagCache.NamedPropertyToResolve((ushort)num, propTag.ValueType(), i));
                    }
                }
            }
            if (list != null)
            {
                NamedProp[] namedPropsFromIds = NamedPropConverter.GetNamedPropsFromIds(storeSession, mapiProp, from namedPropertyToResolve in list
                                                                                        select namedPropertyToResolve.PropId);
                int num2 = 0;
                foreach (PropertyTagCache.NamedPropertyToResolve namedPropertyToResolve2 in list)
                {
                    NativeStorePropertyDefinition propDefByMapiNamedProp = PropertyTagCache.GetPropDefByMapiNamedProp(namedPropsFromIds[num2++], namedPropertyToResolve2.PropType, propertyTypeCheckingFlag);
                    array[namedPropertyToResolve2.Index] = propDefByMapiNamedProp;
                    if (propDefByMapiNamedProp != null)
                    {
                        resolvedPropertyCount++;
                    }
                    else
                    {
                        ExTraceGlobals.PropertyMappingTracer.TraceDebug <ushort, PropType>((long)storeSession.GetHashCode(), "Failed to resolve a named property from PropertyId {0:X} [{1:X}]", namedPropertyToResolve2.PropId, namedPropertyToResolve2.PropType);
                    }
                }
            }
            return(array);
        }
Esempio n. 23
0
 internal ICollection <PropTag> PropTagsFromPropertyDefinitions(MapiProp mapiProp, StoreSession storeSession, bool allowUnresolvedHeaders, IEnumerable <NativeStorePropertyDefinition> propertyDefinitions)
 {
     return(this.PropTagsFromPropertyDefinitions(mapiProp, storeSession, allowUnresolvedHeaders, true, true, propertyDefinitions));
 }
Esempio n. 24
0
 internal static PropertyError[] MapiPropProblemsToPropertyErrors(StoreSession storeSession, MapiProp mapiProp, PropProblem[] problems)
 {
     PropTag[]     array  = new PropTag[problems.Length];
     PropProblem[] array2 = new PropProblem[problems.Length];
     for (int i = 0; i < problems.Length; i++)
     {
         array[i]  = problems[i].PropTag;
         array2[i] = new PropProblem(i, problems[i].PropTag, problems[i].Scode);
     }
     NativeStorePropertyDefinition[] propertyDefinitions = PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, mapiProp, storeSession, array);
     return(StoreObjectPropertyBag.MapiPropProblemsToPropertyErrors(propertyDefinitions, array2));
 }
        internal static StoreObjectId CreateVersion(StoreSession session, StoreObjectId itemId, StoreObjectId versionFolderId)
        {
            StoreObjectId result;

            using (CoreCalendarItemVersion coreCalendarItemVersion = new CoreCalendarItemVersion(session))
            {
                using (MapiProp mapiProp = session.GetMapiProp(itemId, OpenEntryFlags.DeferredErrors | OpenEntryFlags.ShowSoftDeletes))
                {
                    coreCalendarItemVersion.underlyingMessage = Folder.InternalCreateMapiMessage(session, versionFolderId, CreateMessageType.Normal);
                    coreCalendarItemVersion.CopyRequiredData((MapiMessage)mapiProp);
                    object thisObject = null;
                    bool   flag       = false;
                    try
                    {
                        if (session != null)
                        {
                            session.BeginMapiCall();
                            session.BeginServerHealthCall();
                            flag = true;
                        }
                        if (StorageGlobals.MapiTestHookBeforeCall != null)
                        {
                            StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                        }
                        coreCalendarItemVersion.underlyingMessage.SetReadFlag(SetReadFlags.ClearRnPending | SetReadFlags.CleanNrnPending);
                    }
                    catch (MapiPermanentException ex)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("CoreCalendarItemVersion::CreateVersion. Failed to set read flag of underlying message.", new object[0]),
                            ex
                        });
                    }
                    catch (MapiRetryableException ex2)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("CoreCalendarItemVersion::CreateVersion. Failed to set read flag of underlying message.", new object[0]),
                            ex2
                        });
                    }
                    finally
                    {
                        try
                        {
                            if (session != null)
                            {
                                session.EndMapiCall();
                                if (flag)
                                {
                                    session.EndServerHealthCall();
                                }
                            }
                        }
                        finally
                        {
                            if (StorageGlobals.MapiTestHookAfterCall != null)
                            {
                                StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                            }
                        }
                    }
                }
                coreCalendarItemVersion.Save();
                StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(coreCalendarItemVersion.underlyingMessage.GetProp(PropTag.EntryId).GetBytes(), itemId.ObjectType);
                CoreCalendarItemVersion.perfCounters.DumpsterCalendarLogsRate.Increment();
                result = storeObjectId;
            }
            return(result);
        }
Esempio n. 26
0
        internal void Instantiate(PropValue[] propertyValues)
        {
            if (propertyValues == null)
            {
                throw new ArgumentNullException("propertyValues");
            }
            if (propertyValues.Length == 0)
            {
                return;
            }
            if (!(this.ObjectSchema is MapiObjectSchema))
            {
                throw new MapiInvalidOperationException(Strings.ExceptionSchemaInvalidCast(this.ObjectSchema.GetType().ToString()));
            }
            base.InstantiationErrors.Clear();
            MapiStore mapiStore = null;
            MapiProp  mapiProp  = null;

            try
            {
                foreach (PropertyDefinition propertyDefinition in this.ObjectSchema.AllProperties)
                {
                    MapiPropertyDefinition mapiPropertyDefinition = (MapiPropertyDefinition)propertyDefinition;
                    if (!mapiPropertyDefinition.IsCalculated && mapiPropertyDefinition.PropertyTag != PropTag.Null)
                    {
                        bool      flag      = false;
                        PropValue propValue = new PropValue(PropTag.Null, null);
                        foreach (PropValue propValue in propertyValues)
                        {
                            if (propValue.PropTag.Id() == mapiPropertyDefinition.PropertyTag.Id())
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            if (mapiPropertyDefinition.IsMandatory)
                            {
                                base.InstantiationErrors.Add(new PropertyValidationError(Strings.ErrorMandatoryPropertyMissing(mapiPropertyDefinition.Name), mapiPropertyDefinition, null));
                            }
                        }
                        else
                        {
                            if (PropType.Error == propValue.PropType && propValue.GetErrorValue() == -2147024882)
                            {
                                if (mapiProp == null)
                                {
                                    mapiProp = this.GetRawMapiEntry(out mapiStore);
                                }
                                propValue = mapiProp.GetProp(mapiPropertyDefinition.PropertyTag);
                            }
                            if (PropType.Error == propValue.PropType)
                            {
                                ExTraceGlobals.MapiObjectTracer.TraceError <PropTag>((long)this.GetHashCode(), "Retrieving PropTag '{0}' failed.", mapiPropertyDefinition.PropertyTag);
                            }
                            else
                            {
                                try
                                {
                                    object value = mapiPropertyDefinition.Extractor(propValue, mapiPropertyDefinition);
                                    IList <ValidationError> list = mapiPropertyDefinition.ValidateProperty(value, this.propertyBag, false);
                                    if (list != null)
                                    {
                                        base.InstantiationErrors.AddRange(list);
                                    }
                                    this.propertyBag.SetField(mapiPropertyDefinition, value);
                                }
                                catch (MapiConvertingException ex)
                                {
                                    base.InstantiationErrors.Add(new PropertyConversionError(ex.LocalizedString, mapiPropertyDefinition, propValue, ex));
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (mapiProp != null)
                {
                    mapiProp.Dispose();
                    mapiProp = null;
                }
                if (mapiStore != null)
                {
                    mapiStore.Dispose();
                    mapiStore = null;
                }
            }
        }
Esempio n. 27
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);
        }
Esempio n. 28
0
 internal PropTag PropTagFromPropertyDefinition(MapiProp mapiProp, StoreSession storeSession, NativeStorePropertyDefinition propertyDefinition)
 {
     return(this.PropTagFromPropertyDefinition(mapiProp, storeSession, false, true, propertyDefinition));
 }
Esempio n. 29
0
        public NativeStorePropertyDefinition[] PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag propertyTypeCheckingFlag, MapiProp mapiProp, StoreSession storeSession, params PropTag[] propTags)
        {
            int num;

            return(this.InternalPropertyDefinitionsFromPropTags(propertyTypeCheckingFlag, mapiProp, storeSession, propTags, out num));
        }
Esempio n. 30
0
 internal ICollection <PropTag> PropTagsFromPropertyDefinitions(MapiProp mapiProp, StoreSession storeSession, IEnumerable <NativeStorePropertyDefinition> propertyDefinitions)
 {
     return(this.PropTagsFromPropertyDefinitions(mapiProp, storeSession, false, propertyDefinitions));
 }