コード例 #1
0
 private UserConfiguration(UserConfigurationName configurationName, UserConfigurationTypes type, IStorePropertyBag queryPropertyBag)
 {
     EnumValidator.AssertValid <UserConfigurationTypes>(type);
     this.queryPropertyBag = queryPropertyBag;
     StorageGlobals.TraceConstructIDisposable(this);
     this.disposeTracker = this.GetDisposeTracker();
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 private void CheckConfigurationType(UserConfigurationTypes type)
 {
     if ((type & this.configType) == (UserConfigurationTypes)0)
     {
         ExTraceGlobals.StorageTracer.TraceError <UserConfigurationTypes, UserConfigurationTypes>((long)this.GetHashCode(), "UserConfiguration::CheckDataType. The config type is not supported by the current user configuration. ConfigType(defined) = {0}, ConfigType(used) = {1}.", this.configType, type);
         throw new InvalidOperationException(ServerStrings.ExConfigTypeNotMatched(this.configType.ToString(), type.ToString()));
     }
 }
コード例 #4
0
        public UserConfiguration CreateFolderConfiguration(string configurationName, UserConfigurationTypes dataTypes, StoreId folderId)
        {
            EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(dataTypes, "dataTypes");
            if (folderId == null)
            {
                throw new ArgumentNullException("folderId");
            }
            UserConfiguration result;

            using (Folder folder = Folder.Bind(this.mailboxSession, folderId))
            {
                result = this.InternalCreateUserConfiguration(folder, new UserConfigurationName(configurationName, ConfigurationNameKind.Name), dataTypes);
            }
            return(result);
        }
コード例 #5
0
        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);
        }
コード例 #6
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);
        }
コード例 #7
0
 public IUserConfiguration GetConfiguration(MailboxSession mailboxSession, string configName, UserConfigurationTypes freefetchDataTypes)
 {
     return(mailboxSession.UserConfigurationManager.GetFolderConfiguration(configName, freefetchDataTypes, this.GetDefaultFolderId(mailboxSession)));
 }
コード例 #8
0
 public IUserConfiguration CreateConfiguration(MailboxSession mailboxSession, string configurationName, UserConfigurationTypes dataType)
 {
     return(mailboxSession.UserConfigurationManager.CreateMailboxConfiguration(configurationName, dataType));
 }
コード例 #9
0
 public UserConfiguration GetMailboxConfiguration(string configName, UserConfigurationTypes freefetchDataTypes)
 {
     EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(freefetchDataTypes, "freefetchDataTypes");
     return(this.InternalGetUserConfiguration(this.GetDefaultFolderId(DefaultFolderType.Configuration), new UserConfigurationName(configName, ConfigurationNameKind.Name), freefetchDataTypes));
 }
コード例 #10
0
 IUserConfiguration IUserConfigurationManager.CreateMailboxConfiguration(string configurationName, UserConfigurationTypes dataTypes)
 {
     return(this.CreateMailboxConfiguration(configurationName, dataTypes));
 }
コード例 #11
0
 IUserConfiguration IUserConfigurationManager.GetMailboxConfiguration(string configName, UserConfigurationTypes freefetchDataTypes)
 {
     return(this.GetMailboxConfiguration(configName, freefetchDataTypes));
 }
コード例 #12
0
 public UserConfiguration GetFolderConfiguration(string configName, UserConfigurationTypes freefetchDataTypes, StoreId folderId, StoreObjectId messageId)
 {
     EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(freefetchDataTypes, "freefetchDataTypes");
     return(this.InternalGetUserConfiguration(folderId, new UserConfigurationName(configName, ConfigurationNameKind.Name), freefetchDataTypes, messageId));
 }
コード例 #13
0
 public static UserConfigurationDescriptor CreateFolderDescriptor(string configName, UserConfigurationTypes types, StoreObjectId folderId)
 {
     return(new UserConfigurationDescriptor.FolderIdDescriptor(configName, types, folderId));
 }
