Beispiel #1
0
        public static void InitCache()
        {
            string t = "AnimeSeries";

            ServerState.Instance.CurrentSetupStatus = string.Format(JMMServer.Properties.Resources.Database_Cache, t, string.Empty);

            AnimeSeriesRepository repo = new AnimeSeriesRepository();

            Cache = new PocoCache <int, AnimeSeries>(repo.InternalGetAll(), a => a.AnimeSeriesID);
            Changes.AddOrUpdateRange(Cache.Keys);
            AniDBIds = Cache.CreateIndex(a => a.AniDB_ID);
            Groups   = Cache.CreateIndex(a => a.AnimeGroupID);
            int cnt = 0;
            List <AnimeSeries> sers =
                Cache.Values.Where(
                    a => a.ContractVersion < AnimeSeries.CONTRACT_VERSION || a.Contract?.AniDBAnime?.AniDBAnime == null)
                .ToList();
            int max = sers.Count;

            foreach (AnimeSeries s in sers)
            {
                repo.Save(s, false, false, true);
                cnt++;
                if (cnt % 10 == 0)
                {
                    ServerState.Instance.CurrentSetupStatus = string.Format(JMMServer.Properties.Resources.Database_Cache, t,
                                                                            " DbRegen - " + cnt + "/" + max);
                }
            }
            ServerState.Instance.CurrentSetupStatus = string.Format(JMMServer.Properties.Resources.Database_Cache, t,
                                                                    " DbRegen - " + max + "/" + max);
        }