예제 #1
0
        public void RefreshBookmarkedAnime()
        {
            try
            {
                // set this to null so that it will be refreshed the next time it is needed

                List <VM_BookmarkedAnime> baRaw = VM_ShokoServer.Instance.ShokoServices.GetAllBookmarkedAnime().CastList <VM_BookmarkedAnime>();

                //if (baRaw.Count == 0) return;

                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate
                {
                    BookmarkedAnime.Clear();

                    // must series before groups the binding is based on the groups, and will refresh when that is changed
                    foreach (VM_BookmarkedAnime ba in baRaw)
                    {
                        if (ba.DownloadingBool && BookmarkFilter_Downloading)
                        {
                            BookmarkedAnime.Add(ba);
                        }

                        if (!ba.DownloadingBool && BookmarkFilter_NotDownloading)
                        {
                            BookmarkedAnime.Add(ba);
                        }
                    }
                    ViewBookmarkedAnime.Refresh();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
예제 #2
0
        public static Serie GenerateFromBookmark(NancyContext ctx, BookmarkedAnime bookmark, int uid, bool nocast, bool notag, int level, bool all, bool allpics, int pic, TagFilter.Filter tagfilter)
        {
            var series = RepoFactory.AnimeSeries.GetByAnimeID(bookmark.AnimeID);

            if (series != null)
            {
                return(GenerateFromAnimeSeries(ctx, series, uid, nocast, notag, level, all, allpics, pic, tagfilter));
            }

            SVR_AniDB_Anime aniDB_Anime = RepoFactory.AniDB_Anime.GetByAnimeID(bookmark.AnimeID);

            if (aniDB_Anime == null)
            {
                Commands.CommandRequest_GetAnimeHTTP cr_anime = new Commands.CommandRequest_GetAnimeHTTP(bookmark.AnimeID, true, false);
                cr_anime.Save();

                Serie empty_serie = new Serie
                {
                    id   = -1,
                    name = "GetAnimeInfoHTTP",
                    aid  = bookmark.AnimeID
                };
                return(empty_serie);
            }
            return(GenerateFromAniDB_Anime(ctx, aniDB_Anime, nocast, notag, allpics, pic, tagfilter));
        }
예제 #3
0
        public static Serie GenerateFromBookmark(HttpContext ctx, BookmarkedAnime bookmark, int uid, bool nocast, bool notag, int level, bool all, bool allpics, int pic, TagFilter.Filter tagfilter)
        {
            var series = Repo.Instance.AnimeSeries.GetByAnimeID(bookmark.AnimeID);

            if (series != null)
            {
                return(GenerateFromAnimeSeries(ctx, series, uid, nocast, notag, level, all, allpics, pic, tagfilter));
            }

            SVR_AniDB_Anime aniDB_Anime = Repo.Instance.AniDB_Anime.GetByID(bookmark.AnimeID);

            if (aniDB_Anime == null)
            {
                CommandQueue.Queue.Instance.Add(new CmdAniDBGetAnimeHTTP(bookmark.AnimeID, true, false));

                Serie empty_serie = new Serie
                {
                    id   = -1,
                    name = "GetAnimeInfoHTTP",
                    aid  = bookmark.AnimeID
                };
                return(empty_serie);
            }
            return(GenerateFromAniDB_Anime(ctx, aniDB_Anime, nocast, notag, allpics, pic, tagfilter));
        }
 public BookmarkedAnime GetByAnimeID(int animeID)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         BookmarkedAnime cr = session
                              .CreateCriteria(typeof(BookmarkedAnime))
                              .Add(Restrictions.Eq("AnimeID", animeID))
                              .UniqueResult <BookmarkedAnime>();
         return(cr);
     }
 }
 public void Save(BookmarkedAnime obj)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }
 public void Delete(int id)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             BookmarkedAnime cr = GetByID(id);
             if (cr != null)
             {
                 session.Delete(cr);
                 transaction.Commit();
             }
         }
     }
 }
예제 #7
0
        public static CL_BookmarkedAnime ToClient(this BookmarkedAnime bookmarkedanime)
        {
            CL_BookmarkedAnime cl = new CL_BookmarkedAnime
            {
                AnimeID     = bookmarkedanime.AnimeID,
                Priority    = bookmarkedanime.Priority,
                Notes       = bookmarkedanime.Notes,
                Downloading = bookmarkedanime.Downloading
            };

            cl.Anime = null;
            SVR_AniDB_Anime an = Repo.Instance.AniDB_Anime.GetByID(bookmarkedanime.AnimeID);

            if (an != null)
            {
                cl.Anime = an.Contract.AniDBAnime;
            }

            return(cl);
        }
예제 #8
0
        public void RefreshBookmarkedAnime()
        {
            try
            {
                // set this to null so that it will be refreshed the next time it is needed

                List <JMMServerBinary.Contract_BookmarkedAnime> baRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllBookmarkedAnime();

                //if (baRaw.Count == 0) return;

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    BookmarkedAnime.Clear();

                    // must series before groups the binding is based on the groups, and will refresh when that is changed
                    foreach (JMMServerBinary.Contract_BookmarkedAnime contract in baRaw)
                    {
                        BookmarkedAnimeVM ba = new BookmarkedAnimeVM(contract);

                        if (ba.DownloadingBool && BookmarkFilter_Downloading)
                        {
                            BookmarkedAnime.Add(ba);
                        }

                        if (ba.NotDownloadingBool && BookmarkFilter_NotDownloading)
                        {
                            BookmarkedAnime.Add(ba);
                        }
                    }
                    ViewBookmarkedAnime.Refresh();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }