private void ReadInstanceTraces(Dictionary<string, TraceInfo> instances)
{
foreach (var instance in instances)
{
// has the trace been read already
if (instance.Value.TraceRead) continue;
// read the second last written trace, the last one is still in use by sql server
var fileNumberToRead = instance.Value.MaxFileNumber - 1;
if (fileNumberToRead < 0) continue;
DebugHelper.LogEntry(_eventLog, string.Format("Read instance trace: {0}", instance.Key));
var filename = string.Format(string.Format("{0}\\graphdat_{1}{2}{3}.trc",
_workDirectory,
instance.Key,
fileNumberToRead > 0 ? "_" : "",
fileNumberToRead > 0 ? fileNumberToRead.ToString() : ""));
// does the file still exist
if (!File.Exists(filename)) continue;
// read the trace
ReadTraceFile(filename);
instance.Value.TraceRead = true;
}
}