Пример #1
0
        private static UserConfiguration BuildConfigurationFromQueryItem(Folder folder, IStorePropertyBag row, bool hasLoadedUserConfigurationData)
        {
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemClass)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = ItemClass.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ItemClass"));
            }
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.ItemId)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id"));
            }
            if (PropertyError.IsPropertyError(row.TryGetProperty(InternalSchema.UserConfigurationType)))
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = UserConfigurationType.");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("UserConfigurationType"));
            }
            string name = (string)row[InternalSchema.ItemClass];

            if (!UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass))
            {
                return(null);
            }
            UserConfigurationName configurationName = new UserConfigurationName(name, ConfigurationNameKind.ItemClass);

            if (hasLoadedUserConfigurationData)
            {
                object dictionaryObject = UserConfiguration.CheckDictionaryData(row.TryGetProperty(InternalSchema.UserConfigurationDictionary));
                return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], dictionaryObject, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row));
            }
            return(new UserConfiguration(configurationName, folder.Session, folder.Id.ObjectId, (VersionedId)row[InternalSchema.ItemId], null, UserConfiguration.CheckUserConfigurationType((int)row[InternalSchema.UserConfigurationType]), row));
        }
Пример #2
0
        private static IList <IStorePropertyBag> QueryConfigurations(Folder folder, SortBy[] sorts, UserConfigurationName configurationName, UserConfigurationSearchFlags searchFlags, int maxRow, params PropertyDefinition[] columns)
        {
            List <IStorePropertyBag> list = new List <IStorePropertyBag>();

            columns = UserConfiguration.BuildPrefetchProperties(columns);
            IList <IStorePropertyBag> list2 = UserConfiguration.FetchAllConfigurations(folder, sorts, 10000, columns);
            IComparer customComparer        = UserConfigurationName.GetCustomComparer(searchFlags);

            foreach (IStorePropertyBag storePropertyBag in list2)
            {
                string x = storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;
                if (customComparer.Compare(x, configurationName) == 0)
                {
                    list.Add(storePropertyBag);
                }
            }
            if (folder.Session is MailboxSession)
            {
                if (folder.Session.LogonType == LogonType.Owner)
                {
                    UserConfiguration.AddToConfigurationCache(folder, list);
                }
                else
                {
                    UserConfiguration.AddToConfigurationCache(folder, list2);
                }
            }
            return(list);
        }
