예제 #1
0
        public void UpdateAll()
        {
            try
            {
                Contract_MainChanges changes = JMMServerVM.Instance.clientBinaryHTTP.GetAllChanges(LastChange, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
                AllAnimeDetailedDictionary = null;
                //Update Anime Series
                foreach (int sr in changes.Series.RemovedItems)
                {
                    if (AllSeriesDictionary.ContainsKey(sr))
                    {
                        AnimeSeriesVM vm = AllSeriesDictionary[sr];
                        AllSeriesDictionary.Remove(sr);
                    }
                }
                foreach (Contract_AnimeSeries s in changes.Series.ChangedItems)
                {
                    if (AllSeriesDictionary.ContainsKey(s.AnimeSeriesID))
                    {
                        AnimeSeriesVM v = AllSeriesDictionary[s.AnimeSeriesID];
                        v.Populate(s);
                    }
                    else
                    {
                        AnimeSeriesVM v = new AnimeSeriesVM(s);
                        AllSeriesDictionary[s.AnimeSeriesID] = v;
                    }
                }
                //Update Anime Groups
                foreach (int gr in changes.Groups.RemovedItems)
                {
                    if (AllGroupsDictionary.ContainsKey(gr))
                    {
                        AnimeGroupVM vm = AllGroupsDictionary[gr];
                        AllGroupsDictionary.Remove(gr);
                    }
                }
                foreach (Contract_AnimeGroup g in changes.Groups.ChangedItems)
                {
                    AnimeGroupVM v;
                    if (AllGroupsDictionary.ContainsKey(g.AnimeGroupID))
                    {
                        v = AllGroupsDictionary[g.AnimeGroupID];
                        v.Populate(g);
                    }
                    else
                    {
                        v = new AnimeGroupVM(g);
                        AllGroupsDictionary[g.AnimeGroupID] = v;
                    }
                }
                foreach (AnimeGroupVM v in AllGroupsDictionary.Values)
                {
                    v.PopulateSerieInfo(AllGroupsDictionary, AllSeriesDictionary);
                }

                //Update Group Filters
                foreach (int gfr in changes.Filters.RemovedItems)
                {
                    if (AllGroupFiltersDictionary.ContainsKey(gfr))
                    {
                        GroupFilterVM vm = AllGroupFiltersDictionary[gfr];
                        AllGroupFiltersDictionary.Remove(gfr);
                    }
                }
                foreach (Contract_GroupFilter gf in changes.Filters.ChangedItems)
                {
                    if (AllGroupFiltersDictionary.ContainsKey(gf.GroupFilterID.Value))
                    {
                        GroupFilterVM v = AllGroupFiltersDictionary[gf.GroupFilterID.Value];
                        v.Populate(gf);
                    }
                    else
                    {
                        GroupFilterVM v = new GroupFilterVM(gf);
                        AllGroupFiltersDictionary[gf.GroupFilterID.Value] = v;
                    }
                }

                foreach (int gf in changes.Filters.ChangedItems.Select(a => a.GroupFilterID.Value))
                {
                    GroupFilterVM v = AllGroupFiltersDictionary[gf];
                    //Recalculate Groups Count
                    v.GetDirectChildren();
                }
                LastChange = changes.LastChange;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
예제 #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);
            }
        }