private void FlushCategoryUsageLog()
 {
     foreach (KeyValuePair <StoreObjectId, MasterCategoryList.PerFolderCategoryUsageLog> keyValuePair in this.categoryUsageLog)
     {
         if (keyValuePair.Key != MasterCategoryList.invalidId && keyValuePair.Value.OutlookModule == null)
         {
             try
             {
                 using (Folder folder = Folder.Bind(this.session, keyValuePair.Key))
                 {
                     keyValuePair.Value.OutlookModule = new OutlookModule?(MasterCategoryList.GetModuleForObjectClass(folder.ClassName));
                 }
             }
             catch (ObjectNotFoundException)
             {
                 keyValuePair.Value.OutlookModule = new OutlookModule?(OutlookModule.None);
             }
         }
     }
     foreach (KeyValuePair <StoreObjectId, MasterCategoryList.PerFolderCategoryUsageLog> keyValuePair2 in this.categoryUsageLog)
     {
         foreach (KeyValuePair <MasterCategoryList.CategoryUsageRecord, ExDateTime> keyValuePair3 in keyValuePair2.Value.CategoryUsageRecords)
         {
             Category category = this[keyValuePair3.Key.CategoryName];
             if (category != null)
             {
                 category.UpdateLastTimeUsed(keyValuePair3.Value, (keyValuePair2.Value.OutlookModule != null && keyValuePair2.Value.OutlookModule != OutlookModule.None) ? keyValuePair2.Value.OutlookModule : new OutlookModule?(keyValuePair3.Key.ModuleForItem));
             }
         }
         keyValuePair2.Value.CategoryUsageRecords.Clear();
     }
 }
        internal void CategoryWasUsed(StoreId itemId, string itemClass, string categoryName)
        {
            if (this.IsLoaded && !this.Contains(categoryName))
            {
                return;
            }
            if (this.categoryUsageLogSize >= 500)
            {
                ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "Category usage log size has reached its maximum of {0} entries. Cannot add this: category=\"{1}\", class=\"{2}\", id=\"{3}\"", new object[]
                {
                    500,
                    categoryName,
                    itemClass,
                    itemId
                });
                return;
            }
            StoreObjectId parentFolderId;

            if (itemId != null)
            {
                StoreObjectId storeObjectId = StoreId.GetStoreObjectId(itemId);
                parentFolderId = this.session.GetParentFolderId(storeObjectId);
            }
            else
            {
                parentFolderId = MasterCategoryList.invalidId;
            }
            MasterCategoryList.PerFolderCategoryUsageLog perFolderCategoryUsageLog;
            if (!this.categoryUsageLog.TryGetValue(parentFolderId, out perFolderCategoryUsageLog))
            {
                perFolderCategoryUsageLog = new MasterCategoryList.PerFolderCategoryUsageLog();
                this.categoryUsageLog.Add(parentFolderId, perFolderCategoryUsageLog);
            }
            MasterCategoryList.CategoryUsageRecord key = new MasterCategoryList.CategoryUsageRecord(categoryName, MasterCategoryList.GetModuleForObjectClass(itemClass));
            perFolderCategoryUsageLog.CategoryUsageRecords[key] = ExDateTime.GetNow(ExTimeZone.UtcTimeZone);
            this.categoryUsageLogSize++;
        }