Skip to content

Commit 52f0dba

Browse files
authored
Merge pull request #106 from microsoft/Fixorama_ToddJo_Jan2021
Merging all fixed into master
2 parents a80d2f6 + 4cd8ff5 commit 52f0dba

31 files changed

Lines changed: 1907 additions & 1279 deletions

NexusInterfaces/csql.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ private void ReInit()
4141
}
4242
public void ExecuteSqlScript(String script)
4343
{
44+
string dlgTitle = "SQL Script Execution Failure";
4445
ExecuteBatches(ParseBatches(script));
4546

46-
Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, ( (m_Success == true ) ? TraceEventType.Information: TraceEventType.Error));
47+
Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, ( (m_Success == true ) ? TraceEventType.Information: TraceEventType.Error), dlgTitle);
4748
}
4849
private String[] ParseBatches(string scriptText)
4950
{
@@ -70,9 +71,10 @@ public DataTable GetDataTable (string sql)
7071
}
7172
catch (Exception ex)
7273
{
74+
string dlgTitle = "Failed to Get DataTable";
7375
m_Success = false;
7476
m_ErrorMessages.AppendFormat("{0} \r\n", ex.ToString());
75-
Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, (m_Success == true? TraceEventType.Information: TraceEventType.Error));
77+
Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, (m_Success == true? TraceEventType.Information: TraceEventType.Error), dlgTitle);
7678
throw ex;
7779
}
7880

@@ -81,7 +83,8 @@ public DataTable GetDataTable (string sql)
8183
}
8284
private void ExecuteBatches(string[] batches)
8385
{
84-
86+
string batchText;
87+
string upperBatchText;
8588
SqlConnection conn = new SqlConnection(m_ConnStringBuilder.ConnectionString);
8689
conn.InfoMessage += new SqlInfoMessageEventHandler(OnInfoMessage);
8790
conn.Open(); //we want this exception to pop up when we can't make a connection
@@ -100,11 +103,32 @@ private void ExecuteBatches(string[] batches)
100103
cmd.CommandText = bat;
101104
cmd.Connection = conn;
102105
cmd.CommandTimeout = 0;
103-
cmd.ExecuteNonQuery();
106+
107+
//printing the fact that batch is being executed
108+
if (String.IsNullOrEmpty(bat))
109+
batchText = "Empty Batch";
110+
else if (bat.Length <= 100)
111+
batchText = bat;
112+
else
113+
batchText = bat.Substring(0, 100);
114+
115+
batchText = batchText.Replace("\r\n", " ");
116+
batchText = batchText.Replace("*****", "*");
117+
batchText = batchText.Replace(" ", " ");
118+
119+
upperBatchText = batchText.ToUpper();
120+
121+
int position = upperBatchText.IndexOf("OWNER:");
122+
if (position > -1)
123+
{
124+
batchText = "'Script owner found in a comment here'";
125+
}
126+
m_ErrorMessages.AppendFormat("Starting execution of {0} \r\n", batchText);
127+
104128
SqlDataReader dr = cmd.ExecuteReader();
105129
while (dr.NextResult())
106130
{
107-
m_ErrorMessages.AppendFormat("{0} \r\n", GetStringFromReader(dr));
131+
m_ErrorMessages.AppendFormat("{0} \r\n", GetStringFromReader(dr));
108132
}
109133

110134

NexusInterfaces/interfaces.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TraceSource TraceLogger
3030
void LogMessage(string msg);
3131
void LogMessage(string msg, MessageOptions options);
3232

33-
void LogMessage(string msg, MessageOptions options, TraceEventType eventtype);
33+
void LogMessage(string msg, MessageOptions options, TraceEventType eventtype, string title);
3434
void LogMessage(string msg, string[] args);
3535
void LogMessage(string msg, string[] args, MessageOptions options, TraceEventType eventtype);
3636
void ClearMessage();
@@ -111,7 +111,7 @@ ImportState State // Host can check this to see current state
111111
{
112112
get;
113113
}
114-
bool Canceled // Will be set to true if the current import has been canceled
114+
bool Cancelled // Will be set to true if the current import has been cancelled
115115
{
116116
get;
117117
}

NexusReports/Bottleneck Analysis_C.rdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ ELSE
20872087
<ActionInfo>
20882088
<Actions>
20892089
<Action>
2090-
<Hyperlink>http://www.codeplex.com/sqlnexus</Hyperlink>
2090+
<Hyperlink>https://github.com/microsoft/SqlNexus</Hyperlink>
20912091
</Action>
20922092
</Actions>
20932093
</ActionInfo>

NexusReports/Instructions.rdl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<rd:DefaultName>textbox24</rd:DefaultName>
1414
<ZIndex>4</ZIndex>
1515
<Action>
16-
<Hyperlink>http://www.codeplex.com/</Hyperlink>
16+
<Hyperlink>https://github.com/microsoft/SqlNexus</Hyperlink>
1717
</Action>
1818
<Width>1.5in</Width>
1919
<Style>
@@ -49,7 +49,7 @@
4949
<Top>0.95833in</Top>
5050
<ZIndex>2</ZIndex>
5151
<Action>
52-
<Hyperlink>http://www.codeplex.com/</Hyperlink>
52+
<Hyperlink>https://github.com/microsoft/SqlNexus/issues</Hyperlink>
5353
</Action>
5454
<Width>1in</Width>
5555
<Style>

PerfmonImporter/BLGImporter.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void Initialize(string Filemask, string connString, string Server, bool U
8080

8181
// Init status members
8282
state = ImportState.Idle;
83-
canceled = false;
83+
cancelled = false;
8484
knownRowsets = new ArrayList();
8585
totalRowsInserted = 0;
8686
totalLinesProcessed = 0;
@@ -138,16 +138,16 @@ public ImportState State
138138
}
139139
}
140140

