zhouxianguang 6 роки тому
батько
коміт
be6c588048
2 змінених файлів з 34 додано та 8 видалено
  1. 22 0
      WinBox/CloseForm.cs
  2. 12 8
      WinBox/MainForm.cs

+ 22 - 0
WinBox/CloseForm.cs

@@ -2,7 +2,9 @@
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
+using System.Diagnostics;
 using System.Drawing;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -43,6 +45,26 @@ namespace WinBox
         private void button2_Click(object sender, EventArgs e)
         {
             this.Close();
+            try
+            {
+                RunBat("C:\\Lingjiao\\winBoxNode\\stop.bat");
+            }
+            catch (Exception ex)
+            {
+            }
         }
+
+        private void RunBat(string batPath)
+        {
+            Process pro = new Process();
+            FileInfo file = new FileInfo(batPath);
+            pro.StartInfo.WorkingDirectory = file.Directory.FullName;
+            pro.StartInfo.FileName = batPath;
+            pro.StartInfo.CreateNoWindow = false;
+            pro.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+            pro.Start();
+            pro.Close();
+        }
+
     }
 }

+ 12 - 8
WinBox/MainForm.cs

@@ -42,14 +42,14 @@ namespace WinBox
             this.webBrowser1.Url = new System.Uri("http://tt-web.api.ai160.com/debug/build/stage/index/index.html", System.UriKind.Absolute);
             this.Controls.Add(this.webBrowser1);
 
-           // RunBat("C:\\Lingjiao\\winBoxNode\\start.bat");
+            RunBat("C:\\Lingjiao\\winBoxNode\\start.bat");
+
+            //检测端口
+            detectionPort();
         }
 
-        private void Form1_Activated(object sender, System.EventArgs e)
+        private void detectionPort()
         {
-            // Label1.Text = "x: " + x + " y: " + y;
-            // Label2.Text = "Number of forms currently open: " + count;
-
             string tcpPort = "9191";
             try
             {
@@ -78,11 +78,11 @@ namespace WinBox
                         }
                         else
                         {
-                            MessageBox.Show("TCP:" + tcpPort + "端口没有被占用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
+                            //MessageBox.Show("TCP:" + tcpPort + "端口没有被占用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                             break;
                         }
                     }
-                    
+
                     reader.Close();
                     process.Close();
                 }
@@ -92,8 +92,12 @@ namespace WinBox
                 MessageBox.Show("检测TCP端口:" + tcpPort + "失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
 
+        }
 
-
+        private void Form1_Activated(object sender, System.EventArgs e)
+        {
+            // Label1.Text = "x: " + x + " y: " + y;
+            // Label2.Text = "Number of forms currently open: " + count;
         }
 
         private void RunBat(string batPath)