Skip to content

Commit

Permalink
Merge pull request #106 from microsoft/Fixorama_ToddJo_Jan2021
Browse files Browse the repository at this point in the history
Merging all fixed into master
  • Loading branch information
gambit9009 authored Mar 27, 2021
2 parents a80d2f6 + 4cd8ff5 commit 52f0dba
Show file tree
Hide file tree
Showing 31 changed files with 1,907 additions and 1,279 deletions.
34 changes: 29 additions & 5 deletions NexusInterfaces/csql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ private void ReInit()
}
public void ExecuteSqlScript(String script)
{
string dlgTitle = "SQL Script Execution Failure";
ExecuteBatches(ParseBatches(script));

Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, ( (m_Success == true ) ? TraceEventType.Information: TraceEventType.Error));
Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, ( (m_Success == true ) ? TraceEventType.Information: TraceEventType.Error), dlgTitle);
}
private String[] ParseBatches(string scriptText)
{
Expand All @@ -70,9 +71,10 @@ public DataTable GetDataTable (string sql)
}
catch (Exception ex)
{
string dlgTitle = "Failed to Get DataTable";
m_Success = false;
m_ErrorMessages.AppendFormat("{0} \r\n", ex.ToString());
Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, (m_Success == true? TraceEventType.Information: TraceEventType.Error));
Util.Logger.LogMessage (m_ErrorMessages.ToString(), MessageOptions.Silent, (m_Success == true? TraceEventType.Information: TraceEventType.Error), dlgTitle);
throw ex;
}

Expand All @@ -81,7 +83,8 @@ public DataTable GetDataTable (string sql)
}
private void ExecuteBatches(string[] batches)
{

string batchText;
string upperBatchText;
SqlConnection conn = new SqlConnection(m_ConnStringBuilder.ConnectionString);
conn.InfoMessage += new SqlInfoMessageEventHandler(OnInfoMessage);
conn.Open(); //we want this exception to pop up when we can't make a connection
Expand All @@ -100,11 +103,32 @@ private void ExecuteBatches(string[] batches)
cmd.CommandText = bat;
cmd.Connection = conn;
cmd.CommandTimeout = 0;
cmd.ExecuteNonQuery();

//printing the fact that batch is being executed
if (String.IsNullOrEmpty(bat))
batchText = "Empty Batch";
else if (bat.Length <= 100)
batchText = bat;
else
batchText = bat.Substring(0, 100);

batchText = batchText.Replace("\r\n", " ");
batchText = batchText.Replace("*****", "*");
batchText = batchText.Replace(" ", " ");

upperBatchText = batchText.ToUpper();

int position = upperBatchText.IndexOf("OWNER:");
if (position > -1)
{
batchText = "'Script owner found in a comment here'";
}
m_ErrorMessages.AppendFormat("Starting execution of {0} \r\n", batchText);

SqlDataReader dr = cmd.ExecuteReader();
while (dr.NextResult())
{
m_ErrorMessages.AppendFormat("{0} \r\n", GetStringFromReader(dr));
m_ErrorMessages.AppendFormat("{0} \r\n", GetStringFromReader(dr));
}


Expand Down
4 changes: 2 additions & 2 deletions NexusInterfaces/interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TraceSource TraceLogger
void LogMessage(string msg);
void LogMessage(string msg, MessageOptions options);

void LogMessage(string msg, MessageOptions options, TraceEventType eventtype);
void LogMessage(string msg, MessageOptions options, TraceEventType eventtype, string title);
void LogMessage(string msg, string[] args);
void LogMessage(string msg, string[] args, MessageOptions options, TraceEventType eventtype);
void ClearMessage();
Expand Down Expand Up @@ -111,7 +111,7 @@ ImportState State // Host can check this to see current state
{
get;
}
bool Canceled // Will be set to true if the current import has been canceled
bool Cancelled // Will be set to true if the current import has been cancelled
{
get;
}
Expand Down
2 changes: 1 addition & 1 deletion NexusReports/Bottleneck Analysis_C.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,7 @@ ELSE
<ActionInfo>
<Actions>
<Action>
<Hyperlink>http://www.codeplex.com/sqlnexus</Hyperlink>
<Hyperlink>https://github.com/microsoft/SqlNexus</Hyperlink>
</Action>
</Actions>
</ActionInfo>
Expand Down
4 changes: 2 additions & 2 deletions NexusReports/Instructions.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<rd:DefaultName>textbox24</rd:DefaultName>
<ZIndex>4</ZIndex>
<Action>
<Hyperlink>http://www.codeplex.com/</Hyperlink>
<Hyperlink>https://github.com/microsoft/SqlNexus</Hyperlink>
</Action>
<Width>1.5in</Width>
<Style>
Expand Down Expand Up @@ -49,7 +49,7 @@
<Top>0.95833in</Top>
<ZIndex>2</ZIndex>
<Action>
<Hyperlink>http://www.codeplex.com/</Hyperlink>
<Hyperlink>https://github.com/microsoft/SqlNexus/issues</Hyperlink>
</Action>
<Width>1in</Width>
<Style>
Expand Down
14 changes: 7 additions & 7 deletions PerfmonImporter/BLGImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void Initialize(string Filemask, string connString, string Server, bool U

// Init status members
state = ImportState.Idle;
canceled = false;
cancelled = false;
knownRowsets = new ArrayList();
totalRowsInserted = 0;
totalLinesProcessed = 0;
Expand Down Expand Up @@ -138,16 +138,16 @@ public ImportState State
}
}

