Exemple #1
0
        internal void Build(DataManager data)
        {
            ChangeNumber = data.CurrentEntryChangeCount;
            Dictionary <string, CategoryCacheEntry> build = new Dictionary <string, CategoryCacheEntry>();
            CategoryCacheEntry categoryCacheEntry;

            foreach (DayEntry day in data.Days)
            {
                day.Load(data);

                foreach (Entry entry in day.Entries)
                {
                    foreach (string cat in entry.GetSplitCategories())
                    {
                        if (!build.ContainsKey(cat))
                        {
                            categoryCacheEntry              = new CategoryCacheEntry();
                            categoryCacheEntry.Name         = cat;
                            categoryCacheEntry.EntryDetails = new CategoryCacheEntryDetailCollection();
                            build[cat] = categoryCacheEntry;
                            if (!_urlSafeCategories.ContainsKey(HttpHelper.GetURLSafeString(cat)))
                            {
                                _urlSafeCategories.Add(HttpHelper.GetURLSafeString(cat), cat);
                            }
                        }
                        else
                        {
                            categoryCacheEntry = build[cat];
                        }
                        CategoryCacheEntryDetail entryDetail = new CategoryCacheEntryDetail();
                        entryDetail.DayDateUtc = day.DateUtc;
                        entryDetail.EntryId    = entry.EntryId;

                        // If we have not yet found a public entry but the
                        // current entry is public then
                        if (!categoryCacheEntry.IsPublic && entry.IsPublic)
                        {
                            categoryCacheEntry.IsPublic = true;
                        }

                        categoryCacheEntry.EntryDetails.Add(entryDetail);
                    }
                }
            }

            _entries.Clear();
            foreach (KeyValuePair <string, CategoryCacheEntry> de in build)
            {
                _entries.Add(de.Value);
            }

            _entries.Sort(new CategorySorter());
        }