Пример #3
0
 private UserConfiguration(UserConfigurationName configurationName, UserConfigurationTypes type, IStorePropertyBag queryPropertyBag)
 {
     EnumValidator.AssertValid <UserConfigurationTypes>(type);
     this.queryPropertyBag = queryPropertyBag;
     StorageGlobals.TraceConstructIDisposable(this);
     this.disposeTracker = this.GetDisposeTracker();
 }
        private UserConfiguration GetMessageConfiguration(UserConfigurationName configurationName, UserConfigurationTypes freefetchDataTypes, StoreObjectId messageId)
        {
            UserConfiguration result            = null;
            ConfigurationItem configurationItem = null;

            EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(freefetchDataTypes, "freefetchDataTypes");
            try
            {
                configurationItem = ConfigurationItem.Bind(this.mailboxSession, messageId);
                result            = new UserConfiguration(configurationItem, (StoreObjectId)configurationItem.TryGetProperty(StoreObjectSchema.ParentItemId), configurationName, freefetchDataTypes, true);
            }
            catch (ObjectNotFoundException arg)
            {
                result = null;
                if (configurationItem != null)
                {
                    configurationItem.Dispose();
                }
                ExTraceGlobals.StorageTracer.TraceError <ObjectNotFoundException>(0L, "UserConfigurationManager::GetMessageConfiguration. Message object not found. Exception = {0}.", arg);
            }
            catch (Exception arg2)
            {
                result = null;
                if (configurationItem != null)
                {
                    configurationItem.Dispose();
                }
                ExTraceGlobals.StorageTracer.TraceError <Exception>(0L, "UserConfigurationManager::GetMessageConfiguration. Unable to create user configuration. Exception = {0}.", arg2);
            }
            return(result);
        }
        internal UserConfiguration Get(UserConfigurationName configName, StoreObjectId folderId)
        {
            bool flag = false;
            UserConfigurationCacheEntry userConfigurationCacheEntry;

            if (!this.SharedCacheEntryManager.TryGetUserConfigurationCachedEntry(configName, folderId, out userConfigurationCacheEntry))
            {
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName, StoreObjectId>((long)this.GetHashCode(), "UserConfigurationCache::Get. Miss the cache. ConfigName = {0}, folderId = {1}.", configName, folderId);
                return(null);
            }
            StoreObjectId     itemId            = userConfigurationCacheEntry.ItemId;
            ConfigurationItem configurationItem = null;
            bool flag2 = false;
            UserConfiguration result;

            try
            {
                configurationItem = ConfigurationItem.Bind(this.mailboxSession, itemId);
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationCache::Get. Hit the item in the cache. ConfigName = {0}.", configName);
                object obj = configurationItem.TryGetProperty(InternalSchema.UserConfigurationType);
                if (!(obj is int))
                {
                    ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName, object>((long)this.GetHashCode(), "UserConfigurationCache::Get. The type has been corrupted. ConfigName = {0}. Actual = {1}.", configName, configurationItem.TryGetProperty(InternalSchema.UserConfigurationType));
                    ExTraceGlobals.UserConfigurationTracer.TraceError((long)this.GetHashCode(), "UserConfiguration::Get. The configuration type has been corrupted. PropValue = {0}.", new object[]
                    {
                        configurationItem.TryGetProperty(InternalSchema.UserConfigurationType)
                    });
                    throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ConfigurationType"));
                }
                UserConfigurationTypes type = UserConfiguration.CheckUserConfigurationType((int)obj);
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationCache::Get. Hit the cache. ConfigName = {0}.", configName);
                UserConfiguration userConfiguration = new UserConfiguration(configurationItem, folderId, configName, type, true);
                flag2  = true;
                result = userConfiguration;
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationCache::Get. Miss the cache. The object has been deleted. ConfigName = {0}.", configName);
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "The user configuration object cannot be found though we hold its itemId in cache. ConfigName = {0}.", configName);
                this.Remove(configName, folderId);
                flag   = true;
                result = null;
            }
            finally
            {
                if (!flag2)
                {
                    if (configurationItem != null)
                    {
                        configurationItem.Dispose();
                    }
                    if (flag && this.mailboxSession.LogonType == LogonType.Owner)
                    {
                        this.Save();
                    }
                }
            }
            return(result);
        }
 public static bool IsValidName(string configurationName)
 {
     if (configurationName == null)
     {
         throw new ArgumentNullException("configurationName");
     }
     return(UserConfigurationName.IsValidName(configurationName, ConfigurationNameKind.Name));
 }
