Skip to content

Commit df1d135

Browse files
authored
ReadTrace post processing scripts added directly into sql nexus folder instead of generating dynamically (#473)
* #469 Inherit SQLScripts from Reporter and add hash for those Removed the invoke of Reporter for scripts Reformat scripts Add files to the project Add hash for these new scripts First set of modifications, this still needs additional testing. * #469 Correcting some typos on the Script #469 Correcting some typos on the Script * #469 final modifications and test +fixed minor typo issues +removed the GO at the end , it was messing up batch parser and causing a fake failure +Copilot confirmed old and new scripts are functionally same. "only differences are in formatting, capitalization, and comments for readability. There are no changes to the logic, structure, or output of any procedures or functions." +import tests
1 parent 5b52696 commit df1d135

File tree

5 files changed

+2855
-67
lines changed

5 files changed

+2855
-67
lines changed

ReadTraceNexusImporter/ReadTraceNexusImporter.cs

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ReadTraceNexusImporter : INexusImporter, INexusProgressReporter
3434
const string OPTION_ENABLE_MARS = "Enable -T35 to support MARs";
3535
const string OPTION_USE_LOCAL_SERVER_TIME = "Import events using local server time (not UTC)";
3636

37-
37+
3838
// Due to the batch flush levels for the BCP from ReadTrace these are often
3939
// going to be 0 until you exceed 1 million loaded. The progress for ReadTrace
4040
// has been updated some to help this display
@@ -108,7 +108,7 @@ private bool FindReadTraceExe()
108108

109109

110110

111-
111+
112112
if (readTracePath != null)
113113
{
114114
//Util.Logger.LogMessage("readtrace path " + FileVersionInfo.GetVersionInfo(readTracePath).ToString(), MessageOptions.Dialog);
@@ -134,7 +134,7 @@ private bool FindReadTraceExe()
134134
extractedOK = ExtractReadTraceReports();
135135
}
136136

137-
137+
138138
}
139139

140140
catch (Exception e)
@@ -190,43 +190,8 @@ public bool ExtractReadTraceReports()
190190
File.Delete(f);
191191

192192
}
193+
HasPostScript = true;
193194

194-
195-
196-
197-
Util.Logger.LogMessage("Report path " + reportPath);
198-
MethodInfo GetSetupSQLScript = type.GetMethod("GetSetupSQLScript");
199-
MethodInfo GetValidateSQLScript = type.GetMethod("GetValidateSQLScript");
200-
if (GetSetupSQLScript != null)
201-
{
202-
String setupscript = (string) GetSetupSQLScript.Invoke(null, null);
203-
String postScriptFile = reportPath + "ReadTracePostProcessing.sql";
204-
if (File.Exists (postScriptFile))
205-
File.Delete(postScriptFile);
206-
207-
StreamWriter sr = File.CreateText(postScriptFile);
208-
sr.Write(setupscript);
209-
sr.Flush();
210-
sr.Close();
211-
HasPostScript = true;
212-
213-
}
214-
bool HasValidateScript = false;
215-
string ValidateScriptName = "ReadTraceReportValidate.sql";
216-
if (GetValidateSQLScript != null)
217-
{
218-
HasValidateScript = true;
219-
String validateScriptString = (string) GetValidateSQLScript.Invoke(null, null);
220-
String validateScriptFile = reportPath + ValidateScriptName;
221-
if (File.Exists(validateScriptFile))
222-
File.Delete(validateScriptFile);
223-
StreamWriter sr = File.CreateText(validateScriptFile);
224-
sr.Write(validateScriptString);
225-
sr.Flush();
226-
sr.Close();
227-
228-
}
229-
230195
foreach (string key in dict.Keys)
231196
{
232197
XmlDocument doc = new XmlDocument();
@@ -236,20 +201,11 @@ public bool ExtractReadTraceReports()
236201
bool isChildReport = bool.Parse(n.Attributes["ischild"].Value);
237202
String reportDefinition = dict[key];
238203

239-
240204
XmlDocument reportDoc = new XmlDocument();
241205
reportDoc.LoadXml(reportDefinition);
242206
String reportExt = ".RDLC"; //(isChildReport ? ".RDLC" : ".RDL");
243207
String reportFullFileName = reportPath + reportName + reportExt;
244208
reportDoc.Save(reportFullFileName);
245-
if (HasValidateScript == true)
246-
{
247-
String validateXml = "<report><validate script=\"" + ValidateScriptName + "\"/></report>";
248-
XmlDocument validateDoc = new XmlDocument();
249-
validateDoc.LoadXml(validateXml);
250-
validateDoc.Save(reportFullFileName + ".xml");
251-
}
252-
253209

254210
}
255211
}
@@ -260,8 +216,6 @@ public bool ExtractReadTraceReports()
260216

261217
}
262218

263-
264-
265219
return ret;
266220
}
267221

@@ -331,10 +285,10 @@ private decimal GetLocalServerTimeOffset()
331285

332286

333287
private bool SkipFile(string FullFileName)
334-
{
288+
{
335289
bool ret = false;
336-
if (FullFileName.ToLower().EndsWith ("_blk.trc"))
337-
ret= true;
290+
if (FullFileName.ToLower().EndsWith("_blk.trc"))
291+
ret = true;
338292

339293
return ret;
340294

@@ -345,7 +299,7 @@ private bool SkipFile(string FullFileName)
345299
/// used instead of "ABC_sp_trace_15.trc").</remarks>
346300
private string FindFirstTraceFile(string[] files)
347301
{
348-
if (this.traceFileSpec.ToUpper().Contains("XEL"))
302+
if (this.traceFileSpec.ToUpper().Contains("XEL"))
349303
{
350304
return FileFirstXelFile(files);
351305
}
@@ -388,7 +342,7 @@ private string FileFirstXelFile(string[] files)
388342
{
389343
logger.LogMessage("Looking at file " + file);
390344
FileInfo fs = new FileInfo(file);
391-
DateTime CurrentFileCreateTime = fs.CreationTime;
345+
DateTime CurrentFileCreateTime = fs.CreationTime;
392346
if (CurrentFileCreateTime < LastFileCreateTime)
393347
{
394348
FirstFile = file;
@@ -472,12 +426,12 @@ public bool DoImport()
472426
Path.GetTempPath() + "RML", // -o{7} Temp output path (%TEMP%\RML)
473427
((bool)this.options[OPTION_IGNORE_PSSDIAG_HOST] ? "-H\"!PSSDIAG\"" : ""), // {8} Using 9.00.009 ReadTrace ignore events with HOST=PSSDIAG
474428
((bool)this.options[OPTION_DISABLE_EVENT_REQUIREMENTS] ? "-T28 -T29 " : ""), // {9} tell ReadTrace to override event requirement checks
475-
((bool)this.options[OPTION_ENABLE_MARS] ? "-T35":""), // {10} tell ReadTrace that there's MARS sessions
476-
((bool)this.options[OPTION_USE_LOCAL_SERVER_TIME] ? "-B"+timeAdjForLocalTimeMinutes : "") //{11} Optional: -B### Time bias: Adjusts the start and end times, as read by (+-)### minutes.
429+
((bool)this.options[OPTION_ENABLE_MARS] ? "-T35" : ""), // {10} tell ReadTrace that there's MARS sessions
430+
((bool)this.options[OPTION_USE_LOCAL_SERVER_TIME] ? "-B" + timeAdjForLocalTimeMinutes : "") //{11} Optional: -B### Time bias: Adjusts the start and end times, as read by (+-)### minutes.
477431
);
478432

479433
Util.Env["RMLLogDir"] = Path.GetTempPath() + "RML";
480-
434+
481435
Util.Env.ReadTraceLogFile = Path.GetTempPath() + @"RML\readtrace.log";
482436
Util.Logger.LogMessage("ReadTraceNexusImporter: Loading " + firstTrcFile);
483437
Util.Logger.LogMessage("ReadTraceNexusImporter: Temp Path: " + Path.GetTempPath());
@@ -627,12 +581,13 @@ public System.Windows.Forms.Form OptionsDialog
627581
/// <remarks>Scripts must be present in the host .exe's directory</remarks>
628582
public string[] PostScripts
629583
{ // No scripts needed by this importer
630-
get {
584+
get
585+
{
631586
if (HasPostScript == true)
632587
return new string[] { POST_LOAD_SQL_SCRIPT };
633588
else
634589
return new string[0];
635-
590+
636591
}
637592
}
638593

0 commit comments

Comments
 (0)