Exemple #1
0
        public AnimeSeriesVM GetSeries(int animeSeriesID)
        {
            try
            {
                if (AllSeriesDictionary.ContainsKey(animeSeriesID))
                {
                    return(AllSeriesDictionary[animeSeriesID]);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            return(null);
        }
Exemple #2
0
        public void RefreshGroupFiltersOnly()
        {
            //LoadTestData();
            //return;

            try
            {
                // set this to null so that it will be refreshed the next time it is needed
                List <JMMServerBinary.Contract_GroupFilter> gfRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFilters();


                if (gfRaw.Count == 0)
                {
                    return;
                }

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    object p = CurrentWrapper;


                    GroupFilterVM vms = AllGroupFiltersDictionary.Values.Where(a => a.GroupFilterID == 0).FirstOrDefault();
                    AllGroupFiltersDictionary.Clear();
                    if (vms != null)
                    {
                        AllGroupFiltersDictionary.Add(0, vms);
                    }
                    foreach (JMMServerBinary.Contract_GroupFilter gf_con in gfRaw.OrderBy(a => a.GroupFilterName))
                    {
                        GroupFilterVM gf = new GroupFilterVM(gf_con);
                        gf.AllowEditing  = !gf.IsLocked;
                        AllGroupFiltersDictionary[gf.GroupFilterID.Value] = gf;
                    }

                    //Restore previous condition
                    if (p is GroupFilterVM)
                    {
                        int id = ((GroupFilterVM)p).GroupFilterID.Value;
                        if (AllGroupFiltersDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupFiltersDictionary[id];
                        }
                    }
                    else if (p is AnimeGroupVM)
                    {
                        int id = ((AnimeGroupVM)p).AnimeGroupID.Value;
                        if (AllGroupsDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupsDictionary[id];
                        }
                    }
                    else if (p is AnimeSeriesVM)
                    {
                        int id = ((AnimeSeriesVM)p).AnimeSeriesID.Value;
                        if (AllSeriesDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllSeriesDictionary[id];
                        }
                    }
                    OnRefreshed();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        public void RefreshGroupFiltersOnly()
        {
            //LoadTestData();
            //return;

            try
            {
                // set this to null so that it will be refreshed the next time it is needed
                List <VM_GroupFilter> gfRaw = VM_ShokoServer.Instance.ShokoServices.GetAllGroupFilters().CastList <VM_GroupFilter>();


                if (gfRaw.Count == 0)
                {
                    return;
                }

                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate
                {
                    object p = CurrentWrapper;


                    VM_GroupFilter vms = AllGroupFiltersDictionary.Values.FirstOrDefault(a => a.GroupFilterID == 0);
                    AllGroupFiltersDictionary.Clear();
                    if (vms != null)
                    {
                        AllGroupFiltersDictionary.Add(0, vms);
                    }
                    foreach (VM_GroupFilter gf in gfRaw.OrderBy(a => a.GroupFilterName))
                    {
                        AllGroupFiltersDictionary[gf.GroupFilterID] = gf;
                    }

                    //Restore previous condition
                    if (p is VM_GroupFilter)
                    {
                        int id = ((VM_GroupFilter)p).GroupFilterID;
                        if (AllGroupFiltersDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupFiltersDictionary[id];
                        }
                    }
                    else if (p is VM_AnimeGroup_User)
                    {
                        int id = ((VM_AnimeGroup_User)p).AnimeGroupID;
                        if (AllGroupsDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllGroupsDictionary[id];
                        }
                    }
                    else if (p is VM_AnimeSeries_User)
                    {
                        int id = ((VM_AnimeSeries_User)p).AnimeSeriesID;
                        if (AllSeriesDictionary.ContainsKey(id))
                        {
                            CurrentWrapper = AllSeriesDictionary[id];
                        }
                    }
                    OnRefreshed();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }