示例#1
0
 private void UpdateGroupAndSeriesForEpisode(AnimeEpisodeVM ep)
 {
     try
     {
         // update the attached series
         JMMServerBinary.Contract_AnimeSeries serContract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(ep.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
         AnimeSeriesVM ser = AllSeriesDictionary.SureGet(serContract.AnimeSeriesID);
         if (ser != null)
         {
             ser.Populate(serContract);
             // TODO update the episode list
         }
         List <JMMServerBinary.Contract_AnimeGroup> grps = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupsAboveSeries(ep.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
         foreach (JMMServerBinary.Contract_AnimeGroup grpContract in grps)
         {
             AnimeGroupVM agrp = AllGroupsDictionary.SureGet(grpContract.AnimeGroupID);
             agrp?.Populate(grpContract);
             agrp?.PopulateSerieInfo(AllGroupsDictionary, AllSeriesDictionary);
         }
     }
     catch (Exception ex)
     {
         Utils.ShowErrorMessage(ex);
     }
 }
示例#2
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);
            }
        }