public static bool Parse()
{
Results.Clear();
OpenFileDialog dialog = new OpenFileDialog();
dialog.AddExtension = true;
dialog.Filter = "Script Log files (script.log)|script.log";
dialog.InitialDirectory = Program.opt.DefaultPOLPath.ToString();
if (dialog.ShowDialog() != DialogResult.OK)
{
MessageBox.Show("Error Reading Log File or no Log File Selected!");
return false;
}
StreamReader LogFile = File.OpenText(dialog.FileName.ToString());
ScriptLogParsed = dialog.FileName.ToString();
// LogLine is the text line read in
// We use a StringBuilder here to build the output for the text window.
string LogLine = "";
StringBuilder LogResults = new StringBuilder();
string ScriptName = "";
bool FindLST = false;
bool DupCheck = false;
while ((LogLine = LogFile.ReadLine()) != null)
{
// Ok, we need to check LST.
if (FindLST == true)
{
// We need to keep going until we find the ">" at the first position
if (LogLine.IndexOf(">") == 0)
{
// Ok, this is the line. Let's see if a Dup was detected.
if (DupCheck == true)
{
if (ContainsDup(LogLine))
{
// This IS a dup entry! BOOOOO
ScriptName = "";
FindLST = false;
DupCheck = false;
continue;
}
else
{
// This is NOT a Dup LST entry! Let's add everything now
LogResults.Append("Script: " + ScriptName);
LogResults.Append(Environment.NewLine);
LogResults.Append(".LST Line: " + LogLine.ToString());
LogResults.Append(Environment.NewLine);
LogResults.Append(Environment.NewLine);
AddScript(ScriptName, LogLine);
ScriptName = "";
}
}
else
{
LogResults.Append(LogLine);
LogResults.Append(Environment.NewLine);
LogResults.Append(Environment.NewLine);
AddScript(ScriptName, LogLine);
ScriptName = "";
}
FindLST = false;
DupCheck = false;
continue;
}
}
else
{
if (LogLine.IndexOf("Runaway script") != -1)
{
// We found a match!
LogLine = LogLine.Remove(0, (LogLine.IndexOf("]:") + 3));
LogLine = LogLine.Remove((LogLine.IndexOf(".ecl") + 4));
ScriptName = LogLine;
if (ContainsDup(ScriptName))
{
// HEY!!! We found a dup. Let's see if it's LST matches too!
FindLST = true;
DupCheck = true;
continue;
}
else
{
// Doesn't contain this script
LogResults.Append("Script: " + ScriptName);
LogResults.Append(Environment.NewLine);
LogResults.Append(".LST Line: ");
FindLST = true;
continue;
}
}
}
}
dialog.Dispose();
LogFile.Close();
return true;
}