141-
bool canceled = false;
142-
public bool Canceled
141+
bool cancelled = false;
142+
public bool Cancelled
143143
{
144144
get
145145
{
146-
return canceled;
146+
return cancelled;
147147
}
148148
set
149149
{
150-
canceled = value;
150+
cancelled = value;
151151
}
152152
}
153153

@@ -300,7 +300,7 @@ public bool DoImport()
300300
//{
301301
// throw new Exception ("Failed to generate reduced counter list.");
302302
//}
303-
if (canceled)
303+
if (cancelled)
304304
{
305305
break;
306306
}
@@ -313,7 +313,7 @@ public bool DoImport()
313313

314314
public void Cancel()
315315
{
316-
canceled = true;
316+
cancelled = true;
317317
}
318318

319319
public event EventHandler StatusChanged;

ReadTraceNexusImporter/ReadTraceNexusImporter.cs

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,39 +89,53 @@ public ReadTraceNexusImporter()
8989
/// <returns></returns>
9090
private bool FindReadTraceExe()
9191
{
92-
readTracePath = Util.GetReadTraceExe();
93-
94-
Util.Logger.LogMessage(String.Format(@"ReadTraceNexusImporter: Discovered readtrace at {0} ", readTracePath));
95-
96-
97-
9892
bool extractedOK = true;
99-
if (readTracePath != null)
93+
94+
try
10095
{
101-
//Util.Logger.LogMessage("readtrace path " + FileVersionInfo.GetVersionInfo(readTracePath).ToString(), MessageOptions.Dialog);
102-
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(readTracePath);
96+
readTracePath = Util.GetReadTraceExe();
10397

104-
int MajorFactor = 1000000;
105-
int MinorFactor = 1000;
106-
int BuildFactor = 10;
107-
int RequiredVersion = 9 * MajorFactor + 3 * MinorFactor + 78 * BuildFactor;
108-
int CurrentVersion = fvi.FileMajorPart * MajorFactor + fvi.FileMinorPart * MinorFactor + fvi.FileBuildPart * BuildFactor;
98+
Util.Logger.LogMessage(String.Format(@"ReadTraceNexusImporter: Discovered readtrace at {0} ", readTracePath));
10999

110100

111-
//if (!(fvi.FileMajorPart >= 9 && fvi.FileMinorPart >= 3 && fvi.FileBuildPart >= 78))
112-
if (CurrentVersion < RequiredVersion)
101+
102+
103+
if (readTracePath != null)
113104
{
114-
Util.Logger.LogMessage("ReadTrace needs to be at least 9.3.78. Readtrace reports may fail. Please install latest RML utilities", MessageOptions.All);
115-
Util.Logger.LogMessage("Readtrace is has a display issue, skipping extracting");
116-
105+
//Util.Logger.LogMessage("readtrace path " + FileVersionInfo.GetVersionInfo(readTracePath).ToString(), MessageOptions.Dialog);
106+
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(readTracePath);
107+
108+
int MajorFactor = 1000000;
109+
int MinorFactor = 1000;
110+
int BuildFactor = 10;
111+
int RequiredVersion = 9 * MajorFactor + 3 * MinorFactor + 78 * BuildFactor;
112+
int CurrentVersion = fvi.FileMajorPart * MajorFactor + fvi.FileMinorPart * MinorFactor + fvi.FileBuildPart * BuildFactor;
113+
114+
115+
//if (!(fvi.FileMajorPart >= 9 && fvi.FileMinorPart >= 3 && fvi.FileBuildPart >= 78))
116+
if (CurrentVersion < RequiredVersion)
117+
{
118+
Util.Logger.LogMessage("ReadTrace needs to be at least 9.3.78. Readtrace reports may fail. Please install latest RML utilities", MessageOptions.All);
119+
Util.Logger.LogMessage("Readtrace is has a display issue, skipping extracting");
117120

121+
122+
}
123+
124+
125+
extractedOK = ExtractReadTraceReports();
118126
}
119127

128+
129+
}
120130

121-
extractedOK = ExtractReadTraceReports();
131+
catch (Exception e)
132+
{
133+
//string exception_message = e.Message;
134+
//MessageBox.Show("There was a problem", "Title: Missing ReadTrace", MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
122135
}
123-
return (readTracePath != null) && extractedOK == true; ;
124-
136+
137+
return (readTracePath != null) && extractedOK == true;
138+
125139
}
126140

