private void btnAdd_Click(object sender, EventArgs e) { try { string path = txtRootPath.Text; if (Directory.Exists(path) == true) { long res = Movie_SP.RootPathInsert(path); if (res > 0) { txtRootPath.Text = ""; LoadRootPaths(); } } else { throw new Exception(Messages.InvalidTargetPath); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void mnuStripQuick_Click(object sender, EventArgs e) { try { DataTable dtMovie = new DataTable(); dtMovie = Movie_SP.SuggestRandom(1, "", 1900, 2100, 0, 10, "00:00:00", "10:00:00", false, null, null, enFilterType.Any, null, enFilterType.Any, null, enFilterType.Any, null, enFilterType.Any, null); Movie suggested = new Movie(); suggested.FetchSingleMovie(dtMovie); if (dtMovie.Rows.Count >= 1) { if (FormManager.IsFormOpen(enForms.frmMovie, suggested.MovieID) == false) { frmMovie movieTemp = new frmMovie(suggested.MovieID); movieTemp.Show(); } } else { MessageBox.Show(Messages.NoMovieFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mnuContextDeleteItem_Click(object sender, EventArgs e) { try { if (lstRootPath.SelectedIndex >= 0) { string name = lstRootPath.GetItemText(lstRootPath.SelectedItem); long id = Convert.ToInt64(lstRootPath.SelectedValue); if (MessageBox.Show(Messages.AreYouSureDeleteItem + Environment.NewLine + name, Messages.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { long result = Movie_SP.RootPathDelete(id); if (result > 0) { LoadRootPaths(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void mnuStripFavorite_Click(object sender, EventArgs e) { try { DataTable dtFavorite = new DataTable(); dtFavorite = Movie_SP.FavoriteGetList(); if (dtFavorite.Rows.Count > 0) { Movie[] favoriteMovies = new Movie[0]; favoriteMovies = Movie.FetchAllMovie(dtFavorite); if (FormManager.IsFormOpen(enForms.frmFavoriteMovieList, null) == false) { frmFavoriteMovieList favoriteTemp = new frmFavoriteMovieList(favoriteMovies); favoriteTemp.Show(); } } else { MessageBox.Show(Messages.FavoriteListEmpty, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mnuStripOfflineMovie_Click(object sender, EventArgs e) { try { DataTable dtAllMovie = new DataTable(); dtAllMovie = Movie_SP.GetOfflineList(); if (FormManager.IsFormOpen(enForms.frmOfflineMovieList, null) == false) { frmOfflineMovieList movieTemp = new frmOfflineMovieList(dtAllMovie); movieTemp.Show(); } else { foreach (Form frm in Application.OpenForms) { if (frm is frmOfflineMovieList) { frmOfflineMovieList availableForm = (frm as frmOfflineMovieList); availableForm.DataSource = dtAllMovie; break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static void SetFavoriteRate(int rate, DataRepeater repeater, ref Movie[] movieDataSource) { try { long count = 0; int index = repeater.CurrentItemIndex; int lastRate = movieDataSource[index].FavoriteRate; movieDataSource[index].FavoriteRate = rate; if (rate == 0) { count = Movie_SP.FavoriteDelete(movieDataSource[index].MovieID); } else { count = Movie_SP.FavoriteInsert(movieDataSource[index].MovieID, rate); } if (count >= 0) { repeater.BeginResetItemTemplate(); repeater.EndResetItemTemplate(); } else { movieDataSource[index].FavoriteRate = lastRate; } } catch (Exception ex) { throw ex; } }
private void btnMovieList_Click(object sender, EventArgs e) { try { DataTable dtAllMovie = new DataTable(); dtAllMovie = Movie_SP.GetList(false); Movie[] movie = new Movie[0]; movie = Movie.FetchAllMovie(dtAllMovie); if (FormManager.IsFormOpen(enForms.frmMovieList, null) == false) { frmMovieList movieTemp = new frmMovieList(dtAllMovie); movieTemp.Show(); } else { foreach (Form frm in Application.OpenForms) { if (frm is frmMovieList) { (frm as frmMovieList).DataSource = dtAllMovie; break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mnuStripGenerate_Click(object sender, EventArgs e) { try { if (this.dgvMovie.DataSource.Rows.Count > 0) { if (saveScript.ShowDialog() == DialogResult.OK) { DataTable dt = new DataTable(); dt = Movie_SP.RequestMovieCopyGetList(); InsertManager im = new InsertManager(false, false); string file = saveScript.FileName; bool a = im.GenerateCopyRequestScript(dt, file); if (a == true) { MessageBox.Show(Messages.ScriptGeneratedSuccessfuly, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Messages.ScriptGenerationFailed, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { throw new Exception(Messages.NoMovieToCopyScript); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static void SetIsSeen(bool isSeen, DataRepeater repeater, ref Movie[] movieDataSource) { try { long count = 0; int index = repeater.CurrentItemIndex; bool lastIsSeen = movieDataSource[index].IsSeen; movieDataSource[index].IsSeen = isSeen; count = Movie_SP.UpdateIsSeen(movieDataSource[index].MovieID, movieDataSource[index].IsSeen); if (count > 0) { repeater.BeginResetItemTemplate(); repeater.EndResetItemTemplate(); } else { movieDataSource[index].IsSeen = lastIsSeen; } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static void SetFavoriteRate(int favoriteRate, ref Movie movie, Label lblFavValue) { try { long count = 0; int lastRate = movie.FavoriteRate; movie.FavoriteRate = favoriteRate; if (favoriteRate == 0) { count = Movie_SP.FavoriteDelete(movie.MovieID); if (count >= 0) { lblFavValue.Text = "-"; } else { movie.FavoriteRate = lastRate; if (lastRate == 0) { lblFavValue.Text = "-"; } else { lblFavValue.Text = lastRate.ToString(); } } } else { count = Movie_SP.FavoriteInsert(movie.MovieID, favoriteRate); if (count > 0) { lblFavValue.Text = favoriteRate.ToString(); } else { movie.FavoriteRate = lastRate; if (lastRate == 0) { lblFavValue.Text = "-"; } else { lblFavValue.Text = lastRate.ToString(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void requestCopyToolStripMenuItem_Click(object sender, EventArgs e) { try { Movie_SP.RequestMovieCopyInsert(this.movieID); } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static void RequestCopy(DataRepeater repeater, ref Movie[] movieDataSource) { try { int index = repeater.CurrentItemIndex; Movie_SP.RequestMovieCopyInsert(movieDataSource[index].MovieID); } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void removeDirectorsToolStripMenuItem_Click(object sender, EventArgs e) { try { Movie_SP.DeleteAllMovieDirector(this.movieID); lblDirectorValue.Text = Messages.NotAvailable; repDirector.DataSource = null; } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mnuStripClearCache_Click(object sender, EventArgs e) { try { if (MessageBox.Show(Messages.DeleteCache, Messages.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Movie_SP.SuggestionCacheDelete(); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mnuStripDuplicate_Click(object sender, EventArgs e) { try { DataTable dtDuplicate = new DataTable(); dtDuplicate = Movie_SP.GetDuplicateListTradeOff(); this.ShowDuplicate(dtDuplicate); } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void LoadRootPaths() { try { iMovieBase.MovieRootPath = Movie_SP.RootPathGetList(); lstRootPath.DisplayMember = "PathString"; lstRootPath.ValueMember = "PathID"; lstRootPath.DataSource = iMovieBase.MovieRootPath; } catch (Exception ex) { throw ex; } }
private void btnClear_Click(object sender, EventArgs e) { try { if (MessageBox.Show(Messages.ClearCopyList, Messages.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Movie_SP.RequestMovieCopyDeleteAll(); this.dataSource.Rows.Clear(); this.dgvMovie.DataSource = this.dataSource; } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void frmMain_Load(object sender, EventArgs e) { try { dropPreset.SelectedIndex = 0; Thread SecondThread = new Thread( new ThreadStart(() => { try { DelHideSplash dlgVisible = new DelHideSplash(HideSplash); BeginInvoke(dlgVisible, false); if (base.SecondThread != null) { base.SecondThread.Join(); } try { iMovieBase.MovieRootPath = Movie_SP.RootPathGetList(); } catch (Exception ex) { } Thread.Sleep(1000); BeginInvoke(dlgVisible, true); return; } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } })); SecondThread.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void SetIsSeen(bool isSeen, ref Movie movie, PictureBox picIsSeen, ToolTip tip) { try { long count = 0; bool lastIsSeen = movie.IsSeen; movie.IsSeen = isSeen; count = Movie_SP.UpdateIsSeen(movie.MovieID, movie.IsSeen); if (count > 0) { if (isSeen == true) { picIsSeen.Image = global::iMovie.Properties.Resources.seen; tip.SetToolTip(picIsSeen, Messages.IsSeen); } else { picIsSeen.Image = global::iMovie.Properties.Resources.not_seen; tip.SetToolTip(picIsSeen, Messages.NotSeen); } } else { movie.IsSeen = lastIsSeen; if (lastIsSeen == true) { picIsSeen.Image = global::iMovie.Properties.Resources.seen; tip.SetToolTip(picIsSeen, Messages.IsSeen); } else { picIsSeen.Image = global::iMovie.Properties.Resources.not_seen; tip.SetToolTip(picIsSeen, Messages.NotSeen); } } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void copyRequestListToolStripMenuItem_Click(object sender, EventArgs e) { try { DataTable dtCopy = new DataTable(); dtCopy = Movie_SP.RequestMovieCopyGetList(); if (FormManager.IsFormOpen(enForms.frmCopyRequestList, null) == false) { frmCopyRequestList copy = new frmCopyRequestList(dtCopy); copy.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void mnuStripClearAllMovie_Click(object sender, EventArgs e) { try { if (MessageBox.Show(Messages.DeleteAllMovies.Replace("\n", Environment.NewLine), Messages.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { long r = 0; r = Movie_SP.DeleteAll(); if (r > 0) { mnuStripKeepMain_Click(sender, e); } } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void frmStatistics_Load(object sender, EventArgs e) { try { DataTable dtStats = new DataTable(); dtStats = Movie_SP.GetStatistics(); if (dtStats.Rows[0]["Value"].ToString() != null && dtStats.Rows[0]["Value"].ToString().Trim().Length > 0) { if (dtStats.Rows[0]["Value"].ToString().Contains(".") == true) { double avg = Convert.ToDouble(dtStats.Rows[0]["Value"].ToString()); lblRateValue.Text = avg.ToString("#.##"); } else { lblRateValue.Text = dtStats.Rows[0]["Value"].ToString(); } } else { lblRateValue.Text = "N/A"; } lblAllValue.Text = dtStats.Rows[7]["Value"].ToString(); lblWatchValue.Text = dtStats.Rows[3]["Value"].ToString(); lblDirectorValue.Text = dtStats.Rows[1]["Value"].ToString(); lblActorValue.Text = dtStats.Rows[2]["Value"].ToString(); lblCacheValue.Text = dtStats.Rows[5]["Value"].ToString(); lblFavValue.Text = dtStats.Rows[6]["Value"].ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Initialize() { try { DataSet dsMovie = new DataSet(); DataTable dtSimilar = new DataTable(); dsMovie = Movie_SP.GetDetailsByID(this.movieID); dtSimilar = Movie_SP.GetSimilarByID(this.movieID); this.movie.FetchSingleMovie(dsMovie.Tables[0]); this.director = Person.FetchAllPerson(dsMovie.Tables[1]); this.actor = dsMovie.Tables[2]; this.language = Language.FetchAllLanguage(dsMovie.Tables[3]); this.genre = Genre.FetchAllGenre(dsMovie.Tables[4]); this.similar = Movie.FetchAllMovie(dtSimilar); // Form Title this.Text = this.movie.FullTitle; // Summary switch (this.movie.Quality) { case enVideoQuality._1080p: picQuality.Image = global::iMovie.Properties.Resources._1080p; break; case enVideoQuality._720p: picQuality.Image = global::iMovie.Properties.Resources._720p; break; case enVideoQuality.DVD: picQuality.Image = global::iMovie.Properties.Resources.dvd; break; case enVideoQuality.Indeterminate: picQuality.Image = global::iMovie.Properties.Resources.na; break; case enVideoQuality.VCD: picQuality.Image = global::iMovie.Properties.Resources.vcd; break; default: picQuality.Image = global::iMovie.Properties.Resources.na; break; } if (this.movie.IsSeen == true) { this.tooltip.SetToolTip(this.picIsSeen, Messages.IsSeen); picIsSeen.Image = global::iMovie.Properties.Resources.seen; } else { this.tooltip.SetToolTip(this.picIsSeen, Messages.NotSeen); picIsSeen.Image = global::iMovie.Properties.Resources.not_seen; } string title = this.movie.FullTitle; lblMovieName.Text = title; lblRateValue.Text = this.movie.IMDBRate.ToString(); if (this.movie.FavoriteRate == 0) { lblFavValue.Text = "-"; } else { lblFavValue.Text = this.movie.FavoriteRate.ToString(); } if (File.Exists(PathUtils.GetApplicationMoviePosterPath() + this.movie.PosterLink) == true) { try { picPoster.Image = Image.FromFile(PathUtils.GetApplicationMoviePosterPath() + this.movie.PosterLink); } catch { // Do nothing for image that is corrupted } } int i = this.director.Length; int j = 0; if (i > 0) { lblDirectorValue.Text = ""; } foreach (Person dir in this.director) { lblDirectorValue.Text += dir.FullName; j++; if (j < i) { lblDirectorValue.Text += ", "; } } j = 0; i = this.genre.Length; if (i > 0) { lblGenreValue.Text = ""; } foreach (Genre gen in this.genre) { lblGenreValue.Text += gen.GenreName; j++; if (j < i) { lblGenreValue.Text += ", "; } } j = 0; i = this.language.Length; if (i > 0) { lblLanguageValue.Text = ""; } foreach (Language lan in this.language) { lblLanguageValue.Text += lan.LanguageName; j++; if (j < i) { lblLanguageValue.Text += ", "; } } lblDurationValue.Text = this.movie.Duration.ToString(); lblAddDateValue.Text = this.movie.AddDate.ToShortDateString(); // StoryLine lblStoryText.Text = movie.StoryLine; // Cast & Crew repDirector.DataSource = this.director; this.ucActorList.DtPersons = this.actor; this.ucActorList.PersonType = "Actor"; // Similar Movies repMovie.EnableRightClickMenu = iMovieBase.IsLogin; repMovie.DataSource = this.similar; } catch (Exception ex) { throw ex; } }
private void btnCopy_Click(object sender, EventArgs e) { try { string destination = txtCopy.Text; if (Directory.Exists(destination) == true) { DataTable dtMovies = Movie_SP.RequestMovieCopyGetList(); if (dtMovies.Rows.Count > 0) { btnCopy.Enabled = false; btnClear.Enabled = false; InsertManager im = new InsertManager(false, false); List <string> notFounded = new List <string>(); try { float size = im.CalculateSize(dtMovies, iMovieBase.MovieRootPath); if (MessageBox.Show("Size to copy is about: " + SizeUtils.GetSizeString(size, SizeModeEnum.HumanReadable) + Environment.NewLine + "Start copying?", "iMovie", MessageBoxButtons.OKCancel) == DialogResult.OK) { notFounded = im.CopyMovies(destination, dtMovies, iMovieBase.MovieRootPath); } } catch (Exception ex) { throw ex; } finally { this.dataSource = Movie_SP.RequestMovieCopyGetList(); dgvMovie.DataSource = dataSource; } if (notFounded.Count > 0) { MessageBox.Show(Messages.RemainingMoviesNotFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } btnCopy.Enabled = true; btnClear.Enabled = true; } else { throw new Exception(Messages.NoMovieToCopy); } } else { throw new Exception(Messages.SelectDestinationPath); } } catch (Exception ex) { btnCopy.Enabled = true; btnClear.Enabled = true; MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnQuick_Click(object sender, EventArgs e) { try { bool seen = chkSeen.Checked; bool notSeen = chkNotSeen.Checked; bool?fav = chkFavorite.Checked; int count = Convert.ToInt32(txtCount.Value); bool?isSeen = null; if (fav != true) { fav = null; } if (seen == true && notSeen == true) { isSeen = null; } else if (seen == true && notSeen == false) { isSeen = true; } else if (seen == false && notSeen == true) { isSeen = false; } else { isSeen = null; } double rateLow = 0; double rateHigh = 10; int productLow = 1900; int productHigh = 2100; string durationLow = "00:00:00"; string durationHigh = "20:00:00"; string[] qualityID = null; switch (dropPreset.SelectedIndex) { case 0: // All Movies break; case 1: // Top Movies qualityID = new string[] { "3", "4" }; rateLow = 8; break; case 2: // High Rated Movies rateLow = 7; break; case 3: // High Quality Movies qualityID = new string[] { "3", "4" }; break; case 4: // Recent Movies productLow = (DateTime.Now.Year - 3); productHigh = DateTime.Now.Year; break; case 5: // Old Movies productLow = 1901; productHigh = (DateTime.Now.Year - 40); break; case 6: // Short Movies durationHigh = "01:40:00"; break; case 7: // Long Movies durationLow = "02:15:00"; break; } DataTable dtMovies = new DataTable(); dtMovies = Movie_SP.SuggestRandom(count, "", productLow, productHigh, rateLow, rateHigh, durationLow, durationHigh, isSeen, fav, null, enFilterType.Any, null, enFilterType.Any, null, enFilterType.Any, null, enFilterType.Any, qualityID); Movie[] suggestedMovies = new Movie[0]; suggestedMovies = Movie.FetchAllMovie(dtMovies); if (suggestedMovies.Length == 1) { if (FormManager.IsFormOpen(enForms.frmMovie, suggestedMovies[0].MovieID) == false) { frmMovie movieTemp = new frmMovie(suggestedMovies[0].MovieID); movieTemp.Show(); } } else if (suggestedMovies.Length > 1) { if (FormManager.IsFormOpen(enForms.frmMovieSuggestList, suggestedMovies) == false) { frmMovieSuggestList suggestList = new frmMovieSuggestList(suggestedMovies); suggestList.Show(); } } else { MessageBox.Show(Messages.NoMovieFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { if (isRunning == false) { prgUpdate.Value = 0; int totals = 0; int updated = 0; int updateError = 0; lblMovie.Text = ""; if (DataOperation.IsConnected() == true) { bool ignore = chkIgnore.Checked; bool image = chkImage.Checked; bool rate = chkRate.Checked; bool link = chkLink.Checked; bool year = chkYear.Checked; bool duration = chkDuration.Checked; bool story = chkStory.Checked; bool genre = chkGenre.Checked; bool director = chkDirector.Checked; bool directorPhoto = chkDirectorPhoto.Checked; bool actor = chkActors.Checked; bool actorPhoto = chkActorPhoto.Checked; bool language = chkLanguage.Checked; DateTime?fromDate = null; DateTime?toDate = null; if (this.datePickFrom.Checked) { fromDate = this.datePickFrom.Value; } if (this.datePickTo.Checked) { toDate = this.datePickTo.Value; } DataTable dtMovies = new DataTable(); if (image == true || rate == true || link == true || year == true || duration == true || story == true || genre == true || director == true || directorPhoto == true || language == true || actor == true || actorPhoto == true) { string logName = "iMovie Update Log [" + Helper.GetShortDateTimeString().Replace(":", "-") + "].txt"; iMovieBase.log.Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), logName); dtMovies = Movie_SP.GetList(true, fromDate, toDate); Movie[] movieList = Movie.FetchAllMovie(dtMovies); prgUpdate.Maximum = movieList.Length; SecondThread = new Thread( new ThreadStart(() => { try { enUpdateResult result = enUpdateResult.UpdateError; int BannedIP = 0; int ConnectionLost = 0; int UpdateError = 0; isRunning = true; this.exitRequest = false; foreach (Movie m in movieList) { if (this.exitRequest == false) { totals++; DelegateName dlName = new DelegateName(GetCurrentName); BeginInvoke(dlName, "Updating: " + m.FullTitle); result = Movie_SP.UpdateOnline(m, image, rate, link, year, duration, story, genre, director, directorPhoto, language, actor, actorPhoto, ignore, true, false, null); if (result == enUpdateResult.Updated) { updated++; } else if (result == enUpdateResult.NotOpen || result == enUpdateResult.UpdateError) { updateError++; } if (result == enUpdateResult.NotOpen) { if (DataOperation.IsConnected() == true) { BannedIP++; ConnectionLost = 0; } else { ConnectionLost++; BannedIP = 0; } } if (result == enUpdateResult.UpdateError) { UpdateError++; } else if (result != enUpdateResult.NoNeedUpdate && result != enUpdateResult.UpdateError) { UpdateError = 0; } if (chkWarn.Checked == true) { if (UpdateError >= 20) { if (MessageBox.Show(Messages.CheckInternet.Replace(@"\n", Environment.NewLine).Replace("@NUM@", UpdateError.ToString()), Messages.MessageBoxTitle, MessageBoxButtons.RetryCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { this.exitRequest = true; } UpdateError = 0; } else if (ConnectionLost >= 8) { MessageBox.Show(Messages.NotConnected, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); ConnectionLost = 0; } else if (BannedIP >= 10) { if (MessageBox.Show(Messages.IPBanned.Replace(@"\n", Environment.NewLine).Replace("@NUM@", BannedIP.ToString()), Messages.MessageBoxTitle, MessageBoxButtons.RetryCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { this.exitRequest = true; } BannedIP = 0; } } RegistryManager.WriteValue(Helper.GetShortDateTimeString(m.AddDate), Messages.RootKey, Messages.SubKeyLastToArchiveDateTime); } else { break; } InvokeHandle(); } while (prgUpdate.Value < prgUpdate.Maximum) { InvokeHandle(); } DelegateName dlReset = new DelegateName(GetCurrentName); BeginInvoke(dlReset, ""); isRunning = false; this.exitRequest = false; iMovieBase.log.GenerateSilent("Total movies processed: " + totals.ToString() + Environment.NewLine + "Movies updated: " + updated.ToString() + Environment.NewLine + "Movies failed to update: " + updateError.ToString()); MessageBox.Show(Messages.UpdateComplete + Environment.NewLine + Messages.LogCreated + Environment.NewLine + logName, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } catch (Exception ex) { isRunning = false; exitRequest = false; DelegateName dlResetName = new DelegateName(GetCurrentName); BeginInvoke(dlResetName, ""); DelegateGeneral dlReset = new DelegateGeneral(ResetProgress); BeginInvoke(dlReset); iMovieBase.log.GenerateSilent("Total movies processed: " + totals.ToString() + Environment.NewLine + "Movies updated: " + updated.ToString() + Environment.NewLine + "Movies failed to update: " + updateError.ToString()); MessageBox.Show(Messages.UpdateError + Environment.NewLine + Messages.LogCreated + Environment.NewLine + ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } })); SecondThread.Start(); } else { MessageBox.Show(Messages.SelectValues, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(Messages.NotConnected, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(Messages.WaitForUpdate, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { prgUpdate.Value = 0; MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Initialize() { try { DataTable dtPerson = new DataTable(); DataTable dtMoviesActed = new DataTable(); DataTable dtMoviesDirected = new DataTable(); DataTable dtPersonType = new DataTable(); dtPerson = Person_SP.GetByID(this.personID); Person_SP.GetTypeByID(this.personID, out this.isActor, out this.isDirector); if (this.isDirector == true) { dtMoviesDirected = Movie_SP.GetByDirectorID(this.personID); } if (this.isActor == true) { dtMoviesActed = Movie_SP.GetByActorID(this.personID); } this.person.FetchSinglePerson(dtPerson); this.moviesDirected = Movie.FetchAllMovie(dtMoviesDirected); this.moviesActed = Movie.FetchAllMovie(dtMoviesActed); // Form Title this.Text = this.person.FullName; // Summary lblActorName.Text = this.person.FullName; if (File.Exists(PathUtils.GetApplicationPersonPath() + this.person.PhotoLink) == true) { try { picPhoto.Image = Image.FromFile(PathUtils.GetApplicationPersonPath() + this.person.PhotoLink); } catch { // Do nothing for image that is corrupted } } if (this.isActor == true && this.isDirector == true) { lblUp.Visible = true; lblUpValue.Visible = true; lblDown.Visible = true; lblDownValue.Visible = true; lblUp.Text = "Number of Movies Directed:"; lblDown.Text = "Number of Movies Acted:"; lblUpValue.Text = this.moviesDirected.Length.ToString(); lblDownValue.Text = this.moviesActed.Length.ToString(); } else if (this.isActor == true && this.isDirector == false) { lblUp.Visible = false; lblUpValue.Visible = false; lblDown.Visible = true; lblDownValue.Visible = true; lblUp.Text = ""; lblDown.Text = "Number of Movies Acted:"; lblUpValue.Text = ""; lblDownValue.Text = this.moviesActed.Length.ToString(); DataOperation.HideTabPage(tab, tabDirected); } else if (this.isActor == false && this.isDirector == true) { lblUp.Visible = false; lblUpValue.Visible = false; lblDown.Visible = true; lblDownValue.Visible = true; lblUp.Text = ""; lblDown.Text = "Number of Movies Directed:"; lblUpValue.Text = ""; lblDownValue.Text = this.moviesDirected.Length.ToString(); DataOperation.HideTabPage(tab, tabActed); } else { lblUp.Visible = false; lblUpValue.Visible = false; lblDown.Visible = false; lblDownValue.Visible = false; lblUp.Text = ""; lblDown.Text = ""; lblUpValue.Text = ""; lblDownValue.Text = ""; DataOperation.HideTabPage(tab, tabDirected); DataOperation.HideTabPage(tab, tabActed); } // Movies Directed repDirected.EnableRightClickMenu = iMovieBase.IsLogin; repDirected.DataSource = moviesDirected; // Movies Acted repActed.EnableRightClickMenu = iMovieBase.IsLogin; repActed.DataSource = moviesActed; } catch (Exception ex) { throw ex; } }
private void btnView_Click(object sender, EventArgs e) { try { enFilterType languageFilter = enFilterType.Any; if (radExactLanguage.Checked == true) { languageFilter = enFilterType.Exact; } enFilterType genreFilter = enFilterType.Any; if (radExactGenre.Checked == true) { genreFilter = enFilterType.Exact; } enFilterType directorFilter = enFilterType.Any; if (radExactDirector.Checked == true) { directorFilter = enFilterType.Exact; } enFilterType actorFilter = enFilterType.Any; if (radExactActor.Checked == true) { actorFilter = enFilterType.Exact; } int count = Convert.ToInt32(txtCount.Value); bool?isSeen = null; if (chkSeen.Checked == true && chkNotSeen.Checked == false) { isSeen = true; } else if (chkSeen.Checked == false && chkNotSeen.Checked == true) { isSeen = false; } bool?isFavorite = null; if (chkFavorite.Checked == true) { isFavorite = true; } double imdbLow = Convert.ToDouble(dropRateLow.SelectedItem); double imdbUp = Convert.ToDouble(dropRateUp.SelectedItem); int productLow = 1900; int productUp = DateTime.Now.Year; if (Movie.IsProductYear(txtProductLow.Text) == true) { productLow = Convert.ToInt32(txtProductLow.Text); } if (Movie.IsProductYear(txtProductUp.Text) == true) { productUp = Convert.ToInt32(txtProductUp.Text); } string durationLow = "00:00:00"; string durationUp = "20:00:00"; if (Movie.IsDuration(txtDurationLow.Text) == true) { durationLow = txtDurationLow.Text; } if (Movie.IsDuration(txtDurationUp.Text) == true) { durationUp = txtDurationUp.Text; } string movieName = txtMovieName.Text; string[] quality = chkQuality.SelectedID; if (quality.Length == 0 || chkQuality.SelectAll == true) { quality = null; } string[] language = chkLanguage.SelectedID; if (language.Length == 0 || chkLanguage.SelectAll == true) { language = null; } string[] genre = dgvGenre.SelectedID; if (genre.Length == 0 || dgvGenre.SelectAll == true) { genre = null; } string[] director = dgvDirector.SelectedID; if (director.Length == 0 || dgvDirector.SelectAll == true) { director = null; } string[] actor = dgvActor.SelectedID; if (actor.Length == 0 || dgvActor.SelectAll == true) { actor = null; } InsertManager insertManager = new InsertManager(false, false); List <Movie> excludedMovies = new List <Movie>(); foreach (PathSource pathSource in pathListBox.DataSource) { excludedMovies.AddRange(insertManager.GetMovieListFromPath(pathSource.PathString)); } List <Movie> duplicateMovies = new List <Movie>(); duplicateMovies = Movie_SP.GetDuplicateMoviesInSource(excludedMovies); DataTable dtMovies = Movie_SP.SuggestRandom(count, movieName, productLow, productUp, imdbLow, imdbUp, durationLow, durationUp, isSeen, isFavorite, director, directorFilter, actor, actorFilter, genre, genreFilter, language, languageFilter, quality, duplicateMovies); Movie[] suggestedMovies = new Movie[0]; suggestedMovies = Movie.FetchAllMovie(dtMovies); if (suggestedMovies.Length == 1) { if (FormManager.IsFormOpen(enForms.frmMovie, suggestedMovies[0].MovieID) == false) { frmMovie movieTemp = new frmMovie(suggestedMovies[0].MovieID); movieTemp.Show(); } } else if (suggestedMovies.Length > 1) { if (FormManager.IsFormOpen(enForms.frmMovieSuggestList, suggestedMovies) == false) { frmMovieSuggestList suggestList = new frmMovieSuggestList(suggestedMovies); suggestList.Show(); } } else { MessageBox.Show(Messages.NoMovieFound, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnInsert_Click(object sender, EventArgs e) { try { if (isRunning == false) { string path = txtRoot.Text; prgBatch.Value = 0; lblMovie.Text = ""; if (Directory.Exists(path) == true) { string[] folders = new string[0]; folders = Directory.GetDirectories(path); prgBatch.Maximum = folders.Length; string logName = "iMovie Insert Log [" + Helper.GetShortDateTimeString().Replace(":", "-") + "].txt"; iMovieBase.log.Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), logName); bool addRoot = chkAsRoot.Checked; bool includeIndividual = chkIndividual.Checked; SecondThread = new Thread( new ThreadStart(() => { try { isRunning = true; insertManager.ExitRequest = false; try { if (addRoot == true) { Movie_SP.RootPathInsert(path); } } catch (Exception ex) { } insertManager.InsertMovieBatch(path, includeIndividual, this); while (prgBatch.Value < prgBatch.Maximum) { InvokeHandle(); } InvokeHandle(""); isRunning = false; insertManager.ExitRequest = false; DelegateGeneral dlResetText = new DelegateGeneral(ResetPath); BeginInvoke(dlResetText); MessageBox.Show(Messages.InsertComplete + Environment.NewLine + Messages.LogCreated + Environment.NewLine + logName, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); RegistryManager.WriteValue(path, Messages.RootKey, Messages.SubKeyLastBatchInsertPath); return; } catch (Exception ex) { isRunning = false; insertManager.ExitRequest = false; DelegateGeneral dlReset = new DelegateGeneral(ResetProgress); BeginInvoke(dlReset); InvokeHandle(""); MessageBox.Show(Messages.InsertError + Environment.NewLine + Messages.LogCreated + Environment.NewLine + ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } })); SecondThread.Start(); } else { throw new Exception(Messages.InvalidTargetPath); } } else { MessageBox.Show(Messages.WaitForInsert, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { prgBatch.Value = 0; insertManager.ExitRequest = false; MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnInsert_Click(object sender, EventArgs e) { try { if (isRunning == false) { string path = txtRoot.Text; prgBatch.Value = 0; if (Directory.Exists(path) == true) { prgBatch.Maximum = 1; SecondThread = new Thread( new ThreadStart(() => { try { isRunning = true; insertManager.ExitRequest = false; enInsertResult result = insertManager.InsertMovieSingle(path); string messageResult = ""; switch (result) { case enInsertResult.AlreadyExisted: messageResult = "It seems that this movie has been already existed."; break; case enInsertResult.EmptyFolder: messageResult = "This folder does not have any movie files."; break; case enInsertResult.SuccessfullInsert: messageResult = "Movie inserted successfully."; break; default: messageResult = "Movie could not be inserted due to an error."; break; } while (prgBatch.Value < prgBatch.Maximum) { InvokeHandle(); } if (result == enInsertResult.SuccessfullInsert) { try { if (Path.GetDirectoryName(path) != null) { Movie_SP.RootPathInsert(Path.GetDirectoryName(path)); } else { Movie_SP.RootPathInsert(path); } } catch (Exception ex) { } } isRunning = false; insertManager.ExitRequest = false; DelegateGeneral dlResetText = new DelegateGeneral(ResetPath); BeginInvoke(dlResetText); MessageBox.Show(Messages.InsertComplete + Environment.NewLine + messageResult, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } catch (Exception ex) { isRunning = false; insertManager.ExitRequest = false; DelegateGeneral dlReset = new DelegateGeneral(ResetProgress); BeginInvoke(dlReset); MessageBox.Show(Messages.InsertError + Environment.NewLine + ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } })); SecondThread.Start(); } else { throw new Exception(Messages.InvalidTargetPath); } } else { MessageBox.Show(Messages.WaitForInsert, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { prgBatch.Value = 0; insertManager.ExitRequest = false; MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }