Пример #1
0
 /// <summary>
 /// This constructor will be called when Syncing Movies from PlanetM
 /// </summary>
 /// <param name="movObj"></param>
 /// <param name="iMovObj"></param>
 public MovieIMDBDetails(Movie movObj,MovieIMDB iMovObj)
 {
     InitializeComponent();
     LoadControls();
     mov = movObj;
     movieName = movObj.Name;
     Language = movObj.Language;
     iMov = iMovObj;
     iMov.Language = mov.Language;
     btnDeleteMovie.Enabled = false;
 }
Пример #2
0
 public MovieIMDBDetails(Movie movObj, bool IsAvailable)
 {
     InitializeComponent();
     LoadControls();
     mov = movObj;
     movieName = movObj.Name;
     Language = movObj.Language;
     if (IsAvailable)
     {
         LoadMovieDataFromDB(mov.IMDBID);
     }
     else
     {
         LoadMovieDataFromInternet();
         btnDeleteMovie.Enabled = false;
     }
 }
Пример #3
0
 private void DeleteSelectedMovie()
 {
     if (dgMovies.SelectedRows.Count == 1)
     {
         Movie mov = new Movie();
         mov.Name = (string)dgMovies.SelectedRows[0].Cells["MovieName"].Value;
         mov.Language = (string)dgMovies.SelectedRows[0].Cells["Language"].Value;
         if (MessageBox.Show("Do you want to delete Movie : " + mov.Name + " from PlanetM ?", "Delete Movie Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             if (dbObj.DeleteMovie(mov))
             {
                 MessageBox.Show("Movie details has been deleted from Database", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LoadMovies();
             }
             else
                 MessageBox.Show("Error while deleting movie details from Database !", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
         MessageBox.Show("Please select one Movie from the available Movies !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 }
Пример #4
0
        public bool AddNewMovie(Movie movie)
        {
            SqlTransaction objTrans = null;
            SqlConnection myConnection = new SqlConnection(m_Connection_String);
            try
            {
                myConnection.Open();
                objTrans = myConnection.BeginTransaction();
                SqlParameter[] arrParam = new SqlParameter[5];

                arrParam[0] = new SqlParameter("@name", movie.Name);
                arrParam[1] = new SqlParameter("@language", movie.Language);
                arrParam[2] = new SqlParameter("@location", movie.Location);
                arrParam[3] = new SqlParameter("@size", movie.Size);
                arrParam[4] = new SqlParameter("@year", movie.Year);

                StringBuilder sbSPParams = new StringBuilder();
                foreach (var param in arrParam)
                {
                    sbSPParams.Append(param.ParameterName + ":" + param.Value + " & ");
                }
                sbSPParams.Remove(sbSPParams.Length - 3, 3);
                PlanetM_Utility.LogWrapper.LogInfo(string.Format("Executing SP:{0} Parameter Details>> {1}", StoredProcedure.AddNewMovieInPlanetM, sbSPParams.ToString()));
                SqlHelper.ExecuteNonQuery(m_Connection_String, CommandType.StoredProcedure, StoredProcedure.AddNewMovieInPlanetM, arrParam);
            }
            catch (Exception Ex)
            {
                objTrans.Rollback();
                PlanetM_Utility.LogWrapper.LogError(Ex);
                return false;
            }
            finally
            {
                myConnection.Close();
            }
            return true;
        }
Пример #5
0
 public bool DeleteMovie(Movie movie)
 {
     LogWrapper.LogInfo("Deleting movie from PlanetM.");
     return DBAObj.DeleteMovie(movie);
 }
Пример #6
0
 public bool AddNewMovie(Movie movie)
 {
     LogWrapper.LogInfo("Adding new movie in PlanetM.");
     return DBAObj.AddNewMovie(movie);
 }
Пример #7
0
 public bool UpdateMovieFromIMDB(string MovieName, string Language, Movie movie, byte[] poster)
 {
     LogWrapper.LogInfo("Updating movie details in MiniIMDB.");
     return DBAObj.UpdateMovieFromIMDB(MovieName, Language, movie, poster);
 }
Пример #8
0
 public bool UpdateMovieCover(Movie mov, byte[] pic)
 {
     LogWrapper.LogInfo("Updating movie cover in PlanetM.");
     return DBAObj.UpdateCover(mov, pic);
 }
Пример #9
0
 /// <summary>
 /// This is delegated function, runs in the primary-thread (i.e. the thread that owns the Form!)
 /// </summary>
 /// <param name="percentComplete"></param>
 /// <param name="progressStatus"></param>
 /// <param name="movObj"></param>
 /// <param name="iMovObj"></param>
 void UpdateImdbSyncProgressDetails(int percentComplete, bool progressStatus, Movie movObj, MovieIMDB iMovObj)
 {
     if (progressStatus == true)
     {
         labelChecksumProgress.Text = percentComplete.ToString() + "% complete! Processed Movie : " + movObj.Name;
         listBoxStatus.Items.Insert(0, string.Format("Processed Movie : {0}", movObj.Name));
         MovieIMDBDetails movIMDB = new MovieIMDBDetails(movObj, iMovObj);
         if (!movIMDB.IsDisposed)
             movIMDB.Show();
     }
     else
     {
         labelChecksumProgress.Text = percentComplete.ToString() + "% complete! Can not process Movie : " + movObj.Name;
         listBoxStatus.Items.Insert(0, string.Format("Can not process Movie : {0}", movObj.Name));
     }
     progressBar.Value = percentComplete;
     if (percentComplete == 100)
         syncWithIMDBToolStripMenuItem.Enabled = syncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncIMDB.Enabled = true;
 }
Пример #10
0
 public bool UpdateMovie(string MovieName, string Language, Movie movie)
 {
     LogWrapper.LogInfo("Updating movie details in PlanetM.");
     return DBAObj.UpdateMovie(MovieName, Language, movie);
 }
Пример #11
0
 public byte[] GetMovieCover(Movie mov)
 {
     LogWrapper.LogInfo("Retrieving movie cover in PlanetM.");
     return DBAObj.GetCover(mov);
 }
Пример #12
0
        public bool UpdateMovieFromIMDB(string MovieName, string Language, Movie movie, byte[] poster)
        {
            SqlTransaction objTrans = null;
            SqlConnection myConnection = new SqlConnection(m_Connection_String);
            try
            {
                myConnection.Open();
                objTrans = myConnection.BeginTransaction();
                SqlParameter[] arrParam = new SqlParameter[9];

                arrParam[0] = new SqlParameter("@name", MovieName);
                arrParam[1] = new SqlParameter("@language", Language);
                arrParam[2] = new SqlParameter("@newName", movie.Name);
                arrParam[3] = new SqlParameter("@newLanguage", movie.Language);
                arrParam[4] = new SqlParameter("@imdbID", movie.IMDBID);
                arrParam[5] = new SqlParameter("@imdbRating", movie.IMDBRating);
                arrParam[6] = new SqlParameter("@year", movie.Year);
                arrParam[7] = new SqlParameter("@cover", poster);
                StringBuilder Genre = new StringBuilder();
                foreach (string gen in movie.Genre)
                {
                    Genre.Append(gen + ",");
                }
                if (movie.Genre.Count != 0)
                    Genre.Remove(Genre.Length - 1, 1);
                arrParam[8] = new SqlParameter("@genre", Genre.ToString());

                StringBuilder sbSPParams = new StringBuilder();
                foreach (var param in arrParam)
                {
                    sbSPParams.Append(param.ParameterName + ":" + param.Value + " & ");
                }
                sbSPParams.Remove(sbSPParams.Length - 3, 3);
                PlanetM_Utility.LogWrapper.LogInfo(string.Format("Executing SP:{0} Parameter Details>> {1}", StoredProcedure.UpdateMovieInPlanetMFromMiniIMDB, sbSPParams.ToString()));
                SqlHelper.ExecuteNonQuery(m_Connection_String, CommandType.StoredProcedure, StoredProcedure.UpdateMovieInPlanetMFromMiniIMDB, arrParam);
            }
            catch (Exception Ex)
            {
                objTrans.Rollback();
                PlanetM_Utility.LogWrapper.LogError(Ex);
                return false;
            }
            finally
            {
                myConnection.Close();
            }
            return true;
        }
Пример #13
0
 public byte[] GetCover(Movie movie)
 {
     DataSet ds;
     DataRow myRow;
     SqlParameter[] arrParam = new SqlParameter[2];
     byte[] imageData = new byte[0];
     try
     {
         arrParam[0] = new SqlParameter("@name", movie.Name);
         arrParam[1] = new SqlParameter("@language", movie.Language);
         StringBuilder sbSPParams = new StringBuilder();
         foreach (var param in arrParam)
         {
             sbSPParams.Append(param.ParameterName + ":" + param.Value + " & ");
         }
         sbSPParams.Remove(sbSPParams.Length - 3, 3);
         PlanetM_Utility.LogWrapper.LogInfo(string.Format("Executing SP:{0} Parameter Details>> {1}", StoredProcedure.GetMovieCoverFromPlanetM, sbSPParams.ToString()));
         ds = SqlHelper.ExecuteDataset(m_Connection_String, CommandType.StoredProcedure, StoredProcedure.GetMovieCoverFromPlanetM, arrParam);
         myRow = ds.Tables[0].Rows[0];
         if (!myRow.IsNull(0))
             imageData = (byte[])myRow["Cover"];
     }
     catch (Exception Ex)
     {
         PlanetM_Utility.LogWrapper.LogError(Ex);
     }
     return imageData;
 }
Пример #14
0
        public List<Movie> getMoviesForFolder(string folderPath, string language)
        {
            movies.Clear();
            MoviePathInfo mPathInfo = new MoviePathInfo();
            mPathInfo.MoviePath = folderPath;
            mPathInfo.MovieLanguage = language;
            getMoviesForPath(mPathInfo);
            List<string> CDRoms = new List<string>();
            foreach (DriveInfo drive in DriveInfo.GetDrives())
            {
                if (drive.DriveType == DriveType.CDRom)
                    CDRoms.Add(drive.Name);
            }
            if (CDRoms.Contains(Path.GetPathRoot(folderPath)))
            {
                IEnumerable<FileInfo> movieFilesOnCDRom = from fileinf in
                                                              from file in Directory.GetFiles(folderPath)
                                                              select new FileInfo(file)
                                                          orderby fileinf.LastWriteTime descending
                                                          select fileinf;

                foreach (FileInfo moviefile in movieFilesOnCDRom)
                {
                    Movie mov = new Movie();
                    mov.Name = removeStopwordsFromMovName(Regex.Replace(moviefile.Name, moviefile.Extension, ""));
                    mov.Language = language;
                    mov.Location = moviefile.FullName;
                    mov.Size = (float)moviefile.Length / (1024 * 1024);
                    mov.Year = GetYearForMovie(mov.Name);
                    if (mov.Size >= 100)
                        movies.Add(mov);
                }
            }
            return movies;
        }
Пример #15
0
        public bool getMoviesForPath(MoviePathInfo moviePath)
        {
            bool success = false;
            try
            {
                if (Directory.Exists(moviePath.MoviePath))
                {
                    //string[] moviesInCurrentDirArray = Directory.GetDirectories(moviePath.MoviePath);
                    //DateTime[] modificationTimes = new DateTime[moviesInCurrentDirArray.Length];
                    //for (int i = 0; i < moviesInCurrentDirArray.Length; i++)
                    //    modificationTimes[i] = new DirectoryInfo(moviesInCurrentDirArray[i]).LastWriteTime;
                    //Array.Sort(modificationTimes, moviesInCurrentDirArray);
                    //List<string> moviesInCurrentDir = moviesInCurrentDirArray.Reverse().ToList();

                    List<string> moviesInCurrentDir = (from dir in
                                                           from e in Directory.GetDirectories(moviePath.MoviePath)
                                                           select new DirectoryInfo(e)
                                                       orderby dir.LastWriteTime descending
                                                       select dir.FullName).ToList();

                    moviesInCurrentDir.RemoveAll(ContainsSubDir);
                    foreach (string movieDir in moviesInCurrentDir)
                    {
                        try
                        {
                            Movie mov = new Movie();
                            mov.Name = removeStopwordsFromMovName(movieDir);
                            mov.Language = moviePath.MovieLanguage;
                            mov.Location = movieDir;
                            //mov.Checksum = GetMD5HashFromFile(movieDir);
                            mov.Size = (float)GetSizeForMovie(movieDir) / (1024 * 1024);
                            mov.Year = GetYearForMovie(mov.Name);
                            movies.Add(mov);
                            string[] CollectionWords = Configuration.GetConfigurationValues("CollectionGroupWords");
                            foreach (string collectionWord in CollectionWords)
                            {
                                if (mov.Name.Contains(collectionWord))
                                {
                                    Random rand = new Random();
                                    MoviePathInfo CollectionPath = new MoviePathInfo();
                                    CollectionPath.MoviePath = movieDir;
                                    CollectionPath.MovieLanguage = moviePath.MovieLanguage;
                                    CollectionPath.Order = rand.Next(1000, 2000);
                                    getMoviesForPath(CollectionPath);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogWrapper.LogError(ex);
                        }
                    }
                    success = true;
                }
            }
            catch (Exception ex)
            {
                LogWrapper.LogError(ex);
            }
            return success;
        }
Пример #16
0
        private void OpenSelectedMovie(string Name, string Language)
        {
            DataSet dtStMovie;
            Movie tmpMov = new Movie();
            tmpMov.Name = Name;
            tmpMov.Language = Language;
            dtStMovie = dbObj.GetMovieDetails(tmpMov.Name, tmpMov.Language);
            if (dtStMovie.Tables[0].Rows.Count != 0)
            {
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Year"))
                    tmpMov.Year = (int)dtStMovie.Tables[0].Rows[0]["Year"];
                tmpMov.IsWatched = (bool)dtStMovie.Tables[0].Rows[0]["Seen"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("SeenDate"))
                    tmpMov.WhenSeen = (DateTime)dtStMovie.Tables[0].Rows[0]["SeenDate"];
                tmpMov.Size = (float)(double)dtStMovie.Tables[0].Rows[0]["Size"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("MyRating"))
                    tmpMov.MyRating = (int)dtStMovie.Tables[0].Rows[0]["MyRating"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("IMDBRating"))
                    tmpMov.IMDBRating = (float)Convert.ToDouble(dtStMovie.Tables[0].Rows[0]["IMDBRating"]);
                if (!dtStMovie.Tables[0].Rows[0].IsNull("IMDBID"))
                    tmpMov.IMDBID = (string)dtStMovie.Tables[0].Rows[0]["IMDBID"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Quality"))
                    tmpMov.Quality = (string)dtStMovie.Tables[0].Rows[0]["Quality"];
                foreach (string genre in dtStMovie.Tables[0].Rows[0]["Genre"].ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                {
                    tmpMov.Genre.Add(genre);
                }
                foreach (DataRow dr in dtStMovie.Tables[0].Rows)
                {
                    tmpMov.Locations.Add(dr.Field<string>("Location"));
                    tmpMov.Checksums.Add(dr.Field<string>("Checksum"));
                    if (dr.Field<object>("LocationSize") != null)
                        tmpMov.LocationSize.Add((float)dr.Field<double>("LocationSize"));
                }

                MovieDetails fmmovie = new MovieDetails(tmpMov);
                fmmovie.Show();
            }
            else
                MessageHandler.ShowError("Refresh and try again!", "Error");
        }
Пример #17
0
 public bool UpdateMovieChecksum(Movie movie)
 {
     LogWrapper.LogInfo("Updating movie checksum in PlanetM.");
     return DBAObj.UpdateMovieChecksum(movie);
 }
Пример #18
0
        private void SyncSelectedMoviesFromIMDB()
        {
            // Set the delegate
            ImdbSyncDelegate = UpdateImdbSyncProgressDetails;
            if (dgMovies.SelectedRows.Count > 0)
            {
                List<Movie> movies = new List<Movie>();
                Movie mov;
                bool skipMovie;
                foreach (DataGridViewRow dgMov in dgMovies.SelectedRows)
                {
                    skipMovie = false;
                    mov = new Movie();
                    mov.Name = (string)dgMov.Cells["MovieName"].Value;
                    foreach (string collectionWord in Configuration.GetConfigurationValues("CollectionGroupWords"))
                    {
                        if (mov.Name.Contains(collectionWord))
                            skipMovie = true;
                    }
                    if (!skipMovie)
                    {
                        mov.Language = (string)dgMov.Cells["Language"].Value;
                        movies.Add(mov);
                    }
                    else if (skipMovie)
                    {
                        listBoxStatus.Items.Insert(0, string.Format("Movie : {0} is not eligible for syncing.", mov.Name));
                    }
                }
                if (movies.Count > 0)
                {
                    if (MessageBox.Show("Do you want to retrieve information from Internet?", "Connect to Internet?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        syncWithIMDBToolStripMenuItem.Enabled = syncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncIMDB.Enabled = false;
                        ImdbSyncThread = new Thread(new ParameterizedThreadStart(ImdbSyncBackgroundOperation));
                        ImdbSyncThread.Start(movies);
                    }
                }
                else
                    MessageBox.Show("No valid movies available for Synching !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                progressBar.Value = highestPercentageReached = 0;
                labelChecksumProgress.Text = "";
            }
            else
                MessageBox.Show("Please select few Movies from the available Movies !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }