Skip to content

Commit 27a84b8

Browse files
committed
#35: Finalizing files generation.
1 parent 75f57fc commit 27a84b8

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

Solution/LanguageServer.Robot.Monitor/Controller/LanguageServerRobotMonitor.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,31 @@ public void PlayScenario()
628628
}
629629
}
630630

631+
/// <summary>
632+
/// Get the path of the LSR executable application.
633+
/// </summary>
634+
/// <returns></returns>
635+
private static string GetLSRExePath()
636+
{
637+
string defaultPath = Path.Combine(Settings.Default.LSRPath, Settings.Default.LSRExe);
638+
FileInfo LSRInfo = new FileInfo(defaultPath);
639+
if (!LSRInfo.Exists)
640+
{ //Using user setting we cannot find the LSR application ==> locate it in the current application location directory.
641+
string location = Assembly.GetExecutingAssembly().Location;
642+
Uri uri = new Uri(location);
643+
string localLocation = uri.LocalPath;
644+
FileInfo fi = new FileInfo(localLocation);
645+
string localDir = fi.DirectoryName;
646+
string monitorPath = Path.Combine(localDir, Settings.Default.LSRExe);
647+
LSRInfo = new FileInfo(monitorPath);
648+
if (LSRInfo.Exists)
649+
{
650+
defaultPath = LSRInfo.FullName;
651+
}
652+
}
653+
return defaultPath;
654+
}
655+
631656
/// <summary>
632657
/// Replays a scenario
633658
/// </summary>
@@ -661,7 +686,7 @@ private bool ReplayScenario(string scenario_path, Script scenario, out Result sc
661686
}
662687

663688
System.Diagnostics.Process process = new System.Diagnostics.Process();
664-
process.StartInfo.FileName = Path.Combine(Settings.Default.LSRPath, Settings.Default.LSRExe);
689+
process.StartInfo.FileName = GetLSRExePath();
665690
string arguments = string.Format(Settings.Default.LSRReplayArguments,
666691
Settings.Default.ServerPath, scenario_path);
667692
process.StartInfo.Arguments = arguments;
@@ -771,10 +796,11 @@ private void CreateTestFiles(Script scenario, String scenarioFile)
771796
{
772797
FileInfo fi = new FileInfo(scenarioFile);
773798
string basename = scenarioFile.Substring(0, scenarioFile.Length - fi.Extension.Length);
799+
string name = fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length);
774800
//Write the batch file
775801
using (FileStream stream = System.IO.File.Create(Path.Combine(fi.DirectoryName,basename + ".bat")))
776802
{
777-
string templ = string.Format(Settings.Default.BatchTemplate, basename, Settings.Default.LSRPath,
803+
string templ = string.Format(Settings.Default.BatchTemplate, name, Settings.Default.LSRPath,
778804
Settings.Default.ServerPath);
779805
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(templ);
780806
stream.Write(bytes, 0, bytes.Length);
@@ -910,10 +936,13 @@ private void CreateSnapshot(object sender, DocumentItemViewModel e, bool bLastSa
910936
snapshot.name = (new FileInfo(saveFileDialog.FileName)).Name;
911937
try
912938
{
939+
snapshot.uri = new Uri(saveFileDialog.FileName).ToString();
940+
FileInfo fi = new FileInfo(saveFileDialog.FileName);
941+
snapshot.name = fi.Name;
913942
using (FileStream stream = System.IO.File.Create(saveFileDialog.FileName))
914943
{
915944
snapshot.Write(stream);
916-
}
945+
}
917946
e.AddScenario(snapshot);
918947
//Write in backgound result files.
919948
Task testFile = new Task(() => CreateTestFiles(snapshot, saveFileDialog.FileName));

0 commit comments

Comments
 (0)