in sqlnexus/fmnexus.as.resource.cs [352:491]
private void fmNexus_Load(object sender, EventArgs e)
{
// Write our location to the registry so ReadTrace.exe can find us.
Registry.SetValue(REG_HKCU_APP_KEY, "InstallPath",
Path.GetDirectoryName(Application.ExecutablePath));
Registry.SetValue(REG_HKCU_APP_KEY2, "InstallPath",
Path.GetDirectoryName(Application.ExecutablePath));
//Undo weird effect where Windows gets confused because
//we're not flagged a GUI app
// TODO: have console detect whether it's minimized and pass this info to fmNexus so that
// fmNexus can preseve a minimized state (e.g. START /MIN sqlnexus.exe ...). Low priority.
this.WindowState = FormWindowState.Minimized;
Application.DoEvents();
this.WindowState = FormWindowState.Maximized;
MakeTaskPaneImagesTransparent();
SetupSpinners();
AutoHide (false);
Application.DoEvents();
ReportWrapper r = new ReportWrapper();
r.name = "Blocking Report";
r.topLevelReport=true;
r.reportDefinition = Properties.Resources.BlockingReport;
Globals.resourceReport.Add(r.name, r);
ReportWrapper r2 = new ReportWrapper();
r2.name = "Blocking Chain Detail_C";
r2.topLevelReport = false;
r2.reportDefinition = Properties.Resources.Blocking_Chain_Detail_C;
Globals.resourceReport.Add(r2.name, r2);
//Nuke image cache
if (0 != Directory.GetDirectories(Path.GetTempPath(), "sqlnexus").Length)
Directory.Delete(Path.GetTempPath() + "sqlnexus", true);
// InitializeLog(Application.StartupPath + @"\sqlnexus.log");
InitializeLog(@"%TEMP%\sqlnexus.log");
LogMessage("sqlnexus.exe running at: " + Application.ExecutablePath);
InitAppEnvironment();
// Kick off async (background) ClickOnce autoupdate check. Results of check will be
// written to the log file
clickOnce.TraceLogger = this.TraceLogger;
clickOnce.UpdateApplicationAsync();
if (!Globals.ConsoleMode)
{
try
{
// Check to see whether the user has already acknowledged the EULA
int regValEula = (int)Registry.GetValue(REG_HKCU_APP_KEY, "EulaAccepted", 0);
if (0 == regValEula)
{
DialogResult res = fmEula.ShowPrompt();
if (DialogResult.Yes == res)
{
LogMessage("EULA was accepted");
Registry.SetValue(REG_HKCU_APP_KEY, "EulaAccepted", 1, RegistryValueKind.DWord);
}
else
{
LogMessage("EULA was not accepted. Exiting.");
Application.Exit();
return;
}
}
}
catch (Exception ex)
{
LogMessage("Failed to show EULA. Exception: " + ex.ToString());
this.Close();
}
if (DialogResult.OK != ShowConnectionDlg())
{ // User clicked Cancel on connection dialog
Application.Exit();
return;
}
string inst=Globals.Server;
int i=inst.IndexOf('\\');
if (-1 != i)
{
inst = inst.Substring(i + 1);
}
else
{
inst = "(Default)";
}
UpdateSQLDiagInstance(inst);
if (false)
{
// PromptStartCollector();
}
}
Cursor save = StartWaiting();
try
{
try
{
EnumReports();
//// InitCollectorService();
if (Globals.ConsoleMode)
{
ProcessReportQueue();
// If we were passed /X, exit after importing data and exporting reports
if (Globals.ExitAfterProcessingReports)
Application.Exit();
}
else
{
//Select the first report if there is one
if (0 != tvReports.Nodes.Count)
tvReports.SelectedNode = tvReports.Nodes[0];
ShowHideUIElements();
Application.DoEvents();
//// UpdateServiceButtons();
}
}
catch (Exception ex)
{
Globals.HandleException(ex, this, this);
}
}
finally
{
StopWaiting(save);
}
}