void shoutsWorker_DoWork(object sender, DoWorkEventArgs e) { AnimeSeriesVM ser = e.Argument as AnimeSeriesVM; List<Trakt_ShoutUserVM> tempShouts = new List<Trakt_ShoutUserVM>(); try { System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate() { Shouts.Clear(); }); // get shouts from trakt List<JMMServerBinary.Contract_Trakt_ShoutUser> rawShouts = JMMServerVM.Instance.clientBinaryHTTP.GetTraktShoutsForAnime(ser.AniDB_ID); foreach (JMMServerBinary.Contract_Trakt_ShoutUser contract in rawShouts) { Trakt_ShoutUserVM shout = new Trakt_ShoutUserVM(contract); shout.DelayedUserImage = @"/Images/blankposter.png"; System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate() { Shouts.Add(shout); }); imagesToDownload.Add(shout); } // get recommendations from AniDB List<JMMServerBinary.Contract_AniDB_Recommendation> rawRecs = JMMServerVM.Instance.clientBinaryHTTP.GetAniDBRecommendations(ser.AniDB_ID); foreach (JMMServerBinary.Contract_AniDB_Recommendation contract in rawRecs) { AniDB_RecommendationVM rec = new AniDB_RecommendationVM(contract); rec.DelayedUserImage = @"/Images/blankposter.png"; System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate() { Shouts.Add(rec); }); imagesToDownload.Add(rec); } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } }
void refreshDataWorker_DoWork(object sender, DoWorkEventArgs e) { List<Trakt_ShoutUserVM> tempShouts = new List<Trakt_ShoutUserVM>(); try { AnimeSeriesVM animeSeries = (AnimeSeriesVM)e.Argument; if (animeSeries == null) return; List<JMMServerBinary.Contract_Trakt_ShoutUser> rawShouts = JMMServerVM.Instance.clientBinaryHTTP.GetTraktShoutsForAnime(animeSeries.AniDB_ID); foreach (JMMServerBinary.Contract_Trakt_ShoutUser contract in rawShouts) { Trakt_ShoutUserVM shout = new Trakt_ShoutUserVM(contract); if (!string.IsNullOrEmpty(shout.UserFullImagePath) && !File.Exists(shout.UserFullImagePath)) { // re-download the friends avatar image try { ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.Trakt_ShoutUser, shout, false); MainWindow.imageHelper.DownloadImage(req); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } tempShouts.Add(shout); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } e.Result = tempShouts; }