public void ThreadManager() { AsyncTabPageEventArgs args = new AsyncTabPageEventArgs(0, ""); while (true) { for (int index = 0; index < _ta.Count(); index++) { args.CurrentTabIndex = index; if (_ta[index] != null) { if (_ta[index].ThreadState == System.Threading.ThreadState.Stopped) { BCPCommandCtrl par = (BCPCommandCtrl)_tabPages[index].Controls[0]; if (par.CurrentJobInfo.JobStatus == CommandStatus.Success || par.CurrentJobInfo.JobStatus == CommandStatus.Skip) { args.Show = false; UpdateTabHandler(args); _ta[index] = null; } } } args.Show = true; if (_ta[index] == null) { BCPJobInfo jobInfo = GetNextWaitingJob(); if (jobInfo != null) { args.DisplayText = jobInfo.TableName; args.CurrentTabIndex = index; jobInfo.CurrentThreadIndex = index; UpdateTabHandler(args); BCPCommandCtrl par = (BCPCommandCtrl)_tabPages[index].Controls[0]; par.CurrentJobInfo = jobInfo; ThreadStart ts = new System.Threading.ThreadStart(delegate() { StartUpload(par); }); _ta[index] = new Thread(ts); _ta[index].CurrentCulture = CultureInfo.CurrentCulture; _ta[index].CurrentUICulture = CultureInfo.CurrentUICulture; _ta[index].Start(); } } } Thread.Sleep(500); // Sleep for awhile and then look for more data to process if (AsyncProcessingStatus.FinishedAddingJobs && BCPJobsDone()) { break; } } args.RemoveTabs = true; UpdateTabHandler(args); AsyncProcessingStatus.FinishedProcessingJobs = true; }
private void btnSkip_Click(object sender, EventArgs e) { BCPCommandCtrl cmdCtrl = (BCPCommandCtrl)tabCtlUploadStatus.TabPages[tabCtlUploadStatus.SelectedIndex].Controls[0]; cmdCtrl.CurrentJobInfo.JobStatus = CommandStatus.Skip; AsyncBCPJobEventArgs args = new AsyncBCPJobEventArgs(tabCtlUploadStatus.TabPages[tabCtlUploadStatus.SelectedIndex], CommandStatus.Skip, cmdCtrl.Results, "", Color.Red); BCPAsyncUpdateResultsHandler(args); cmdCtrl.NotifyJobIsFinished(); }
private void btnRetry_Click(object sender, EventArgs e) { BCPCommandCtrl par = (BCPCommandCtrl)tabCtlUploadStatus.TabPages[tabCtlUploadStatus.SelectedIndex].Controls[0]; BCPJobInfo jobInfo = par.CurrentJobInfo; ThreadStart ts = new System.Threading.ThreadStart(delegate() { StartUpload(par); }); _ta[par.CurrentJobInfo.CurrentThreadIndex] = new Thread(ts); _ta[par.CurrentJobInfo.CurrentThreadIndex].Start(); }
private void btnEdit_Click(object sender, EventArgs e) { BCPCommandCtrl cmdCtrl = (BCPCommandCtrl)tabCtlUploadStatus.TabPages[tabCtlUploadStatus.SelectedIndex].Controls[0]; BCPJobInfo jobInfo = cmdCtrl.CurrentJobInfo; BCPCommandEditor editor = new BCPCommandEditor(jobInfo.NumberOfRows, jobInfo.BCPUploadCommand); if (editor.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { jobInfo.BCPUploadCommand = editor.BCPCommand; jobInfo.NumberOfRows = editor.NumberOfRows; } }
private BCPCommandCtrl GetBCPCommandCtrl() { BCPCommandCtrl bcc = new BCPCommandCtrl(); bcc.UpdateBCPJobStatus = new AsyncBCPJobUpdateStatus(BCPAsyncUpdateResultsHandler); bcc.Dock = System.Windows.Forms.DockStyle.Fill; bcc.Location = new System.Drawing.Point(3, 3); bcc.Name = "ctrl" + tabCtlUploadStatus.Controls.Count.ToString(); bcc.Size = new System.Drawing.Size(tabResults.Size.Width - 10, tabResults.Size.Height - 10); bcc.TabIndex = 0; return(bcc); }
public static void ThreadManager() { AsyncTabPageEventArgs args = new AsyncTabPageEventArgs(0, ""); while (true) { for (int index = 0; index < _ta.Count(); index++) { args.CurrentTabIndex = index; if (_ta[index] == null || _ta[index].ThreadState == ThreadState.Stopped) { BCPJobInfo jobInfo = GetNextWaitingJob(); if (jobInfo != null) { args.DisplayText = jobInfo.TableName; args.CurrentTabIndex = index; jobInfo.CurrentThreadIndex = index; BCPCommandCtrl bcc = new BCPCommandCtrl(); bcc.UpdateBCPJobStatus = new AsyncBCPJobUpdateStatus(BCPAsyncUpdateResultsHandler); bcc.CurrentJobInfo = jobInfo; _bcpWorkingCommand[index] = bcc; ThreadStart ts = new System.Threading.ThreadStart(delegate() { StartUpload(bcc); }); _ta[index] = new Thread(ts); _ta[index].CurrentCulture = CultureInfo.CurrentCulture; _ta[index].CurrentUICulture = CultureInfo.CurrentUICulture; _ta[index].Start(); } } } Thread.Sleep(500); // Sleep for awhile and then look for more data to process if (AsyncProcessingStatus.FinishedAddingJobs && BCPJobsDone()) { break; } } BCPAsyncUploadProcessDone(); AsyncProcessingStatus.FinishedProcessingJobs = true; }
private void tabCtlUploadStatus_SelectedIndexChanged(object sender, EventArgs e) { if (tabCtlUploadStatus.SelectedIndex == 0) { ResetBCPFailedButtions(CommandStatus.Success); } else { try { BCPCommandCtrl par = (BCPCommandCtrl)tabCtlUploadStatus.TabPages[tabCtlUploadStatus.SelectedIndex].Controls[0]; BCPJobInfo jobInfo = par.CurrentJobInfo; ResetBCPFailedButtions(jobInfo.JobStatus); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); ResetBCPFailedButtions(CommandStatus.Success); } } }
public static void StartUpload(object obj) { BCPCommandCtrl bcc = (BCPCommandCtrl)obj; bcc.ExecuteBCPCommand(); }