bool canceled = false;
public bool Canceled
bool cancelled = false;
public bool Cancelled
{
get
{
return canceled;
return cancelled;
}
set
{
canceled = value;
cancelled = value;
}
}

Expand Down Expand Up @@ -300,7 +300,7 @@ public bool DoImport()
//{
// throw new Exception ("Failed to generate reduced counter list.");
//}
if (canceled)
if (cancelled)
{
break;
}
Expand All @@ -313,7 +313,7 @@ public bool DoImport()

public void Cancel()
{
canceled = true;
cancelled = true;
}

public event EventHandler StatusChanged;
Expand Down
64 changes: 39 additions & 25 deletions ReadTraceNexusImporter/ReadTraceNexusImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,39 +89,53 @@ public ReadTraceNexusImporter()
/// <returns></returns>
private bool FindReadTraceExe()
{
readTracePath = Util.GetReadTraceExe();

Util.Logger.LogMessage(String.Format(@"ReadTraceNexusImporter: Discovered readtrace at {0} ", readTracePath));



bool extractedOK = true;
if (readTracePath != null)

try
{
//Util.Logger.LogMessage("readtrace path " + FileVersionInfo.GetVersionInfo(readTracePath).ToString(), MessageOptions.Dialog);
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(readTracePath);
readTracePath = Util.GetReadTraceExe();

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


//if (!(fvi.FileMajorPart >= 9 && fvi.FileMinorPart >= 3 && fvi.FileBuildPart >= 78))
if (CurrentVersion < RequiredVersion)


if (readTracePath != null)
{
Util.Logger.LogMessage("ReadTrace needs to be at least 9.3.78. Readtrace reports may fail. Please install latest RML utilities", MessageOptions.All);
Util.Logger.LogMessage("Readtrace is has a display issue, skipping extracting");

//Util.Logger.LogMessage("readtrace path " + FileVersionInfo.GetVersionInfo(readTracePath).ToString(), MessageOptions.Dialog);
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(readTracePath);

int MajorFactor = 1000000;
int MinorFactor = 1000;
int BuildFactor = 10;
int RequiredVersion = 9 * MajorFactor + 3 * MinorFactor + 78 * BuildFactor;
int CurrentVersion = fvi.FileMajorPart * MajorFactor + fvi.FileMinorPart * MinorFactor + fvi.FileBuildPart * BuildFactor;


//if (!(fvi.FileMajorPart >= 9 && fvi.FileMinorPart >= 3 && fvi.FileBuildPart >= 78))
if (CurrentVersion < RequiredVersion)
{
Util.Logger.LogMessage("ReadTrace needs to be at least 9.3.78. Readtrace reports may fail. Please install latest RML utilities", MessageOptions.All);
Util.Logger.LogMessage("Readtrace is has a display issue, skipping extracting");


}


extractedOK = ExtractReadTraceReports();
}


}

extractedOK = ExtractReadTraceReports();
catch (Exception e)
{
//string exception_message = e.Message;
//MessageBox.Show("There was a problem", "Title: Missing ReadTrace", MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
return (readTracePath != null) && extractedOK == true; ;


return (readTracePath != null) && extractedOK == true;

}

/// <summary>
Expand Down Expand Up @@ -354,7 +368,7 @@ private string FileFirstXelFile(string[] files)
/// the host will wait until <c>DoImport()</c> returns.</remarks>
public void Cancel()
{
Canceled = true;
Cancelled = true;
State = ImportState.Canceling;
Util.Logger.LogMessage("ReadTraceNexusImporter - Received cancel request");
try
Expand All @@ -372,7 +386,7 @@ public void Cancel()
}

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

public string Name
{
get { return "ReadTrace (SQL Profiler TRC Files)"; }
get { return "ReadTrace (SQL XEL/TRC Files)"; }
}

/// <summary>Set of true/false importer options (initialized in ctor)</summary>
Expand Down
2 changes: 1 addition & 1 deletion RowsetImportEngine/ErrorDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public virtual void Handle ()
if (this.isIgnorable)
msg += "\n\nDo you want to try to continue anyway?";
else
msg += "\n\nImport canceled.";
msg += "\n\nImport cancelled.";

buttons =
isIgnorable ?
Expand Down
Loading

0 comments on commit 52f0dba

Please sign in to comment.