wenxiangchao
3 天以前 b544d5cccd76735e034c8055918a50927b437474
Plugin.BurnIn/ManualDebug/ManualDebug.xaml.cs
@@ -6,14 +6,18 @@
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
{
@@ -219,16 +223,39 @@
            });
        }
        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
            {
@@ -247,6 +274,7 @@
                        return;
                    }
                    ChangeTcpServerStatus("RUNNING", this.lang("Tr.TcpServer.Running"));
                    AppendLog(LogLevel.Debug, $"数据接收服务器启动,端口:{port}");
                }
                else if (tcpServer.State != SuperSocket.SocketBase.ServerState.Running)
                {
@@ -261,11 +289,13 @@
                        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;
            }
@@ -613,6 +643,7 @@
            {
                executionWrapper?.SetFileGlobalValue("Running.StopTest", 1, true);
                executionWrapper?.WaitForExit();
                executionWrapper?.Dispose();
                tcpServer?.Stop();
            }
            catch (Exception ex)