Skip to content

Commit 75f57fc

Browse files
committed
#35: Adding -td options for the Server.
1 parent b1533d5 commit 75f57fc

File tree

8 files changed

+137
-23
lines changed

8 files changed

+137
-23
lines changed

Solution/LanguageServer.Robot.Common/Controller/LanguageServerRobotController.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public IDataConnection MonitorConnection
6666
private set;
6767
}
6868

69+
/// <summary>
70+
/// Server Option sif any.
71+
/// </summary>
72+
public string ServerOptions
73+
{
74+
get; set;
75+
}
76+
6977
/// <summary>
7078
/// Timeoout to wait for the Monitor Application to establish the connection : 30s == 10000ms
7179
/// </summary>
@@ -427,7 +435,10 @@ private bool StartMonitor()
427435
string local_dir = fi.DirectoryName;
428436
string monitor_path = Path.Combine(local_dir, LSR_MONITOR_EXE);
429437
string monitor_argument = string.Format("-pipe \"{0}\"", pipeName);
430-
438+
if (ServerOptions != null)
439+
{
440+
monitor_argument += " -so \"" + ServerOptions + "\"";
441+
}
431442
this.MonitorProcess = new System.Diagnostics.Process();
432443
this.MonitorProcess.StartInfo.FileName = monitor_path;
433444
this.MonitorProcess.StartInfo.Arguments = monitor_argument;
@@ -767,12 +778,14 @@ public virtual void FromServer(string message)
767778
/// <param name="script_path">The path of the script to replay</param>
768779
/// <param name="script">The script model to replay</param>
769780
/// <param name="serverPath">The Server's path</param>
781+
/// <param name="serverOptions">The Server's options</param>
770782
/// <param name="scriptRepositoryPath">The script repository path</param>
771783
/// <returns>0 if no error -1 otherwise.</returns>
772-
public static int ReplayScript(string script_path, Script script, string serverPath, string scriptRepositoryPath)
784+
public static int ReplayScript(string script_path, Script script, string serverPath, string serverOptions, string scriptRepositoryPath)
773785
{
774786
var server = new ServerRobotConnectionController(new ProcessMessageConnection(serverPath));
775787
var robot = new LanguageServerRobotController(script_path, script, server, scriptRepositoryPath);
788+
robot.ServerOptions = serverOptions;
776789
robot.PropagateConnectionLogs();
777790
if (!robot.Start())
778791
{
@@ -791,9 +804,10 @@ public static int ReplayScript(string script_path, Script script, string serverP
791804
/// <param name="session_path">The path of the session to replay</param>
792805
/// <param name="session">The session model to replay</param>
793806
/// <param name="serverPath">The Server's path</param>
807+
/// <param name="serverOptions">The Server's options</param>
794808
/// <param name="scriptRepositoryPath">The script repository path</param>
795809
/// <returns>0 if no error -1 otherwise.</returns>
796-
public static int ReplaySession(string session_path, Session session, string serverPath, string scriptRepositoryPath)
810+
public static int ReplaySession(string session_path, Session session, string serverPath, string serverOptions, string scriptRepositoryPath)
797811
{
798812
bool bResult = true;
799813
foreach (string scriptPath in session.scripts)
@@ -803,7 +817,7 @@ public static int ReplaySession(string session_path, Session session, string ser
803817
bool bValid = Util.ReadScriptFile(scriptPath, out script, out exc);
804818
if (bValid)
805819
{
806-
if (ReplayScript(scriptPath, script, serverPath, scriptRepositoryPath) != 0)
820+
if (ReplayScript(scriptPath, script, serverPath, serverOptions, scriptRepositoryPath) != 0)
807821
{
808822
bResult = false;
809823
}

Solution/LanguageServer.Robot.Monitor/App.config

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,71 @@
1313
</startup>
1414
<applicationSettings>
1515
<LanguageServer.Robot.Monitor.Settings>
16+
<setting name="ServerPath" serializeAs="String">
17+
<value>C:\TypeCobol\Sources\##Latest_Release##</value>
18+
</setting>
19+
<setting name="LSRPath" serializeAs="String">
20+
<value>C:\TypeCobol\Sources\##Latest_Release##</value>
21+
</setting>
22+
<setting name="ScriptPath" serializeAs="String">
23+
<value>C:\TypeCobol\Sources\LSRSession</value>
24+
</setting>
25+
<setting name="BatchTemplate" serializeAs="String">
26+
<value>@ECHO OFF
27+
SET TEST_NAME=$1
28+
SET PATH_TEST=%~dp0
29+
SET LSR_EXE=$2\LanguageServerRobot.exe
30+
SET LSP_EXE=$3\TypeCobol.LanguageServer.exe
31+
DEL %PATH_TEST%\Results\%TEST_NAME%.rlsp 2&gt; nul
32+
33+
SET result=KO
34+
%LSR_EXE% -c -s %LSP_EXE% -script %PATH_TEST%\%TEST_NAME%.tlsp 1&gt; nul 2&gt; nul
35+
FC %PATH_TEST%\%TEST_NAME%.rlsp %PATH_TEST%\Results\%TEST_NAME%.rlsp 1&gt; nul 2&gt; nul
36+
if %ERRORLEVEL%==0 set result=OK
37+
echo %PATH_TEST%\%TEST_NAME%.tlsp %result%
38+
exit %ERRORLEVEL%
39+
</value>
40+
</setting>
41+
<setting name="Setting" serializeAs="String">
42+
<value />
43+
</setting>
1644
</LanguageServer.Robot.Monitor.Settings>
1745
</applicationSettings>
1846
<userSettings>
1947
<LanguageServer.Robot.Monitor.Properties.Settings>
48+
<setting name="ServerPath" serializeAs="String">
49+
<value>C:\TypeCobol\Sources\##Latest_Release##</value>
50+
</setting>
51+
<setting name="LSRPath" serializeAs="String">
52+
<value>C:\TypeCobol\Sources\##Latest_Release##</value>
53+
</setting>
54+
<setting name="ScriptPath" serializeAs="String">
55+
<value>C:\TypeCobol\Sources\Sessions</value>
56+
</setting>
57+
<setting name="BatchTemplate" serializeAs="String">
58+
<value>@ECHO OFF
59+
SET TEST_NAME={0}
60+
SET PATH_TEST=%~dp0
61+
REM {1} = LSR Path value
62+
SET LSR_EXE={1}\LanguageServerRobot.exe
63+
REM {2} = ServerPath value
64+
SET LSP_EXE={2}\TypeCobol.LanguageServer.exe
65+
DEL %PATH_TEST%\Results\%TEST_NAME%.rlsp 2&gt; nul
66+
67+
SET result=KO
68+
%LSR_EXE% -c -s %LSP_EXE% -script %PATH_TEST%\%TEST_NAME%.tlsp 1&gt; nul 2&gt; nul
69+
FC %PATH_TEST%\%TEST_NAME%.rlsp %PATH_TEST%\Results\%TEST_NAME%.rlsp 1&gt; nul 2&gt; nul
70+
if %ERRORLEVEL%==0 set result=OK
71+
echo %PATH_TEST%\%TEST_NAME%.tlsp %result%
72+
exit %ERRORLEVEL%
73+
</value>
74+
</setting>
75+
<setting name="LSRReplayArguments" serializeAs="String">
76+
<value>-c -so "-td" -s {0}\TypeCobol.LanguageServer.exe -script {1}</value>
77+
</setting>
78+
<setting name="LSRExe" serializeAs="String">
79+
<value>LanguageServerRobot.exe</value>
80+
</setting>
2081
</LanguageServer.Robot.Monitor.Properties.Settings>
2182
</userSettings>
2283
</configuration>

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ public LanguageServerRobotMonitor()
259259
PendingSession = new Queue<Common.Model.Session>();
260260
}
261261

262+
/// <summary>
263+
/// Server options.
264+
/// </summary>
265+
public static string ServerOptions
266+
{
267+
get; internal set;
268+
}
269+
262270
/// <summary>
263271
/// Entry point of the LSRM Controller, with access to the command line arguments.
264272
/// </summary>
@@ -306,6 +314,7 @@ public void Main(object sender, StartupEventArgs e)
306314
{ "p|pipe=","Communication Pipe's name with LSR", (string v) => PipeName = v },
307315
{ "d|dir=","{PATH} Scripts repository directory", (string v) => ScriptRepositoryPath = v },
308316
{ "s|server=","{PATH} the server path", (string v) => ServerPath = v },
317+
{ "so|soptions=","Server options", (string v) => ServerOptions = v },
309318
};
310319
System.Collections.Generic.List<string> arguments;
311320
try { arguments = p.Parse(e.Args); }
@@ -765,7 +774,7 @@ private void CreateTestFiles(Script scenario, String scenarioFile)
765774
//Write the batch file
766775
using (FileStream stream = System.IO.File.Create(Path.Combine(fi.DirectoryName,basename + ".bat")))
767776
{
768-
string templ = string.Format(Settings.Default.BatchTemplate, fi.Name, Settings.Default.LSRPath,
777+
string templ = string.Format(Settings.Default.BatchTemplate, basename, Settings.Default.LSRPath,
769778
Settings.Default.ServerPath);
770779
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(templ);
771780
stream.Write(bytes, 0, bytes.Length);

Solution/LanguageServer.Robot.Monitor/Properties/Settings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Solution/LanguageServer.Robot.Monitor/Properties/Settings.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exit %ERRORLEVEL%
3030
</Value>
3131
</Setting>
3232
<Setting Name="LSRReplayArguments" Type="System.String" Scope="User">
33-
<Value Profile="(Default)">-c -s {0}\TypeCobol.LanguageServer.exe -script {1}</Value>
33+
<Value Profile="(Default)">-c -so "-td" -s {0}\TypeCobol.LanguageServer.exe -script {1}</Value>
3434
</Setting>
3535
<Setting Name="LSRExe" Type="System.String" Scope="User">
3636
<Value Profile="(Default)">LanguageServerRobot.exe</Value>

Solution/LanguageServer.Robot.Monitor/Utilities/FolderBrowserDialog.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ void Init()
148148
Title = string.Empty;
149149
RootFolder = Environment.SpecialFolder.Desktop;
150150
// default options
151-
_dialogOptions = FolderBrowserOptions.ShowEditBox
151+
_dialogOptions = FolderBrowserOptions.ShowEditBox
152152
| FolderBrowserOptions.UseNewStyle
153153
| FolderBrowserOptions.BrowseShares
154154
| FolderBrowserOptions.ShowStatusText
155-
| FolderBrowserOptions.ValidateResult;
155+
| FolderBrowserOptions.ValidateResult
156+
;
156157
}
157158

158159
/// <summary>

Solution/LanguageServer.Robot.Monitor/View/SettingsView.xaml.cs

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using System.Windows;
8-
using System.Windows.Controls;
98
using System.Windows.Data;
109
using System.Windows.Documents;
10+
using System.Windows.Forms;
1111
using System.Windows.Input;
1212
using System.Windows.Media;
1313
using System.Windows.Media.Imaging;
1414
using System.Windows.Navigation;
1515
using System.Windows.Shapes;
16-
using LanguageServer.Robot.Monitor.Utilities.Microsoft.Win32;
16+
using FolderBrowserDialog = LanguageServer.Robot.Monitor.Utilities.Microsoft.Win32.FolderBrowserDialog;
17+
using UserControl = System.Windows.Controls.UserControl;
1718

1819
namespace LanguageServer.Robot.Monitor.View
1920
{
@@ -29,29 +30,47 @@ public SettingsView()
2930

3031
private void BrowseServerPath_OnClick(object sender, RoutedEventArgs e)
3132
{
32-
FolderBrowserDialog browser = new FolderBrowserDialog();
33-
browser.Title = Properties.Resources.LSRMName;
34-
if (browser.ShowDialog().HasValue)
33+
//FolderBrowserDialog browser = new FolderBrowserDialog();
34+
//browser.Title = Properties.Resources.LSRMName;
35+
//if (browser.ShowDialog().HasValue)
36+
//{
37+
// ServerPath.Text = browser.SelectedPath;
38+
//}
39+
40+
System.Windows.Forms.FolderBrowserDialog browser = new System.Windows.Forms.FolderBrowserDialog();
41+
if (browser.ShowDialog() == DialogResult.OK)
3542
{
3643
ServerPath.Text = browser.SelectedPath;
3744
}
3845
}
3946

4047
private void BrowseLSRPath_OnClick(object sender, RoutedEventArgs e)
4148
{
42-
FolderBrowserDialog browser = new FolderBrowserDialog();
43-
browser.Title = Properties.Resources.LSRMName;
44-
if (browser.ShowDialog().HasValue)
49+
//FolderBrowserDialog browser = new FolderBrowserDialog();
50+
//browser.Title = Properties.Resources.LSRMName;
51+
//if (browser.ShowDialog().HasValue)
52+
//{
53+
// LSRPath.Text = browser.SelectedPath;
54+
//}
55+
56+
System.Windows.Forms.FolderBrowserDialog browser = new System.Windows.Forms.FolderBrowserDialog();
57+
if (browser.ShowDialog() == DialogResult.OK)
4558
{
4659
LSRPath.Text = browser.SelectedPath;
4760
}
4861
}
4962

5063
private void BrowseScriptPath_OnClick(object sender, RoutedEventArgs e)
5164
{
52-
FolderBrowserDialog browser = new FolderBrowserDialog();
53-
browser.Title = Properties.Resources.LSRMName;
54-
if (browser.ShowDialog().HasValue)
65+
//FolderBrowserDialog browser = new FolderBrowserDialog();
66+
//browser.Title = Properties.Resources.LSRMName;
67+
//if (browser.ShowDialog().HasValue)
68+
//{
69+
// ScriptRepository.Text = browser.SelectedPath;
70+
//}
71+
72+
System.Windows.Forms.FolderBrowserDialog browser = new System.Windows.Forms.FolderBrowserDialog();
73+
if (browser.ShowDialog() == DialogResult.OK)
5574
{
5675
ScriptRepository.Text = browser.SelectedPath;
5776
}

Solution/LanguageServerRobot/LanguageServerRobot.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ public static string ScriptRepositoryPath
8484
internal set;
8585
}
8686

87+
/// <summary>
88+
/// Server options.
89+
/// </summary>
90+
public static string ServerOptions
91+
{
92+
get; internal set;
93+
}
94+
8795
/// <summary>
8896
/// The file type
8997
/// </summary>
@@ -171,6 +179,7 @@ static int Main(string[] args)
171179
if (!version)Files.Add(new Tuple<string,FileType>(v,FileType.SessionFile)); }
172180
},
173181
{ "s|server=","{PATH} the server path", (string v) => ServerPath = v },
182+
{ "so|soptions=","Server options", (string v) => ServerOptions = v },
174183
{ "d|dir=","{PATH} Scripts repository directory", (string v) => ScriptRepositoryPath = v },
175184
{ "m|monitoring","Show the monitoring Window", _ => monitoring = true },
176185
};
@@ -248,10 +257,11 @@ static int Main(string[] args)
248257
{
249258
//Create and start Language Server Robot controller.
250259
var client = new ClientRobotConnectionController();
251-
var server = new ServerRobotConnectionController(new ProcessMessageConnection(ServerPath));
260+
var server = new ServerRobotConnectionController(new ProcessMessageConnection(ServerPath, ServerOptions));
252261
var robot = monitoring
253262
? new LanguageServerRobotController(client, server, DataConnectionfactory.Create(DataConnectionfactory.ConnectionType.PIPE, DataConnectionfactory.ConnectionSide.Producer), ScriptRepositoryPath)
254263
: new LanguageServerRobotController(client, server, ScriptRepositoryPath);
264+
robot.ServerOptions = ServerOptions;
255265
robot.PropagateConnectionLogs();
256266
if (!robot.Start())
257267
{
@@ -347,7 +357,7 @@ static int Main(string[] args)
347357
/// <returns>0 if no error -1 otherwise.</returns>
348358
private static int ReplayScript(string script_path, Script script)
349359
{
350-
return LanguageServerRobotController.ReplayScript(script_path, script, ServerPath, ScriptRepositoryPath);
360+
return LanguageServerRobotController.ReplayScript(script_path, script, ServerPath, ServerOptions, ScriptRepositoryPath);
351361
}
352362

353363
/// <summary>
@@ -358,7 +368,7 @@ private static int ReplayScript(string script_path, Script script)
358368
/// <returns>0 if no error -1 otherwise.</returns>
359369
private static int ReplaySession(string session_path, Session session)
360370
{
361-
return LanguageServerRobotController.ReplaySession(session_path, session, ServerPath, ScriptRepositoryPath);
371+
return LanguageServerRobotController.ReplaySession(session_path, session, ServerPath, ServerOptions, ScriptRepositoryPath);
362372
}
363373

364374
/// <summary>

0 commit comments

Comments
 (0)