/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; CurrentWorkbook = new ExcelWorkbook(); if (CurrentWorkbook.Valid) { if (Framework.ReadProcess()) { int percentage = 100 / Framework.Process.TestCases.Count; Framework.Percentage = 0; Framework.TestCaseIndex = 1; worker.ReportProgress(Framework.Percentage); foreach (ExcelTest test in Framework.Process.TestCases) { if (worker.CancellationPending == true) { e.Cancel = true; break; } else { if (Framework.PutTestCase(test)) { Framework.TestCaseIndex++; } else { worker.CancelAsync(); statusform.Close(); System.Windows.Forms.MessageBox.Show("Error uploading testcase " + test.Name); } Framework.Percentage = Framework.Percentage + percentage; worker.ReportProgress(Framework.Percentage); } } } } if (Framework.Percentage < 100) { worker.CancelAsync(); statusform.Close(); System.Windows.Forms.MessageBox.Show("Error preparing upload.\n"); } }
public bool UploadProcess() { bool blnResult = false; CurrentWorkbook = new ExcelWorkbook(); if (CurrentWorkbook.Valid) { if (Framework.UploadTemplate()) { blnResult = true; } } return blnResult; }