Exemplo n.º 1
0
 public void SetMovieStopTime(int movieId, int userId, int stoptime)
 {
     try
     {
         QueryUpdate setStopTime = new QueryUpdate(String.Format(_setStopTime, movieId, userId, stoptime));
         setStopTime.Execute(_connection);
     }
     catch (Exception ex)
     {
         Log.Error("MyMovies::SetMovieStopTime - exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
     }
 }
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
 public void SetMovieWatched(int movieId, bool yes)
 {
     try
     {
         QueryUpdate update = new QueryUpdate(string.Format("UPDATE tblTitlePersonal SET bitWatched = {0} WHERE intTitle = {1}", (yes) ? 1 : 0, movieId));
         update.Execute(_connection);
     }
     catch (Exception ex)
     {
         Log.Error("MyMovies::SetMovieWatched - unable to set watched status");
         Log.Error(ex);
     }
 }
Exemplo n.º 4
0
        private void btnTestConnection_Click(object sender, EventArgs e)
        {
            try
            {
                string connection = QueryReader<int>.Connection(txtServerName.Text, txtDBInstance.Text, txtUserName.Text, txtPassword.Text);
                using (SqlConnection conn = new SqlConnection(connection))
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = conn;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandTimeout = 5;
                    cmd.CommandText = _tblResumeExists;

                    conn.Open();

                    // if the table does not exist, then create it.
                    if (System.Convert.ToInt32(cmd.ExecuteScalar()) == 0)
                    {
                        QueryUpdate createTable = new QueryUpdate(_createTableResume);
                        createTable.Execute(connection);
                    }
                    // else check if the UserId column exists
                    else
                    {
                        cmd.CommandText = _userIdExists;

                        // if the table does not exist, then create it.
                        if (System.Convert.ToInt32(cmd.ExecuteScalar()) == 0)
                        {
                            QueryUpdate createTable = new QueryUpdate(_addUserId);
                            createTable.Execute(connection);
                        }
                    }
                }

                TestConnectionResult(true);
            }
            catch (SqlException sqlEx)
            {
                TestConnectionResult(false);
                Log.Debug("MyMovies::btnTestConnection_Click - Sql Exception '{0}'", sqlEx.Message);
            }
            catch (Exception ex)
            {
                TestConnectionResult(false);
                Log.Debug("MyMovies::btnTestConnection_Click - Exception '{0}'", ex.Message);
            }
        }