void searchWorker_DoWork(object sender, DoWorkEventArgs e) { App.Current.Dispatcher.BeginInvoke((Action) delegate { this.SearchResults.Clear(); }); List <Content> results; switch (this.Content.ContentType) { case ContentType.Movie: MovieDatabaseSelection movieDbSel = (MovieDatabaseSelection)this.SelectedSearchDatabaseIndex; results = MovieDatabaseHelper.PerformMovieSearch(movieDbSel, this.SearchString, true); break; case ContentType.TvShow: TvDataBaseSelection tvDbSel = (TvDataBaseSelection)this.SelectedSearchDatabaseIndex; results = TvDatabaseHelper.PerformTvShowSearch(tvDbSel, this.SearchString, true); break; default: throw new Exception("Unknown content type"); } if (results != null) { App.Current.Dispatcher.BeginInvoke((Action) delegate { foreach (Content result in results) { this.SearchResults.Add(result); } }); } }
/// <summary> /// Get private database to use from selection /// </summary> /// <param name="selection">Database selection</param> /// <returns></returns> private static TvDatabaseAccess GetDataBaseAccess(TvDataBaseSelection selection) { switch (selection) { case TvDataBaseSelection.TheTvDb: return TheTvDbAccess; case TvDataBaseSelection.TvRage: return TvRageAccess; default: throw new Exception("Unknown database selection"); } }
/// <summary> /// Get private database to use from selection /// </summary> /// <param name="selection">Database selection</param> /// <returns></returns> private static TvDatabaseAccess GetDataBaseAccess(TvDataBaseSelection selection) { switch (selection) { case TvDataBaseSelection.TheTvDb: return(TheTvDbAccess); case TvDataBaseSelection.TvRage: return(TvRageAccess); default: throw new Exception("Unknown database selection"); } }
/// <summary> /// Performs search for a show in database. /// </summary> /// <param name="searchString">The string to search for</param> /// <returns>Array of results from the search</returns> public static List<Content> PerformTvShowSearch(TvDataBaseSelection selection, string searchString, bool includeSummaries) { return GetDataBaseAccess(selection).PerformSearch(searchString, includeSummaries); }
/// <summary> /// Gets database server's time /// </summary> /// <param name="time">retrieved server time</param> /// <returns>whether time was successfully retrieved</returns> public static bool GetServerTime(TvDataBaseSelection selection, out string time) { return GetDataBaseAccess(selection).GetServerTime(out time); }
/// <summary> /// Return lists of series Ids that need updating. /// </summary> /// <param name="info"></param> /// <returns></returns> public static bool GetDataToBeUpdated(TvDataBaseSelection selection, out List<int> info, out string time) { return GetDataBaseAccess(selection).GetDataToBeUpdated(out info, out time); }
/// <summary> /// Performs search for a show in database. /// </summary> /// <param name="searchString">The string to search for</param> /// <returns>Array of results from the search</returns> public static List <Content> PerformTvShowSearch(TvDataBaseSelection selection, string searchString, bool includeSummaries) { return(GetDataBaseAccess(selection).PerformSearch(searchString, includeSummaries)); }
/// <summary> /// Return lists of series Ids that need updating. /// </summary> /// <param name="info"></param> /// <returns></returns> public static bool GetDataToBeUpdated(TvDataBaseSelection selection, out List <int> info, out string time) { return(GetDataBaseAccess(selection).GetDataToBeUpdated(out info, out time)); }
/// <summary> /// Gets database server's time /// </summary> /// <param name="time">retrieved server time</param> /// <returns>whether time was successfully retrieved</returns> public static bool GetServerTime(TvDataBaseSelection selection, out string time) { return(GetDataBaseAccess(selection).GetServerTime(out time)); }