Пример #7
0
        private static void AddToConfigurationCache(Folder folder, IList <IStorePropertyBag> items)
        {
            if (items == null || items.Count == 0)
            {
                return;
            }
            MailboxSession mailboxSession = folder.Session as MailboxSession;

            if (mailboxSession == null)
            {
                throw new NotSupportedException();
            }
            UserConfigurationManager userConfigurationManager = mailboxSession.UserConfigurationManager;
            List <VersionedId>       list = new List <VersionedId>();

            new List <int>();
            string a = null;

            for (int i = 0; i < items.Count; i++)
            {
                IStorePropertyBag storePropertyBag = items[i];
                if (PropertyError.IsPropertyError(storePropertyBag.TryGetProperty(InternalSchema.ItemClass)))
                {
                    ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = ItemClass.");
                    throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("ItemClass"));
                }
                if (PropertyError.IsPropertyError(storePropertyBag.TryGetProperty(InternalSchema.ItemId)))
                {
                    ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = Id.");
                    throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Id"));
                }
                string b = storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;
                if (a == b)
                {
                    list.Add((VersionedId)storePropertyBag[InternalSchema.ItemId]);
                    items.RemoveAt(i);
                    i--;
                }
                else
                {
                    string name = (string)storePropertyBag[InternalSchema.ItemClass];
                    if (UserConfigurationName.IsValidName(name, ConfigurationNameKind.ItemClass))
                    {
                        userConfigurationManager.UserConfigurationCache.Add(folder.Id.ObjectId, new UserConfigurationName(name, ConfigurationNameKind.ItemClass), ((VersionedId)storePropertyBag[InternalSchema.ItemId]).ObjectId);
                    }
                }
                a = (storePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string);
            }
            if (folder.Session.LogonType == LogonType.Owner)
            {
                userConfigurationManager.UserConfigurationCache.Save();
            }
            AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.SoftDelete, list.ToArray());

            UserConfiguration.CheckOperationResults(result, "DeleteDuplicates");
        }
        private UserConfiguration InternalGetUserConfiguration(StoreId folderId, UserConfigurationName configurationName, UserConfigurationTypes freefetchDataType, StoreObjectId messageId)
        {
            if (this.aggregators.Count > 0)
            {
                lock (this.aggregators)
                {
                    foreach (UserConfigurationManager.AggregationContext aggregationContext in this.aggregators)
                    {
                        ExTraceGlobals.StorageTracer.TraceWarning <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration cache miss = {0}.", configurationName);
                        aggregationContext.FaiCacheMiss();
                    }
                }
            }
            if (folderId == null)
            {
                throw new ArgumentNullException("folderId");
            }
            UserConfiguration userConfiguration = null;
            bool flag2 = false;
            UserConfiguration result;

            try
            {
                userConfiguration = this.userConfigurationCache.Get(configurationName, StoreId.GetStoreObjectId(folderId));
                if (userConfiguration == null)
                {
                    if (messageId != null)
                    {
                        userConfiguration = this.GetMessageConfiguration(configurationName, freefetchDataType, messageId);
                    }
                    if (userConfiguration == null)
                    {
                        ExTraceGlobals.UserConfigurationTracer.TraceDebug <string>((long)this.GetHashCode(), "UserConfigurationManager::InternalBindAndGetUserConfiguration. Miss the cache. ConfigName = {0}.", configurationName.Name);
                        userConfiguration = this.InternalBindAndGetUserConfiguration(folderId, configurationName, freefetchDataType);
                    }
                }
                if ((userConfiguration.DataTypes & freefetchDataType) == (UserConfigurationTypes)0)
                {
                    ExTraceGlobals.StorageTracer.TraceError(0L, "The configuration data's field has been corrupted. Field = UserConfigurationType.");
                    throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("UserConfigurationType"));
                }
                flag2  = true;
                result = userConfiguration;
            }
            finally
            {
                if (!flag2 && userConfiguration != null)
                {
                    userConfiguration.Dispose();
                    userConfiguration = null;
                }
            }
            return(result);
        }
        private static string CheckConfigurationName(string name, ConfigurationNameKind kind)
        {
            Util.ThrowOnNullArgument(name, "name");
            string result;

            if (!UserConfigurationName.TryCheckConfigurationName(name, kind, out result))
            {
                throw new ArgumentException(ServerStrings.ExConfigNameInvalid(name));
            }
            return(result);
        }
