Esempio n. 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;
 }
Esempio n. 2
0
 /// <summary>
 /// Movie details will be retrieved from Internet based on URL.
 /// This will be used in Sync Operation in MiniIMDB
 /// </summary>
 /// <param name="movie"></param>
 public IMDBOperations(MovieIMDB movie)
 {
     LogWrapper.LogInfo(string.Format("Searching Movie with URL : {0}", movie.ImdbURL));
     iMov = movie;
     status = false;
     if (!string.IsNullOrEmpty(movie.ImdbURL))
     {
         string html = getUrlData(movie.ImdbURL + "combined");
         parseIMDbPage(html, false);
         string error;
         if (!string.IsNullOrWhiteSpace(iMov.ImdbID))
             SaveHtmlInBackup(html, iMov, out error);
     }
 }
        public bool AddNewMovieIMDB(MovieIMDB movie, byte[] poster)
        {
            SqlTransaction objTrans = null;
            SqlConnection myConnection = new SqlConnection(m_Connection_String);
            try
            {
                myConnection.Open();
                objTrans = myConnection.BeginTransaction();
                SqlParameter[] arrParam = new SqlParameter[23];

                arrParam[0] = new SqlParameter("@imdbID", movie.ImdbID);
                arrParam[1] = new SqlParameter("@title", movie.Title);
                arrParam[2] = new SqlParameter("@language", movie.Language);
                arrParam[3] = new SqlParameter("@year", movie.Year);
                arrParam[4] = new SqlParameter("@rating", movie.Rating);
                StringBuilder sb = new StringBuilder();
                foreach (string gen in movie.Genres)
                {
                    sb.Append(gen + ",");
                }
                if (movie.Genres.Count != 0)
                    sb.Remove(sb.Length - 1, 1);
                arrParam[5] = new SqlParameter("@genre", sb.ToString());
                arrParam[6] = new SqlParameter("@mpaaRating", movie.MpaaRating);
                arrParam[7] = new SqlParameter("@releaseDate", movie.ReleaseDate);
                arrParam[8] = new SqlParameter("@runtime", movie.Runtime);

                arrParam[9] = new SqlParameter("@tagline", movie.Tagline);
                arrParam[10] = new SqlParameter("@plot", movie.Plot);
                arrParam[11] = new SqlParameter("@storyline", movie.Storyline);

                arrParam[12] = new SqlParameter("@poster", poster);
                arrParam[13] = new SqlParameter("@posterURL", movie.PosterURL);
                arrParam[14] = new SqlParameter("@awards", movie.Awards);
                arrParam[15] = new SqlParameter("@nominations", movie.Nominations);
                arrParam[16] = new SqlParameter("@top250", movie.Top250);
                arrParam[17] = new SqlParameter("@oscars", movie.Oscars);
                arrParam[18] = new SqlParameter("@imdbURL", movie.ImdbURL);

                sb.Clear();
                foreach (string director in movie.Directors)
                {
                    sb.Append(director + "~");
                }
                if (movie.Directors.Count != 0)
                    sb.Remove(sb.Length - 1, 1);
                arrParam[19] = new SqlParameter("@directors", sb.ToString());
                sb.Clear();
                foreach (string star in movie.Stars)
                {
                    sb.Append(star + "~");
                }
                if (movie.Stars.Count != 0)
                    sb.Remove(sb.Length - 1, 1);
                arrParam[20] = new SqlParameter("@stars", sb.ToString());
                sb.Clear();
                foreach (string writer in movie.Writers)
                {
                    sb.Append(writer + "~");
                }
                if (movie.Writers.Count != 0)
                    sb.Remove(sb.Length - 1, 1);
                arrParam[21] = new SqlParameter("@writers", sb.ToString());
                sb.Clear();
                foreach (string cast in movie.Cast)
                {
                    sb.Append(cast + "~");
                }
                if (movie.Cast.Count != 0)
                    sb.Remove(sb.Length - 1, 1);
                arrParam[22] = new SqlParameter("@cast", sb.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.AddNewMovieInMiniIMDB, sbSPParams.ToString()));
                SqlHelper.ExecuteNonQuery(m_Connection_String, CommandType.StoredProcedure, StoredProcedure.AddNewMovieInMiniIMDB, arrParam);
            }
            catch (Exception Ex)
            {
                objTrans.Rollback();
                PlanetM_Utility.LogWrapper.LogError(Ex);
                return false;
            }
            finally
            {
                myConnection.Close();
            }
            return true;
        }
