Exemplo n.º 1
0
        public void RefreshRecentlyWatchedEps()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    EpsWatchedRecently.Clear();
                });

                List <JMMServerBinary.Contract_AnimeEpisode> epContracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyWatched(UserSettingsVM.Instance.Dash_RecentlyWatchedEp_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                    {
                        AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
                        ep.RefreshAnime();
                        if (ep.AniDB_Anime != null && JMMServerVM.Instance.CurrentUser.EvaluateAnime(ep.AniDB_Anime))
                        {
                            ep.SetTvDBInfo();
                            EpsWatchedRecently.Add(ep);
                        }
                    }
                    ViewEpsWatchedRecently.Refresh();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Exemplo n.º 2
0
 private void UpdateGroupAndSeriesForEpisode(AnimeEpisodeVM ep)
 {
     try
     {
         // update the attached series
         JMMServerBinary.Contract_AnimeSeries serContract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(ep.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
         AnimeSeriesVM ser = AllSeriesDictionary.SureGet(serContract.AnimeSeriesID);
         if (ser != null)
         {
             ser.Populate(serContract);
             // TODO update the episode list
         }
         List <JMMServerBinary.Contract_AnimeGroup> grps = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupsAboveSeries(ep.AnimeSeriesID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
         foreach (JMMServerBinary.Contract_AnimeGroup grpContract in grps)
         {
             AnimeGroupVM agrp = AllGroupsDictionary.SureGet(grpContract.AnimeGroupID);
             agrp?.Populate(grpContract);
             agrp?.PopulateSerieInfo(AllGroupsDictionary, AllSeriesDictionary);
         }
     }
     catch (Exception ex)
     {
         Utils.ShowErrorMessage(ex);
     }
 }
Exemplo n.º 3
0
        public AnimeEpisodeVM GetEpisodeForVideo(VideoDetailedVM vid, EpisodeList epList)
        {
            // get the episodes that this file applies to


            try
            {
                List <JMMServerBinary.Contract_AnimeEpisode> eps = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesForFile(vid.VideoLocalID,
                                                                                                                            JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                foreach (JMMServerBinary.Contract_AnimeEpisode epcontract in eps)
                {
                    foreach (object epObj in epList.lbEpisodes.ItemsSource)
                    {
                        AnimeEpisodeVM epItem = epObj as AnimeEpisodeVM;
                        if (epItem.AnimeEpisodeID == vid.AnimeEpisodeID)
                        {
                            return(epItem);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            return(null);
        }
Exemplo n.º 4
0
        public void RefreshEpsWatchNext_Recent()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    EpsWatchNext_Recent.Clear();
                });

                DateTime start = DateTime.Now;

                List <JMMServerBinary.Contract_AnimeEpisode> epContracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetContinueWatchingFilter(JMMServerVM.Instance.CurrentUser.JMMUserID.Value, UserSettingsVM.Instance.Dash_WatchNext_Items);

                TimeSpan ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: contracts: {0}", ts.TotalMilliseconds);

                start = DateTime.Now;
                List <AnimeEpisodeVM> epList = new List <AnimeEpisodeVM>();
                foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                {
                    AnimeEpisodeVM ep        = new AnimeEpisodeVM(contract);
                    string         animename = ep.AnimeName;             // just do this to force anidb anime detail record to be loaded

                    ts = DateTime.Now - start;
                    logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: Stage 1: {0}", ts.TotalMilliseconds);

                    ep.RefreshAnime();

                    ts = DateTime.Now - start;
                    logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: Stage 2: {0}", ts.TotalMilliseconds);

                    ep.SetTvDBInfo();

                    ts = DateTime.Now - start;
                    logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: Stage 3: {0}", ts.TotalMilliseconds);

                    epList.Add(ep);
                }
                ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: {0}", ts.TotalMilliseconds);

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    foreach (AnimeEpisodeVM ep in epList)
                    {
                        EpsWatchNext_Recent.Add(ep);
                    }

                    ViewEpsWatchNext_Recent.Refresh();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Exemplo n.º 5
0
        public void RefreshNewEpisodes()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    NewEpisodes.Clear();
                });

                List <JMMServerBinary.Contract_AnimeEpisode> epContracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyAddedSummary(UserSettingsVM.Instance.DashMetro_NewEpisodes_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                {
                    AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
                    ep.RefreshAnime();
                    if (ep.AniDB_Anime != null)
                    {
                        //ep.SetTvDBInfo();

                        string imageName = "";
                        if (AppSettings.DashMetroImageType == DashboardMetroImageType.Fanart)
                        {
                            imageName = ep.AnimeSeries.AniDB_Anime.FanartPath;
                        }
                        else
                        {
                            imageName = ep.AnimeSeries.AniDB_Anime.PosterPathWithRandoms;
                        }

                        NewEpisodeTile tile = new NewEpisodeTile()
                        {
                            EpisodeDetails = ep.EpisodeNumberAndName,
                            AnimeName      = ep.AnimeSeries.SeriesName,
                            Picture        = imageName,
                            AnimeSeries    = ep.AnimeSeries,
                            TileSize       = "Large",
                            Height         = 100
                        };


                        System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                        {
                            NewEpisodes.Add(tile);
                        });
                    }
                }

                OnFinishedProcess(new FinishedProcessEventArgs(DashboardMetroProcessType.NewEpisodes));
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            finally
            {
            }
        }
Exemplo n.º 6
0
        public void RefreshRecentAdditions(RecentAdditionsType addType)
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    RecentAdditions.Clear();
                });

                if (addType == RecentAdditionsType.Episode)
                {
                    List <JMMServerBinary.Contract_AnimeEpisode> epContracts =
                        JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                        {
                            AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
                            ep.RefreshAnime();

                            if (ep.AniDB_Anime == null)
                            {
                                ep.RefreshAnime(true); // this might be a new series
                            }
                            if (ep.AniDB_Anime != null)
                            {
                                ep.SetTvDBInfo();
                                RecentAdditions.Add(ep);
                            }
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
                else
                {
                    List <JMMServerBinary.Contract_AnimeSeries> serContracts =
                        JMMServerVM.Instance.clientBinaryHTTP.GetSeriesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        foreach (JMMServerBinary.Contract_AnimeSeries contract in serContracts)
                        {
                            AnimeSeriesVM ser = new AnimeSeriesVM(contract);
                            RecentAdditions.Add(ser);
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Exemplo n.º 7
0
        public AnimeSeriesVM GetSeriesForEpisode(AnimeEpisodeVM ep)
        {
            try
            {
                return(AllSeriesDictionary.SureGet(ep.AnimeSeriesID));
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            return(null);
        }
Exemplo n.º 8
0
 public void UpdateHeirarchy(AnimeEpisodeVM ep)
 {
     try
     {
         // update the episode first
         JMMServerBinary.Contract_AnimeEpisode contract = JMMServerVM.Instance.clientBinaryHTTP.GetEpisode(ep.AnimeEpisodeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
         UpdateHeirarchy(contract);
     }
     catch (Exception ex)
     {
         Utils.ShowErrorMessage(ex);
     }
 }
Exemplo n.º 9
0
        public AnimeSeriesVM GetSeriesForEpisode(AnimeEpisodeVM ep)
        {
            try
            {
                AnimeSeriesVM thisSeries = null;
                foreach (AnimeSeriesVM ser in MainListHelperVM.Instance.AllSeries)
                {
                    if (ser.AnimeSeriesID == ep.AnimeSeriesID)
                    {
                        thisSeries = ser;
                        break;
                    }
                }
                return(thisSeries);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            return(null);
        }
Exemplo n.º 10
0
        public void RefreshEpisodes()
        {
            allEpisodes = new List <AnimeEpisodeVM>();

            try
            {
                DateTime start = DateTime.Now;
                List <JMMServerBinary.Contract_AnimeEpisode> eps = JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesForSeries(AnimeSeriesID.Value,
                                                                                                                              JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
                TimeSpan ts = DateTime.Now - start;
                logger.Info("Got episode data from service: {0} in {1} ms", AniDB_Anime.FormattedTitle, ts.TotalMilliseconds);

                start = DateTime.Now;

                TvDBSummary tvSummary = AniDB_Anime.TvSummary;
                // Normal episodes
                List <AnimeEpisodeVM> specials = new List <AnimeEpisodeVM>();
                foreach (JMMServerBinary.Contract_AnimeEpisode ep in eps)
                {
                    AnimeEpisodeVM epvm = new AnimeEpisodeVM(ep);
                    epvm.SetTvDBInfo(tvSummary);
                    allEpisodes.Add(epvm);
                }

                ts = DateTime.Now - start;
                logger.Info("Got episode contracts: {0} in {1} ms", AniDB_Anime.FormattedTitle, ts.TotalMilliseconds);

                start = DateTime.Now;
                allEpisodes.Sort();
                ts = DateTime.Now - start;
                logger.Info("Sorted episode contracts: {0} in {1} ms", AniDB_Anime.FormattedTitle, ts.TotalMilliseconds);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemplo n.º 11
0
        private void UpdateGroupAndSeriesForEpisode(AnimeEpisodeVM ep)
        {
            try
            {
                // update the attached series
                JMMServerBinary.Contract_AnimeSeries serContract = JMMServerVM.Instance.clientBinaryHTTP.GetSeries(ep.AnimeSeriesID,
                                                                                                                   JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
                foreach (AnimeSeriesVM ser in MainListHelperVM.Instance.AllSeries)
                {
                    if (ser.AnimeSeriesID == serContract.AnimeSeriesID)
                    {
                        ser.Populate(serContract);

                        // TODO update the episode list
                        break;
                    }
                }

                List <JMMServerBinary.Contract_AnimeGroup> grps = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupsAboveSeries(ep.AnimeSeriesID,
                                                                                                                                JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
                foreach (AnimeGroupVM grp in MainListHelperVM.Instance.AllGroups)
                {
                    foreach (JMMServerBinary.Contract_AnimeGroup grpContract in grps)
                    {
                        if (grp.AnimeGroupID.Value == grpContract.AnimeGroupID)
                        {
                            grp.Populate(grpContract);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemplo n.º 12
0
        //[LogExecutionTime]
        public void ShowChildWrappers(MainListWrapper wrapper)
        {
            try
            {
                CurrentWrapper            = wrapper;
                CurrentWrapperIsGroup     = wrapper is GroupFilterVM;
                CurrentListWrapperIsGroup = wrapper is AnimeGroupVM;

                if (wrapper is AnimeGroupVM)
                {
                    //LastAnimeGroupID = ((AnimeGroupVM)wrapper).AnimeGroupID.Value;
                    MainListHelperVM.Instance.CurrentOpenGroupFilter = "AnimeGroupVM|" + ((AnimeGroupVM)wrapper).AnimeGroupID.Value;
                }
                if (wrapper is GroupFilterVM)
                {
                    CurrentGroupFilter = (GroupFilterVM)wrapper;
                    //LastGroupFilterID = ((GroupFilterVM)wrapper).GroupFilterID.Value;

                    MainListHelperVM.Instance.CurrentOpenGroupFilter = "GroupFilterVM|" + ((GroupFilterVM)wrapper).GroupFilterID.Value;
                }
                if (wrapper is AnimeSeriesVM)
                {
                    CurrentSeries = wrapper as AnimeSeriesVM;
                    //LastAnimeSeriesID = ((AnimeSeriesVM)wrapper).AnimeSeriesID.Value;

                    MainListHelperVM.Instance.CurrentOpenGroupFilter = "NoGroup";
                }

                if (wrapper == null)
                {
                    MainListHelperVM.Instance.CurrentOpenGroupFilter = "Init";
                }


                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    // update wrappers
                    // check where this wrapper sits in the heirarchy and remove anything below it
                    int pos = -1;



                    if (wrapper != null)
                    {
                        for (int i = 0; i < BreadCrumbs.Count; i++)
                        {
                            if (wrapper is GroupFilterVM && BreadCrumbs[i] is GroupFilterVM)
                            {
                                GroupFilterVM wrapObj = wrapper as GroupFilterVM;
                                GroupFilterVM bcObj   = BreadCrumbs[i] as GroupFilterVM;
                                if (wrapObj.FilterName == bcObj.FilterName)
                                {
                                    pos = i;
                                }
                            }
                            if (wrapper is AnimeGroupVM && BreadCrumbs[i] is AnimeGroupVM)
                            {
                                AnimeGroupVM wrapObj = wrapper as AnimeGroupVM;
                                AnimeGroupVM bcObj   = BreadCrumbs[i] as AnimeGroupVM;
                                if (wrapObj.AnimeGroupID == bcObj.AnimeGroupID)
                                {
                                    pos = i;
                                }
                            }
                            if (wrapper is AnimeSeriesVM && BreadCrumbs[i] is AnimeSeriesVM)
                            {
                                AnimeSeriesVM wrapObj = wrapper as AnimeSeriesVM;
                                AnimeSeriesVM bcObj   = BreadCrumbs[i] as AnimeSeriesVM;
                                if (wrapObj.AnimeSeriesID == bcObj.AnimeSeriesID)
                                {
                                    pos = i;
                                }
                            }
                            if (wrapper is AnimeEpisodeTypeVM && BreadCrumbs[i] is AnimeEpisodeTypeVM)
                            {
                                AnimeEpisodeTypeVM wrapObj = wrapper as AnimeEpisodeTypeVM;
                                AnimeEpisodeTypeVM bcObj   = BreadCrumbs[i] as AnimeEpisodeTypeVM;
                                if (wrapObj.EpisodeTypeDescription == bcObj.EpisodeTypeDescription)
                                {
                                    pos = i;
                                }
                            }
                            if (wrapper is AnimeEpisodeVM && BreadCrumbs[i] is AnimeEpisodeVM)
                            {
                                AnimeEpisodeVM wrapObj = wrapper as AnimeEpisodeVM;
                                AnimeEpisodeVM bcObj   = BreadCrumbs[i] as AnimeEpisodeVM;
                                if (wrapObj.AnimeEpisodeID == bcObj.AnimeEpisodeID)
                                {
                                    pos = i;
                                }
                            }
                        }
                    }
                    else
                    {
                        pos = 0;
                    }

                    if (pos >= 0)
                    {
                        for (int i = BreadCrumbs.Count - 1; i >= 0; i--)
                        {
                            if (i >= pos)
                            {
                                BreadCrumbs.RemoveAt(i);
                            }
                        }
                    }


                    BreadCrumbs.Add(wrapper);

                    if (wrapper is GroupFilterVM)
                    {
                        if (AllGroupsDictionary.Count == 0)
                        {
                            RefreshGroupsSeriesData();
                        }

                        // apply sorting
                        // get default sorting from the group filter
                    }


                    // means we are at the top level
                    if (wrapper == null)
                    {
                        CurrentWrapperList.Clear();
                        foreach (GroupFilterVM grpFilter in AllGroupFiltersDictionary.Values.Where(a => !a.GroupFilterParentId.HasValue).OrderBy(a => a.FilterName))
                        {
                            CurrentWrapperList.Add(grpFilter);
                        }
                    }
                    else
                    {
                        CurrentWrapperList.Clear();
                        foreach (MainListWrapper wp in wrapper.GetDirectChildren())
                        {
                            CurrentWrapperList.Add(wp);
                        }
                    }

                    SetGroupFilterSortingOnMainList();
                    ViewGroups.Refresh();

                    //new FilterMainListBox(ViewGroups, SearchTextBox, CurrentGroupFilter);
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemplo n.º 13
0
        public void RefreshContinueWatching()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    ContinueWatching.Clear();
                });

                DateTime start = DateTime.Now;

                List <JMMServerBinary.Contract_AnimeEpisode> epContracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetContinueWatchingFilter(JMMServerVM.Instance.CurrentUser.JMMUserID.Value, UserSettingsVM.Instance.DashMetro_WatchNext_Items);

                TimeSpan ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: contracts: {0}", ts.TotalMilliseconds);

                start = DateTime.Now;
                List <AnimeEpisodeVM> epList = new List <AnimeEpisodeVM>();
                foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                {
                    AnimeEpisodeVM ep        = new AnimeEpisodeVM(contract);
                    string         animename = ep.AnimeName;             // just do this to force anidb anime detail record to be loaded
                    ep.RefreshAnime();
                    //ep.SetTvDBInfo();
                    epList.Add(ep);
                }
                ts = DateTime.Now - start;
                logger.Trace("Dashboard Time: RefreshEpsWatchNext_Recent: episode details: {0}", ts.TotalMilliseconds);

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    foreach (AnimeEpisodeVM ep in epList)
                    {
                        string imageName = "";
                        if (AppSettings.DashMetroImageType == DashboardMetroImageType.Fanart)
                        {
                            imageName = ep.AniDB_Anime.FanartPathPreferThumb;
                        }
                        else
                        {
                            imageName = ep.AniDB_Anime.PosterPathWithRandoms;
                        }

                        ContinueWatching.Add(new ContinueWatchingTile()
                        {
                            EpisodeDetails    = ep.EpisodeNumberAndName, AnimeName = ep.AnimeSeries.SeriesName,
                            Picture           = imageName,
                            AnimeSeries       = ep.AnimeSeries,
                            UnwatchedEpisodes = ep.AnimeSeries.UnwatchedEpisodeCount,
                            TileSize          = "Large",
                            Height            = 100
                        });
                    }

                    ViewContinueWatching.Refresh();
                });

                OnFinishedProcess(new FinishedProcessEventArgs(DashboardMetroProcessType.ContinueWatching));
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }