Beispiel #1
0
 public void ClearData()
 {
     AllGroupsDictionary.Clear();
     AllSeriesDictionary.Clear();
     AllAnimeDictionary.Clear();
     AllGroupFiltersDictionary.Clear();
     ViewSeriesSearch.Refresh();
     LastChange = DateTime.MinValue;
     OnRefreshed();
 }
Beispiel #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);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
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);
            }
        }