| | |
| | | using Plugin.BurnIn.Model; |
| | | using Plugin.TsSupport; |
| | | using SuperSocket.SocketBase.Config; |
| | | using System.Collections; |
| | | using System.Collections.ObjectModel; |
| | | using System.ComponentModel; |
| | | using System.Configuration; |
| | | using System.Globalization; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | | using System.Windows.Data; |
| | | using System.Windows.Documents; |
| | | using System.Windows.Media; |
| | | using System.Xml.Linq; |
| | | |
| | | namespace Plugin.BurnIn |
| | | { |
| | |
| | | }); |
| | | } |
| | | |
| | | private int GetConfigPort() |
| | | { |
| | | try |
| | | { |
| | | var customConfig = (Hashtable)ConfigurationManager.GetSection("TestResultConfig"); |
| | | if (customConfig.ContainsKey("PortStart")) |
| | | { |
| | | int port = int.Parse(customConfig["PortStart"].ToString()) - 1; |
| | | return port; |
| | | } |
| | | else |
| | | { |
| | | return 6659; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | AppendLog(LogLevel.Error, $"读取起始端口错误: {ex.Message} {ex.StackTrace} 使用默认端口6659"); |
| | | return 6659; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 启动Tcp服务器 |
| | | /// </summary> |
| | | [RelayCommand] |
| | | private void StartTcpServer() |
| | | { |
| | | int port = GetConfigPort(); |
| | | var serverConfig = new ServerConfig() |
| | | { |
| | | MaxRequestLength = 1024 * 1024, |
| | | Port = 7777 |
| | | Port = port |
| | | }; |
| | | try |
| | | { |
| | |
| | | return; |
| | | } |
| | | ChangeTcpServerStatus("RUNNING", this.lang("Tr.TcpServer.Running")); |
| | | AppendLog(LogLevel.Debug, $"数据接收服务器启动,端口:{port}"); |
| | | } |
| | | else if (tcpServer.State != SuperSocket.SocketBase.ServerState.Running) |
| | | { |
| | |
| | | return; |
| | | } |
| | | ChangeTcpServerStatus("RUNNING", this.lang("Tr.TcpServer.Running")); |
| | | AppendLog(LogLevel.Debug, $"数据接收服务器启动,端口:{port}"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ChangeTcpServerStatus("ERROR", $"{ex.Message}"); |
| | | AppendLog(LogLevel.Error, $"数据接收服务器启动错误: {ex.Message} {ex.StackTrace}"); |
| | | tcpServer?.Stop(); |
| | | tcpServer = null; |
| | | } |
| | |
| | | { |
| | | executionWrapper?.SetFileGlobalValue("Running.StopTest", 1, true); |
| | | executionWrapper?.WaitForExit(); |
| | | executionWrapper?.Dispose(); |
| | | tcpServer?.Stop(); |
| | | } |
| | | catch (Exception ex) |