Пример #10
0
 public static UserConfiguration GetConfiguration(Folder folder, UserConfigurationName configurationName, UserConfigurationTypes type)
 {
     EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(type, "type");
     try
     {
         return(UserConfiguration.GetIgnoringCache(null, folder, configurationName, type));
     }
     catch (ObjectNotFoundException arg)
     {
         ExTraceGlobals.StorageTracer.TraceError <ObjectNotFoundException>(0L, "UserConfiguration::GetConfiguration. User Configuration object not found. Exception = {0}.", arg);
     }
     return(UserConfiguration.Create(folder, configurationName, type));
 }
 private UserConfiguration InternalCreateUserConfiguration(Folder folder, UserConfigurationName configurationName, UserConfigurationTypes dataTypes)
 {
     ExTraceGlobals.StorageTracer.Information <UserConfigurationName, UserConfigurationTypes>((long)this.GetHashCode(), "UserConfigurationManager::InternalCreateUserConfiguration. configurationName = {0}, dataTypes = {1}.", configurationName, dataTypes);
     if (folder == null)
     {
         throw new ArgumentNullException("folder");
     }
     if (!EnumValidator.IsValidValue <UserConfigurationTypes>(dataTypes))
     {
         ExTraceGlobals.StorageTracer.TraceError((long)this.GetHashCode(), "UserConfigurationManager::InternalCreateUserConfiguration. dataTypes is invalid.");
         throw new ArgumentException("dataTypes");
     }
     return(UserConfiguration.Create(folder, configurationName, dataTypes));
 }
        internal void Remove(UserConfigurationName configName, StoreObjectId folderId)
        {
            LinkedListNode <UserConfigurationCacheEntry> linkedListNode = this.userConfigCacheEntryList.First;

            lock (this.userConfigCacheEntryList)
            {
                while (linkedListNode != null)
                {
                    UserConfigurationCacheEntry value = linkedListNode.Value;
                    if (value.CheckMatch(configName.Name, folderId))
                    {
                        this.userConfigCacheEntryList.Remove(linkedListNode);
                        break;
                    }
                    linkedListNode = linkedListNode.Next;
                }
            }
        }
        private static bool TryCheckConfigurationName(string name, ConfigurationNameKind kind, out string validatedName)
        {
            validatedName = null;
            int num = name.IndexOf("IPM.Configuration.");

            switch (kind)
            {
            case ConfigurationNameKind.Name:
            case ConfigurationNameKind.PartialName:
                if (num >= 0)
                {
                    ExTraceGlobals.StorageTracer.TraceError <string>(0L, "UserConfigurationName::TryCheckConfigurationName. Invalid config name contains well known prefix. Name = {0}", name);
                    return(false);
                }
                break;

            case ConfigurationNameKind.ItemClass:
                if (num < 0)
                {
                    ExTraceGlobals.StorageTracer.TraceError <string>(0L, "UserConfigurationName::TryCheckConfigurationName. Invalid full name. Name = {0}", name);
                    return(false);
                }
                name = name.Substring("IPM.Configuration.".Length);
                break;
            }
            if (name.Length == 0 && kind != ConfigurationNameKind.PartialName)
            {
                ExTraceGlobals.StorageTracer.TraceError <string, ConfigurationNameKind>(0L, "UserConfigurationName::TryCheckConfigurationName. ConfigName is empty. Name = {0}. Kind = {1}", name, kind);
                return(false);
            }
            if (name.Length > UserConfigurationName.MaxUserConfigurationNameLength)
            {
                ExTraceGlobals.StorageTracer.TraceError <string, int, int>(0L, "UserConfigurationName::TryCheckConfigurationName. Name = {0}, Length = {1}, MaxLength = {2}.", name, name.Length, UserConfigurationName.MaxUserConfigurationNameLength);
                return(false);
            }
            if (!UserConfigurationName.TryValidateConfigName(name))
            {
                return(false);
            }
            validatedName = name;
            return(true);
        }
        internal bool TryGetUserConfigurationCachedEntry(UserConfigurationName configName, StoreObjectId folderId, out UserConfigurationCacheEntry cacheEntry)
        {
            bool result;

            lock (this.userConfigCacheEntryList)
            {
                for (LinkedListNode <UserConfigurationCacheEntry> linkedListNode = this.userConfigCacheEntryList.First; linkedListNode != null; linkedListNode = linkedListNode.Next)
                {
                    UserConfigurationCacheEntry value = linkedListNode.Value;
                    if (value.CheckMatch(configName.Name, folderId))
                    {
                        cacheEntry = value;
                        return(true);
                    }
                }
                cacheEntry = null;
                result     = false;
            }
            return(result);
        }
        public UserConfigurationName(string name, ConfigurationNameKind kind)
        {
            EnumValidator.ThrowIfInvalid <ConfigurationNameKind>(kind, "kind");
            this.kind = kind;
            this.name = UserConfigurationName.CheckConfigurationName(name, kind);
            switch (kind)
            {
            case ConfigurationNameKind.Name:
            case ConfigurationNameKind.PartialName:
                this.fullName = "IPM.Configuration." + this.name;
                return;

            case ConfigurationNameKind.ItemClass:
                this.fullName = this.name;
                return;

            default:
                throw new InvalidOperationException(string.Format("Unrecognized kind. Kind = {0}.", this.kind));
            }
        }
