Exemplo n.º 1
0
        public int GetMovieStopTime(int movieId, int userId)
        {
            try
            {
                QueryValue getStopTime = new QueryValue(string.Format("SELECT * FROM tblResume WHERE intId={0} AND intUserId={1}", movieId, userId));
                return Convert.ToInt32(getStopTime.Execute(_connection));

            }
            catch (Exception ex)
            {
                Log.Error("MyMovies::GetMovieStopTime - exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
            }
            return 0;
        }
Exemplo n.º 2
0
        public void SetMovieStopTimeAndResumeData(int movieId, int userId, int stoptime, byte[] resumeData, string pathName)
        {
            try
            {
                // Only store the file not the path as the next watch may be from a different machine.
                // Delimit the SQL string quotes.
                string fileName = Path.GetFileName(pathName).Replace("'", "''");
                string resumeString = "-";
                if (resumeData != null) resumeString = ToHexString(resumeData);

                string query;
                QueryValue exists = new QueryValue(String.Format("SELECT count(*) FROM tblResume WHERE intId={0} AND intUserId={1}", movieId, userId));
                if (Convert.ToInt32(exists.Execute(_connection)) == 0)
                {
                    query = String.Format("INSERT INTO tblResume (intId, intUserId, intStopTime, nvcResumeData, nvcFileName, datLastPlayed) VALUES({0},{1},{2},'{3}', '{4}', GETDATE())", movieId, userId, stoptime, resumeString, fileName);
                }
                else
                {
                    query = String.Format("UPDATE tblResume SET intStopTime={0}, nvcResumeData='{1}', nvcFileName='{2}', datLastPlayed=GETDATE() WHERE intId={3} AND intUserId={4}", stoptime, resumeString, fileName, movieId, userId);
                }
                QueryUpdate update = new QueryUpdate(query);
                update.Execute(_connection);
            }
            catch (Exception ex)
            {
                Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Read the maximum configured rating within the Database.
 /// </summary>
 /// <returns>The maximum configured rating</returns>
 private int GetMaximumRating()
 {
     int maxRating = 8;  // Add a default.
     try
     {
         QueryValue getMaxRating = new QueryValue(_maxRatingSQL);
         maxRating = Convert.ToInt32(getMaxRating.Execute(ConnectionString));
     }
     catch (Exception ex)
     {
         Log.Error("MyMovies::GetMaximumRating - Cannot read setting. Defaulting");
         Log.Error(ex);
     }
     return maxRating;
 }