1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| private void ExcelReviewController_Activated(object sender, EventArgs e)
{
ComManager.Dev_DebugMsg(DebugMsgPrefix.Event, MethodBase.GetCurrentMethod().DeclaringType.Name + "." + MethodBase.GetCurrentMethod().Name);
try
{
lblStatus.Text = "Please wait. Open Review...";
System.Windows.Forms.Application.DoEvents();
ComManager.Dev_DebugMsg("Start ExcelReviewProcess");
excelReview = new ExcelReview();
// Event Handler
excelReview.Closing += new ExcelReview.ReviewClosingEventHandler(excelReview_Closing);
excelReview.Closed += new ExcelReview.ReviewClosedEventHandler(excelReview_Closed);
excelReview.OpenReview(_FileName);
if (_isNewReview)
{
// Fill 'Config' sheet
excelReview.SelectWorksheet("Config");
excelReview.SetCellNameValue("LORFilename", "QualityCenter"); // Mark review file as saved at qc
// Fill 'Documentation' sheet
excelReview.SelectWorksheet("Documentation");
excelReview.GetCellFromName("majWorkProductType").RefersToRange.Select();
excelReview.SetCellNameValue("majWorkProductType", _ReviewType);
excelReview.SetCellNameValue("ReviewNumber", _BENumber);
excelReview.SetCellNameValue("Customer", _Customer);
excelReview.SetCellNameValue("Project", _Project);
excelReview.SetCellNameValue("ExObject", _ExaminationObject);
excelReview.SetCellNameValue("Author", _Author);
excelReview.SetCellNameValue("DateKickoffSmall", _StartDate);
excelReview.SetCellNameValue("DateKickoffSmall", _StartDate);
}
// TODO post link to Test Instance for email function at excel review
// TODO get TestSetId & TestInstanceID from qc
//td://<project>.<domain>.si0bos98:8080/qcbin/Test%20Lab?Action=FindTestInstance&TestSetID=<tsid>&TestInstanceID=<tstestid>
////string link = String.Format("td://{0}.{1}.si0bos98:8080/qcbin/Test%20Lab?Action=FindTestInstance&TestSetID={2}&TestInstanceID={3}");
////excelReview.SelectWorksheet("Config");
////excelReview.SetCellNameValue("QCFilename", link);
// Show Review
excelReview.ShowReview();
// Refresh Status
lblStatus.Text = "Review opened.";
System.Windows.Forms.Application.DoEvents();
// start auto saving
AutoSaveTimer.Start();
// bring excel on top
if (excelReview != null && excelReview.ExcelProcess != null)
{
Microsoft.VisualBasic.Interaction.AppActivate(excelReview.ExcelProcess.Id);
}
// Alternative for bringing excel window on top with Win32 API.
//[DllImport("user32.dll")]
// static extern bool SetForegroundWindow(IntPtr hWnd);
//SetForegroundWindow(foundProc.MainWindowHandle);
// Unregister Activated event because this will only be used for bringing excel window
// to top. This event will be fired after the FormLoad event where we unfortunatelly can't do this.
// So unregister is neccessary due the Activated event fires every time we hide and show the form.
this.Activated -= new EventHandler(ExcelReviewController_Activated);
active = true;
}
catch (Exception ex)
{
ComManager.Dev_DebugMsg(ex);
AutoSaveTimer.Stop();
excelReview_Closed(null);
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
ComManager.GetInstance().RemoveObjectReference<ExcelReviewController>();
}
} |