Пример #16
0
        public static UserConfiguration Create(Folder folder, UserConfigurationName configurationName, UserConfigurationTypes type)
        {
            EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(type, "type");
            IList <IStorePropertyBag> list = null;

            try
            {
                list = UserConfiguration.QueryConfigurations(folder, null, configurationName, UserConfigurationSearchFlags.FullString, 1, new PropertyDefinition[0]);
            }
            catch (InvalidOperationException innerException)
            {
                throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException);
            }
            if (list.Count > 0)
            {
                ExTraceGlobals.StorageTracer.TraceError <UserConfigurationName>(0L, "UserConfiguration::Create. The configuration object has existed. ConfigName = {0}.", configurationName);
                throw new ObjectExistedException(ServerStrings.ExConfigExisted(configurationName.Name));
            }
            ConfigurationItem configurationItem = null;
            bool flag = false;
            UserConfiguration result;

            try
            {
                configurationItem = ItemBuilder.CreateNewItem <ConfigurationItem>(folder.Session, folder.Id, ItemCreateInfo.ConfigurationItemInfo, CreateMessageType.Associated);
                bool openMode = false;
                UserConfiguration userConfiguration = new UserConfiguration(configurationItem, folder.StoreObjectId, configurationName, type, openMode);
                flag   = true;
                result = userConfiguration;
            }
            finally
            {
                if (!flag)
                {
                    Util.DisposeIfPresent(configurationItem);
                }
            }
            return(result);
        }
            public int Compare(object x, object y)
            {
                string text = x as string;
                UserConfigurationName userConfigurationName = y as UserConfigurationName;

                if (text == null || userConfigurationName == null)
                {
                    return(-1);
                }
                switch (this.searchFlags)
                {
                case UserConfigurationSearchFlags.FullString:
                    if (text == userConfigurationName.FullName)
                    {
                        return(0);
                    }
                    break;

                case UserConfigurationSearchFlags.SubString:
                {
                    int num  = text.IndexOf("IPM.Configuration.");
                    int num2 = text.IndexOf(userConfigurationName.Name);
                    if (num == 0 && num2 >= "IPM.Configuration.".Length)
                    {
                        return(0);
                    }
                    break;
                }

                case UserConfigurationSearchFlags.Prefix:
                    if (text.IndexOf(userConfigurationName.FullName) == 0)
                    {
                        return(0);
                    }
                    break;
                }
                return(-1);
            }
Пример #18
0
        private UserConfiguration(UserConfigurationName configurationName, StoreSession storeSession, StoreObjectId folderId, VersionedId versionedId, object dictionaryObject, UserConfigurationTypes type, IStorePropertyBag queryPropertyBag) : this(configurationName, type, queryPropertyBag)
        {
            PropertyError propertyError = dictionaryObject as PropertyError;

            if (propertyError != null)
            {
                if (propertyError.PropertyErrorCode != PropertyErrorCode.NotFound)
                {
                    ExTraceGlobals.StorageTracer.TraceError <string, PropertyErrorCode>((long)this.GetHashCode(), "UserConfiguration::.ctor. The configuration data is corrupted. Field = {0}, PropertyErrorCode = {1}.", "Dictionary", propertyError.PropertyErrorCode);
                    throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Dictionary"));
                }
            }
            else if (dictionaryObject != null && !(dictionaryObject is byte[]))
            {
                ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "UserConfiguration::.ctor. The configuration data is corrupted. Field = {0}.", "Dictionary");
                throw new CorruptDataException(ServerStrings.ExConfigDataCorrupted("Dictionary"));
            }
            this.storeSession        = storeSession;
            this.folderId            = folderId;
            this.id                  = versionedId.ObjectId;
            this.configName          = configurationName;
            this.configType          = type;
            this.dictionaryPropValue = dictionaryObject;
        }
 internal void Remove(UserConfigurationName configName, StoreObjectId folderId)
 {
     this.SharedCacheEntryManager.Remove(configName, folderId);
 }
 internal void Add(StoreObjectId folderId, UserConfigurationName configName, StoreObjectId itemId)
 {
     this.SharedCacheEntryManager.AddUserConfigurationCachedEntry(folderId, configName.Name, itemId, this.mailboxSession.LogonType == LogonType.Owner);
 }
Пример #21
0
 internal UserConfiguration(ConfigurationItem configurationItem, StoreObjectId folderId, UserConfigurationName configurationName, UserConfigurationTypes type, bool openMode) : this(configurationName, type, null)
 {
     this.storeSession = configurationItem.Session;
     this.configType   = type;
     this.configName   = configurationName;
     this.item         = configurationItem;
     this.id           = configurationItem.StoreObjectId;
     this.folderId     = folderId;
     this.isOpenMode   = openMode;
     if (!this.isOpenMode)
     {
         this.dictionaryPropValue = new PropertyError(InternalSchema.UserConfigurationDictionary, PropertyErrorCode.NotFound);
     }
     else
     {
         this.dictionaryPropValue = null;
     }
     this.isDisposed = false;
 }
        internal static bool IsValidName(string name, ConfigurationNameKind kind)
        {
            string text;

            return(UserConfigurationName.TryCheckConfigurationName(name, kind, out text));
        }
        private UserConfiguration InternalBindAndGetUserConfiguration(StoreId folderId, UserConfigurationName configurationName, UserConfigurationTypes freefetchDataType)
        {
            UserConfiguration result = null;

            using (Folder folder = Folder.Bind(this.mailboxSession, folderId))
            {
                if (folder.IsNew)
                {
                    ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. The folder Id is null maybe it is because the folder has not been saved yet. Id = {0}.", "null");
                    throw new InvalidOperationException(ServerStrings.ExFolderWithoutMapiProp);
                }
                if (!EnumValidator.IsValidValue <UserConfigurationTypes>(freefetchDataType))
                {
                    ExTraceGlobals.StorageTracer.TraceError <UserConfigurationTypes>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. freefetchDataType is not allowed. freefetchDataType = {0}.", freefetchDataType);
                    throw new ArgumentException("freefetchDataType");
                }
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>((long)this.GetHashCode(), "UserConfigurationManager::InternalGetUserConfiguration. Hit code GetIgnoringCache. ConfigName = {0}.", configurationName);
                result = UserConfiguration.GetIgnoringCache(this, folder, configurationName, freefetchDataType);
            }
            return(result);
        }
