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); } }
public void ClearData() { AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); AllGroupFiltersDictionary.Clear(); ViewSeriesSearch.Refresh(); LastChange = DateTime.MinValue; OnRefreshed(); }
public void ClearData() { AllGroups.Clear(); AllSeries.Clear(); AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); ViewSeriesSearch.Refresh(); }
public AnimeSeriesVM GetSeriesForEpisode(AnimeEpisodeVM ep) { try { return(AllSeriesDictionary.SureGet(ep.AnimeSeriesID)); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(null); }
public void RefreshGroupsSeriesData() { //LoadTestData(); //return; try { // set this to null so that it will be refreshed the next time it is needed AllAnimeDetailedDictionary = null; List <JMMServerBinary.Contract_AnimeGroup> grpsRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroups(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); List <JMMServerBinary.Contract_AnimeSeries> seriesRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (grpsRaw.Count == 0 || seriesRaw.Count == 0) { return; } System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { AllGroups.Clear(); AllSeries.Clear(); AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); // must series before groups the binding is based on the groups, and will refresh when that is changed foreach (JMMServerBinary.Contract_AnimeSeries ser in seriesRaw) { AnimeSeriesVM serNew = new AnimeSeriesVM(ser); AllSeries.Add(serNew); AllSeriesDictionary[serNew.AnimeSeriesID.Value] = serNew; } ViewSeriesSearch.Refresh(); foreach (JMMServerBinary.Contract_AnimeGroup grp in grpsRaw) { AnimeGroupVM grpNew = new AnimeGroupVM(grp); AllGroups.Add(grpNew); AllGroupsDictionary[grpNew.AnimeGroupID.Value] = grpNew; } }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void UpdateGroupAndSeriesForEpisode(VM_AnimeEpisode_User ep) { try { UpdateAll(); VM_AnimeSeries_User ser = AllSeriesDictionary.SureGet(ep.AnimeSeriesID); if (ser != null) { UpdateAboveGroups(ser); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
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); }
public void InitGroupsSeriesData() { //LoadTestData(); //return; try { // set this to null so that it will be refreshed the next time it is needed AllAnimeDetailedDictionary = null; List <JMMServerBinary.Contract_AnimeGroup> grpsRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroups(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); List <JMMServerBinary.Contract_AnimeSeries> seriesRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (grpsRaw.Count == 0 || seriesRaw.Count == 0) { return; } AllGroups.Clear(); AllSeries.Clear(); AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); // must series before groups the binding is based on the groups, and will refresh when that is changed foreach (JMMServerBinary.Contract_AnimeSeries ser in seriesRaw) { AnimeSeriesVM serNew = new AnimeSeriesVM(ser); AllSeries.Add(serNew); AllSeriesDictionary[serNew.AnimeSeriesID.Value] = serNew; } foreach (JMMServerBinary.Contract_AnimeGroup grp in grpsRaw) { AnimeGroupVM grpNew = new AnimeGroupVM(grp); AllGroups.Add(grpNew); AllGroupsDictionary[grpNew.AnimeGroupID.Value] = grpNew; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void UpdateHeirarchy(VideoDetailedVM vid) { try { // get the episodes that this file applies to List <JMMServerBinary.Contract_AnimeEpisode> eps = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesForFile(vid.VideoLocalID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_AnimeEpisode epcontract in eps) { AnimeSeriesVM thisSeries = AllSeriesDictionary.SureGet(epcontract.AnimeSeriesID); // update the episodes if (thisSeries != null && thisSeries.AnimeSeriesID.HasValue && thisSeries.AnimeSeriesID.Value == epcontract.AnimeSeriesID) { foreach (AnimeEpisodeVM ep in thisSeries.AllEpisodes) { if (ep.AnimeEpisodeID == epcontract.AnimeEpisodeID) { ep.Populate(epcontract); // update the attached videos List <JMMServerBinary.Contract_VideoDetailed> contracts = JMMServerVM.Instance.clientBinaryHTTP.GetFilesForEpisode(ep.AnimeEpisodeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_VideoDetailed vidcontract in contracts) { if (vid.VideoLocalID == vidcontract.VideoLocalID) { vid.Populate(vidcontract); break; } } // update all the attached groups UpdateGroupAndSeriesForEpisode(ep); } } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void UpdateHeirarchy(VM_VideoDetailed vid) { try { // get the episodes that this file applies to List <VM_AnimeEpisode_User> eps = VM_ShokoServer.Instance.ShokoServices.GetEpisodesForFile(vid.VideoLocalID, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_AnimeEpisode_User>(); foreach (VM_AnimeEpisode_User epcontract in eps) { VM_AnimeSeries_User thisSeries = AllSeriesDictionary.SureGet(epcontract.AnimeSeriesID); // update the episodes if (thisSeries != null && thisSeries.AnimeSeriesID != 0 && thisSeries.AnimeSeriesID == epcontract.AnimeSeriesID) { foreach (VM_AnimeEpisode_User ep in thisSeries.AllEpisodes) { if (ep.AnimeEpisodeID == epcontract.AnimeEpisodeID) { ep.Populate(epcontract); // update the attached videos IEnumerable <VM_VideoDetailed> vids = VM_ShokoServer.Instance.ShokoServices.GetFilesForEpisode(ep.AnimeEpisodeID, VM_ShokoServer.Instance.CurrentUser.JMMUserID).Cast <VM_VideoDetailed>(); foreach (VM_VideoDetailed vidcontract in vids) { if (vid.VideoLocalID == vidcontract.VideoLocalID) { vid.Populate(vidcontract); break; } } // update all the attached groups UpdateGroupAndSeriesForEpisode(ep); } } } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public AnimeSeriesVM GetSeries(int animeSeriesID) { try { if (AllSeriesDictionary.ContainsKey(animeSeriesID)) { return(AllSeriesDictionary[animeSeriesID]); } else { return(null); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(null); }
public VM_AnimeSeries_User GetSeriesForVideo(int videoLocalID) { try { // get the episodes that this file applies to foreach (CL_AnimeEpisode_User epcontract in VM_ShokoServer.Instance.ShokoServices.GetEpisodesForFile(videoLocalID, VM_ShokoServer.Instance.CurrentUser.JMMUserID)) { VM_AnimeSeries_User thisSeries = AllSeriesDictionary.SureGet(epcontract.AnimeSeriesID); if (thisSeries != null) { return(thisSeries); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(null); }
public AnimeSeriesVM GetSeriesForVideo(int videoLocalID) { try { // get the episodes that this file applies to List <JMMServerBinary.Contract_AnimeEpisode> eps = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesForFile(videoLocalID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_AnimeEpisode epcontract in eps) { AnimeSeriesVM thisSeries = AllSeriesDictionary.SureGet(epcontract.AnimeSeriesID); if (thisSeries != null) { return(thisSeries); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(null); }
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); } }
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); } }
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); } }
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); } }