예제 #1
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);
        }
예제 #2
0
        internal static PropertyError[] MapiCopyTo(MapiProp source, MapiProp destination, StoreSession sourceSession, StoreSession destSession, CopyPropertiesFlags copyPropertiesFlags, CopySubObjects copySubObjects, params NativeStorePropertyDefinition[] excludeProperties)
        {
            Util.ThrowOnNullArgument(source, "sources");
            Util.ThrowOnNullArgument(destination, "destination");
            ICollection <PropTag> excludeTags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(source, sourceSession, true, excludeProperties);

            PropProblem[] problems = null;
            bool          flag     = false;

            try
            {
                if (sourceSession != null)
                {
                    sourceSession.BeginMapiCall();
                    sourceSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                try
                {
                    problems = source.CopyTo(destination, false, CoreObject.ToCopyPropertiesFlags(copyPropertiesFlags), copySubObjects == CopySubObjects.Copy, excludeTags);
                }
                catch (MapiExceptionNamedPropsQuotaExceeded)
                {
                    PropTag[] propList = source.GetPropList();
                    NativeStorePropertyDefinition[] propertyDefinitions = PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, source, sourceSession, propList);
                    ICollection <PropTag>           collection          = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(destination, destSession, true, true, true, propertyDefinitions);
                    List <PropTag> list = new List <PropTag>(collection.Count);
                    int            num  = 0;
                    foreach (PropTag propTag in collection)
                    {
                        if (propTag == PropTag.Unresolved)
                        {
                            list.Add(propList[num]);
                        }
                        num++;
                    }
                    problems = source.CopyTo(destination, list);
                }
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCopyMapiProps, ex, sourceSession, source, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("CoreItem::MapiCopyTo.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCopyMapiProps, ex2, sourceSession, source, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("CoreItem::MapiCopyTo.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (sourceSession != null)
                    {
                        sourceSession.EndMapiCall();
                        if (flag)
                        {
                            sourceSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            CoreObject.ProcessCopyPropertyProblems(problems, sourceSession, source);
            return(CoreObject.ToXsoPropertyErrors(destSession, destination, problems));
        }