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; } }
void toolStripRequestCopy_Click(object sender, EventArgs e) { DataOperation.RequestCopy(repMovie, ref this.dataSource); }
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); } }