Esempio n. 4
0
 /// <summary>
 /// This constructor will be called when Syncing Movies from MiniIMDB
 /// </summary>
 /// <param name="iMovObj"></param>
 public MovieIMDBDetails(MovieIMDB iMovObj)
 {
     InitializeComponent();
     LoadControls();
     iMov = iMovObj;
     Language = iMov.Language;
     IsAvailableInDB = true;
     btnAddMovie.Text = "Update Movie";
 }
Esempio n. 5
0
 private void LoadMovieDataFromInternet(MovieIMDB movie)
 {
     IMDBOperations iOps = new IMDBOperations(movie);
     if (iOps.status == true)
     {
         iMov = iOps.iMov;
         DisplayIMovieData();
     }
 }
Esempio n. 6
0
 private void LoadMovieDataFromInternet(string movieNameKeywords)
 {
     IMDBOperations iOps = new IMDBOperations(movieNameKeywords);
     if (iOps.status == true)
     {
         iMov = iOps.iMov;
         if (mov != null)
             iMov.Language = mov.Language;
         DisplayIMovieData();
         btnAddMovie.Enabled = btnOpenInIE.Enabled = true;
     }
 }
Esempio n. 7
0
 private void LoadMovieDataFromInternet()
 {
     Regex regex = new Regex(@"(\.)|(-)|(\[)|(\])|(\s{2,})");
     string movieNameForSearch = regex.Replace(movieName, match =>
     {
         switch (match.ToString())
         {
             case ".":
             case "-":
             case "[":
             case "]":
                 return " ";
             case "  ":
             case "   ":
             case "    ":
                 return "";
         }
         return match.ToString();
     });
     IMDBOperations iOps = new IMDBOperations(movieNameForSearch);
     if (iOps.status == true)
     {
         iMov = iOps.iMov;
         iMov.Language = mov.Language;
     }
     else
     {
         this.Close();
         //MessageBox.Show("Error while getting information ! " + Environment.NewLine + iOps.errorMsg, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 8
0
        private void LoadMovieDataFromDB(string ImdbID)
        {
            DataSet dtStMovie;
            dtStMovie = dbObj.GetMovieDetailsFromIMDB(ImdbID);
            if (dtStMovie.Tables[0].Rows.Count == 1)
            {
                IsAvailableInDB = true;
                btnAddMovie.Text = "Update Movie";
                iMov = new MovieIMDB();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("IMDBID"))
                    iMov.ImdbID = (string)dtStMovie.Tables[0].Rows[0]["IMDBID"];
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Title"))
                    iMov.Title = dtStMovie.Tables[0].Rows[0]["Title"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Language"))
                    iMov.Language = dtStMovie.Tables[0].Rows[0]["Language"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Year"))
                    iMov.Year = dtStMovie.Tables[0].Rows[0]["Year"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Rating"))
                    iMov.Rating = (dtStMovie.Tables[0].Rows[0]["Rating"]).ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("MyRating"))
                    iMov.MyRating = (dtStMovie.Tables[0].Rows[0]["MyRating"]).ToString();
                iMov.Genres = new ArrayList();
                foreach (string genre in dtStMovie.Tables[0].Rows[0]["Genre"].ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                {
                    iMov.Genres.Add(genre);
                }

                if (!dtStMovie.Tables[0].Rows[0].IsNull("MPAARating"))
                    iMov.MpaaRating = dtStMovie.Tables[0].Rows[0]["MPAARating"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("ReleaseDate"))
                    iMov.ReleaseDate = string.Format("{0:d MMMM yyyy}", Convert.ToDateTime(dtStMovie.Tables[0].Rows[0]["ReleaseDate"]));
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Runtime"))
                    iMov.Runtime = dtStMovie.Tables[0].Rows[0]["Runtime"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Tagline"))
                    iMov.Tagline = dtStMovie.Tables[0].Rows[0]["Tagline"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Plot"))
                    iMov.Plot = dtStMovie.Tables[0].Rows[0]["Plot"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Storyline"))
                    iMov.Storyline = dtStMovie.Tables[0].Rows[0]["Storyline"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("PosterURL"))
                    iMov.PosterURL = dtStMovie.Tables[0].Rows[0]["PosterURL"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("IMDBURL"))
                    iMov.ImdbURL = dtStMovie.Tables[0].Rows[0]["IMDBURL"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Awards"))
                    iMov.Awards = dtStMovie.Tables[0].Rows[0]["Awards"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Nominations"))
                    iMov.Nominations = dtStMovie.Tables[0].Rows[0]["Nominations"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Top250"))
                    iMov.Top250 = dtStMovie.Tables[0].Rows[0]["Top250"].ToString();
                if (!dtStMovie.Tables[0].Rows[0].IsNull("Oscars"))
                    iMov.Oscars = dtStMovie.Tables[0].Rows[0]["Oscars"].ToString();

                if (!dtStMovie.Tables[0].Rows[0].IsNull("Poster"))
                {
                    MemoryStream stream = new MemoryStream((byte[])dtStMovie.Tables[0].Rows[0]["Poster"]);
                    if (stream.Capacity != 0)
                        iMov.Poster = Image.FromStream(stream);
                }

                iMov.Directors = new ArrayList();
                foreach (DataRow dr in dtStMovie.Tables[1].Rows)
                {
                    iMov.Directors.Add(dr.Field<string>("Director"));
                } iMov.Stars = new ArrayList();
                foreach (DataRow dr in dtStMovie.Tables[2].Rows)
                {
                    iMov.Stars.Add(dr.Field<string>("Star"));
                }

                iMov.Writers = new ArrayList();
                foreach (DataRow dr in dtStMovie.Tables[3].Rows)
                {
                    iMov.Writers.Add(dr.Field<string>("Writer"));
                }
                iMov.Cast = new ArrayList();
                foreach (DataRow dr in dtStMovie.Tables[4].Rows)
                {
                    iMov.Cast.Add(dr.Field<string>("Cast"));
                }
            }
            else
            {
                if (MessageBox.Show("Record not found in miniImdb for ID : " + ImdbID + Environment.NewLine + "Do you want to retrieve information from Internet?", "Connect to Internet?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    LoadMovieDataFromInternet();
                    btnDeleteMovie.Enabled = false;
                }
                else
                    this.Close();
            }
        }
Esempio n. 9
0
 public bool AddNewMovieIMDB(MovieIMDB movie, byte[] poster)
 {
     LogWrapper.LogInfo("Adding new movie in MiniIMDB.");
     return DBAObj.AddNewMovieIMDB(movie, poster);
 }
Esempio n. 10
0
        private void SyncSelectedMoviesFromIMDB(bool IsSilent)
        {
            if (MessageBox.Show("Do you want to retrieve information from Internet?", "Connect to Internet?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                LogWrapper.LogInfo("Execution started!");
                // Set the delegate
                if (IsSilent)
                    ImdbSyncDelegate = UpdateImdbSilentSyncProgressDetails;
                else
                    ImdbSyncDelegate = UpdateImdbSyncProgressDetails;

                if (dgMovies.SelectedRows.Count > 0)
                {
                    List<MovieIMDB> movies = new List<MovieIMDB>();
                    MovieIMDB mov;
                    foreach (DataGridViewRow dgMov in dgMovies.SelectedRows)
                    {
                        mov = new MovieIMDB();
                        mov.Title = (string)dgMov.Cells["Title"].Value;
                        mov.ImdbID = (string)dgMov.Cells["ImdbID"].Value;
                        mov.ImdbURL = "http://www.imdb.com/title/" + mov.ImdbID + "/";
                        mov.Language = (string)dgMov.Cells["Language"].Value;
                        movies.Add(mov);
                        LogWrapper.LogInfo(string.Format("Movie :: Title : {0}, ImdbID : {1}, Language : {2} >> selected for Sync Operation.", mov.Title, mov.ImdbID, mov.Language));
                    }

                    syncWithIMDBToolStripMenuItem.Enabled = syncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncIMDB.Enabled = false;
                    silentSyncWithIMDBToolStripMenuItem.Enabled = silentSyncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncSilentIMDB.Enabled = false;
                    ImdbSyncThread = new Thread(new ParameterizedThreadStart(ImdbSyncBackgroundOperation));
                    ImdbSyncThread.Start(movies);

                    highestPercentageReached = 0;
                    labelProgress.Text = "";
                }
                else
                    MessageBox.Show("Please select few Movies from the available Movies !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LogWrapper.LogInfo("Execution finished!");
            }
        }
Esempio n. 11
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="iMovObj"></param>
        void UpdateImdbSyncProgressDetails(int percentComplete, bool progressStatus, MovieIMDB iMovObj)
        {
            if (progressStatus == true)
            {
                labelProgress.Text = string.Format("iSync : {0}% complete! Processed Movie : {1}", percentComplete, iMovObj.Title);
                MovieIMDBDetails movIMDB = new MovieIMDBDetails(iMovObj);
                if (!movIMDB.IsDisposed)
                    movIMDB.Show();
            }
            else
                labelProgress.Text = string.Format("iSync : {0}% complete! Can not process Movie : {1}", percentComplete, iMovObj.Title);

            if (percentComplete == 100)
            {
                syncWithIMDBToolStripMenuItem.Enabled = syncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncIMDB.Enabled = true;
                silentSyncWithIMDBToolStripMenuItem.Enabled = silentSyncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncSilentIMDB.Enabled = true;
            }
        }
Esempio n. 12
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="iMovObj"></param>
        void UpdateImdbSilentSyncProgressDetails(int percentComplete, bool progressStatus, MovieIMDB iMovObj)
        {
            if (progressStatus == true)
            {
                byte[] bytes = new byte[0];
                if (iMovObj.Poster != null)
                {
                    MemoryStream stream = new MemoryStream();
                    //through the instruction below, we save the image to byte in the object "stream".
                    iMovObj.Poster.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    bytes = stream.ToArray();
                }
                if (dbObj.AddNewMovieIMDB(iMovObj, bytes))
                {
                    labelProgress.Text = string.Format("iSync : {0}% complete! Processed Movie : {1}", percentComplete, iMovObj.Title);
                }
                else
                {
                    labelProgress.Text = string.Format("iSync : {0}% complete! Can not process Movie : {1}", percentComplete, iMovObj.Title);
                }
            }
            else
                labelProgress.Text = string.Format("iSync : {0}% complete! Can not process Movie : {1}", percentComplete, iMovObj.Title);

            if (percentComplete == 100)
            {
                syncWithIMDBToolStripMenuItem.Enabled = syncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncIMDB.Enabled = true;
                silentSyncWithIMDBToolStripMenuItem.Enabled = silentSyncWithIMDBToolStripMenuItem1.Enabled = toolStripButtonSyncSilentIMDB.Enabled = true;
            }
        }
Esempio n. 13
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;
 }
Esempio n. 14
0
 private bool SaveHtmlInBackup(string html, MovieIMDB movie, out string error)
 {
     bool result = false;
     error = string.Empty;
     try
     {
         LogWrapper.LogInfo(string.Format("Creating IMDB HTML backup for Movie : {0}", movie.ImdbID));
         string backupDirectory = Configuration.ReadConfig("IMDB HTML Backup");
         if (!Directory.Exists(backupDirectory))
             Directory.CreateDirectory(backupDirectory);
         string backupFileName = string.Format("{0} - {1} ({2}) - {3}.html", movie.ImdbID, movie.Title, movie.Year, DateTime.Now.ToString("yyyyMMdd"));
         Regex regex = new Regex(string.Format("[{0}]", Regex.Escape(new string(Path.GetInvalidFileNameChars()))), RegexOptions.Compiled);
         backupFileName = regex.Replace(backupFileName, "");
         LogWrapper.LogInfo(string.Format("IMDB HTML backup file name is : {0}", backupFileName));
         backupFileName = Path.Combine(backupDirectory, backupFileName);
         if (File.Exists(backupFileName))
             File.Delete(backupFileName);
         File.WriteAllText(backupFileName, html);
         LogWrapper.LogInfo(string.Format("Created IMDB HTML backup file successfully : {0}", backupFileName));
         result = true;
     }
     catch (Exception ex)
     {
         error = ex.Message;
         LogWrapper.LogError(ex);
     }
     return result;
 }