Przeglądaj źródła

fix Load Xml bug!

张泳健 8 lat temu
rodzic
commit
0c3f5e04c7

BIN
.vs/GWSocketClient/v15/.suo Wyświetl plik


BIN
GWSocketClient.rar Wyświetl plik


+ 0 - 2
GWSocketClient/Form1.Designer.cs Wyświetl plik

@@ -393,8 +393,6 @@
393 393
             // 
394 394
             // ToolStripMenuItemLogHb
395 395
             // 
396
-            this.ToolStripMenuItemLogHb.Checked = true;
397
-            this.ToolStripMenuItemLogHb.CheckState = System.Windows.Forms.CheckState.Checked;
398 396
             this.ToolStripMenuItemLogHb.Name = "ToolStripMenuItemLogHb";
399 397
             this.ToolStripMenuItemLogHb.Size = new System.Drawing.Size(172, 22);
400 398
             this.ToolStripMenuItemLogHb.Text = "是否打印心跳";

+ 24 - 3
GWSocketClient/Form1.cs Wyświetl plik

@@ -72,7 +72,6 @@ namespace GWSocketClient
72 72
         {
73 73
             while (hbRunFlag)
74 74
             {
75
-            
76 75
                 int interval = 5;
77 76
                 if (!toolStripTextBoxHbtime.Text.Trim().Equals(""))
78 77
                 {
@@ -80,7 +79,7 @@ namespace GWSocketClient
80 79
                 }
81 80
                 Thread.Sleep(interval * 1000);
82 81
 
83
-          
82
+
84 83
                 if (hbRunFlag)
85 84
                 {
86 85
                     string hbCmd = vcarecityProtocolBean.ProtocolStartSymbol;
@@ -96,7 +95,14 @@ namespace GWSocketClient
96 95
                     }
97 96
                 }
98 97
             }
99
-            this.Invoke(this.uiDelegate, new object[] {"心跳线程结束!"});
98
+            try
99
+            {
100
+                this.Invoke(this.uiDelegate, new object[] { "心跳线程结束!" });
101
+            }
102
+            catch (Exception e)
103
+            {
104
+                Console.WriteLine(e);
105
+            }
100 106
         }
101 107
 
102 108
         #endregion
@@ -352,12 +358,15 @@ namespace GWSocketClient
352 358
         {
353 359
             OpenFileDialog ofd = new OpenFileDialog();
354 360
             ofd.Filter = "XML文件|*.xml|所有文件|*.*";
361
+            ofd.InitialDirectory = Application.StartupPath;
355 362
 
356 363
             if (ofd.ShowDialog() == DialogResult.OK)
357 364
             {
358 365
                 string xmlFilepath = ofd.FileName;
359 366
 
360 367
                 vcarecityProtocolBean = new XmlLoader().load(xmlFilepath).getVcarecityPD();
368
+                this.Text = vcarecityProtocolBean.ProtocolName + " - " + vcarecityProtocolBean.ProtocolNo + " - " +
369
+                            vcarecityProtocolBean.ProtocolStartSymbol;
361 370
             }
362 371
         }
363 372
 
@@ -525,6 +534,18 @@ namespace GWSocketClient
525 534
 
526 535
         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
527 536
         {
537
+            try
538
+            {
539
+                sockeTcpClients.Stop();
540
+            }
541
+            catch (Exception exception)
542
+            {
543
+            }
544
+            finally
545
+            {
546
+                sockeTcpClients = null;
547
+            }
548
+
528 549
             AccsessDbLoader.getInstance().closeConnection();
529 550
         }
530 551
 

+ 10 - 2
GWSocketClient/xml/XmlLoader.cs Wyświetl plik

@@ -41,9 +41,17 @@ namespace GWSocketClient.xml
41 41
 
42 42
         public XmlLoader()
43 43
         {
44
+            try
45
+            {
44 46
 //            string xmlFilePath = @"D:\TestProject\GW\config\dtu.xml";
45
-            string xmlFilePath = Application.StartupPath + "/xml/dtu.xml";
46
-            loadXmlDocument(xmlFilePath);
47
+                string xmlFilePath = Application.StartupPath + "/xml/dtu.xml";
48
+
49
+                loadXmlDocument(xmlFilePath);
50
+            }
51
+            catch (Exception exception)
52
+            {
53
+                
54
+            }
47 55
         }
48 56
 
49 57
         public XmlLoader(string xmlFilePath)