Пример #24
0
        internal static UserConfiguration GetIgnoringCache(UserConfigurationManager manager, Folder folder, UserConfigurationName configurationName, UserConfigurationTypes freefetchType)
        {
            EnumValidator.AssertValid <UserConfigurationTypes>(freefetchType);
            UserConfiguration userConfiguration = null;

            PropertyDefinition[] columns;
            if ((freefetchType & UserConfigurationTypes.Dictionary) > (UserConfigurationTypes)0)
            {
                columns = new PropertyDefinition[]
                {
                    InternalSchema.UserConfigurationDictionary
                };
            }
            else
            {
                columns = UserConfiguration.ZeroProperties;
            }
            SortBy[] sorts = new SortBy[]
            {
                new SortBy(InternalSchema.CreationTime, SortOrder.Ascending),
                new SortBy(InternalSchema.MID, SortOrder.Ascending)
            };
            IList <IStorePropertyBag> list = null;

            try
            {
                ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Hit Query. ConfigName = {0}.", configurationName);
                list = UserConfiguration.QueryConfigurations(folder, sorts, configurationName, UserConfigurationSearchFlags.FullString, 2, columns);
            }
            catch (InvalidOperationException innerException)
            {
                throw new InvalidOperationException(ServerStrings.ExCannotQueryAssociatedTable, innerException);
            }
            if (list.Count <= 0)
            {
                ExTraceGlobals.StorageTracer.TraceError <UserConfigurationName, UserConfigurationTypes>(0L, "UserConfiguration::GetIgnoringCache. The configuration object was not found. Name = {0}, type = {1}.", configurationName, freefetchType);
                throw new ObjectNotFoundException(ServerStrings.ExConfigurationNotFound(configurationName.Name));
            }
            ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Find the config item and build user config object from it. ConfigName = {0}.", configurationName);
            bool flag = false;
            UserConfiguration result2;

            try
            {
                userConfiguration = UserConfiguration.BuildConfigurationFromQueryItem(folder, list[0], (freefetchType & UserConfigurationTypes.Dictionary) > (UserConfigurationTypes)0);
                if (list.Count > 1)
                {
                    ExTraceGlobals.UserConfigurationTracer.TraceDebug <UserConfigurationName>(0L, "UserConfiguration::GetIgnoringCache. Found duplicate items. Conflict resolution. ConfigName = {0}.", configurationName);
                    List <VersionedId> list2 = new List <VersionedId>();
                    list = UserConfiguration.QueryConfigurations(folder, sorts, configurationName, UserConfigurationSearchFlags.FullString, 100, new PropertyDefinition[0]);
                    for (int i = 1; i < list.Count; i++)
                    {
                        list2.Add((VersionedId)list[i][InternalSchema.ItemId]);
                    }
                    if (list2.Count > 0)
                    {
                        AggregateOperationResult result = folder.Session.Delete(DeleteItemFlags.HardDelete, list2.ToArray());
                        UserConfiguration.CheckOperationResults(result, "DeleteDuplicates");
                    }
                }
                flag    = true;
                result2 = userConfiguration;
            }
            finally
            {
                if (!flag && userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
            }
            return(result2);
        }
 private UserConfiguration InternalGetUserConfiguration(StoreId folderId, UserConfigurationName configurationName, UserConfigurationTypes freefetchDataType)
 {
     return(this.InternalGetUserConfiguration(folderId, configurationName, freefetchDataType, null));
 }