diff --git a/MainWindow.xaml b/MainWindow.xaml index b82bd17..db31c05 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -24,7 +24,6 @@ - @@ -46,9 +45,13 @@ - + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index ee01017..c0d791b 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -53,7 +53,15 @@ namespace formula_manage InitializeComponent(); this.Closing += Window_Closing; //添加窗口关闭事件 - if (Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L6"))) UserClass.TCPServer.Start(); //开启网路通讯 + if (Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L6"))) + { + UserClass.TCPServer.Start(); //开启网路通讯 + _WorkingMode.Header = "服务端"; + } + else + { + _WorkingMode.Header = "客户端"; + } USER.Text = App.USER_Purview; RRODUCTdataTable.Columns.Add("ID", typeof(int)); diff --git a/UserClass/TCPServer.cs b/UserClass/TCPServer.cs index 8de80b8..d555a2d 100644 --- a/UserClass/TCPServer.cs +++ b/UserClass/TCPServer.cs @@ -18,16 +18,15 @@ namespace formula_manage.UserClass //字典集合:存储IP和Socket的集合 public static Dictionary OnLineList = new Dictionary(); - DataTable IPdataTable = new DataTable(); //建立缓存 - //当前时间 - + + //当前时间 private string CurrentTime { get { return DateTime.Now.ToString("HH:mm:ss") + Environment.NewLine; } } //编码格式 - public static Encoding econding = Encoding.Default; + public static Encoding econding = Encoding.UTF8; public static void Start() { @@ -80,7 +79,7 @@ namespace formula_manage.UserClass while (true) { //定义一个2M的缓冲区 - byte[] buffer = new byte[1024 * 1024 * 2]; + byte[] buffer = new byte[1024 * 1024 * 10]; int length = -1; try @@ -94,12 +93,10 @@ namespace formula_manage.UserClass string ip = clientSocket.RemoteEndPoint.ToString(); UserClass.LogGing.LogGingDATA("IP_Line = " + ip); // AddOnLine(ip, false); - OnLineList.Remove(ip); - - break; + OnLineList.Remove(ip); //移除ip + break; //退出循环 } - if (length == 0) { //客户端下线了 @@ -108,11 +105,9 @@ namespace formula_manage.UserClass UserClass.LogGing.LogGingDATA("IP_Line = " + ip); // AddOnLine(ip, false); OnLineList.Remove(ip); - break; } - - if (length > 0) + else { infoR = econding.GetString(buffer, 0, length); //ShowMessage(info);