Esempio n. 1
0
        void episodesWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                AnimeSeriesVM ser = e.Argument as AnimeSeriesVM;

                List <JMMServerBinary.Contract_AnimeEpisode> rawEps = JMMServerVM.Instance.clientBinaryHTTP.GetAllUnwatchedEpisodes(ser.AnimeSeriesID.Value,
                                                                                                                                    JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                int i = 0;
                foreach (JMMServerBinary.Contract_AnimeEpisode raw in rawEps)
                {
                    i++;
                    AnimeEpisodeVM ep = new AnimeEpisodeVM(raw);
                    ep.SetTvDBInfo();
                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        UnwatchedEpisodes.Add(ep);
                    });

                    if (i == 10)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
        void episodesWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                AnimeSeriesVM ser = e.Argument as AnimeSeriesVM;

                List <JMMServerBinary.Contract_AnimeEpisode> rawEps = JMMServerVM.Instance.clientBinaryHTTP.GetAllUnwatchedEpisodes(ser.AnimeSeriesID.Value,
                                                                                                                                    JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                // find the last watched episode
                JMMServerBinary.Contract_AnimeEpisode rawLastEp = JMMServerVM.Instance.clientBinaryHTTP.GetLastWatchedEpisodeForSeries(ser.AnimeSeriesID.Value,
                                                                                                                                       JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                if (rawLastEp != null)
                {
                    AnimeEpisodeDisplayVM ep = new AnimeEpisodeDisplayVM(rawLastEp);
                    ep.SetTvDBInfo();
                    //if (JMMServerVM.Instance.Trakt_IsEnabled)
                    //    ep.SetTraktInfo();
                    ep.EpisodeOrder = 0;
                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        UnwatchedEpisodes.Add(ep);
                    });
                }

                int i = 0;
                foreach (JMMServerBinary.Contract_AnimeEpisode raw in rawEps)
                {
                    i++;
                    AnimeEpisodeDisplayVM ep = new AnimeEpisodeDisplayVM(raw);
                    ep.SetTvDBInfo();
                    //if (i == 1 && JMMServerVM.Instance.Trakt_IsEnabled) ep.SetTraktInfo();
                    ep.EpisodeOrder = i;
                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        UnwatchedEpisodes.Add(ep);
                    });

                    if (i == 5)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
        void episodesWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                VM_AnimeSeries_User ser = e.Argument as VM_AnimeSeries_User;

                List <VM_AnimeEpisode_User> rawEps = VM_ShokoServer.Instance.ShokoServices.GetAllUnwatchedEpisodes(ser.AnimeSeriesID,
                                                                                                                   VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_AnimeEpisode_User>();

                // find the last watched episode
                VM_AnimeEpisode_User rawLastEp = (VM_AnimeEpisode_User)VM_ShokoServer.Instance.ShokoServices.GetLastWatchedEpisodeForSeries(ser.AnimeSeriesID,
                                                                                                                                            VM_ShokoServer.Instance.CurrentUser.JMMUserID);

                if (rawLastEp != null)
                {
                    rawLastEp.SetTvDBInfo();
                    //if (VM_ShokoServer.Instance.Trakt_IsEnabled)
                    //    ep.SetTraktInfo();
                    rawLastEp.EpisodeOrder = 0;
                    Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        UnwatchedEpisodes.Add(rawLastEp);
                    });
                }

                int i = 0;
                foreach (VM_AnimeEpisode_User raw in rawEps)
                {
                    i++;
                    raw.SetTvDBInfo();
                    //if (i == 1 && VM_ShokoServer.Instance.Trakt_IsEnabled) ep.SetTraktInfo();
                    raw.EpisodeOrder = i;
                    Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        UnwatchedEpisodes.Add(raw);
                    });

                    if (i == 5)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
            }
        }