Пример #1
0
        private void QuickRefreshMovieLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start Refresh : Movies");
            
            var res = _remote.VideoLibrary.GetMoviesRefresh();
          
            Logger.Instance().Log("FrontView+", "Remote Refresh Movies : " + res.Count);

            var currentMovies = _database.GetMovie(_remoteInfo.Id);

            _database.SetBulkInsert(true);
            _database.BeginTransaction();

          //  _database.DeleteRemoteMovie(_remoteInfo.Id);
            var notfound = true;
            foreach (var apiMovie in res)
            {
                notfound = true;    
                foreach (var omovie in currentMovies)
                {

                    if (omovie.IdMovie == apiMovie.IdMovie)
                    {
                        notfound = false;
                        Logger.Instance().Log("FrontView+", "Movie Already In DB omovie ID" + omovie.IdMovie + "apiMovie.Id:" + apiMovie.IdMovie);
                    }

                }
                if (notfound == true)
                {
                     Logger.Instance().Log("FrontView+", "Inserting Movie:" +apiMovie.Title+" apiMovie Id:"+apiMovie.IdMovie);
                     var movie = new Yatse2Movie(apiMovie) { IdRemote = _remoteInfo.Id };
                      _database.InsertMovie(movie);
                }
                

            }

            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+", "End QUICK Refresh : Movies");
        }
Пример #2
0
        private void RefreshMovieLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start Refresh : Movies");
            var res = _remote.VideoLibrary.GetMovies();
            Logger.Instance().Log("FrontView+", "Remote Movies : " + res.Count);

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

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteMovie(_remoteInfo.Id);
            foreach (var apiMovie in res)
            {
                long oldFavorite = 0;
                foreach (var omovie in oldData)
                {
                    if (omovie.IdMovie == apiMovie.IdMovie)
                        oldFavorite = omovie.IsFavorite;
                }

                var movie = new Yatse2Movie(apiMovie) {IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite};
                _database.InsertMovie(movie);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+", "End Refresh : Movies");
        }
Пример #3
0
 public long InsertMovie(Yatse2Movie movie)
 {
     if (movie == null)
         return 0;
     var sqlCmd = _dbConnection.CreateCommand();
     sqlCmd.CommandText =
         @"INSERT INTO `Movies` ( IdRemote ,IdFile,IdScraper,Title,OriginalTitle,Genre,Tagline,Plot,Director,Year,Length,Mpaa,Studio,Rating,Votes,FileName,Path,PlayCount,Hash,Thumb,Fanart,IsStack,IdMovie,IsFavorite,DateAdded, Banner, Logo, MovieIcons ) 
           VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
     sqlCmd.Parameters.AddWithValue("a1", movie.IdRemote);
     sqlCmd.Parameters.AddWithValue("a2", movie.IdFile);
     sqlCmd.Parameters.AddWithValue("a3", movie.IdScraper);
     sqlCmd.Parameters.AddWithValue("a4", movie.Title);
     sqlCmd.Parameters.AddWithValue("a5", movie.OriginalTitle);
     sqlCmd.Parameters.AddWithValue("a6", movie.Genre);
     sqlCmd.Parameters.AddWithValue("a7", movie.Tagline);
     sqlCmd.Parameters.AddWithValue("a8", movie.Plot);
     sqlCmd.Parameters.AddWithValue("a9", movie.Director);
     sqlCmd.Parameters.AddWithValue("a10", movie.Year);
     sqlCmd.Parameters.AddWithValue("a11", movie.Length);
     sqlCmd.Parameters.AddWithValue("a12", movie.Mpaa);
     sqlCmd.Parameters.AddWithValue("a13", movie.Studio);
     sqlCmd.Parameters.AddWithValue("a14", movie.Rating);
     sqlCmd.Parameters.AddWithValue("a15", movie.Votes);
     sqlCmd.Parameters.AddWithValue("a16", movie.FileName);
     sqlCmd.Parameters.AddWithValue("a17", movie.Path);
     sqlCmd.Parameters.AddWithValue("a18", movie.PlayCount);
     sqlCmd.Parameters.AddWithValue("a19", movie.Hash);
     sqlCmd.Parameters.AddWithValue("a20", movie.Thumb);
     sqlCmd.Parameters.AddWithValue("a21", movie.Fanart);
     sqlCmd.Parameters.AddWithValue("a22", movie.IsStack);
     sqlCmd.Parameters.AddWithValue("a23", movie.IdMovie);
     sqlCmd.Parameters.AddWithValue("a24", movie.IsFavorite);
     sqlCmd.Parameters.AddWithValue("a25", movie.DateAdded);
     sqlCmd.Parameters.AddWithValue("a26", movie.Banner);
     sqlCmd.Parameters.AddWithValue("a27", movie.Logo);
     sqlCmd.Parameters.AddWithValue("a28", movie.MovieIcons);
     return QueryInsert(sqlCmd);
 }