コード例 #14
0
 public static UserConfigurationDescriptor CreateDefaultFolderDescriptor(string configName, UserConfigurationTypes types, DefaultFolderType folderType)
 {
     return(new UserConfigurationDescriptor.DefaultFolderDescriptor(configName, types, folderType));
 }
コード例 #15
0
 public FolderIdDescriptor(string configName, UserConfigurationTypes types, StoreObjectId folderId) : base(configName, types)
 {
     this.folderId = folderId;
 }
コード例 #16
0
 public DefaultFolderDescriptor(string configName, UserConfigurationTypes types, DefaultFolderType folderType) : base(configName, types)
 {
     this.folderType = folderType;
 }
コード例 #17
0
 private UserConfigurationDescriptor(string configName, UserConfigurationTypes configurationTypes)
 {
     this.configurationName  = configName;
     this.configurationTypes = configurationTypes;
 }
コード例 #18
0
        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);
        }
コード例 #19
0
        public IReadableUserConfiguration GetReadOnlyFolderConfiguration(string configName, UserConfigurationTypes freefetchDataTypes, StoreId folderId)
        {
            IReadableUserConfiguration result = null;

            if (!this.TryGetAggregatedConfiguration(() => UserConfigurationDescriptor.CreateFolderDescriptor(configName, freefetchDataTypes, StoreId.GetStoreObjectId(folderId)), out result))
            {
                result = this.GetFolderConfiguration(configName, freefetchDataTypes, folderId);
            }
            return(result);
        }
コード例 #20
0
        public UserConfiguration CreateMailboxConfiguration(string configurationName, UserConfigurationTypes dataTypes)
        {
            EnumValidator.ThrowIfInvalid <UserConfigurationTypes>(dataTypes, "dataTypes");
            UserConfiguration result;

            using (Folder folder = Folder.Bind(this.mailboxSession, this.GetDefaultFolderId(DefaultFolderType.Configuration)))
            {
                result = this.InternalCreateUserConfiguration(folder, new UserConfigurationName(configurationName, ConfigurationNameKind.Name), dataTypes);
            }
            return(result);
        }
コード例 #21
0
 IUserConfiguration IUserConfigurationManager.GetFolderConfiguration(string configName, UserConfigurationTypes freefetchDataTypes, StoreId folderId)
 {
     return(this.GetFolderConfiguration(configName, freefetchDataTypes, folderId));
 }
コード例 #22
0
 private UserConfiguration InternalGetUserConfiguration(StoreId folderId, UserConfigurationName configurationName, UserConfigurationTypes freefetchDataType)
 {
     return(this.InternalGetUserConfiguration(folderId, configurationName, freefetchDataType, null));
 }
コード例 #23
0
 IUserConfiguration IUserConfigurationManager.CreateFolderConfiguration(string configurationName, UserConfigurationTypes dataTypes, StoreId folderId)
 {
     return(this.CreateFolderConfiguration(configurationName, dataTypes, folderId));
 }
コード例 #24
0
        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);
        }
コード例 #25
0
 public IUserConfiguration GetConfiguration(MailboxSession mailboxSession, string configName, UserConfigurationTypes freefetchDataTypes)
 {
     return(mailboxSession.UserConfigurationManager.GetMailboxConfiguration(configName, freefetchDataTypes));
 }
コード例 #26
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;
        }
コード例 #27
0
 public IUserConfiguration CreateConfiguration(MailboxSession mailboxSession, string configurationName, UserConfigurationTypes dataType)
 {
     return(mailboxSession.UserConfigurationManager.CreateFolderConfiguration(configurationName, dataType, this.GetDefaultFolderId(mailboxSession)));
 }
コード例 #28
0
 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));
 }
コード例 #29
0
        public IReadableUserConfiguration GetReadOnlyMailboxConfiguration(string configName, UserConfigurationTypes freefetchDataTypes)
        {
            IReadableUserConfiguration result = null;

            if (!this.TryGetAggregatedConfiguration(() => UserConfigurationDescriptor.CreateMailboxDescriptor(configName, freefetchDataTypes), out result))
            {
                result = this.GetMailboxConfiguration(configName, freefetchDataTypes);
            }
            return(result);
        }
コード例 #30
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);
        }