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);
        }
Пример #2
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);
        }
Пример #3
0
 private static bool VerifyAndFixRemindersSearchFolder(DefaultFolderContext context, SearchFolder reminders)
 {
     RemindersSearchFolderValidation.RemindersSearchFolderState remindersSearchFolderState = RemindersSearchFolderValidation.GetRemindersSearchFolderState(context, reminders);
     if (!remindersSearchFolderState.IsUpToDate)
     {
         ExTraceGlobals.DefaultFoldersTracer.TraceDebug <RemindersSearchFolderValidation.RemindersSearchFolderState>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. We are updating reminder's state: {0}", remindersSearchFolderState);
         if (context.Session.LogonType != LogonType.Owner)
         {
             return(false);
         }
         QueryFilter[] array = (remindersSearchFolderState.Version == RemindersSearchFolderValidation.RemindersSearchFolderVersion.O12) ? RemindersSearchFolderValidation.GetO12RemindersSearchFolderExclusionList(reminders.GetSearchCriteria()) : null;
         if (array != null && array.Length > 30)
         {
             string message = "A maximum allowed number of exclusion entries for a Reminders search folder is reached.Either default folders got re-created numerous times or the folder completeness criteria produced false negatives.";
             ExTraceGlobals.DefaultFoldersTracer.TraceError(-1L, message);
             return(true);
         }
         SearchFolderCriteria searchFolderCriteria = RemindersSearchFolderValidation.CreateRemindersQueryForO12(context, array);
         if (array != null)
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <int, int>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Current Reminders search criteria is incomplete: {0} exclusions versus {1} expected", array.Length, RemindersSearchFolderValidation.GetO12RemindersSearchFolderExclusionList(searchFolderCriteria).Length);
         }
         if (remindersSearchFolderState.Version != RemindersSearchFolderValidation.RemindersSearchFolderVersion.O11)
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <RemindersSearchFolderValidation.RemindersSearchFolderState>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Reminder starts to apply new criteria on the folder. folderState = {0}.", remindersSearchFolderState);
             reminders.ApplyContinuousSearch(searchFolderCriteria);
         }
         else
         {
             ExTraceGlobals.DefaultFoldersTracer.TraceDebug <RemindersSearchFolderValidation.RemindersSearchFolderState>(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Outlook12. folderState = {0}.", remindersSearchFolderState);
             IAsyncResult asyncResult = reminders.BeginApplyContinuousSearch(searchFolderCriteria, null, null);
             if (RemindersSearchFolderValidation.InternalWaitForRemindersIndexing(asyncResult))
             {
                 reminders.EndApplyContinuousSearch(asyncResult);
             }
             else
             {
                 ExTraceGlobals.DefaultFoldersTracer.TraceDebug(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. Timeout expired waiting for a Reminders search folder to finish population.");
             }
             RemindersSearchFolderValidation.UnsetStaleReminders(context, reminders);
             UserConfiguration userConfiguration = null;
             try
             {
                 try
                 {
                     userConfiguration = context.Session.UserConfigurationManager.GetFolderConfiguration("Calendar", UserConfigurationTypes.Dictionary, context.Session.GetDefaultFolderId(DefaultFolderType.Calendar));
                 }
                 catch (ObjectNotFoundException)
                 {
                     ExTraceGlobals.DefaultFoldersTracer.TraceDebug(-1L, "RemindersSearchFolderValidation::VerifyAndFixRemindersSearchFolder. No existing Calendar configuration was found. We are creating new one.");
                     userConfiguration = context.Session.UserConfigurationManager.CreateFolderConfiguration("Calendar", UserConfigurationTypes.Dictionary, context.Session.GetDefaultFolderId(DefaultFolderType.Calendar));
                 }
                 IDictionary dictionary = userConfiguration.GetDictionary();
                 dictionary["piReminderUpgradeTime"] = Util.ConvertDateTimeToRTime(ExDateTime.GetNow(context.Session.ExTimeZone));
                 userConfiguration.Save();
             }
             finally
             {
                 if (userConfiguration != null)
                 {
                     userConfiguration.Dispose();
                 }
             }
         }
     }
     return(true);
 }