Пример #4
0
        public bool UpdateMovie(Yatse2Movie movie)
        {
            if (movie == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `Movies` SET IdRemote = ?,IdFile = ?,IdScraper = ?,Title = ?,OriginalTitle = ?,Genre = ?,Tagline = ?,Plot = ?,Director = ?,Year = ?,Length = ?,Mpaa = ?,Studio = ?,Rating = ?,Votes = ?,FileName = ?,Path = ?,PlayCount = ?,Hash = ?,Thumb = ?,Fanart = ?,IsStack = ?,IdMovie = ?,IsFavorite = ?, DateAdded = ?, Banner = ?, Logo = ?, MovieIcons = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", movie.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", movie.IdFile);
            sqlCmd.Parameters.AddWithValue("a3", movie.IdScraper);
            sqlCmd.Parameters.AddWithValue("a4", movie.Title);
            sqlCmd.Parameters.AddWithValue("a5", movie.OriginalTitle);
            sqlCmd.Parameters.AddWithValue("a6", movie.Genre);
            sqlCmd.Parameters.AddWithValue("a7", movie.Tagline);
            sqlCmd.Parameters.AddWithValue("a8", movie.Plot);
            sqlCmd.Parameters.AddWithValue("a9", movie.Director);
            sqlCmd.Parameters.AddWithValue("a10", movie.Year);
            sqlCmd.Parameters.AddWithValue("a11", movie.Length);
            sqlCmd.Parameters.AddWithValue("a12", movie.Mpaa);
            sqlCmd.Parameters.AddWithValue("a13", movie.Studio);
            sqlCmd.Parameters.AddWithValue("a14", movie.Rating);
            sqlCmd.Parameters.AddWithValue("a15", movie.Votes);
            sqlCmd.Parameters.AddWithValue("a16", movie.FileName);
            sqlCmd.Parameters.AddWithValue("a17", movie.Path);
            sqlCmd.Parameters.AddWithValue("a18", movie.PlayCount);
            sqlCmd.Parameters.AddWithValue("a19", movie.Hash);
            sqlCmd.Parameters.AddWithValue("a20", movie.Thumb);
            sqlCmd.Parameters.AddWithValue("a21", movie.Fanart);
            sqlCmd.Parameters.AddWithValue("a22", movie.IsStack);
            sqlCmd.Parameters.AddWithValue("a23", movie.IdMovie);
            sqlCmd.Parameters.AddWithValue("a24", movie.IsFavorite);
            sqlCmd.Parameters.AddWithValue("a25", movie.DateAdded);
            sqlCmd.Parameters.AddWithValue("a26", movie.Banner);
            sqlCmd.Parameters.AddWithValue("a27", movie.Logo);
            sqlCmd.Parameters.AddWithValue("a28", movie.MovieIcons);

            sqlCmd.Parameters.AddWithValue("@Id", movie.Id);

            return Query(sqlCmd);
        }
Пример #5
0
 private Collection<Yatse2Movie> QueryMovie(SQLiteCommand query)
 {
     var movies = new Collection<Yatse2Movie>();
     if (!_connected) return movies;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var movie = new Yatse2Movie
             {
                 Id = GetLong(sqldReader, "Id"),
                 IdRemote = GetLong(sqldReader, "IdRemote"),
                 IdMovie = GetLong(sqldReader, "IdMovie"),
                 IdFile = GetLong(sqldReader, "IdFile"),
                 IdScraper = GetString(sqldReader, "IdScraper"),
                 Title = GetString(sqldReader, "Title"),
                 OriginalTitle = GetString(sqldReader, "OriginalTitle"),
                 Genre = GetString(sqldReader, "Genre"),
                 Tagline = GetString(sqldReader, "Tagline"),
                 Plot = GetString(sqldReader, "Plot"),
                 Director = GetString(sqldReader, "Director"),
                 Year = GetLong(sqldReader, "Year"),
                 Length = GetString(sqldReader, "Length"),
                 Mpaa = GetString(sqldReader, "Mpaa"),
                 Studio = GetString(sqldReader, "Studio"),
                 Rating = GetString(sqldReader, "Rating"),
                 Votes = GetString(sqldReader, "Votes"),
                 FileName = GetString(sqldReader, "FileName"),
                 Path = GetString(sqldReader, "Path"),
                 PlayCount = GetLong(sqldReader, "PlayCount"),
                 Hash = GetString(sqldReader, "Hash"),
                 Thumb = GetString(sqldReader, "Thumb"),
                 Fanart = GetString(sqldReader, "Fanart"),
                 IsStack = GetLong(sqldReader, "IsStack"),
                 IsFavorite = GetLong(sqldReader, "IsFavorite"),
                 DateAdded = GetString(sqldReader, "DateAdded"),
                 Banner = GetString(sqldReader, "Banner"),
                 Logo = GetString(sqldReader, "Logo"),
                 MovieIcons = GetString(sqldReader, "MovieIcons")
             };
             movies.Add(movie);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return movies;
 }