From f080e69e82dc6b8a9a050ca03482042fd7c4c561 Mon Sep 17 00:00:00 2001 From: Michael Ushakov Date: Sun, 5 Nov 2017 00:00:12 +0400 Subject: [PATCH 1/7] Design small update --- .../View/Forms/MainForm.Designer.cs | 87 ++++++++++++++----- 1 file changed, 66 insertions(+), 21 deletions(-) diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs index 90eadae..d2155da 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs @@ -40,12 +40,16 @@ private void InitializeComponent() this._serverParametersBox = new System.Windows.Forms.GroupBox(); this._serverParametersView = new System.Windows.Forms.ListView(); this._applyButton = new System.Windows.Forms.Button(); - this._serverTypeComboBox = new System.Windows.Forms.ComboBox(); this._portTextBox = new System.Windows.Forms.TextBox(); this._ipAddressComboBox = new System.Windows.Forms.ComboBox(); - this._serverTypeLabel = new System.Windows.Forms.Label(); + this._serverSettingsLabel = new System.Windows.Forms.Label(); this._portLabel = new System.Windows.Forms.Label(); this._ipAddressLabel = new System.Windows.Forms.Label(); + this._serverSettingsBox = new System.Windows.Forms.TextBox(); + this._serverSettingsButton = new System.Windows.Forms.Button(); + this._serverScriptLabel = new System.Windows.Forms.Label(); + this._serverScriptBox = new System.Windows.Forms.TextBox(); + this._serverScriptButton = new System.Windows.Forms.Button(); this._logsGroupBox.SuspendLayout(); this._serverSettingsGroup.SuspendLayout(); this._serverParametersBox.SuspendLayout(); @@ -107,14 +111,18 @@ private void InitializeComponent() // // _serverSettingsGroup // + this._serverSettingsGroup.Controls.Add(this._serverScriptButton); + this._serverSettingsGroup.Controls.Add(this._serverScriptBox); + this._serverSettingsGroup.Controls.Add(this._serverScriptLabel); + this._serverSettingsGroup.Controls.Add(this._serverSettingsButton); + this._serverSettingsGroup.Controls.Add(this._serverSettingsBox); this._serverSettingsGroup.Controls.Add(this._logLevelComboBox); this._serverSettingsGroup.Controls.Add(this._logLevelLabel); this._serverSettingsGroup.Controls.Add(this._serverParametersBox); this._serverSettingsGroup.Controls.Add(this._applyButton); - this._serverSettingsGroup.Controls.Add(this._serverTypeComboBox); this._serverSettingsGroup.Controls.Add(this._portTextBox); this._serverSettingsGroup.Controls.Add(this._ipAddressComboBox); - this._serverSettingsGroup.Controls.Add(this._serverTypeLabel); + this._serverSettingsGroup.Controls.Add(this._serverSettingsLabel); this._serverSettingsGroup.Controls.Add(this._portLabel); this._serverSettingsGroup.Controls.Add(this._ipAddressLabel); this._serverSettingsGroup.Location = new System.Drawing.Point(12, 12); @@ -169,14 +177,6 @@ private void InitializeComponent() this._applyButton.Text = "Apply"; this._applyButton.UseVisualStyleBackColor = true; // - // _serverTypeComboBox - // - this._serverTypeComboBox.FormattingEnabled = true; - this._serverTypeComboBox.Location = new System.Drawing.Point(97, 94); - this._serverTypeComboBox.Name = "_serverTypeComboBox"; - this._serverTypeComboBox.Size = new System.Drawing.Size(121, 21); - this._serverTypeComboBox.TabIndex = 5; - // // _portTextBox // this._portTextBox.Location = new System.Drawing.Point(97, 58); @@ -192,14 +192,14 @@ private void InitializeComponent() this._ipAddressComboBox.Size = new System.Drawing.Size(121, 21); this._ipAddressComboBox.TabIndex = 3; // - // _serverTypeLabel + // _serverSettingsLabel // - this._serverTypeLabel.AutoSize = true; - this._serverTypeLabel.Location = new System.Drawing.Point(16, 97); - this._serverTypeLabel.Name = "_serverTypeLabel"; - this._serverTypeLabel.Size = new System.Drawing.Size(68, 13); - this._serverTypeLabel.TabIndex = 2; - this._serverTypeLabel.Text = "Server Type:"; + this._serverSettingsLabel.AutoSize = true; + this._serverSettingsLabel.Location = new System.Drawing.Point(16, 97); + this._serverSettingsLabel.Name = "_serverSettingsLabel"; + this._serverSettingsLabel.Size = new System.Drawing.Size(82, 13); + this._serverSettingsLabel.TabIndex = 2; + this._serverSettingsLabel.Text = "Server Settings:"; // // _portLabel // @@ -219,6 +219,47 @@ private void InitializeComponent() this._ipAddressLabel.TabIndex = 0; this._ipAddressLabel.Text = "IP Address:"; // + // _serverSettingsBox + // + this._serverSettingsBox.Location = new System.Drawing.Point(97, 94); + this._serverSettingsBox.Name = "_serverSettingsBox"; + this._serverSettingsBox.Size = new System.Drawing.Size(97, 20); + this._serverSettingsBox.TabIndex = 10; + // + // _serverSettingsButton + // + this._serverSettingsButton.Location = new System.Drawing.Point(194, 92); + this._serverSettingsButton.Name = "_serverSettingsButton"; + this._serverSettingsButton.Size = new System.Drawing.Size(24, 22); + this._serverSettingsButton.TabIndex = 11; + this._serverSettingsButton.Text = "..."; + this._serverSettingsButton.UseVisualStyleBackColor = true; + // + // _serverScriptLabel + // + this._serverScriptLabel.AutoSize = true; + this._serverScriptLabel.Location = new System.Drawing.Point(16, 133); + this._serverScriptLabel.Name = "_serverScriptLabel"; + this._serverScriptLabel.Size = new System.Drawing.Size(71, 13); + this._serverScriptLabel.TabIndex = 12; + this._serverScriptLabel.Text = "Server Script:"; + // + // _serverScriptBox + // + this._serverScriptBox.Location = new System.Drawing.Point(96, 130); + this._serverScriptBox.Name = "_serverScriptBox"; + this._serverScriptBox.Size = new System.Drawing.Size(98, 20); + this._serverScriptBox.TabIndex = 13; + // + // _serverScriptButton + // + this._serverScriptButton.Location = new System.Drawing.Point(194, 128); + this._serverScriptButton.Name = "_serverScriptButton"; + this._serverScriptButton.Size = new System.Drawing.Size(24, 22); + this._serverScriptButton.TabIndex = 14; + this._serverScriptButton.Text = "..."; + this._serverScriptButton.UseVisualStyleBackColor = true; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -248,18 +289,22 @@ private void InitializeComponent() private System.Windows.Forms.GroupBox _logsGroupBox; private System.Windows.Forms.ListBox _clientsListBox; private System.Windows.Forms.GroupBox _serverSettingsGroup; - private System.Windows.Forms.Label _serverTypeLabel; + private System.Windows.Forms.Label _serverSettingsLabel; private System.Windows.Forms.Label _portLabel; private System.Windows.Forms.Label _ipAddressLabel; private System.Windows.Forms.ComboBox _ipAddressComboBox; private System.Windows.Forms.TextBox _portTextBox; - private System.Windows.Forms.ComboBox _serverTypeComboBox; private System.Windows.Forms.Button _applyButton; private System.Windows.Forms.RichTextBox _logsTextBox; private System.Windows.Forms.GroupBox _serverParametersBox; private System.Windows.Forms.ListView _serverParametersView; private System.Windows.Forms.ComboBox _logLevelComboBox; private System.Windows.Forms.Label _logLevelLabel; + private System.Windows.Forms.Button _serverScriptButton; + private System.Windows.Forms.TextBox _serverScriptBox; + private System.Windows.Forms.Label _serverScriptLabel; + private System.Windows.Forms.Button _serverSettingsButton; + private System.Windows.Forms.TextBox _serverSettingsBox; } } From 135e352d4188accab95d07b86788ae8966b7578e Mon Sep 17 00:00:00 2001 From: Michael Ushakov Date: Sun, 5 Nov 2017 20:36:58 +0400 Subject: [PATCH 2/7] Script selection --- .../View/Forms/MainForm.cs | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs index 658249e..af4e175 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs @@ -27,6 +27,7 @@ public MainForm() _startButton.Click += (sender, args) => Start(); _stopButton.Click += (sender, args) => Stop(); _restartButton.Click += (sender, args) => Restart(); + _serverScriptButton.Click += OnChooseScriptFileButtonClick; _logLevelComboBox.SelectedIndexChanged += (sender, args) => ApplyLogLevel(); } @@ -54,9 +55,9 @@ private void FillControls() } // add server type - foreach (KeyValuePair server in _servers) - _serverTypeComboBox.Items.Add(server.Value); - _serverTypeComboBox.SelectedIndex = 0; + //foreach (KeyValuePair server in _servers) + //_serverTypeComboBox.Items.Add(server.Value); + //_serverTypeComboBox.SelectedIndex = 0; // init logger + fill log level XmlConfigurator.Configure(); @@ -87,14 +88,8 @@ private void ApplySettings(IDictionary options) private void Start() { - // getting server type - if (_serverTypeComboBox.SelectedIndex < 0) - { - // log - return; - } ServerType serverType = ServerType.Scripting; - foreach (KeyValuePair server in _servers) +/* foreach (KeyValuePair server in _servers) { if (String.Equals(_serverTypeComboBox.Items[_serverTypeComboBox.SelectedIndex].ToString(), server.Value)) serverType = server.Key; @@ -110,7 +105,7 @@ private void Start() System.Threading.Timer periodicalUpdater = new System.Threading.Timer(StateUpdater, null, 500, 500); _timers[0] = periodicalUpdater; } - else _timers[0].Change(500, 500); + else _timers[0].Change(500, 500);*/ } public void Stop() @@ -129,6 +124,19 @@ public void Restart() Start(); } + public void OnChooseScriptFileButtonClick(Object sender, EventArgs args) + { + OpenFileDialog openScriptFile = new OpenFileDialog(); + openScriptFile.RestoreDirectory = true; + openScriptFile.Title = @"Choose C# script file"; + openScriptFile.Filter = @" CSharp files (*.cs)|*.cs"; + if (openScriptFile.ShowDialog() == DialogResult.OK) + { + _scriptFile = openScriptFile.SafeFileName; + _serverScriptBox.Text = Path.GetFileName(_scriptFile); + } + } + void UpdateControlsState() { if (_server == null) @@ -174,18 +182,24 @@ void ApplyLogLevel() private const String TotalClientsTemplate = "Total connected clients: {0}"; private const String ClientInfoTemplate = "Client {0}, ip: {1}"; - private readonly IDictionary _servers = new Dictionary() +/* private readonly IDictionary _servers = new Dictionary() { {ServerType.Echo, "Echo server"}, {ServerType.Time, "Time server"}, - }; + };*/ private readonly IDictionary _logLevels = new Dictionary() { - {Level.Alert, "Alert"}, {Level.Critical, "Critical"}, {Level.Debug, "Debug"}, - {Level.Emergency, "Emergency"}, {Level.Error, "Error"}, {Level.Info, "Info"}, {Level.Warn, "Warn"} + {Level.Alert, "Alert"}, + {Level.Critical, "Critical"}, + {Level.Debug, "Debug"}, + {Level.Emergency, "Emergency"}, + {Level.Error, "Error"}, + {Level.Info, "Info"}, + {Level.Warn, "Warn"} }; + private String _scriptFile; private ILog _logger; private RichTextBoxAppender _richTextBoxAppender; private readonly TcpServerConfig _serverConfig = new TcpServerConfig(); From 2fe56b64872108ee22be2d035828235b4b4f9db6 Mon Sep 17 00:00:00 2001 From: Michael Ushakov Date: Sun, 5 Nov 2017 20:44:54 +0400 Subject: [PATCH 3/7] Gui update, server usage from nuget --- .../Data/ServerType.cs | 12 ---------- .../Factories/ServerFactory.cs | 14 ++++++++++++ .../MossbauerLab.TinyTcpServer.MnGUI.csproj | 17 +++++++------- .../View/Forms/Factories/ServerFactory.cs | 21 ------------------ .../View/Forms/MainForm.cs | 3 +-- .../packages.config | 5 +++++ .../lib/MossbauerLab.SimpleExtensions.dll | Bin 6656 -> 0 bytes .../lib/MossbauerLab.TinyTcpServer.Core.dll | Bin 23552 -> 0 bytes 8 files changed, 28 insertions(+), 44 deletions(-) delete mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Data/ServerType.cs create mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Factories/ServerFactory.cs delete mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/Factories/ServerFactory.cs create mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/packages.config delete mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/lib/MossbauerLab.SimpleExtensions.dll delete mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/lib/MossbauerLab.TinyTcpServer.Core.dll diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Data/ServerType.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Data/ServerType.cs deleted file mode 100644 index c5798c9..0000000 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Data/ServerType.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace MossbauerLab.TinyTcpServer.MnGUI.Data -{ - [Flags] - public enum ServerType - { - Echo, - Time, - Scripting // this option is for Server specifying with script - } -} diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Factories/ServerFactory.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Factories/ServerFactory.cs new file mode 100644 index 0000000..f99f8f1 --- /dev/null +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Factories/ServerFactory.cs @@ -0,0 +1,14 @@ +using System; +using log4net; +using MossbauerLab.TinyTcpServer.Core.Server; + +namespace MossbauerLab.TinyTcpServer.MnGUI.Factories +{ + public static class ServerFactory + { + public static ITcpServer Create(String ipAddress, UInt16 port, String serverScriptFile, ILog logger = null, TcpServerConfig config = null) + { + return new FlexibleTcpServer(serverScriptFile, ipAddress, port, logger, false, config); + } + } +} diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj index cf0cc1e..f0d394c 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj @@ -32,14 +32,13 @@ 4 - - ..\lib\log4net.dll + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + True - - ..\lib\MossbauerLab.SimpleExtensions.dll - - - ..\lib\MossbauerLab.TinyTcpServer.Core.dll + + ..\packages\MossbauerLab.TinyTcpServer.Core.1.2.0\lib\net40\MossbauerLab.TinyTcpServer.Core.dll + True @@ -53,9 +52,8 @@ - - + Form @@ -78,6 +76,7 @@ Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/Factories/ServerFactory.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/Factories/ServerFactory.cs deleted file mode 100644 index 6deba98..0000000 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/Factories/ServerFactory.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using log4net; -using MossbauerLab.SimpleExtensions.Echo; -using MossbauerLab.SimpleExtensions.Time; -using MossbauerLab.TinyTcpServer.Core.Server; -using MossbauerLab.TinyTcpServer.MnGUI.Data; - -namespace MossbauerLab.TinyTcpServer.MnGUI.Factories -{ - public static class ServerFactory - { - public static ITcpServer Create(ServerType type, String ipAddress, UInt16 port, ILog logger = null, TcpServerConfig config = null) - { - if(type == ServerType.Echo) - return new EchoTcpServer(ipAddress, port, logger, false, config); - if(type == ServerType.Time) - return new TimeTcpServer(ipAddress, port, logger, false, config); - throw new NotImplementedException("Other types were not implemented"); - } - } -} diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs index af4e175..5e80779 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs @@ -11,7 +11,6 @@ using log4net.Repository.Hierarchy; using MossbauerLab.TinyTcpServer.Core.Client; using MossbauerLab.TinyTcpServer.Core.Server; -using MossbauerLab.TinyTcpServer.MnGUI.Data; using MossbauerLab.TinyTcpServer.MnGUI.Factories; using MossbauerLab.TinyTcpServer.MnGUI.LogUtils; using MossbauerLab.TinyTcpServer.MnGUI.View.Helpers; @@ -88,7 +87,7 @@ private void ApplySettings(IDictionary options) private void Start() { - ServerType serverType = ServerType.Scripting; + //ServerType serverType = ServerType.Scripting; /* foreach (KeyValuePair server in _servers) { if (String.Equals(_serverTypeComboBox.Items[_serverTypeComboBox.SelectedIndex].ToString(), server.Value)) diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/packages.config b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/packages.config new file mode 100644 index 0000000..0d6e450 --- /dev/null +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/lib/MossbauerLab.SimpleExtensions.dll b/GUI/MossbauerLab.TinyTcpServer.MnGUI/lib/MossbauerLab.SimpleExtensions.dll deleted file mode 100644 index 7bab19abf40728d2587fe065a7f1ed12f9653c9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6656 zcmeHLeQX>@6@Rn0_u+HS^<82oPU2)!C+HI5-P; zEIahc*GisS^o)6}U^tE&XnC%AWk<6dZR~JXn|DpFClc}PHPh4MM2A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#?mWr%qY|N4Nx95(N*{&X7~Vc0#uwRtcMfFN}|B31s={P)- ztmsOfMh|1dUC6&idyqpPU4b)ImBO=G`V#pZuGto|EApw=T=c3lbs@W#uJLkSGjcws z;mbv?Wz1#JR5`j}?3ea|{|4neuC#srY@R=tgL2G>Tz?#S=8<^?HN4a~S-AhhyRQOT S^*`fG{ek=LtH8TD<9`7c9VnOp diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/lib/MossbauerLab.TinyTcpServer.Core.dll b/GUI/MossbauerLab.TinyTcpServer.MnGUI/lib/MossbauerLab.TinyTcpServer.Core.dll deleted file mode 100644 index f8edbe989240e52cfb52f6b2ee2875f91799b46e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23552 zcmeHv3wT@AmF_x6N9V}0tyq#RWAakS1H~`wB;-*-66bB2x1ARl99dQz5k<#HazZc$ zr%X#Jq=hN%(76Kx1GF$L9ojOzoqq5YXyL+4VM;qpOWR4IADxz=y=|wobLnl9`>(an zk&diT`ndO-``z1kL|Zf;E!Z}?-)-$>(&yA_wM4tX2`KJ=AH_Y6&m=xX4T9^+Zf3CkayOCaP- z-Iu@^n|dr!Be&VZg+`XuS5VVb5sPmH)|c=DZJni$L#fevp6;6v1PpXpF$4hvttf^d zU|@h1Ll7{aOECli1MXD}LBK%6iXjLX2uQ^c1PoZO7=q+guhF>}n`|V`;hR5ku46R@ zNR<`@)zMwW5Cn{n%Mb*<^mXa9-tlQ3{utHmW@zIEg6*|Uy4?b5vEJOO_&z(xQbeoS z9#KMvH507XSnHEYiPZ0y<6~t(8)gQJ^DywNEoj5spe`j^n_I7I(mPwK%1!4Yr!~l7 zTNLB2VIc57tQXLBa3YR==moSHoS4I?M1vmk&+jl76gI$=2{dfzJ|nRlgszV>Y3~7k z5^jDa_)=#?J$*FdJwA%7YUy((t#}=>7@tjJ84o?F5T$s2ntHlnt7B z7&&Us1zKyFHo6zI3iAQ&1%jSmLhS_5W_ux^88SMo>(HrSoBui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-tBAtJsU(N5uj!9Qj*XbponfQI>P@cYpQ|K80AFgD2mzulzz zcu)(JE`4&9yjOr%Jut7rSApPZuWNb$Z+_^ZkRLOA5;+0zq`(g~HAN;rqE*=<+(>}y z&N!!rXW8VP;mLdagqjaZ%};?FnfzOjA@m&bht%yckv?dck;$hN$GN=_uu$P4)Ulxb zMJ>`%!?SksB`r$Kc?le3oG9TJs*w(d0e3Y-Ii!+G-HO((sVS6 zUp^v)PWU610c91cAPAqRS8OD!pMm*FKT+gu=D`W#7KQ)VLhy?FWHAq>4ETxCLY!o ztA>@iFI90l9JOG1ilVJ3hB&J2w=l!mps8UvmF7}s3&zOuaLZYntU(ND4Krs^z!%i~ zb#Z@WA(poQchHI(JO(rHx3iFFPWS`pDjXMxEJWC2>9c%b>XD{Rc;l*b+lKzqGKPGfs{ALyaYo^U#A2-wj+RUXsL@%+qN0+q`&#-?njj!rPft=Pin#-fA?r^mH}; zdua#2GQtbLG;jHmrOSs>i;^APi!NN&v1EA3P{&YucyY(#72PYA9$a*A zS@%->l%x)Ct#x;HysC+nZ00ZnJZxV;`PB*~j>ADd2Md zt|3>Q0oK(xFkQV9f9|huecw%&4=+A_!QX8E%fu~j9DUDtFV{%FV_?`W;@QH$y14@t zZ&gj9yuCZi>sJHz(3Jzum)ZkwQ?_$-c!+KNzvX&#v~0;K#^Yt$i@ATh(96SL>cA7j z_1Wy!WG1IxrAn)J(YVx^`Owu+S^key*#rCwRr#9)lVu)b>P^HhqAEU1H{-JplE<-I zaIeRG{DYu9c*-ycxBcf+b?RblF5ch4g5jbCu89zR)^mFvPE#WbTP}pJ~8np6xX(LX1d;%{$jev}QC&_;#GcV_^0_1#_an7EQ5It Date: Sun, 5 Nov 2017 21:21:15 +0400 Subject: [PATCH 4/7] Added util class, ssome fixes in controls position --- .../MossbauerLab.TinyTcpServer.MnGUI.csproj | 1 + .../View/Forms/MainForm.Designer.cs | 92 +++++++++---------- .../View/Forms/MainForm.cs | 59 +++++++----- .../View/Utils/OpenDialogRunner.cs | 24 +++++ 4 files changed, 107 insertions(+), 69 deletions(-) create mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Utils/OpenDialogRunner.cs diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj index f0d394c..89ab39f 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj @@ -63,6 +63,7 @@ + MainForm.cs diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs index d2155da..b1d36b4 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs @@ -35,6 +35,11 @@ private void InitializeComponent() this._logsTextBox = new System.Windows.Forms.RichTextBox(); this._clientsListBox = new System.Windows.Forms.ListBox(); this._serverSettingsGroup = new System.Windows.Forms.GroupBox(); + this._serverScriptButton = new System.Windows.Forms.Button(); + this._serverScriptBox = new System.Windows.Forms.TextBox(); + this._serverScriptLabel = new System.Windows.Forms.Label(); + this._serverSettingsButton = new System.Windows.Forms.Button(); + this._serverSettingsBox = new System.Windows.Forms.TextBox(); this._logLevelComboBox = new System.Windows.Forms.ComboBox(); this._logLevelLabel = new System.Windows.Forms.Label(); this._serverParametersBox = new System.Windows.Forms.GroupBox(); @@ -45,11 +50,6 @@ private void InitializeComponent() this._serverSettingsLabel = new System.Windows.Forms.Label(); this._portLabel = new System.Windows.Forms.Label(); this._ipAddressLabel = new System.Windows.Forms.Label(); - this._serverSettingsBox = new System.Windows.Forms.TextBox(); - this._serverSettingsButton = new System.Windows.Forms.Button(); - this._serverScriptLabel = new System.Windows.Forms.Label(); - this._serverScriptBox = new System.Windows.Forms.TextBox(); - this._serverScriptButton = new System.Windows.Forms.Button(); this._logsGroupBox.SuspendLayout(); this._serverSettingsGroup.SuspendLayout(); this._serverParametersBox.SuspendLayout(); @@ -132,6 +132,47 @@ private void InitializeComponent() this._serverSettingsGroup.TabStop = false; this._serverSettingsGroup.Text = "Server settings"; // + // _serverScriptButton + // + this._serverScriptButton.Location = new System.Drawing.Point(194, 130); + this._serverScriptButton.Name = "_serverScriptButton"; + this._serverScriptButton.Size = new System.Drawing.Size(24, 20); + this._serverScriptButton.TabIndex = 14; + this._serverScriptButton.Text = "..."; + this._serverScriptButton.UseVisualStyleBackColor = true; + // + // _serverScriptBox + // + this._serverScriptBox.Location = new System.Drawing.Point(96, 130); + this._serverScriptBox.Name = "_serverScriptBox"; + this._serverScriptBox.Size = new System.Drawing.Size(98, 20); + this._serverScriptBox.TabIndex = 13; + // + // _serverScriptLabel + // + this._serverScriptLabel.AutoSize = true; + this._serverScriptLabel.Location = new System.Drawing.Point(16, 133); + this._serverScriptLabel.Name = "_serverScriptLabel"; + this._serverScriptLabel.Size = new System.Drawing.Size(71, 13); + this._serverScriptLabel.TabIndex = 12; + this._serverScriptLabel.Text = "Server Script:"; + // + // _serverSettingsButton + // + this._serverSettingsButton.Location = new System.Drawing.Point(194, 94); + this._serverSettingsButton.Name = "_serverSettingsButton"; + this._serverSettingsButton.Size = new System.Drawing.Size(24, 20); + this._serverSettingsButton.TabIndex = 11; + this._serverSettingsButton.Text = "..."; + this._serverSettingsButton.UseVisualStyleBackColor = true; + // + // _serverSettingsBox + // + this._serverSettingsBox.Location = new System.Drawing.Point(97, 94); + this._serverSettingsBox.Name = "_serverSettingsBox"; + this._serverSettingsBox.Size = new System.Drawing.Size(97, 20); + this._serverSettingsBox.TabIndex = 10; + // // _logLevelComboBox // this._logLevelComboBox.FormattingEnabled = true; @@ -219,47 +260,6 @@ private void InitializeComponent() this._ipAddressLabel.TabIndex = 0; this._ipAddressLabel.Text = "IP Address:"; // - // _serverSettingsBox - // - this._serverSettingsBox.Location = new System.Drawing.Point(97, 94); - this._serverSettingsBox.Name = "_serverSettingsBox"; - this._serverSettingsBox.Size = new System.Drawing.Size(97, 20); - this._serverSettingsBox.TabIndex = 10; - // - // _serverSettingsButton - // - this._serverSettingsButton.Location = new System.Drawing.Point(194, 92); - this._serverSettingsButton.Name = "_serverSettingsButton"; - this._serverSettingsButton.Size = new System.Drawing.Size(24, 22); - this._serverSettingsButton.TabIndex = 11; - this._serverSettingsButton.Text = "..."; - this._serverSettingsButton.UseVisualStyleBackColor = true; - // - // _serverScriptLabel - // - this._serverScriptLabel.AutoSize = true; - this._serverScriptLabel.Location = new System.Drawing.Point(16, 133); - this._serverScriptLabel.Name = "_serverScriptLabel"; - this._serverScriptLabel.Size = new System.Drawing.Size(71, 13); - this._serverScriptLabel.TabIndex = 12; - this._serverScriptLabel.Text = "Server Script:"; - // - // _serverScriptBox - // - this._serverScriptBox.Location = new System.Drawing.Point(96, 130); - this._serverScriptBox.Name = "_serverScriptBox"; - this._serverScriptBox.Size = new System.Drawing.Size(98, 20); - this._serverScriptBox.TabIndex = 13; - // - // _serverScriptButton - // - this._serverScriptButton.Location = new System.Drawing.Point(194, 128); - this._serverScriptButton.Name = "_serverScriptButton"; - this._serverScriptButton.Size = new System.Drawing.Size(24, 22); - this._serverScriptButton.TabIndex = 14; - this._serverScriptButton.Text = "..."; - this._serverScriptButton.UseVisualStyleBackColor = true; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs index 5e80779..0477f9b 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs @@ -14,6 +14,7 @@ using MossbauerLab.TinyTcpServer.MnGUI.Factories; using MossbauerLab.TinyTcpServer.MnGUI.LogUtils; using MossbauerLab.TinyTcpServer.MnGUI.View.Helpers; +using MossbauerLab.TinyTcpServer.MnGUI.View.Utils; namespace MossbauerLab.TinyTcpServer.MnGUI.View.Forms { @@ -27,6 +28,7 @@ public MainForm() _stopButton.Click += (sender, args) => Stop(); _restartButton.Click += (sender, args) => Restart(); _serverScriptButton.Click += OnChooseScriptFileButtonClick; + _serverSettingsButton.Click += OnChooseSettingsFileButtonClick; _logLevelComboBox.SelectedIndexChanged += (sender, args) => ApplyLogLevel(); } @@ -53,10 +55,6 @@ private void FillControls() _portTextBox.Text = DefaultTcpPort.ToString(); } - // add server type - //foreach (KeyValuePair server in _servers) - //_serverTypeComboBox.Items.Add(server.Value); - //_serverTypeComboBox.SelectedIndex = 0; // init logger + fill log level XmlConfigurator.Configure(); @@ -71,6 +69,8 @@ private void FillControls() IList configStrings = ServerConfigInfoHelper.GetConfigStrings(_serverConfig); foreach (String configString in configStrings) _serverParametersView.Items.Add(configString); + // update controls state + UpdateControlsState(); } private IDictionary GetOptions(String[] lines) @@ -123,23 +123,39 @@ public void Restart() Start(); } - public void OnChooseScriptFileButtonClick(Object sender, EventArgs args) + private void OnChooseScriptFileButtonClick(Object sender, EventArgs args) { OpenFileDialog openScriptFile = new OpenFileDialog(); - openScriptFile.RestoreDirectory = true; - openScriptFile.Title = @"Choose C# script file"; - openScriptFile.Filter = @" CSharp files (*.cs)|*.cs"; - if (openScriptFile.ShowDialog() == DialogResult.OK) + String file = openScriptFile.Run(@" CSharp files (*.cs)|*.cs", Path.GetFullPath("."), @"Choose C# script file", 0); + if (file != String.Empty) { - _scriptFile = openScriptFile.SafeFileName; + _scriptFile = file; _serverScriptBox.Text = Path.GetFileName(_scriptFile); } } - void UpdateControlsState() + private void OnChooseSettingsFileButtonClick(Object sender, EventArgs args) + { + OpenFileDialog openScriptFile = new OpenFileDialog(); + String file = openScriptFile.Run(@" Text files (*.txt)|*.txt | Config files (*.conf) |*.conf | Config files (*.cfg) |*.cfg | Any file (*.*)|*.*", + Path.GetFullPath("."), @"Choose Server settings file", 0); + if (file != String.Empty) + { + _settingsFile = file; + _serverSettingsBox.Text = Path.GetFileName(_settingsFile); + } + } + + private void UpdateControlsState() { if (_server == null) + { + _startButton.Enabled = true; + _restartButton.Enabled = false; + _stopButton.Enabled = false; return; + } + _startButton.Enabled = !_server.IsReady; _restartButton.Enabled = _server.IsReady; _stopButton.Enabled = _server.IsReady; @@ -149,7 +165,7 @@ void UpdateControlsState() _portTextBox.Enabled = !_server.IsReady; } - void PopulateClients() + private void PopulateClients() { _clientsListBox.Items.Clear(); IList clients = _server.Clients; @@ -164,13 +180,13 @@ void PopulateClients() } } - void StateUpdater(Object state) + private void StateUpdater(Object state) { BeginInvoke((Action)(UpdateControlsState)); BeginInvoke((Action) PopulateClients); } - void ApplyLogLevel() + private void ApplyLogLevel() { Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository(); hierarchy.Threshold =_logLevels.First(item => item.Value.Equals(_logLevelComboBox.Items[_logLevelComboBox.SelectedIndex].ToString())).Key; @@ -179,13 +195,8 @@ void ApplyLogLevel() private const String ConfigFile = @".\settings.txt"; private const UInt16 DefaultTcpPort = 9999; private const String TotalClientsTemplate = "Total connected clients: {0}"; - private const String ClientInfoTemplate = "Client {0}, ip: {1}"; + private const String ClientInfoTemplate = "Client {0}, ip: {1}"; // todo: umv add sctipt and settings .... -/* private readonly IDictionary _servers = new Dictionary() - { - {ServerType.Echo, "Echo server"}, - {ServerType.Time, "Time server"}, - };*/ private readonly IDictionary _logLevels = new Dictionary() { @@ -198,11 +209,13 @@ void ApplyLogLevel() {Level.Warn, "Warn"} }; - private String _scriptFile; + private ILog _logger; - private RichTextBoxAppender _richTextBoxAppender; - private readonly TcpServerConfig _serverConfig = new TcpServerConfig(); private ITcpServer _server; + private String _scriptFile; + private String _settingsFile; + private readonly TcpServerConfig _serverConfig = new TcpServerConfig(); + private RichTextBoxAppender _richTextBoxAppender; private readonly System.Threading.Timer[] _timers = new System.Threading.Timer[1]; } } diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Utils/OpenDialogRunner.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Utils/OpenDialogRunner.cs new file mode 100644 index 0000000..b6b590c --- /dev/null +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Utils/OpenDialogRunner.cs @@ -0,0 +1,24 @@ +using System; +using System.Windows.Forms; + +namespace MossbauerLab.TinyTcpServer.MnGUI.View.Utils +{ + public static class OpenDialogRunner + { + public static String Run(this OpenFileDialog fileDlg, String filterString, String initialPath, String dialogTitle, UInt16 filterIndex) + { + fileDlg.Title = dialogTitle; + if (!String.IsNullOrEmpty(initialPath)) + fileDlg.InitialDirectory = initialPath; + fileDlg.RestoreDirectory = true; + fileDlg.Filter = filterString; + fileDlg.FilterIndex = filterIndex; + + if (fileDlg.ShowDialog() == DialogResult.OK) + { + return fileDlg.FileName; + } + return String.Empty; + } + } +} From 93e60669931fa436f245064cd82d4cbce50fa169 Mon Sep 17 00:00:00 2001 From: Michael Ushakov Date: Sun, 5 Nov 2017 22:37:06 +0400 Subject: [PATCH 5/7] Server start restored --- .../View/Forms/MainForm.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs index 0477f9b..a8b42c2 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs @@ -87,24 +87,26 @@ private void ApplySettings(IDictionary options) private void Start() { - //ServerType serverType = ServerType.Scripting; -/* foreach (KeyValuePair server in _servers) - { - if (String.Equals(_serverTypeComboBox.Items[_serverTypeComboBox.SelectedIndex].ToString(), server.Value)) - serverType = server.Key; - } + UInt16 port = Convert.ToUInt16(_portTextBox.Text); if (_server == null) - { - _server = ServerFactory.Create(serverType, _ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), - UInt16.Parse(_portTextBox.Text), _logger, _serverConfig); + { + if (_ipAddressComboBox.SelectedIndex >= 0 && _portTextBox.Text != null && !String.IsNullOrEmpty(_scriptFile)) + _server = ServerFactory.Create(_ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), port, _scriptFile, _logger, _serverConfig); + else + { + MessageBox.Show(@"Can not start server, please select IP address, port and server script"); + return; + } + _server.Start(); } - _server.Start(); + else _server.Start(_ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), port); + if (_timers[0] == null) { System.Threading.Timer periodicalUpdater = new System.Threading.Timer(StateUpdater, null, 500, 500); _timers[0] = periodicalUpdater; } - else _timers[0].Change(500, 500);*/ + else _timers[0].Change(500, 500); } public void Stop() From 9e5ac5fdcbb7e1ef37ef9783511b2416d38d8de3 Mon Sep 17 00:00:00 2001 From: Michael Ushakov Date: Sun, 5 Nov 2017 23:12:17 +0400 Subject: [PATCH 6/7] Was copied TcpServerConfigBuilder from console project, read config --- .../Helpers/TcpServerConfigBuilder.cs | 88 +++++++++++++++++++ .../MossbauerLab.TinyTcpServer.MnGUI.csproj | 1 + .../View/Forms/MainForm.Designer.cs | 36 ++++---- .../View/Forms/MainForm.cs | 60 ++++++------- 4 files changed, 135 insertions(+), 50 deletions(-) create mode 100644 GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Helpers/TcpServerConfigBuilder.cs diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Helpers/TcpServerConfigBuilder.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Helpers/TcpServerConfigBuilder.cs new file mode 100644 index 0000000..fd7b124 --- /dev/null +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/Helpers/TcpServerConfigBuilder.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using MossbauerLab.TinyTcpServer.Core.Server; + +namespace MossbauerLab.TinyTcpServer.MnGUI.Helpers +{ + public static class TcpServerConfigBuilder + { + public static TcpServerConfig Build(String serverConfig) + { + if(String.IsNullOrEmpty(serverConfig)) + throw new ArgumentNullException("serverConfig"); + if(!File.Exists(serverConfig)) + throw new ApplicationException("Config file does not exists"); + IList content = File.ReadAllLines(serverConfig).Select(line=>line.Trim().ToLower()) + .Where(line => !String.IsNullOrEmpty(line)) + .Where(line => !line.StartsWith(CommentarySymbol)) + .ToList(); + TcpServerConfig config = new TcpServerConfig(); + Int32 value = GetConfigurationValue(content, ParallelTaskKey); + if (value != -1) // otherwise we using default value + config.ParallelTask = value; + value = GetConfigurationValue(content, ClientBufferSizeKey); + if (value != -1) // otherwise we using default value + config.ClientBufferSize = value; + value = GetConfigurationValue(content, ChunkSizeKey); + if (value != -1) // otherwise we using default value + config.ChunkSize = value; + value = GetConfigurationValue(content, ClientConnectAttemptsKey); + if (value != -1) // otherwise we using default value + config.ClientConnectAttempts = value; + value = GetConfigurationValue(content, ClientConnectTimeoutKey); + if (value != -1) // otherwise we using default value + config.ClientConnectTimeout = value; + value = GetConfigurationValue(content, ClientInactivityTimeKey); + if (value != -1) // otherwise we using default value + config.ClientInactivityTime = value; + value = GetConfigurationValue(content, ReadTimeoutKey); + if (value != -1) // otherwise we using default value + config.ReadTimeout = value; + value = GetConfigurationValue(content, WriteTimeoutKey); + if (value != -1) // otherwise we using default value + config.WriteTimeout = value; + value = GetConfigurationValue(content, ClientReadAttemptsKey); + if (value != -1) // otherwise we using default value + config.ClientReadAttempts= value; + value = GetConfigurationValue(content, ServerCloseTimeoutKey); + if (value != -1) // otherwise we using default value + config.ServerCloseTimeout = value; + return config; + } + + private static Int32 GetConfigurationValue(IList fileContent, String key) + { + try + { + String configLine = fileContent.FirstOrDefault(line => line.ToLower().StartsWith(key.ToLower())); + if (configLine == null) + return -1; + Int32 index = configLine.IndexOf(KeyValueSeparator, StringComparison.InvariantCulture); + if (index <= 0) + return -1; + String value = configLine.Substring(index + 1); + return Int32.Parse(value); + } + catch (Exception) + { + return -1; + } + } + + private const String KeyValueSeparator = "="; + private const String CommentarySymbol = "#"; + + private const String ParallelTaskKey = "ParallelTask"; + private const String ClientBufferSizeKey = "ClientBufferSize"; + private const String ChunkSizeKey = "ChunkSize"; + private const String ClientConnectAttemptsKey = "ClientConnectAttempts"; + private const String ClientInactivityTimeKey = "ClientInactivityTime"; + private const String ClientConnectTimeoutKey = "ClientConnectTimeout"; + private const String ClientReadAttemptsKey = "ClientReadAttempts"; + private const String ReadTimeoutKey = "ReadTimeout"; + private const String ServerCloseTimeoutKey = "ServerCloseTimeout"; + private const String WriteTimeoutKey = "WriteTimeout"; + } +} diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj index 89ab39f..42b08cc 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI.csproj @@ -52,6 +52,7 @@ + diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs index b1d36b4..56ddb6b 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.Designer.cs @@ -38,8 +38,8 @@ private void InitializeComponent() this._serverScriptButton = new System.Windows.Forms.Button(); this._serverScriptBox = new System.Windows.Forms.TextBox(); this._serverScriptLabel = new System.Windows.Forms.Label(); - this._serverSettingsButton = new System.Windows.Forms.Button(); - this._serverSettingsBox = new System.Windows.Forms.TextBox(); + this._serverConfigButton = new System.Windows.Forms.Button(); + this._serverConfigBox = new System.Windows.Forms.TextBox(); this._logLevelComboBox = new System.Windows.Forms.ComboBox(); this._logLevelLabel = new System.Windows.Forms.Label(); this._serverParametersBox = new System.Windows.Forms.GroupBox(); @@ -114,8 +114,8 @@ private void InitializeComponent() this._serverSettingsGroup.Controls.Add(this._serverScriptButton); this._serverSettingsGroup.Controls.Add(this._serverScriptBox); this._serverSettingsGroup.Controls.Add(this._serverScriptLabel); - this._serverSettingsGroup.Controls.Add(this._serverSettingsButton); - this._serverSettingsGroup.Controls.Add(this._serverSettingsBox); + this._serverSettingsGroup.Controls.Add(this._serverConfigButton); + this._serverSettingsGroup.Controls.Add(this._serverConfigBox); this._serverSettingsGroup.Controls.Add(this._logLevelComboBox); this._serverSettingsGroup.Controls.Add(this._logLevelLabel); this._serverSettingsGroup.Controls.Add(this._serverParametersBox); @@ -157,21 +157,21 @@ private void InitializeComponent() this._serverScriptLabel.TabIndex = 12; this._serverScriptLabel.Text = "Server Script:"; // - // _serverSettingsButton + // _serverConfigButton // - this._serverSettingsButton.Location = new System.Drawing.Point(194, 94); - this._serverSettingsButton.Name = "_serverSettingsButton"; - this._serverSettingsButton.Size = new System.Drawing.Size(24, 20); - this._serverSettingsButton.TabIndex = 11; - this._serverSettingsButton.Text = "..."; - this._serverSettingsButton.UseVisualStyleBackColor = true; + this._serverConfigButton.Location = new System.Drawing.Point(194, 94); + this._serverConfigButton.Name = "_serverConfigButton"; + this._serverConfigButton.Size = new System.Drawing.Size(24, 20); + this._serverConfigButton.TabIndex = 11; + this._serverConfigButton.Text = "..."; + this._serverConfigButton.UseVisualStyleBackColor = true; // - // _serverSettingsBox + // _serverConfigBox // - this._serverSettingsBox.Location = new System.Drawing.Point(97, 94); - this._serverSettingsBox.Name = "_serverSettingsBox"; - this._serverSettingsBox.Size = new System.Drawing.Size(97, 20); - this._serverSettingsBox.TabIndex = 10; + this._serverConfigBox.Location = new System.Drawing.Point(97, 94); + this._serverConfigBox.Name = "_serverConfigBox"; + this._serverConfigBox.Size = new System.Drawing.Size(97, 20); + this._serverConfigBox.TabIndex = 10; // // _logLevelComboBox // @@ -303,8 +303,8 @@ private void InitializeComponent() private System.Windows.Forms.Button _serverScriptButton; private System.Windows.Forms.TextBox _serverScriptBox; private System.Windows.Forms.Label _serverScriptLabel; - private System.Windows.Forms.Button _serverSettingsButton; - private System.Windows.Forms.TextBox _serverSettingsBox; + private System.Windows.Forms.Button _serverConfigButton; + private System.Windows.Forms.TextBox _serverConfigBox; } } diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs index a8b42c2..2dad1fc 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs @@ -12,8 +12,8 @@ using MossbauerLab.TinyTcpServer.Core.Client; using MossbauerLab.TinyTcpServer.Core.Server; using MossbauerLab.TinyTcpServer.MnGUI.Factories; +using MossbauerLab.TinyTcpServer.MnGUI.Helpers; using MossbauerLab.TinyTcpServer.MnGUI.LogUtils; -using MossbauerLab.TinyTcpServer.MnGUI.View.Helpers; using MossbauerLab.TinyTcpServer.MnGUI.View.Utils; namespace MossbauerLab.TinyTcpServer.MnGUI.View.Forms @@ -28,7 +28,7 @@ public MainForm() _stopButton.Click += (sender, args) => Stop(); _restartButton.Click += (sender, args) => Restart(); _serverScriptButton.Click += OnChooseScriptFileButtonClick; - _serverSettingsButton.Click += OnChooseSettingsFileButtonClick; + _serverConfigButton.Click += OnChooseConfigFileButtonClick; _logLevelComboBox.SelectedIndexChanged += (sender, args) => ApplyLogLevel(); } @@ -45,16 +45,13 @@ private void FillControls() // load last IP address and TCP Port settings if (File.Exists(ConfigFile)) { - String[] filelines = File.ReadAllLines(ConfigFile); - ApplySettings(GetOptions(filelines)); - } - else - { - if (_ipAddressComboBox.Items.Count > 0) - _ipAddressComboBox.SelectedIndex = 0; - _portTextBox.Text = DefaultTcpPort.ToString(); + _configFile = ConfigFile; + DisplayConfig(); } + if (_ipAddressComboBox.Items.Count > 0) + _ipAddressComboBox.SelectedIndex = 0; + _portTextBox.Text = DefaultTcpPort.ToString(); // init logger + fill log level XmlConfigurator.Configure(); @@ -65,31 +62,26 @@ private void FillControls() _logLevelComboBox.Items.Add(level.Value); _logLevelComboBox.SelectedIndex = 5; - // fill server config - IList configStrings = ServerConfigInfoHelper.GetConfigStrings(_serverConfig); - foreach (String configString in configStrings) - _serverParametersView.Items.Add(configString); - // update controls state UpdateControlsState(); } - private IDictionary GetOptions(String[] lines) + private void DisplayConfig() { - IDictionary options = new Dictionary(); - // todo: parse options .... - return options; + String[] lines = File.ReadAllLines(_configFile).Where(line => !line.Trim().StartsWith("#")).ToArray(); + _serverParametersView.Items.Clear(); + foreach (String line in lines) + _serverParametersView.Items.Add(line); + _serverConfigBox.Text = Path.GetFileName(_configFile); } - private void ApplySettings(IDictionary options) - { - - } private void Start() { UInt16 port = Convert.ToUInt16(_portTextBox.Text); if (_server == null) { + if (!String.IsNullOrEmpty(_configFile)) + _serverConfig = TcpServerConfigBuilder.Build(_configFile); if (_ipAddressComboBox.SelectedIndex >= 0 && _portTextBox.Text != null && !String.IsNullOrEmpty(_scriptFile)) _server = ServerFactory.Create(_ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), port, _scriptFile, _logger, _serverConfig); else @@ -99,7 +91,11 @@ private void Start() } _server.Start(); } - else _server.Start(_ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), port); + else + { + // todo umv: if server config changed => re-create server + _server.Start(_ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), port); + } if (_timers[0] == null) { @@ -109,7 +105,7 @@ private void Start() else _timers[0].Change(500, 500); } - public void Stop() + private void Stop() { _server.Stop(false); if (_timers[0] != null) @@ -119,7 +115,7 @@ public void Stop() UpdateControlsState(); } - public void Restart() + private void Restart() { Stop(); Start(); @@ -136,15 +132,15 @@ private void OnChooseScriptFileButtonClick(Object sender, EventArgs args) } } - private void OnChooseSettingsFileButtonClick(Object sender, EventArgs args) + private void OnChooseConfigFileButtonClick(Object sender, EventArgs args) { OpenFileDialog openScriptFile = new OpenFileDialog(); - String file = openScriptFile.Run(@" Text files (*.txt)|*.txt | Config files (*.conf) |*.conf | Config files (*.cfg) |*.cfg | Any file (*.*)|*.*", + String file = openScriptFile.Run(@" Text files (*.txt)|*.txt|Config files (*.conf)|*.conf|Config files (*.cfg)|*.cfg|Any file (*.*)|*.*", Path.GetFullPath("."), @"Choose Server settings file", 0); if (file != String.Empty) { - _settingsFile = file; - _serverSettingsBox.Text = Path.GetFileName(_settingsFile); + _configFile = file; + DisplayConfig(); } } @@ -215,8 +211,8 @@ private void ApplyLogLevel() private ILog _logger; private ITcpServer _server; private String _scriptFile; - private String _settingsFile; - private readonly TcpServerConfig _serverConfig = new TcpServerConfig(); + private String _configFile; + private TcpServerConfig _serverConfig = new TcpServerConfig(); private RichTextBoxAppender _richTextBoxAppender; private readonly System.Threading.Timer[] _timers = new System.Threading.Timer[1]; } From 4f8c7e6e0ebb8b5e77940b26b4d38b02b735812e Mon Sep 17 00:00:00 2001 From: Michael Ushakov Date: Sun, 5 Nov 2017 23:18:51 +0400 Subject: [PATCH 7/7] If config file was changed, it setting will applied on next run --- .../MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs index 2dad1fc..de90df3 100644 --- a/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs +++ b/GUI/MossbauerLab.TinyTcpServer.MnGUI/MossbauerLab.TinyTcpServer.MnGUI/View/Forms/MainForm.cs @@ -93,7 +93,8 @@ private void Start() } else { - // todo umv: if server config changed => re-create server + if(_configChanged) + _server = ServerFactory.Create(_ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), port, _scriptFile, _logger, _serverConfig); _server.Start(_ipAddressComboBox.Items[_ipAddressComboBox.SelectedIndex].ToString(), port); } @@ -141,6 +142,7 @@ private void OnChooseConfigFileButtonClick(Object sender, EventArgs args) { _configFile = file; DisplayConfig(); + _configChanged = true; } } @@ -213,6 +215,7 @@ private void ApplyLogLevel() private String _scriptFile; private String _configFile; private TcpServerConfig _serverConfig = new TcpServerConfig(); + private Boolean _configChanged = false; private RichTextBoxAppender _richTextBoxAppender; private readonly System.Threading.Timer[] _timers = new System.Threading.Timer[1]; }