Esempio n. 1
0
        public VM_AnimeSeries_User GetSeries(int animeSeriesID)
        {
            try
            {
                VM_AnimeSeries_User vm;

                AllSeriesDictionary.TryGetValue(animeSeriesID, out vm);

                return(vm);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            return(null);
        }
Esempio n. 2
0
        public void UpdateAll()
        {
            try
            {
                CL_MainChanges changes = VM_ShokoServer.Instance.ShokoServices.GetAllChanges(LastChange, VM_ShokoServer.Instance.CurrentUser.JMMUserID);
                AllAnimeDetailedDictionary = null;

                //Update Anime Groups (Must be done before Series)
                foreach (int gr in changes.Groups.RemovedItems)
                {
                    AllGroupsDictionary.Remove(gr);
                }

                foreach (VM_AnimeGroup_User g in changes.Groups.ChangedItems.CastList <VM_AnimeGroup_User>())
                {
                    VM_AnimeGroup_User v;

                    if (AllGroupsDictionary.TryGetValue(g.AnimeGroupID, out v))
                    {
                        v.Populate(g);
                    }
                    else
                    {
                        AllGroupsDictionary[g.AnimeGroupID] = g;
                    }
                }

                //Update Anime Series (NOTE: relies on AllGroupsDictionary being up to date)
                foreach (int sr in changes.Series.RemovedItems)
                {
                    AllSeriesDictionary.Remove(sr);
                }

                foreach (VM_AnimeSeries_User s in changes.Series.ChangedItems.CastList <VM_AnimeSeries_User>())
                {
                    VM_AnimeSeries_User v;

                    if (AllSeriesDictionary.TryGetValue(s.AnimeSeriesID, out v))
                    {
                        v.Populate(s);
                    }
                    else
                    {
                        AllSeriesDictionary[s.AnimeSeriesID] = s;
                    }
                }

                foreach (VM_AnimeGroup_User v in AllGroupsDictionary.Values)
                {
                    v.PopulateSerieInfo(AllGroupsDictionary, AllSeriesDictionary);
                }

                //Update Group Filters
                foreach (int gfr in changes.Filters.RemovedItems)
                {
                    AllGroupFiltersDictionary.Remove(gfr);
                }

                foreach (VM_GroupFilter gf in changes.Filters.ChangedItems.CastList <VM_GroupFilter>())
                {
                    VM_GroupFilter v;

                    if (AllGroupFiltersDictionary.TryGetValue(gf.GroupFilterID, out v))
                    {
                        v.Populate(gf);
                    }
                    else
                    {
                        AllGroupFiltersDictionary[gf.GroupFilterID] = gf;
                    }
                }

                foreach (int gf in changes.Filters.ChangedItems.Select(a => a.GroupFilterID))
                {
                    VM_GroupFilter v = AllGroupFiltersDictionary[gf];
                    //Recalculate Groups Count
                    v.GetDirectChildren();
                }
                LastChange = changes.LastChange;

                GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                GC.Collect();
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }