private void CommandBinding_Revoke(object sender, ExecutedRoutedEventArgs e) { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(CrossRef_AniDB_TvDBVMV2)) { CrossRef_AniDB_TvDBVMV2 xref = obj as CrossRef_AniDB_TvDBVMV2; string res = JMMServerVM.Instance.clientBinaryHTTP.RevokeTVDBCrossRefWebCache(xref.CrossRef_AniDB_TvDBV2ID); if (string.IsNullOrEmpty(res)) { xref.IsAdminApproved = 0; } else { MessageBox.Show(res, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void PopulateSeasons(CrossRef_AniDB_TvDBVMV2 xref) { cboSeason.SelectionChanged -= new SelectionChangedEventHandler(cboSeason_SelectionChanged); SeasonNumbers.Clear(); cboSeason.Items.Clear(); TvDetails = null; if (Anime.TvSummary.TvDetails.ContainsKey(xref.TvDBID)) { TvDetails = Anime.TvSummary.TvDetails[xref.TvDBID]; } if (TvDetails == null) { return; } foreach (int season in TvDetails.DictTvDBSeasons.Keys) { cboSeason.Items.Add(season); } cboSeason.SelectionChanged += new SelectionChangedEventHandler(cboSeason_SelectionChanged); if (cboSeason.Items.Count > 0) { cboSeason.SelectedIndex = 0; } }
private void CommandBinding_ReportTvDBLink(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(CrossRef_AniDB_TvDBVMV2)) { CrossRef_AniDB_TvDBVMV2 link = obj as CrossRef_AniDB_TvDBVMV2; AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM; if (anime == null) { return; } this.Cursor = Cursors.Wait; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
private void CommandBinding_DeleteTvDBLink(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(CrossRef_AniDB_TvDBVMV2)) { CrossRef_AniDB_TvDBVMV2 link = obj as CrossRef_AniDB_TvDBVMV2; AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM; if (anime == null) { return; } this.Cursor = Cursors.Wait; Window wdw = Window.GetWindow(this); string msg = string.Format("Are you sure you want to delete this link?"); MessageBoxResult result = MessageBox.Show(msg, "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { this.Cursor = Cursors.Wait; string res = JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBTvDB(link.AnimeID, link.AniDBStartEpisodeType, link.AniDBStartEpisodeNumber, link.TvDBID, link.TvDBSeasonNumber, link.TvDBStartEpisodeNumber); if (res.Length > 0) { MessageBox.Show(res, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { // update info RefreshData(); } this.Cursor = Cursors.Arrow; } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
void dgTvDBResults_SelectionChanged(object sender, SelectionChangedEventArgs e) { e.Handled = true; CrossRef_AniDB_TvDBVMV2 xref = ((DataGrid)sender).SelectedItem as CrossRef_AniDB_TvDBVMV2; if (xref == null) { return; } webAniDB.Navigate(xref.AniDBURL); webOther.Navigate(xref.SeriesURL); }
private void CommandBinding_EditTvDBLink(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(CrossRef_AniDB_TvDBVMV2)) { CrossRef_AniDB_TvDBVMV2 link = obj as CrossRef_AniDB_TvDBVMV2; AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM; if (anime == null) { return; } Window wdw = Window.GetWindow(this); this.Cursor = Cursors.Wait; SelectTvDBSeasonForm frm = new SelectTvDBSeasonForm(); frm.Owner = wdw; //TODO frm.Init(anime.AnimeID, anime.FormattedTitle, (EpisodeType)link.AniDBStartEpisodeType, link.AniDBStartEpisodeNumber, link.TvDBID, link.TvDBSeasonNumber, link.TvDBStartEpisodeNumber, link.TvDBTitle, anime, link.CrossRef_AniDB_TvDBV2ID); bool?result = frm.ShowDialog(); if (result.Value) { // update info RefreshData(); } } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
void btnSearch_Click(object sender, RoutedEventArgs e) { HasWebCacheRec = false; if (!JMMServerVM.Instance.ServerOnline) { return; } this.Cursor = Cursors.Wait; try { CrossRef_AniDB_TvDBResult.Clear(); // first find what the community recommends List <JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB> xrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTVDBCrossRefWebCache(AnimeID, false); if (xrefs != null && xrefs.Count > 0) { foreach (JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB xref in xrefs) { CrossRef_AniDB_TvDBVMV2 xrefAzure = new CrossRef_AniDB_TvDBVMV2(xref); CrossRef_AniDB_TvDBResult.Add(xrefAzure); } HasWebCacheRec = true; } // now search the TvDB TVDBSeriesSearchResults = new List <TVDBSeriesSearchResultVM>(); List <JMMServerBinary.Contract_TVDBSeriesSearchResult> tvResults = JMMServerVM.Instance.clientBinaryHTTP.SearchTheTvDB(txtSearch.Text.Trim()); foreach (JMMServerBinary.Contract_TVDBSeriesSearchResult tvResult in tvResults) { TVDBSeriesSearchResults.Add(new TVDBSeriesSearchResultVM(tvResult)); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
void searchWorker_DoWork(object sender, DoWorkEventArgs e) { SearchResults res = new SearchResults(); res.ErrorMessage = string.Empty; res.TvDBLinks = new List <CrossRef_AniDB_TvDBVMV2>(); res.ExtraInfo = string.Empty; try { SearchCriteria crit = e.Argument as SearchCriteria; if (!string.IsNullOrEmpty(crit.ExtraInfo)) { res.ExtraInfo = crit.ExtraInfo; } try { List <JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB> xrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTVDBCrossRefWebCache(crit.AnimeID, true); if (xrefs != null && xrefs.Count > 0) { foreach (JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB xref in xrefs) { CrossRef_AniDB_TvDBVMV2 xrefAzure = new CrossRef_AniDB_TvDBVMV2(xref); res.TvDBLinks.Add(xrefAzure); } } } catch (Exception ex) { res.ErrorMessage = ex.Message; } e.Result = res; } catch (Exception ex) { res.ErrorMessage = ex.Message; e.Result = res; } }
void cboSeries_SelectionChanged(object sender, SelectionChangedEventArgs e) { CrossRef_AniDB_TvDBVMV2 xref = cboSeries.SelectedItem as CrossRef_AniDB_TvDBVMV2; PopulateSeasons(xref); }
/// <summary> /// Set the Episode image and overview, also over-write the episode name if user has selected this /// </summary> /// <param name="dictTvDBEpisodes"></param> /// <param name="dictTvDBSeasons"></param> /// <param name="dictTvDBSeasonsSpecials"></param> /// <param name="tvDBCrossRef"></param> public void SetTvDBInfo(TvDBSummary tvSummary) { TvDBLinkExists = false; TvDBLinkMissing = true; #region episode override // check if this episode has a direct tvdb over-ride if (tvSummary.DictTvDBCrossRefEpisodes.ContainsKey(AniDB_EpisodeID)) { foreach (TvDB_EpisodeVM tvep in tvSummary.DictTvDBEpisodes.Values) { if (tvSummary.DictTvDBCrossRefEpisodes[AniDB_EpisodeID] == tvep.Id) { if (string.IsNullOrEmpty(tvep.Overview)) { this.EpisodeOverviewLoading = "Episode Overview Not Available"; } else { this.EpisodeOverviewLoading = tvep.Overview; } if (string.IsNullOrEmpty(tvep.FullImagePathPlain) || !File.Exists(tvep.FullImagePath)) { this.EpisodeImageLoading = @"/Images/EpisodeThumb_NotFound.png"; // if there is no proper image to show, we will hide it on the dashboard ShowEpisodeImageInDashboard = false; } else { this.EpisodeImageLoading = tvep.FullImagePath; } if (JMMServerVM.Instance.EpisodeTitleSource == DataSourceType.TheTvDB && !string.IsNullOrEmpty(tvep.EpisodeName)) { EpisodeName = tvep.EpisodeName; } TvDBLinkExists = true; TvDBLinkMissing = false; return; } } } #endregion //logger.Trace("SetTvDBInfo: normal episodes start"); #region normal episodes // now do stuff to improve performance if (this.EpisodeTypeEnum == JMMClient.EpisodeType.Episode) { if (tvSummary != null && tvSummary.CrossRefTvDBV2 != null && tvSummary.CrossRefTvDBV2.Count > 0) { //logger.Trace("SetTvDBInfo: sorting TvDB cross refs: {0} records", tvSummary.CrossRefTvDBV2.Count); // find the xref that is right // relies on the xref's being sorted by season number and then episode number (desc) List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("AniDBStartEpisodeNumber", true, JMMClient.SortType.eInteger)); List <CrossRef_AniDB_TvDBVMV2> tvDBCrossRef = Sorting.MultiSort <CrossRef_AniDB_TvDBVMV2>(tvSummary.CrossRefTvDBV2, sortCriteria); //logger.Trace("SetTvDBInfo: looking for starting points"); bool foundStartingPoint = false; CrossRef_AniDB_TvDBVMV2 xrefBase = null; foreach (CrossRef_AniDB_TvDBVMV2 xrefTV in tvDBCrossRef) { if (xrefTV.AniDBStartEpisodeType != (int)JMMClient.EpisodeType.Episode) { continue; } if (this.EpisodeNumber >= xrefTV.AniDBStartEpisodeNumber) { foundStartingPoint = true; xrefBase = xrefTV; break; } } //logger.Trace("SetTvDBInfo: looking for starting points - done"); // we have found the starting epiosde numbder from AniDB // now let's check that the TvDB Season and Episode Number exist if (foundStartingPoint) { //logger.Trace("SetTvDBInfo: creating dictionary"); Dictionary <int, int> dictTvDBSeasons = null; Dictionary <int, TvDB_EpisodeVM> dictTvDBEpisodes = null; foreach (TvDBDetails det in tvSummary.TvDetails.Values) { if (det.TvDBID == xrefBase.TvDBID) { dictTvDBSeasons = det.DictTvDBSeasons; dictTvDBEpisodes = det.DictTvDBEpisodes; break; } } //logger.Trace("SetTvDBInfo: creating dictionary - done"); if (dictTvDBSeasons.ContainsKey(xrefBase.TvDBSeasonNumber)) { int episodeNumber = dictTvDBSeasons[xrefBase.TvDBSeasonNumber] + (this.EpisodeNumber + xrefBase.TvDBStartEpisodeNumber - 2) - (xrefBase.AniDBStartEpisodeNumber - 1); if (dictTvDBEpisodes.ContainsKey(episodeNumber)) { //logger.Trace("SetTvDBInfo: loading episode overview"); TvDB_EpisodeVM tvep = dictTvDBEpisodes[episodeNumber]; if (string.IsNullOrEmpty(tvep.Overview)) { this.EpisodeOverviewLoading = "Episode Overview Not Available"; } else { this.EpisodeOverviewLoading = tvep.Overview; } //logger.Trace("SetTvDBInfo: loading episode overview - done"); if (string.IsNullOrEmpty(tvep.FullImagePathPlain) || !File.Exists(tvep.FullImagePath)) { this.EpisodeImageLoading = @"/Images/EpisodeThumb_NotFound.png"; // if there is no proper image to show, we will hide it on the dashboard ShowEpisodeImageInDashboard = false; } else { this.EpisodeImageLoading = tvep.FullImagePath; } //logger.Trace("SetTvDBInfo: episode image - done"); if (JMMServerVM.Instance.EpisodeTitleSource == DataSourceType.TheTvDB && !string.IsNullOrEmpty(tvep.EpisodeName)) { EpisodeName = tvep.EpisodeName; } } } } } } #endregion //logger.Trace("SetTvDBInfo: normal episodes finish"); #region special episodes if (this.EpisodeTypeEnum == JMMClient.EpisodeType.Special) { // find the xref that is right // relies on the xref's being sorted by season number and then episode number (desc) List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("AniDBStartEpisodeNumber", true, JMMClient.SortType.eInteger)); List <CrossRef_AniDB_TvDBVMV2> tvDBCrossRef = Sorting.MultiSort <CrossRef_AniDB_TvDBVMV2>(tvSummary.CrossRefTvDBV2, sortCriteria); bool foundStartingPoint = false; CrossRef_AniDB_TvDBVMV2 xrefBase = null; foreach (CrossRef_AniDB_TvDBVMV2 xrefTV in tvDBCrossRef) { if (xrefTV.AniDBStartEpisodeType != (int)JMMClient.EpisodeType.Special) { continue; } if (this.EpisodeNumber >= xrefTV.AniDBStartEpisodeNumber) { foundStartingPoint = true; xrefBase = xrefTV; break; } } if (tvSummary != null && tvSummary.CrossRefTvDBV2 != null && tvSummary.CrossRefTvDBV2.Count > 0) { // we have found the starting epiosde numbder from AniDB // now let's check that the TvDB Season and Episode Number exist if (foundStartingPoint) { Dictionary <int, int> dictTvDBSeasons = null; Dictionary <int, TvDB_EpisodeVM> dictTvDBEpisodes = null; foreach (TvDBDetails det in tvSummary.TvDetails.Values) { if (det.TvDBID == xrefBase.TvDBID) { dictTvDBSeasons = det.DictTvDBSeasons; dictTvDBEpisodes = det.DictTvDBEpisodes; break; } } if (dictTvDBSeasons.ContainsKey(xrefBase.TvDBSeasonNumber)) { int episodeNumber = dictTvDBSeasons[xrefBase.TvDBSeasonNumber] + (this.EpisodeNumber + xrefBase.TvDBStartEpisodeNumber - 2) - (xrefBase.AniDBStartEpisodeNumber - 1); if (dictTvDBEpisodes.ContainsKey(episodeNumber)) { TvDB_EpisodeVM tvep = dictTvDBEpisodes[episodeNumber]; this.EpisodeOverviewLoading = tvep.Overview; if (string.IsNullOrEmpty(tvep.FullImagePathPlain) || !File.Exists(tvep.FullImagePath)) { this.EpisodeImageLoading = @"/Images/EpisodeThumb_NotFound.png"; // if there is no proper image to show, we will hide it on the dashboard ShowEpisodeImageInDashboard = false; } else { this.EpisodeImageLoading = tvep.FullImagePath; } if (JMMServerVM.Instance.EpisodeTitleSource == DataSourceType.TheTvDB && !string.IsNullOrEmpty(tvep.EpisodeName)) { EpisodeName = tvep.EpisodeName; } } } } } } #endregion }
void communityWorker_DoWork(object sender, DoWorkEventArgs e) { SearchCommunityResults res = new SearchCommunityResults(); res.ErrorMessage = string.Empty; res.TvDBLinks = new List <CrossRef_AniDB_TvDBVMV2>(); res.TraktLinks = new List <CrossRef_AniDB_TraktVMV2>(); res.ExtraInfo = string.Empty; res.AnimeID = -1; try { AniDB_AnimeVM anime = e.Argument as AniDB_AnimeVM; if (anime == null) { return; } res.AnimeID = anime.AnimeID; SearchCriteria crit = new SearchCriteria(); crit.AnimeID = anime.AnimeID; crit.ExtraInfo = string.Empty; // search for TvDB links try { List <JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB> xrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTVDBCrossRefWebCache(crit.AnimeID, true); if (xrefs != null && xrefs.Count > 0) { foreach (JMMServerBinary.Contract_Azure_CrossRef_AniDB_TvDB xref in xrefs) { CrossRef_AniDB_TvDBVMV2 xrefAzure = new CrossRef_AniDB_TvDBVMV2(xref); res.TvDBLinks.Add(xrefAzure); } } } catch (Exception ex) { res.ErrorMessage = ex.Message; } // search for Trakt links try { List <JMMServerBinary.Contract_Azure_CrossRef_AniDB_Trakt> xrefs = JMMServerVM.Instance.clientBinaryHTTP.GetTraktCrossRefWebCache(crit.AnimeID, true); if (xrefs != null && xrefs.Count > 0) { foreach (JMMServerBinary.Contract_Azure_CrossRef_AniDB_Trakt xref in xrefs) { CrossRef_AniDB_TraktVMV2 xrefAzure = new CrossRef_AniDB_TraktVMV2(xref); res.TraktLinks.Add(xrefAzure); } } } catch (Exception ex) { res.ErrorMessage = ex.Message; } e.Result = res; } catch (Exception ex) { res.ErrorMessage = ex.Message; e.Result = res; } }