127141
/// <summary>
@@ -354,7 +368,7 @@ private string FileFirstXelFile(string[] files)
354368
/// the host will wait until <c>DoImport()</c> returns.</remarks>
355369
public void Cancel()
356370
{
357-
Canceled = true;
371+
Cancelled = true;
358372
State = ImportState.Canceling;
359373
Util.Logger.LogMessage("ReadTraceNexusImporter - Received cancel request");
360374
try
@@ -372,7 +386,7 @@ public void Cancel()
372386
}
373387

374388
/// <summary>True if the import has been asked to cancel an in-progress load. Set by the <c>Cancel</c> method.</summary>
375-
public bool Canceled
389+
public bool Cancelled
376390
{
377391
get { return canceled; }
378392
set { canceled = value; }
@@ -528,7 +542,7 @@ public ArrayList KnownRowsets
528542

529543
public string Name
530544
{
531-
get { return "ReadTrace (SQL Profiler TRC Files)"; }
545+
get { return "ReadTrace (SQL XEL/TRC Files)"; }
532546
}
533547

534548
/// <summary>Set of true/false importer options (initialized in ctor)</summary>

RowsetImportEngine/ErrorDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public virtual void Handle ()
5757
if (this.isIgnorable)
5858
msg += "\n\nDo you want to try to continue anyway?";
5959
else
60-
msg += "\n\nImport canceled.";
60+
msg += "\n\nImport cancelled.";
6161

6262
buttons =
6363
isIgnorable ?

0 commit comments

Comments
 (0)