Ejemplo n.º 1
0
        private void RefreshTvSeasonLibrary()
        {
            Logger.Instance().Log("Yatse2", "Start Refresh : TvSeasons");
            var res = _remote.VideoLibrary.GetTvSeasons();
            Logger.Instance().Log("Yatse2", "Remote TvSeasons : " + res.Count);

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

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteTvSeasons(_remoteInfo.Id);
            foreach (var apiTvSeason in res)
            {
                long oldFavorite = 0;
                foreach (var show in oldData)
                {
                    if (show.IdShow == apiTvSeason.IdShow)
                        oldFavorite = show.IsFavorite;
                }
                var tvSeason = new Yatse2TvSeason(apiTvSeason) {IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite};
                _database.InsertTvSeason(tvSeason);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("Yatse2", "End Refresh : TvSeasons");
        }
Ejemplo n.º 2
0
        public bool UpdateTvSeason(Yatse2TvSeason season)
        {
            if (season == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `TvShows` SET IdRemote = ?,IdShow = ?,SeasonNumber = ?,EpisodeCount = ?,Hash = ?,Thumb = ?,Fanart = ?,IsFavorite = ?, Show = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", season.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", season.IdShow);
            sqlCmd.Parameters.AddWithValue("a3", season.SeasonNumber);
            sqlCmd.Parameters.AddWithValue("a4", season.EpisodeCount);
            sqlCmd.Parameters.AddWithValue("a5", season.Hash);
            sqlCmd.Parameters.AddWithValue("a6", season.Thumb);
            sqlCmd.Parameters.AddWithValue("a7", season.Fanart);
            sqlCmd.Parameters.AddWithValue("a8", season.IsFavorite);
            sqlCmd.Parameters.AddWithValue("a9", season.Show);
            sqlCmd.Parameters.AddWithValue("@Id", season.Id);

            return Query(sqlCmd);
        }
Ejemplo n.º 3
0
 private Collection<Yatse2TvSeason> QueryTvSeason(SQLiteCommand query)
 {
     var tvSeasons = new Collection<Yatse2TvSeason>();
     if (!_connected) return tvSeasons;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var episode = new Yatse2TvSeason
             {
                 Id = GetLong(sqldReader, "Id"),
                 IdRemote = GetLong(sqldReader, "IdRemote"),
                 IdShow = GetLong(sqldReader, "IdShow"),
                 SeasonNumber = GetLong(sqldReader, "SeasonNumber"),
                 EpisodeCount = GetLong(sqldReader, "EpisodeCount"),
                 Hash = GetString(sqldReader, "Hash"),
                 Thumb = GetString(sqldReader, "Thumb"),
                 Fanart = GetString(sqldReader, "Fanart"),
                 IsFavorite = GetLong(sqldReader, "IsFavorite"),
                 Show = GetString(sqldReader, "Show")
             };
             tvSeasons.Add(episode);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return tvSeasons;
 }
Ejemplo n.º 4
0
 public long InsertTvSeason(Yatse2TvSeason season)
 {
     if (season == null)
         return 0;
     var sqlCmd = _dbConnection.CreateCommand();
     sqlCmd.CommandText =
         @"INSERT INTO `TvSeasons` ( IdRemote ,IdShow,SeasonNumber,EpisodeCount,Hash,Thumb,Fanart,IsFavorite,Show )
           VALUES ( ?,?,?,?,?,?,?,?,?);";
     sqlCmd.Parameters.AddWithValue("a1", season.IdRemote);
     sqlCmd.Parameters.AddWithValue("a2", season.IdShow);
     sqlCmd.Parameters.AddWithValue("a3", season.SeasonNumber);
     sqlCmd.Parameters.AddWithValue("a4", season.EpisodeCount);
     sqlCmd.Parameters.AddWithValue("a5", season.Hash);
     sqlCmd.Parameters.AddWithValue("a6", season.Thumb);
     sqlCmd.Parameters.AddWithValue("a7", season.Fanart);
     sqlCmd.Parameters.AddWithValue("a8", season.IsFavorite);
     sqlCmd.Parameters.AddWithValue("a9", season.Show);
     return QueryInsert(sqlCmd);
 }