void searchTvDBWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            SearchTvDBResults res = new SearchTvDBResults();
            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;
            }
        }
		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;
		}
Example #3
0
		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);
				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 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;
            }
        }