void btnSearch_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtSearch.Text)) return; int animeID = 0; if (!int.TryParse(txtSearch.Text, out animeID)) return; SearchCriteria crit = new SearchCriteria(); crit.AnimeID = animeID; crit.ExtraInfo = string.Empty; if (tabResults.SelectedIndex == 0) PerformTvDBSearch(crit); else if (tabResults.SelectedIndex == 1) PerformTraktSearch(crit); }
public void PerformTvDBSearch(SearchCriteria crit) { if (!JMMServerVM.Instance.ServerOnline) return; this.Cursor = Cursors.Wait; SearchStatus = string.Format(Properties.Resources.Community_Searching); txtSearch.Text = crit.AnimeID.ToString(); try { TVDBResults.Clear(); btnRandomAnime.IsEnabled = false; btnSearch.IsEnabled = false; this.Cursor = Cursors.Wait; searchTvDBWorker.RunWorkerAsync(crit); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void btnRandomAnime_Click(object sender, RoutedEventArgs e) { if (!JMMServerVM.Instance.ServerOnline) return; SearchStatus = Properties.Resources.Community_Searching; btnRandomAnime.IsEnabled = false; btnSearch.IsEnabled = false; this.Cursor = Cursors.Wait; try { if (tabResults.SelectedIndex == 0) { TVDBResults.Clear(); JMMServerBinary.Contract_Azure_AnimeLink contract = JMMServerVM.Instance.clientBinaryHTTP.Admin_GetRandomLinkForApproval((int)AzureLinkType.TvDB); if (contract != null) { AzureAnimeLink link = new AzureAnimeLink(contract); SearchCriteria crit = new SearchCriteria(); crit.AnimeID = link.RandomAnimeID; crit.ExtraInfo = string.Format(Properties.Resources.Community_TvDBApproval, link.AnimeNeedingApproval); PerformTvDBSearch(crit); } } else if (tabResults.SelectedIndex == 1) { TraktResults.Clear(); JMMServerBinary.Contract_Azure_AnimeLink contract = JMMServerVM.Instance.clientBinaryHTTP.Admin_GetRandomLinkForApproval((int)AzureLinkType.Trakt); if (contract != null) { AzureAnimeLink link = new AzureAnimeLink(contract); SearchCriteria crit = new SearchCriteria(); crit.AnimeID = link.RandomAnimeID; crit.ExtraInfo = string.Format(Properties.Resources.Community_TraktApproval, link.AnimeNeedingApproval); PerformTraktSearch(crit); } } } catch (Exception ex) { this.Cursor = Cursors.Arrow; btnRandomAnime.IsEnabled = true; btnSearch.IsEnabled = true; Utils.ShowErrorMessage(ex); } }
public void ShowWebCacheAdmin(AniDB_AnimeVM anime) { try { SearchCriteria crit = new SearchCriteria(); crit = new SearchCriteria(); crit.ExtraInfo = string.Empty; crit.AnimeID = anime.AnimeID; tabControl1.SelectedIndex = TAB_MAIN_Community; tabcCommunity.SelectedIndex = 0; ucComLinks.PerformTvDBSearch(crit); ucComLinks.PerformTraktSearch(crit); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void CommandBinding_ShowWebCacheAdmin(object sender, ExecutedRoutedEventArgs e) { object obj = e.Parameter; if (obj == null) return; try { SearchCriteria crit = null; if (obj.GetType() == typeof(AniDB_AnimeVM)) { AniDB_AnimeVM anime = (AniDB_AnimeVM)obj; crit = new SearchCriteria(); crit.ExtraInfo = string.Empty; crit.AnimeID = anime.AnimeID; } if (crit != null) { tabControl1.SelectedIndex = TAB_MAIN_Community; tabcCommunity.SelectedIndex = 0; ucComLinks.PerformTvDBSearch(crit); ucComLinks.PerformTraktSearch(crit); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
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; } }
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; } }
public void PerformTraktSearch(SearchCriteria crit) { if (!JMMServerVM.Instance.ServerOnline) return; this.Cursor = Cursors.Wait; SearchStatus = string.Format("Searching..."); try { TraktResults.Clear(); btnRandomAnime.IsEnabled = false; btnSearch.IsEnabled = false; this.Cursor = Cursors.Wait; searchTraktWorker.RunWorkerAsync(crit); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }