张泳健 8 anni fa
parent
commit
0c3f5e04c7

BIN
.vs/GWSocketClient/v15/.suo Vedi File


BIN
GWSocketClient.rar Vedi File


+ 0 - 2
GWSocketClient/Form1.Designer.cs Vedi File

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

+ 24 - 3
GWSocketClient/Form1.cs Vedi File

72
         {
72
         {
73
             while (hbRunFlag)
73
             while (hbRunFlag)
74
             {
74
             {
75
-            
76
                 int interval = 5;
75
                 int interval = 5;
77
                 if (!toolStripTextBoxHbtime.Text.Trim().Equals(""))
76
                 if (!toolStripTextBoxHbtime.Text.Trim().Equals(""))
78
                 {
77
                 {
80
                 }
79
                 }
81
                 Thread.Sleep(interval * 1000);
80
                 Thread.Sleep(interval * 1000);
82
 
81
 
83
-          
82
+
84
                 if (hbRunFlag)
83
                 if (hbRunFlag)
85
                 {
84
                 {
86
                     string hbCmd = vcarecityProtocolBean.ProtocolStartSymbol;
85
                     string hbCmd = vcarecityProtocolBean.ProtocolStartSymbol;
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
         #endregion
108
         #endregion
352
         {
358
         {
353
             OpenFileDialog ofd = new OpenFileDialog();
359
             OpenFileDialog ofd = new OpenFileDialog();
354
             ofd.Filter = "XML文件|*.xml|所有文件|*.*";
360
             ofd.Filter = "XML文件|*.xml|所有文件|*.*";
361
+            ofd.InitialDirectory = Application.StartupPath;
355
 
362
 
356
             if (ofd.ShowDialog() == DialogResult.OK)
363
             if (ofd.ShowDialog() == DialogResult.OK)
357
             {
364
             {
358
                 string xmlFilepath = ofd.FileName;
365
                 string xmlFilepath = ofd.FileName;
359
 
366
 
360
                 vcarecityProtocolBean = new XmlLoader().load(xmlFilepath).getVcarecityPD();
367
                 vcarecityProtocolBean = new XmlLoader().load(xmlFilepath).getVcarecityPD();
368
+                this.Text = vcarecityProtocolBean.ProtocolName + " - " + vcarecityProtocolBean.ProtocolNo + " - " +
369
+                            vcarecityProtocolBean.ProtocolStartSymbol;
361
             }
370
             }
362
         }
371
         }
363
 
372
 
525
 
534
 
526
         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
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
             AccsessDbLoader.getInstance().closeConnection();
549
             AccsessDbLoader.getInstance().closeConnection();
529
         }
550
         }
530
 
551
 

+ 10 - 2
GWSocketClient/xml/XmlLoader.cs Vedi File

41
 
41
 
42
         public XmlLoader()
42
         public XmlLoader()
43
         {
43
         {
44
+            try
45
+            {
44
 //            string xmlFilePath = @"D:\TestProject\GW\config\dtu.xml";
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
         public XmlLoader(string xmlFilePath)
57
         public XmlLoader(string xmlFilePath)