コード例 #1
0
        private void RefreshTvShowLibrary()
        {
            Logger.Instance().Log("Yatse2", "Start Refresh : TvShows");
            var res = _remote.VideoLibrary.GetTvShows();
            Logger.Instance().Log("Yatse2", "Remote TvShows : " + res.Count);

            var oldData = _database.GetTvShowFavorites(_remoteInfo.Id);

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteTvShows(_remoteInfo.Id);
            foreach (var apiTvShow in res)
            {
                long oldFavorite = 0;
                foreach (var show in oldData)
                {
                    if (show.IdShow == apiTvShow.IdShow)
                        oldFavorite = show.IsFavorite;
                }
                var tvShow = new Yatse2TvShow(apiTvShow) {IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite};
                _database.InsertTvShow(tvShow);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("Yatse2", "End Refresh : TvShows");
        }
コード例 #2
0
ファイル: Yatse2Db.cs プロジェクト: GroupXTech/Yatse2
        public bool UpdateTvShow(Yatse2TvShow show)
        {
            if (show == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `TvShows` SET IdRemote = ?,IdShow = ?,IdScraper = ?,Title = ?,Plot = ?,Premiered = ?,Rating = ?,Genre = ?,Mpaa = ?,Studio = ?,Path = ?,TotalCount = ?,Hash = ?,Thumb = ?,Fanart = ?,IsFavorite = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", show.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", show.IdShow);
            sqlCmd.Parameters.AddWithValue("a3", show.IdScraper);
            sqlCmd.Parameters.AddWithValue("a4", show.Title);
            sqlCmd.Parameters.AddWithValue("a5", show.Plot);
            sqlCmd.Parameters.AddWithValue("a6", show.Premiered);
            sqlCmd.Parameters.AddWithValue("a7", show.Rating);
            sqlCmd.Parameters.AddWithValue("a8", show.Genre);
            sqlCmd.Parameters.AddWithValue("a9", show.Mpaa);
            sqlCmd.Parameters.AddWithValue("a10", show.Studio);
            sqlCmd.Parameters.AddWithValue("a11", show.Path);
            sqlCmd.Parameters.AddWithValue("a12", show.TotalCount);
            sqlCmd.Parameters.AddWithValue("a13", show.Hash);
            sqlCmd.Parameters.AddWithValue("a14", show.Thumb);
            sqlCmd.Parameters.AddWithValue("a15", show.Fanart);
            sqlCmd.Parameters.AddWithValue("a16", show.IsFavorite);
            sqlCmd.Parameters.AddWithValue("@Id", show.Id);

            return Query(sqlCmd);
        }
コード例 #3
0
ファイル: Yatse2Db.cs プロジェクト: GroupXTech/Yatse2
 private Collection<Yatse2TvShow> QueryTvShow(SQLiteCommand query)
 {
     var tvShows = new Collection<Yatse2TvShow>();
     if (!_connected) return tvShows;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var movie = new Yatse2TvShow
             {
                 Id = GetLong(sqldReader, "Id"),
                 IdRemote = GetLong(sqldReader, "IdRemote"),
                 IdShow = GetLong(sqldReader, "IdShow"),
                 IdScraper = GetString(sqldReader, "IdScraper"),
                 Title = GetString(sqldReader, "Title"),
                 Plot = GetString(sqldReader, "Plot"),
                 Premiered = GetString(sqldReader, "Premiered"),
                 Rating = GetString(sqldReader, "Rating"),
                 Genre = GetString(sqldReader, "Genre"),
                 Mpaa = GetString(sqldReader, "Mpaa"),
                 Studio = GetString(sqldReader, "Studio"),
                 Path = GetString(sqldReader, "Path"),
                 TotalCount = GetLong(sqldReader, "TotalCount"),
                 Hash = GetString(sqldReader, "Hash"),
                 Thumb = GetString(sqldReader, "Thumb"),
                 Fanart = GetString(sqldReader, "Fanart"),
                 IsFavorite = GetLong(sqldReader, "IsFavorite")
             };
             tvShows.Add(movie);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return tvShows;
 }
コード例 #4
0
ファイル: Yatse2Db.cs プロジェクト: GroupXTech/Yatse2
        public long InsertTvShow(Yatse2TvShow show)
        {
            if (show == null)
                return 0;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"INSERT INTO `TvShows` ( IdRemote ,IdShow,IdScraper,Title,Plot,Premiered,Rating,Genre,Mpaa,Studio,Path,TotalCount,Hash,Thumb,Fanart,IsFavorite )
                  VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
            sqlCmd.Parameters.AddWithValue("a1", show.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", show.IdShow);
            sqlCmd.Parameters.AddWithValue("a3", show.IdScraper);
            sqlCmd.Parameters.AddWithValue("a4", show.Title);
            sqlCmd.Parameters.AddWithValue("a5", show.Plot);
            sqlCmd.Parameters.AddWithValue("a6", show.Premiered);
            sqlCmd.Parameters.AddWithValue("a7", show.Rating);
            sqlCmd.Parameters.AddWithValue("a8", show.Genre);
            sqlCmd.Parameters.AddWithValue("a9", show.Mpaa);
            sqlCmd.Parameters.AddWithValue("a10", show.Studio);
            sqlCmd.Parameters.AddWithValue("a11", show.Path);
            sqlCmd.Parameters.AddWithValue("a12", show.TotalCount);
            sqlCmd.Parameters.AddWithValue("a13", show.Hash);
            sqlCmd.Parameters.AddWithValue("a14", show.Thumb);
            sqlCmd.Parameters.AddWithValue("a15", show.Fanart);
            sqlCmd.Parameters.AddWithValue("a16", show.IsFavorite);

            return QueryInsert(sqlCmd);
        }