Procházet zdrojové kódy

添加指令中...

张泳健 před 7 roky
rodič
revize
8f835e7053

+ 23 - 0
DotNettyFrom/DotNettyFrom.csproj Zobrazit soubor

@@ -129,13 +129,27 @@
129 129
   <ItemGroup>
130 130
     <Compile Include="common\DataModel.cs" />
131 131
     <Compile Include="common\UIInfoModel..cs" />
132
+    <Compile Include="config\DBConfig.cs" />
132 133
     <Compile Include="config\SystemConfig.cs" />
134
+    <Compile Include="db\DBHelper.cs" />
133 135
     <Compile Include="dialog\HeartBeatTime.cs">
134 136
       <SubType>Form</SubType>
135 137
     </Compile>
136 138
     <Compile Include="dialog\HeartBeatTime.Designer.cs">
137 139
       <DependentUpon>HeartBeatTime.cs</DependentUpon>
138 140
     </Compile>
141
+    <Compile Include="form\ItemEditorForm.cs">
142
+      <SubType>Form</SubType>
143
+    </Compile>
144
+    <Compile Include="form\ItemEditorForm.Designer.cs">
145
+      <DependentUpon>ItemEditorForm.cs</DependentUpon>
146
+    </Compile>
147
+    <Compile Include="form\ItemManagerForm.cs">
148
+      <SubType>Form</SubType>
149
+    </Compile>
150
+    <Compile Include="form\ItemManagerForm.Designer.cs">
151
+      <DependentUpon>ItemManagerForm.cs</DependentUpon>
152
+    </Compile>
139 153
     <Compile Include="MainForm.cs">
140 154
       <SubType>Form</SubType>
141 155
     </Compile>
@@ -146,9 +160,18 @@
146 160
     <Compile Include="Program.cs" />
147 161
     <Compile Include="Properties\AssemblyInfo.cs" />
148 162
     <Compile Include="util\AryUtil.cs" />
163
+    <Compile Include="util\CheckUtil.cs" />
164
+    <Compile Include="util\CmdUtil.cs" />
165
+    <Compile Include="WvBean.cs" />
149 166
     <EmbeddedResource Include="dialog\HeartBeatTime.resx">
150 167
       <DependentUpon>HeartBeatTime.cs</DependentUpon>
151 168
     </EmbeddedResource>
169
+    <EmbeddedResource Include="form\ItemEditorForm.resx">
170
+      <DependentUpon>ItemEditorForm.cs</DependentUpon>
171
+    </EmbeddedResource>
172
+    <EmbeddedResource Include="form\ItemManagerForm.resx">
173
+      <DependentUpon>ItemManagerForm.cs</DependentUpon>
174
+    </EmbeddedResource>
152 175
     <EmbeddedResource Include="MainForm.resx">
153 176
       <DependentUpon>MainForm.cs</DependentUpon>
154 177
     </EmbeddedResource>

+ 99 - 2
DotNettyFrom/MainForm.Designer.cs Zobrazit soubor

@@ -28,6 +28,7 @@
28 28
         /// </summary>
29 29
         private void InitializeComponent()
30 30
         {
31
+            this.components = new System.ComponentModel.Container();
31 32
             this.LBLogShow = new System.Windows.Forms.ListBox();
32 33
             this.TbHost = new System.Windows.Forms.TextBox();
33 34
             this.TbPort = new System.Windows.Forms.TextBox();
@@ -60,9 +61,19 @@
60 61
             this.label1 = new System.Windows.Forms.Label();
61 62
             this.label5 = new System.Windows.Forms.Label();
62 63
             this.TbSendData = new System.Windows.Forms.TextBox();
64
+            this.ListBoxLogContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
65
+            this.LB_Context_CpCmd = new System.Windows.Forms.ToolStripMenuItem();
66
+            this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
67
+            this.LB_Context_GJson = new System.Windows.Forms.ToolStripMenuItem();
68
+            this.LB_Context_AnaCmd = new System.Windows.Forms.ToolStripMenuItem();
69
+            this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
70
+            this.LB_Context_ClearAll = new System.Windows.Forms.ToolStripMenuItem();
71
+            this.LB_Context_CpLine = new System.Windows.Forms.ToolStripMenuItem();
72
+            this.BtnClearAll = new System.Windows.Forms.Button();
63 73
             this.menuStrip1.SuspendLayout();
64 74
             this.statusStrip1.SuspendLayout();
65 75
             this.groupBox1.SuspendLayout();
76
+            this.ListBoxLogContextMenu.SuspendLayout();
66 77
             this.SuspendLayout();
67 78
             // 
68 79
             // LBLogShow
@@ -70,6 +81,9 @@
70 81
             this.LBLogShow.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
71 82
             | System.Windows.Forms.AnchorStyles.Left) 
72 83
             | System.Windows.Forms.AnchorStyles.Right)));
84
+            this.LBLogShow.ContextMenuStrip = this.ListBoxLogContextMenu;
85
+            this.LBLogShow.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
86
+            this.LBLogShow.Font = new System.Drawing.Font("微软雅黑", 9F);
73 87
             this.LBLogShow.FormattingEnabled = true;
74 88
             this.LBLogShow.ItemHeight = 16;
75 89
             this.LBLogShow.Location = new System.Drawing.Point(12, 277);
@@ -77,6 +91,8 @@
77 91
             this.LBLogShow.Name = "LBLogShow";
78 92
             this.LBLogShow.Size = new System.Drawing.Size(961, 404);
79 93
             this.LBLogShow.TabIndex = 0;
94
+            this.LBLogShow.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.LBLogShow_DrawItem);
95
+            this.LBLogShow.DoubleClick += new System.EventHandler(this.LBLogShow_DoubleClick);
80 96
             // 
81 97
             // TbHost
82 98
             // 
@@ -251,6 +267,7 @@
251 267
             // 
252 268
             this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
253 269
             | System.Windows.Forms.AnchorStyles.Right)));
270
+            this.groupBox1.Controls.Add(this.BtnClearAll);
254 271
             this.groupBox1.Controls.Add(this.TbSendData);
255 272
             this.groupBox1.Controls.Add(this.label5);
256 273
             this.groupBox1.Controls.Add(this.BtnTest);
@@ -276,7 +293,6 @@
276 293
             // 
277 294
             // BtnTest
278 295
             // 
279
-            this.BtnTest.Enabled = false;
280 296
             this.BtnTest.Location = new System.Drawing.Point(471, 45);
281 297
             this.BtnTest.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
282 298
             this.BtnTest.Name = "BtnTest";
@@ -287,7 +303,6 @@
287 303
             // 
288 304
             // BtnCmdManager
289 305
             // 
290
-            this.BtnCmdManager.Enabled = false;
291 306
             this.BtnCmdManager.Location = new System.Drawing.Point(378, 45);
292 307
             this.BtnCmdManager.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
293 308
             this.BtnCmdManager.Name = "BtnCmdManager";
@@ -295,6 +310,7 @@
295 310
             this.BtnCmdManager.TabIndex = 8;
296 311
             this.BtnCmdManager.Text = "命令管理";
297 312
             this.BtnCmdManager.UseVisualStyleBackColor = true;
313
+            this.BtnCmdManager.Click += new System.EventHandler(this.BtnCmdManager_Click);
298 314
             // 
299 315
             // label4
300 316
             // 
@@ -373,6 +389,75 @@
373 389
     "92210592902000004170922105929020000051709221059290001160617092210592900012f07170" +
374 390
     "92210592902000008170922105929020000cd";
375 391
             // 
392
+            // ListBoxLogContextMenu
393
+            // 
394
+            this.ListBoxLogContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
395
+            this.LB_Context_CpCmd,
396
+            this.LB_Context_CpLine,
397
+            this.toolStripSeparator3,
398
+            this.LB_Context_GJson,
399
+            this.LB_Context_AnaCmd,
400
+            this.toolStripSeparator4,
401
+            this.LB_Context_ClearAll});
402
+            this.ListBoxLogContextMenu.Name = "ListBoxLogContextMenu";
403
+            this.ListBoxLogContextMenu.Size = new System.Drawing.Size(170, 126);
404
+            // 
405
+            // LB_Context_CpCmd
406
+            // 
407
+            this.LB_Context_CpCmd.Name = "LB_Context_CpCmd";
408
+            this.LB_Context_CpCmd.Size = new System.Drawing.Size(169, 22);
409
+            this.LB_Context_CpCmd.Text = "复制指令(&C)";
410
+            this.LB_Context_CpCmd.Click += new System.EventHandler(this.LB_Context_CpCmd_Click);
411
+            // 
412
+            // toolStripSeparator3
413
+            // 
414
+            this.toolStripSeparator3.Name = "toolStripSeparator3";
415
+            this.toolStripSeparator3.Size = new System.Drawing.Size(166, 6);
416
+            // 
417
+            // LB_Context_GJson
418
+            // 
419
+            this.LB_Context_GJson.Name = "LB_Context_GJson";
420
+            this.LB_Context_GJson.Size = new System.Drawing.Size(169, 22);
421
+            this.LB_Context_GJson.Text = "指令生成JSON(&J)";
422
+            this.LB_Context_GJson.Click += new System.EventHandler(this.LB_Context_GJson_Click);
423
+            // 
424
+            // LB_Context_AnaCmd
425
+            // 
426
+            this.LB_Context_AnaCmd.Name = "LB_Context_AnaCmd";
427
+            this.LB_Context_AnaCmd.Size = new System.Drawing.Size(169, 22);
428
+            this.LB_Context_AnaCmd.Text = "分析指令(&A)";
429
+            this.LB_Context_AnaCmd.Click += new System.EventHandler(this.LB_Context_AnaCmd_Click);
430
+            // 
431
+            // toolStripSeparator4
432
+            // 
433
+            this.toolStripSeparator4.Name = "toolStripSeparator4";
434
+            this.toolStripSeparator4.Size = new System.Drawing.Size(166, 6);
435
+            // 
436
+            // LB_Context_ClearAll
437
+            // 
438
+            this.LB_Context_ClearAll.Name = "LB_Context_ClearAll";
439
+            this.LB_Context_ClearAll.Size = new System.Drawing.Size(169, 22);
440
+            this.LB_Context_ClearAll.Text = "清空信息(&L)";
441
+            this.LB_Context_ClearAll.Click += new System.EventHandler(this.LB_Context_ClearAll_Click);
442
+            // 
443
+            // LB_Context_CpLine
444
+            // 
445
+            this.LB_Context_CpLine.Name = "LB_Context_CpLine";
446
+            this.LB_Context_CpLine.Size = new System.Drawing.Size(169, 22);
447
+            this.LB_Context_CpLine.Text = "复制整行(&R)";
448
+            this.LB_Context_CpLine.Click += new System.EventHandler(this.LB_Context_CpLine_Click);
449
+            // 
450
+            // BtnClearAll
451
+            // 
452
+            this.BtnClearAll.Location = new System.Drawing.Point(564, 45);
453
+            this.BtnClearAll.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
454
+            this.BtnClearAll.Name = "BtnClearAll";
455
+            this.BtnClearAll.Size = new System.Drawing.Size(87, 31);
456
+            this.BtnClearAll.TabIndex = 11;
457
+            this.BtnClearAll.Text = "清空信息";
458
+            this.BtnClearAll.UseVisualStyleBackColor = true;
459
+            this.BtnClearAll.Click += new System.EventHandler(this.BtnClearAll_Click);
460
+            // 
376 461
             // MainForm
377 462
             // 
378 463
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
@@ -386,7 +471,9 @@
386 471
             this.MainMenuStrip = this.menuStrip1;
387 472
             this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
388 473
             this.Name = "MainForm";
474
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
389 475
             this.Text = "模拟器";
476
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
390 477
             this.Load += new System.EventHandler(this.MainForm_Load);
391 478
             this.menuStrip1.ResumeLayout(false);
392 479
             this.menuStrip1.PerformLayout();
@@ -394,6 +481,7 @@
394 481
             this.statusStrip1.PerformLayout();
395 482
             this.groupBox1.ResumeLayout(false);
396 483
             this.groupBox1.PerformLayout();
484
+            this.ListBoxLogContextMenu.ResumeLayout(false);
397 485
             this.ResumeLayout(false);
398 486
             this.PerformLayout();
399 487
 
@@ -433,6 +521,15 @@
433 521
         private System.Windows.Forms.Button BtnTest;
434 522
         private System.Windows.Forms.TextBox TbSendData;
435 523
         private System.Windows.Forms.Label label5;
524
+        private System.Windows.Forms.ContextMenuStrip ListBoxLogContextMenu;
525
+        private System.Windows.Forms.ToolStripMenuItem LB_Context_CpCmd;
526
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
527
+        private System.Windows.Forms.ToolStripMenuItem LB_Context_GJson;
528
+        private System.Windows.Forms.ToolStripMenuItem LB_Context_AnaCmd;
529
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
530
+        private System.Windows.Forms.ToolStripMenuItem LB_Context_ClearAll;
531
+        private System.Windows.Forms.ToolStripMenuItem LB_Context_CpLine;
532
+        private System.Windows.Forms.Button BtnClearAll;
436 533
     }
437 534
 }
438 535
 

+ 138 - 7
DotNettyFrom/MainForm.cs Zobrazit soubor

@@ -10,8 +10,11 @@ using System.Threading.Tasks;
10 10
 using System.Windows.Forms;
11 11
 using DotNettyFrom.common;
12 12
 using DotNettyFrom.config;
13
+using DotNettyFrom.db;
13 14
 using DotNettyFrom.dialog;
15
+using DotNettyFrom.form;
14 16
 using DotNettyFrom.netty;
17
+using DotNettyFrom.util;
15 18
 
16 19
 namespace DotNettyFrom
17 20
 {
@@ -33,7 +36,19 @@ namespace DotNettyFrom
33 36
 
34 37
         private void MainForm_Load(object sender, EventArgs e)
35 38
         {
36
-            updateUIComponent();
39
+            if (!CheckUtil.CheckDbFileIsExits())
40
+            {
41
+                MessageBox.Show("Access数据库文件不存在! 强制退出程序!");
42
+                Application.Exit();
43
+            }
44
+
45
+            DbHelper.Init();
46
+            
47
+
48
+//            DBHelper.ConnectionAccessDb();
49
+
50
+
51
+            UpdateUiComponent();
37 52
 
38 53
             var consumer = Task.Factory.StartNew(() =>
39 54
             {
@@ -44,10 +59,20 @@ namespace DotNettyFrom
44 59
             });
45 60
         }
46 61
 
62
+        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
63
+        {
64
+            DbHelper.GetInstance().CloseAccessDb();
65
+        }
66
+
47 67
 
48 68
         private void CallUI(UIInfoModel value)
49 69
         {
50 70
             LBLogShow.Items.Add(value);
71
+            LBLogShow.TopIndex = LBLogShow.Items.Count - 1;
72
+            if (LBLogShow.Items.Count > SystemConfig.LBLogShowClearCount)
73
+            {
74
+                LBLogShow.Items.RemoveAt(0);
75
+            }
51 76
             switch (value.action)
52 77
             {
53 78
                 case -1: //连接不上,服务器没开启
@@ -92,14 +117,14 @@ namespace DotNettyFrom
92 117
             BtnSendData.Enabled = false;
93 118
         }
94 119
 
95
-        private void beforeConnection()
120
+        private void BeforeConnection()
96 121
         {
97 122
             this.host = TbHost.Text.Trim();
98 123
             this.port = int.Parse(TbPort.Text.Trim());
99
-            updateUIComponent();
124
+            UpdateUiComponent();
100 125
         }
101 126
 
102
-        private void updateUIComponent()
127
+        private void UpdateUiComponent()
103 128
         {
104 129
             StatusItemHbTime.Text = "R:" + SystemConfig.ReaderIdleTimeSeconds + "/s,W:" +
105 130
                                     SystemConfig.WriterIdleTimeSeconds + "/s,A:" + SystemConfig.AllIdleTimeSeconds +
@@ -123,7 +148,7 @@ namespace DotNettyFrom
123 148
             t = new Thread(() => { _nettyClient.StartNetty("127.0.0.1", 4001); });
124 149
             t.Start();*/
125 150
 
126
-            beforeConnection();
151
+            BeforeConnection();
127 152
 
128 153
             Task startNew = Task.Factory.StartNew(() =>
129 154
             {
@@ -134,13 +159,12 @@ namespace DotNettyFrom
134 159
 
135 160
         private void BtnLogin_Click(object sender, EventArgs e)
136 161
         {
137
-            beforeConnection();
162
+            BeforeConnection();
138 163
 
139 164
             Task startNew = Task.Factory.StartNew(() =>
140 165
             {
141 166
                 _nettyClient = new NettyClient();
142 167
                 _nettyClient.StartNetty(host, port);
143
-
144 168
             });
145 169
         }
146 170
 
@@ -171,6 +195,113 @@ namespace DotNettyFrom
171 195
             }
172 196
         }
173 197
 
198
+        private void BtnClearAll_Click(object sender, EventArgs e) => LBLogShow.Items.Clear();
199
+
200
+        private void BtnCmdManager_Click(object sender, EventArgs e)
201
+        {
202
+            ItemManagerForm imf = new ItemManagerForm();
203
+            imf.ShowDialog();
204
+        }
205
+
174 206
         #endregion
207
+
208
+        #region ListBox
209
+
210
+        private void LBLogShow_DrawItem(object sender, DrawItemEventArgs e)
211
+        {
212
+            if (e.Index >= 0 && e.Index < LBLogShow.Items.Count)
213
+            {
214
+                e.DrawBackground();
215
+                UIInfoModel res = LBLogShow.Items[e.Index] as UIInfoModel;
216
+
217
+                if (res.SendType == SystemConfig.SendType)
218
+                {
219
+                    Font f = new Font("微软雅黑", e.Font.Size);
220
+                    e.Graphics.DrawString(((ListBox) sender).Items[e.Index].ToString(), f,
221
+                        new SolidBrush(Color.Crimson),
222
+                        e.Bounds);
223
+                }
224
+                else if (res.SendType == SystemConfig.RecType)
225
+                {
226
+                    Font f = new Font("微软雅黑", e.Font.Size);
227
+                    e.Graphics.DrawString(((ListBox) sender).Items[e.Index].ToString(), f, new SolidBrush(Color.Blue),
228
+                        e.Bounds);
229
+                }
230
+                else if (res.SendType == SystemConfig.ReplyType)
231
+                {
232
+                }
233
+                else
234
+                {
235
+                    e.Graphics.DrawString(((ListBox) sender).Items[e.Index].ToString(), e.Font,
236
+                        new SolidBrush(e.ForeColor),
237
+                        e.Bounds);
238
+                }
239
+            }
240
+        }
241
+
242
+        private void LBLogShow_DoubleClick(object sender, EventArgs e)
243
+        {
244
+            int index = LBLogShow.SelectedIndex;
245
+            if (index >= 0 && index < LBLogShow.Items.Count)
246
+            {
247
+            }
248
+        }
249
+
250
+
251
+        private void LB_Context_CpCmd_Click(object sender, EventArgs e)
252
+        {
253
+            int index = LBLogShow.SelectedIndex;
254
+            if (index >= 0 && index < LBLogShow.Items.Count)
255
+            {
256
+                UIInfoModel uiInfoModel = LBLogShow.SelectedItem as UIInfoModel;
257
+                string line = CmdUtil.FilterCmd(uiInfoModel.ToString());
258
+                if (!line.Trim().Equals(""))
259
+                    Clipboard.SetDataObject(line);
260
+            }
261
+        }
262
+
263
+        private void LB_Context_CpLine_Click(object sender, EventArgs e)
264
+        {
265
+            int index = LBLogShow.SelectedIndex;
266
+            if (index >= 0 && index < LBLogShow.Items.Count)
267
+            {
268
+                UIInfoModel uiInfoModel = LBLogShow.SelectedItem as UIInfoModel;
269
+                string line = uiInfoModel.ToString();
270
+                if (!line.Trim().Equals(""))
271
+                    Clipboard.SetDataObject(line);
272
+            }
273
+        }
274
+
275
+        private void LB_Context_GJson_Click(object sender, EventArgs e)
276
+        {
277
+            int index = LBLogShow.SelectedIndex;
278
+            if (index >= 0 && index < LBLogShow.Items.Count)
279
+            {
280
+                UIInfoModel uiInfoModel = LBLogShow.SelectedItem as UIInfoModel;
281
+                string line = CmdUtil.FilterCmd(uiInfoModel.ToString());
282
+                if (!line.Trim().Equals(""))
283
+                {
284
+                }
285
+            }
286
+        }
287
+
288
+        private void LB_Context_AnaCmd_Click(object sender, EventArgs e)
289
+        {
290
+            int index = LBLogShow.SelectedIndex;
291
+            if (index >= 0 && index < LBLogShow.Items.Count)
292
+            {
293
+                UIInfoModel uiInfoModel = LBLogShow.SelectedItem as UIInfoModel;
294
+                string line = CmdUtil.FilterCmd(uiInfoModel.ToString());
295
+                if (!line.Trim().Equals(""))
296
+                {
297
+                }
298
+            }
299
+        }
300
+
301
+        private void LB_Context_ClearAll_Click(object sender, EventArgs e) => LBLogShow.Items.Clear();
302
+
303
+        #endregion
304
+
305
+       
175 306
     }
176 307
 }

+ 3 - 0
DotNettyFrom/MainForm.resx Zobrazit soubor

@@ -117,6 +117,9 @@
117 117
   <resheader name="writer">
118 118
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119 119
   </resheader>
120
+  <metadata name="ListBoxLogContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
+    <value>258, 17</value>
122
+  </metadata>
120 123
   <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121 124
     <value>17, 17</value>
122 125
   </metadata>

+ 38 - 0
DotNettyFrom/WvBean.cs Zobrazit soubor

@@ -0,0 +1,38 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace DotNettyFrom
8
+{
9
+    public class WvBean
10
+    {
11
+        public int id;
12
+        public int index;
13
+        public string myId = "";
14
+        public string idInfo = "";
15
+        public string len = "";
16
+        public string mode = "";
17
+        public string desp = "";
18
+        public string remark = "";
19
+        public string defalutValue = "";
20
+        public string userValue = "";
21
+
22
+        public override string ToString()
23
+        {
24
+            return "{\"index\":\"" + index + "\",\"myId\":\"" + myId + "\",\"idInfo\":\"" + idInfo + "\",\"len\":\"" +
25
+                   len + "\","
26
+                   + "\"mode\":\"" + mode + "\",\"desp\":\"" + desp + "\",\"remark\":\""
27
+                   + "\"}";
28
+        }
29
+    }
30
+
31
+    class WvBeanComparer : IComparer<WvBean>
32
+    {
33
+        public int Compare(WvBean x, WvBean y)
34
+        {
35
+            return x.index.CompareTo(y.index);
36
+        }
37
+    }
38
+}

+ 6 - 6
DotNettyFrom/common/UIInfoModel..cs Zobrazit soubor

@@ -11,13 +11,13 @@ namespace DotNettyFrom.common
11 11
     public class UIInfoModel
12 12
     {
13 13
         public int action = int.MinValue;
14
-        public string time = DateTime.Now.ToLongTimeString().ToString();
14
+        public string time = DateTime.Now.ToLongTimeString();
15 15
         public string info = "";
16 16
 
17 17
         public string cmd = "";
18 18
 
19
-        //true 发送的. false:接收的
20
-        public bool IsSend = false;
19
+        //1 发送的. 0:接收的, -1.日常信息
20
+        public int SendType = SystemConfig.RecType;
21 21
 
22 22
 
23 23
         public UIInfoModel(string info, string cmd)
@@ -38,9 +38,9 @@ namespace DotNettyFrom.common
38 38
             return this;
39 39
         }
40 40
 
41
-        public UIInfoModel setIsSend(bool IsSend)
41
+        public UIInfoModel setSendType(int SendType)
42 42
         {
43
-            this.IsSend = IsSend;
43
+            this.SendType = SendType;
44 44
             return this;
45 45
         }
46 46
 
@@ -73,7 +73,7 @@ namespace DotNettyFrom.common
73 73
                     string cmdId = cmd.Substring(SystemConfig.FunctionCodeStartPos, SystemConfig.FunctionCodeLength);
74 74
                     res += ". cmdId=" + cmdId;
75 75
                 }
76
-                catch (Exception e)
76
+                catch (Exception)
77 77
                 {
78 78
                 }
79 79
                 res += ". cmd=[" + cmd + "]";

+ 26 - 0
DotNettyFrom/config/DBConfig.cs Zobrazit soubor

@@ -0,0 +1,26 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace DotNettyFrom.config
8
+{
9
+    public class DBConfig
10
+    {
11
+        public const string DbFileName = "DotNettyFrom.accdb";
12
+
13
+
14
+        public const string ConnStr = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source = ";
15
+
16
+
17
+        public const string CmdFw = "fw";
18
+
19
+        //历史表
20
+        public const string IpHis = "ip_his";
21
+
22
+        public const string SendHis = "send_his";
23
+        public const string CcidHis = "ccid_his";
24
+        public const string AddrHis = "addr_his";
25
+    }
26
+}

+ 9 - 0
DotNettyFrom/config/SystemConfig.cs Zobrazit soubor

@@ -20,5 +20,14 @@ namespace DotNettyFrom.config
20 20
         public static int LengthFieldLength = 2;
21 21
         public static int LengthAdjustment = 1;
22 22
         public static int InitialBytesToStrip = 0;
23
+
24
+        public static int LBLogShowClearCount = 1000;
25
+
26
+
27
+        //1 发送的. 0:接收的, -1.Debug.日常信息
28
+        public static int SendType = 1;
29
+        public static int RecType = 0;
30
+        public static int DebugType = -1;
31
+        public static int ReplyType = 2;
23 32
     }
24 33
 }

+ 226 - 0
DotNettyFrom/db/DBHelper.cs Zobrazit soubor

@@ -0,0 +1,226 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Data;
4
+using System.Data.OleDb;
5
+using System.IO;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+using DotNettyFrom.config;
11
+using DotNettyFrom.util;
12
+
13
+namespace DotNettyFrom.db
14
+{
15
+    public class DbHelper
16
+    {
17
+        private static DbHelper Instance;
18
+        private static readonly object locker = new object();
19
+
20
+        private Dictionary<string, string> _idInfo { get; }
21
+
22
+        private OleDbConnection _DbConn = null;
23
+
24
+
25
+        private DbHelper()
26
+        {
27
+            _idInfo = new Dictionary<string, string>();
28
+            _DbConn = new OleDbConnection(DBConfig.ConnStr + Application.StartupPath + @"\" + DBConfig.DbFileName);
29
+            _DbConn.Open();
30
+        }
31
+
32
+        public void CloseAccessDb()
33
+        {
34
+            _DbConn?.Close();
35
+        }
36
+
37
+
38
+        public static void Init()
39
+        {
40
+            lock (locker)
41
+            {
42
+                if (Instance == null)
43
+                {
44
+                    Instance = new DbHelper();
45
+                }
46
+            }
47
+        }
48
+
49
+        public static DbHelper GetInstance()
50
+        {
51
+            if (Instance == null)
52
+            {
53
+                Init();
54
+            }
55
+            return Instance;
56
+        }
57
+
58
+
59
+        //reset user value
60
+        public int ResetUserData()
61
+        {
62
+            string sql = "update fw set user_value=default_value";
63
+            using (OleDbCommand inst = new OleDbCommand(sql, _DbConn))
64
+            {
65
+                return inst.ExecuteNonQuery();
66
+            }
67
+        }
68
+
69
+        //Insert
70
+        public int InsertCmd(WvBean wb)
71
+        {
72
+            if (wb == null)
73
+                return -1;
74
+            string sql =
75
+                "INSERT INTO fw(my_index,MY_ID,idInfo,len,mode,desp,default_value,user_value,remark) VALUES(";
76
+            sql += wb.index + ",";
77
+            sql += "'" + wb.myId + "',";
78
+            sql += "'" + wb.idInfo + "',";
79
+            sql += "'" + wb.len + "',";
80
+            sql += "'" + wb.mode + "',";
81
+            sql += "'" + wb.desp + "',";
82
+            sql += "'" + wb.defalutValue + "',";
83
+            sql += "'" + wb.userValue + "',";
84
+            sql += "'" + wb.remark + "')";
85
+            using (OleDbCommand inst = new OleDbCommand(sql, _DbConn))
86
+            {
87
+                return inst.ExecuteNonQuery();
88
+            }
89
+        }
90
+
91
+        //Delete
92
+        public int DeleteCmdById(int id)
93
+        {
94
+            string sql = "delete from fw where ID=" + id;
95
+            using (OleDbCommand inst = new OleDbCommand(sql, _DbConn))
96
+            {
97
+                return inst.ExecuteNonQuery();
98
+            }
99
+        }
100
+
101
+        //Update
102
+        public int UpdateCmd(WvBean wb)
103
+        {
104
+            string sql = "update fw set my_index=" + wb.index + ",MY_ID=\"" + wb.myId + "\",idInfo=\"" + wb.idInfo +
105
+                         "\",len=\"" + wb.len +
106
+                         "\",mode=\"" +
107
+                         wb.mode + "\",desp=\"" + wb.desp + "\",default_value=\"" + wb.defalutValue +
108
+                         "\",user_value=\"" +
109
+                         wb.userValue + "\",remark=\"" + wb.remark + "\" where ID=" + wb.id;
110
+            using (OleDbCommand inst = new OleDbCommand(sql, _DbConn))
111
+            {
112
+                return inst.ExecuteNonQuery();
113
+            }
114
+        }
115
+
116
+        //Select
117
+        public DataTable SelectCmds()
118
+        {
119
+            DataTable dataTable = new DataTable();
120
+            string sql = @"select * from fw";
121
+
122
+            using (OleDbCommand sqlcmd = new OleDbCommand(sql, _DbConn))
123
+            {
124
+                OleDbDataAdapter adapter = new OleDbDataAdapter(sqlcmd);
125
+                dataTable.Clear();
126
+                adapter.Fill(dataTable);
127
+
128
+                using (OleDbDataReader reader = sqlcmd.ExecuteReader())
129
+                {
130
+                    while (reader.Read()) //这个read调用很重要!不写的话运行时将提示找不到数据  
131
+                    {
132
+                        WvBean wb = new WvBean();
133
+                        int id = 0;
134
+                        int index = 0;
135
+                        var myId = "";
136
+                        var idInfo = "";
137
+                        var len = "";
138
+                        var mode = "";
139
+                        var desp = "";
140
+                        var defalutValue = "";
141
+                        var userValue = "";
142
+                        var remark = "";
143
+
144
+                        id = reader.GetInt32(0);
145
+                        index = reader.GetInt32(1);
146
+                        myId = reader.GetString(2);
147
+                        idInfo = CheckUtil.StringIsEmpty(reader.GetString(3));
148
+                        len = CheckUtil.StringIsEmpty(reader.GetString(4));
149
+                        mode = CheckUtil.StringIsEmpty(reader.GetString(5));
150
+                        desp = CheckUtil.StringIsEmpty(reader.GetString(6));
151
+                        defalutValue = CheckUtil.StringIsEmpty(reader.GetString(7));
152
+                        userValue = CheckUtil.StringIsEmpty(reader.GetString(8));
153
+                        remark = CheckUtil.StringIsEmpty(reader.GetString(9));
154
+
155
+                        wb.id = id;
156
+                        wb.index = index;
157
+                        wb.myId = myId;
158
+                        wb.idInfo = idInfo;
159
+                        wb.len = len;
160
+                        wb.mode = mode;
161
+                        wb.desp = desp;
162
+                        wb.defalutValue = defalutValue;
163
+                        wb.userValue = userValue;
164
+                        wb.remark = remark;
165
+
166
+                        if (!_idInfo.ContainsKey(myId))
167
+                            _idInfo.Add(myId, userValue);
168
+                    }
169
+                }
170
+            }
171
+            return dataTable;
172
+        }
173
+
174
+        public WvBean SelectOneCmdById(int _id)
175
+        {
176
+            WvBean wb = new WvBean();
177
+            string sql = @"select * from fw where id=" + _id;
178
+            using (OleDbCommand sqlcmd = new OleDbCommand(sql, _DbConn))
179
+            {
180
+                OleDbDataAdapter adapter = new OleDbDataAdapter(sqlcmd);
181
+
182
+                using (OleDbDataReader reader = sqlcmd.ExecuteReader())
183
+                {
184
+                    while (reader.Read()) //这个read调用很重要!不写的话运行时将提示找不到数据  
185
+                    {
186
+                        int id = 0;
187
+                        int index = 0;
188
+                        var myId = "";
189
+                        var idInfo = "";
190
+                        var len = "";
191
+                        var mode = "";
192
+                        var desp = "";
193
+                        var defalutValue = "";
194
+                        var userValue = "";
195
+                        var remark = "";
196
+
197
+                        id = reader.GetInt32(0);
198
+                        index = reader.GetInt32(1);
199
+                        myId = reader.GetString(2);
200
+                        idInfo = CheckUtil.StringIsEmpty(reader.GetString(3));
201
+                        len = CheckUtil.StringIsEmpty(reader.GetString(4));
202
+                        mode = CheckUtil.StringIsEmpty(reader.GetString(5));
203
+                        desp = CheckUtil.StringIsEmpty(reader.GetString(6));
204
+                        defalutValue = CheckUtil.StringIsEmpty(reader.GetString(7));
205
+                        userValue = CheckUtil.StringIsEmpty(reader.GetString(8));
206
+                        remark = CheckUtil.StringIsEmpty(reader.GetString(9));
207
+
208
+                        wb.id = id;
209
+                        wb.index = index;
210
+                        wb.myId = myId;
211
+                        wb.idInfo = idInfo;
212
+                        wb.len = len;
213
+                        wb.mode = mode;
214
+                        wb.desp = desp;
215
+                        wb.defalutValue = defalutValue;
216
+                        wb.userValue = userValue;
217
+                        wb.remark = remark;
218
+
219
+                        break;
220
+                    }
221
+                }
222
+            }
223
+            return wb;
224
+        }
225
+    }
226
+}

+ 399 - 0
DotNettyFrom/form/ItemEditorForm.Designer.cs Zobrazit soubor

@@ -0,0 +1,399 @@
1
+namespace DotNettyFrom.form
2
+{
3
+    partial class ItemEditorForm
4
+    {
5
+        /// <summary>
6
+        /// Required designer variable.
7
+        /// </summary>
8
+        private System.ComponentModel.IContainer components = null;
9
+
10
+        /// <summary>
11
+        /// Clean up any resources being used.
12
+        /// </summary>
13
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
+        protected override void Dispose(bool disposing)
15
+        {
16
+            if (disposing && (components != null))
17
+            {
18
+                components.Dispose();
19
+            }
20
+            base.Dispose(disposing);
21
+        }
22
+
23
+        #region Windows Form Designer generated code
24
+
25
+        /// <summary>
26
+        /// Required method for Designer support - do not modify
27
+        /// the contents of this method with the code editor.
28
+        /// </summary>
29
+        private void InitializeComponent()
30
+        {
31
+            this.label1 = new System.Windows.Forms.Label();
32
+            this.LbDbPriKey = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.TbItemId = new System.Windows.Forms.TextBox();
35
+            this.TbitemId2 = new System.Windows.Forms.TextBox();
36
+            this.label4 = new System.Windows.Forms.Label();
37
+            this.textBox3 = new System.Windows.Forms.TextBox();
38
+            this.textBox4 = new System.Windows.Forms.TextBox();
39
+            this.label5 = new System.Windows.Forms.Label();
40
+            this.label6 = new System.Windows.Forms.Label();
41
+            this.checkBox1 = new System.Windows.Forms.CheckBox();
42
+            this.checkBox2 = new System.Windows.Forms.CheckBox();
43
+            this.textBox5 = new System.Windows.Forms.TextBox();
44
+            this.label7 = new System.Windows.Forms.Label();
45
+            this.textBox6 = new System.Windows.Forms.TextBox();
46
+            this.label8 = new System.Windows.Forms.Label();
47
+            this.textBox7 = new System.Windows.Forms.TextBox();
48
+            this.label9 = new System.Windows.Forms.Label();
49
+            this.textBox8 = new System.Windows.Forms.TextBox();
50
+            this.label10 = new System.Windows.Forms.Label();
51
+            this.label11 = new System.Windows.Forms.Label();
52
+            this.label12 = new System.Windows.Forms.Label();
53
+            this.label13 = new System.Windows.Forms.Label();
54
+            this.label14 = new System.Windows.Forms.Label();
55
+            this.RtbInfo = new System.Windows.Forms.RichTextBox();
56
+            this.BtnCancle = new System.Windows.Forms.Button();
57
+            this.BtnOp = new System.Windows.Forms.Button();
58
+            this.CBInputType = new System.Windows.Forms.ComboBox();
59
+            this.label3 = new System.Windows.Forms.Label();
60
+            this.SuspendLayout();
61
+            // 
62
+            // label1
63
+            // 
64
+            this.label1.AutoSize = true;
65
+            this.label1.Location = new System.Drawing.Point(51, 9);
66
+            this.label1.Name = "label1";
67
+            this.label1.Size = new System.Drawing.Size(68, 17);
68
+            this.label1.TabIndex = 0;
69
+            this.label1.Text = "数据库主键";
70
+            // 
71
+            // LbDbPriKey
72
+            // 
73
+            this.LbDbPriKey.AutoSize = true;
74
+            this.LbDbPriKey.Location = new System.Drawing.Point(125, 9);
75
+            this.LbDbPriKey.Name = "LbDbPriKey";
76
+            this.LbDbPriKey.Size = new System.Drawing.Size(34, 17);
77
+            this.LbDbPriKey.TabIndex = 1;
78
+            this.LbDbPriKey.Text = "Keyr";
79
+            // 
80
+            // label2
81
+            // 
82
+            this.label2.AutoSize = true;
83
+            this.label2.Location = new System.Drawing.Point(207, 32);
84
+            this.label2.Name = "label2";
85
+            this.label2.Size = new System.Drawing.Size(46, 17);
86
+            this.label2.TabIndex = 2;
87
+            this.label2.Text = "ItemId";
88
+            // 
89
+            // TbItemId
90
+            // 
91
+            this.TbItemId.Location = new System.Drawing.Point(276, 29);
92
+            this.TbItemId.Name = "TbItemId";
93
+            this.TbItemId.Size = new System.Drawing.Size(121, 23);
94
+            this.TbItemId.TabIndex = 3;
95
+            this.TbItemId.TextChanged += new System.EventHandler(this.TbItemId_TextChanged);
96
+            this.TbItemId.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
97
+            // 
98
+            // TbitemId2
99
+            // 
100
+            this.TbitemId2.Location = new System.Drawing.Point(501, 29);
101
+            this.TbitemId2.Name = "TbitemId2";
102
+            this.TbitemId2.ReadOnly = true;
103
+            this.TbitemId2.Size = new System.Drawing.Size(121, 23);
104
+            this.TbitemId2.TabIndex = 5;
105
+            // 
106
+            // label4
107
+            // 
108
+            this.label4.AutoSize = true;
109
+            this.label4.Location = new System.Drawing.Point(12, 67);
110
+            this.label4.Name = "label4";
111
+            this.label4.Size = new System.Drawing.Size(32, 17);
112
+            this.label4.TabIndex = 6;
113
+            this.label4.Text = "功能";
114
+            // 
115
+            // textBox3
116
+            // 
117
+            this.textBox3.Location = new System.Drawing.Point(50, 64);
118
+            this.textBox3.Name = "textBox3";
119
+            this.textBox3.Size = new System.Drawing.Size(615, 23);
120
+            this.textBox3.TabIndex = 7;
121
+            // 
122
+            // textBox4
123
+            // 
124
+            this.textBox4.Location = new System.Drawing.Point(50, 93);
125
+            this.textBox4.Name = "textBox4";
126
+            this.textBox4.Size = new System.Drawing.Size(615, 23);
127
+            this.textBox4.TabIndex = 9;
128
+            // 
129
+            // label5
130
+            // 
131
+            this.label5.AutoSize = true;
132
+            this.label5.Location = new System.Drawing.Point(12, 96);
133
+            this.label5.Name = "label5";
134
+            this.label5.Size = new System.Drawing.Size(32, 17);
135
+            this.label5.TabIndex = 8;
136
+            this.label5.Text = "长度";
137
+            // 
138
+            // label6
139
+            // 
140
+            this.label6.AutoSize = true;
141
+            this.label6.Location = new System.Drawing.Point(12, 122);
142
+            this.label6.Name = "label6";
143
+            this.label6.Size = new System.Drawing.Size(32, 17);
144
+            this.label6.TabIndex = 10;
145
+            this.label6.Text = "读写";
146
+            // 
147
+            // checkBox1
148
+            // 
149
+            this.checkBox1.AutoSize = true;
150
+            this.checkBox1.Location = new System.Drawing.Point(54, 122);
151
+            this.checkBox1.Name = "checkBox1";
152
+            this.checkBox1.Size = new System.Drawing.Size(52, 21);
153
+            this.checkBox1.TabIndex = 11;
154
+            this.checkBox1.Text = "读/R";
155
+            this.checkBox1.UseVisualStyleBackColor = true;
156
+            // 
157
+            // checkBox2
158
+            // 
159
+            this.checkBox2.AutoSize = true;
160
+            this.checkBox2.Location = new System.Drawing.Point(112, 122);
161
+            this.checkBox2.Name = "checkBox2";
162
+            this.checkBox2.Size = new System.Drawing.Size(56, 21);
163
+            this.checkBox2.TabIndex = 11;
164
+            this.checkBox2.Text = "写/W";
165
+            this.checkBox2.UseVisualStyleBackColor = true;
166
+            // 
167
+            // textBox5
168
+            // 
169
+            this.textBox5.Location = new System.Drawing.Point(50, 149);
170
+            this.textBox5.Name = "textBox5";
171
+            this.textBox5.Size = new System.Drawing.Size(615, 23);
172
+            this.textBox5.TabIndex = 13;
173
+            // 
174
+            // label7
175
+            // 
176
+            this.label7.AutoSize = true;
177
+            this.label7.Location = new System.Drawing.Point(12, 152);
178
+            this.label7.Name = "label7";
179
+            this.label7.Size = new System.Drawing.Size(32, 17);
180
+            this.label7.TabIndex = 12;
181
+            this.label7.Text = "描述";
182
+            // 
183
+            // textBox6
184
+            // 
185
+            this.textBox6.Location = new System.Drawing.Point(62, 178);
186
+            this.textBox6.Name = "textBox6";
187
+            this.textBox6.Size = new System.Drawing.Size(603, 23);
188
+            this.textBox6.TabIndex = 15;
189
+            // 
190
+            // label8
191
+            // 
192
+            this.label8.AutoSize = true;
193
+            this.label8.Location = new System.Drawing.Point(12, 181);
194
+            this.label8.Name = "label8";
195
+            this.label8.Size = new System.Drawing.Size(44, 17);
196
+            this.label8.TabIndex = 14;
197
+            this.label8.Text = "默认值";
198
+            // 
199
+            // textBox7
200
+            // 
201
+            this.textBox7.Location = new System.Drawing.Point(62, 207);
202
+            this.textBox7.Name = "textBox7";
203
+            this.textBox7.Size = new System.Drawing.Size(603, 23);
204
+            this.textBox7.TabIndex = 17;
205
+            // 
206
+            // label9
207
+            // 
208
+            this.label9.AutoSize = true;
209
+            this.label9.Location = new System.Drawing.Point(12, 210);
210
+            this.label9.Name = "label9";
211
+            this.label9.Size = new System.Drawing.Size(44, 17);
212
+            this.label9.TabIndex = 16;
213
+            this.label9.Text = "用户值";
214
+            // 
215
+            // textBox8
216
+            // 
217
+            this.textBox8.Location = new System.Drawing.Point(50, 236);
218
+            this.textBox8.Name = "textBox8";
219
+            this.textBox8.Size = new System.Drawing.Size(615, 23);
220
+            this.textBox8.TabIndex = 19;
221
+            // 
222
+            // label10
223
+            // 
224
+            this.label10.AutoSize = true;
225
+            this.label10.Location = new System.Drawing.Point(12, 239);
226
+            this.label10.Name = "label10";
227
+            this.label10.Size = new System.Drawing.Size(32, 17);
228
+            this.label10.TabIndex = 18;
229
+            this.label10.Text = "备注";
230
+            // 
231
+            // label11
232
+            // 
233
+            this.label11.AutoSize = true;
234
+            this.label11.Location = new System.Drawing.Point(12, 275);
235
+            this.label11.Name = "label11";
236
+            this.label11.Size = new System.Drawing.Size(71, 17);
237
+            this.label11.TabIndex = 20;
238
+            this.label11.Text = "默认值长度:";
239
+            // 
240
+            // label12
241
+            // 
242
+            this.label12.AutoSize = true;
243
+            this.label12.Location = new System.Drawing.Point(207, 275);
244
+            this.label12.Name = "label12";
245
+            this.label12.Size = new System.Drawing.Size(22, 17);
246
+            this.label12.TabIndex = 21;
247
+            this.label12.Text = "00";
248
+            // 
249
+            // label13
250
+            // 
251
+            this.label13.AutoSize = true;
252
+            this.label13.Location = new System.Drawing.Point(130, 275);
253
+            this.label13.Name = "label13";
254
+            this.label13.Size = new System.Drawing.Size(71, 17);
255
+            this.label13.TabIndex = 22;
256
+            this.label13.Text = "用户值长度:";
257
+            // 
258
+            // label14
259
+            // 
260
+            this.label14.AutoSize = true;
261
+            this.label14.Location = new System.Drawing.Point(89, 275);
262
+            this.label14.Name = "label14";
263
+            this.label14.Size = new System.Drawing.Size(22, 17);
264
+            this.label14.TabIndex = 23;
265
+            this.label14.Text = "00";
266
+            // 
267
+            // RtbInfo
268
+            // 
269
+            this.RtbInfo.Location = new System.Drawing.Point(11, 295);
270
+            this.RtbInfo.Name = "RtbInfo";
271
+            this.RtbInfo.ReadOnly = true;
272
+            this.RtbInfo.Size = new System.Drawing.Size(654, 96);
273
+            this.RtbInfo.TabIndex = 24;
274
+            this.RtbInfo.Text = "";
275
+            // 
276
+            // BtnCancle
277
+            // 
278
+            this.BtnCancle.Location = new System.Drawing.Point(509, 397);
279
+            this.BtnCancle.Name = "BtnCancle";
280
+            this.BtnCancle.Size = new System.Drawing.Size(75, 23);
281
+            this.BtnCancle.TabIndex = 25;
282
+            this.BtnCancle.Text = "取消";
283
+            this.BtnCancle.UseVisualStyleBackColor = true;
284
+            // 
285
+            // BtnOp
286
+            // 
287
+            this.BtnOp.Location = new System.Drawing.Point(590, 397);
288
+            this.BtnOp.Name = "BtnOp";
289
+            this.BtnOp.Size = new System.Drawing.Size(75, 23);
290
+            this.BtnOp.TabIndex = 25;
291
+            this.BtnOp.Text = "添加";
292
+            this.BtnOp.UseVisualStyleBackColor = true;
293
+            // 
294
+            // CBInputType
295
+            // 
296
+            this.CBInputType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
297
+            this.CBInputType.FormattingEnabled = true;
298
+            this.CBInputType.Items.AddRange(new object[] {
299
+            "10进制",
300
+            "16进制"});
301
+            this.CBInputType.Location = new System.Drawing.Point(50, 29);
302
+            this.CBInputType.Name = "CBInputType";
303
+            this.CBInputType.Size = new System.Drawing.Size(121, 25);
304
+            this.CBInputType.TabIndex = 26;
305
+            this.CBInputType.SelectedIndexChanged += new System.EventHandler(this.CBInputType_SelectedIndexChanged);
306
+            // 
307
+            // label3
308
+            // 
309
+            this.label3.AutoSize = true;
310
+            this.label3.Location = new System.Drawing.Point(419, 32);
311
+            this.label3.Name = "label3";
312
+            this.label3.Size = new System.Drawing.Size(56, 17);
313
+            this.label3.TabIndex = 4;
314
+            this.label3.Text = "不同进制";
315
+            this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter;
316
+            // 
317
+            // ItemEditorForm
318
+            // 
319
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
320
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
321
+            this.ClientSize = new System.Drawing.Size(677, 432);
322
+            this.Controls.Add(this.CBInputType);
323
+            this.Controls.Add(this.BtnOp);
324
+            this.Controls.Add(this.BtnCancle);
325
+            this.Controls.Add(this.RtbInfo);
326
+            this.Controls.Add(this.label14);
327
+            this.Controls.Add(this.label13);
328
+            this.Controls.Add(this.label12);
329
+            this.Controls.Add(this.label11);
330
+            this.Controls.Add(this.textBox8);
331
+            this.Controls.Add(this.label10);
332
+            this.Controls.Add(this.textBox7);
333
+            this.Controls.Add(this.label9);
334
+            this.Controls.Add(this.textBox6);
335
+            this.Controls.Add(this.label8);
336
+            this.Controls.Add(this.textBox5);
337
+            this.Controls.Add(this.label7);
338
+            this.Controls.Add(this.checkBox2);
339
+            this.Controls.Add(this.checkBox1);
340
+            this.Controls.Add(this.label6);
341
+            this.Controls.Add(this.textBox4);
342
+            this.Controls.Add(this.label5);
343
+            this.Controls.Add(this.textBox3);
344
+            this.Controls.Add(this.label4);
345
+            this.Controls.Add(this.TbitemId2);
346
+            this.Controls.Add(this.label3);
347
+            this.Controls.Add(this.TbItemId);
348
+            this.Controls.Add(this.label2);
349
+            this.Controls.Add(this.LbDbPriKey);
350
+            this.Controls.Add(this.label1);
351
+            this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
352
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
353
+            this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
354
+            this.MaximizeBox = false;
355
+            this.MinimizeBox = false;
356
+            this.Name = "ItemEditorForm";
357
+            this.ShowIcon = false;
358
+            this.ShowInTaskbar = false;
359
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
360
+            this.Text = "添加ID";
361
+            this.Load += new System.EventHandler(this.ItemEditorForm_Load);
362
+            this.ResumeLayout(false);
363
+            this.PerformLayout();
364
+
365
+        }
366
+
367
+        #endregion
368
+
369
+        private System.Windows.Forms.Label label1;
370
+        private System.Windows.Forms.Label LbDbPriKey;
371
+        private System.Windows.Forms.Label label2;
372
+        private System.Windows.Forms.TextBox TbItemId;
373
+        private System.Windows.Forms.TextBox TbitemId2;
374
+        private System.Windows.Forms.Label label4;
375
+        private System.Windows.Forms.TextBox textBox3;
376
+        private System.Windows.Forms.TextBox textBox4;
377
+        private System.Windows.Forms.Label label5;
378
+        private System.Windows.Forms.Label label6;
379
+        private System.Windows.Forms.CheckBox checkBox1;
380
+        private System.Windows.Forms.CheckBox checkBox2;
381
+        private System.Windows.Forms.TextBox textBox5;
382
+        private System.Windows.Forms.Label label7;
383
+        private System.Windows.Forms.TextBox textBox6;
384
+        private System.Windows.Forms.Label label8;
385
+        private System.Windows.Forms.TextBox textBox7;
386
+        private System.Windows.Forms.Label label9;
387
+        private System.Windows.Forms.TextBox textBox8;
388
+        private System.Windows.Forms.Label label10;
389
+        private System.Windows.Forms.Label label11;
390
+        private System.Windows.Forms.Label label12;
391
+        private System.Windows.Forms.Label label13;
392
+        private System.Windows.Forms.Label label14;
393
+        private System.Windows.Forms.RichTextBox RtbInfo;
394
+        private System.Windows.Forms.Button BtnCancle;
395
+        private System.Windows.Forms.Button BtnOp;
396
+        private System.Windows.Forms.ComboBox CBInputType;
397
+        private System.Windows.Forms.Label label3;
398
+    }
399
+}

+ 72 - 0
DotNettyFrom/form/ItemEditorForm.cs Zobrazit soubor

@@ -0,0 +1,72 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+using DotNettyFrom.db;
11
+
12
+namespace DotNettyFrom.form
13
+{
14
+    public delegate void OnItemHandlerResult(int action, string message);
15
+
16
+    public partial class ItemEditorForm : Form
17
+    {
18
+        public event OnItemHandlerResult ItemHandler;
19
+        private int _id;
20
+
21
+        public ItemEditorForm(int id = int.MinValue)
22
+        {
23
+            this._id = id;
24
+            InitializeComponent();
25
+        }
26
+
27
+        private void ItemEditorForm_Load(object sender, EventArgs e)
28
+        {
29
+            CBInputType.SelectedIndex = 0;
30
+
31
+            if (_id != int.MinValue)
32
+            {
33
+                UpdateOption();
34
+            }
35
+        }
36
+
37
+        private void UpdateOption()
38
+        {
39
+            BtnOp.Text = "修改";
40
+            WvBean wb = DbHelper.GetInstance().SelectOneCmdById(_id);
41
+            Console.WriteLine(wb.ToString());
42
+            this.Text = "修改ID - " + wb.id;
43
+        }
44
+
45
+        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
46
+        {
47
+            if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
48
+            {
49
+                e.Handled = true;
50
+            }
51
+        }
52
+
53
+        private void CBInputType_SelectedIndexChanged(object sender, EventArgs e)
54
+        {
55
+            Console.WriteLine(CBInputType.SelectedIndex);
56
+        }
57
+
58
+        private void TbItemId_TextChanged(object sender, EventArgs e)
59
+        {
60
+            if (CBInputType.SelectedIndex == 0)
61
+            {
62
+                //10 ->16
63
+                
64
+
65
+
66
+            }
67
+            else if (CBInputType.SelectedIndex == 1)
68
+            {
69
+            }
70
+        }
71
+    }
72
+}

+ 120 - 0
DotNettyFrom/form/ItemEditorForm.resx Zobrazit soubor

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 252 - 0
DotNettyFrom/form/ItemManagerForm.Designer.cs Zobrazit soubor

@@ -0,0 +1,252 @@
1
+namespace DotNettyFrom.form
2
+{
3
+    partial class ItemManagerForm
4
+    {
5
+        /// <summary>
6
+        /// Required designer variable.
7
+        /// </summary>
8
+        private System.ComponentModel.IContainer components = null;
9
+
10
+        /// <summary>
11
+        /// Clean up any resources being used.
12
+        /// </summary>
13
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
+        protected override void Dispose(bool disposing)
15
+        {
16
+            if (disposing && (components != null))
17
+            {
18
+                components.Dispose();
19
+            }
20
+            base.Dispose(disposing);
21
+        }
22
+
23
+        #region Windows Form Designer generated code
24
+
25
+        /// <summary>
26
+        /// Required method for Designer support - do not modify
27
+        /// the contents of this method with the code editor.
28
+        /// </summary>
29
+        private void InitializeComponent()
30
+        {
31
+            this.components = new System.ComponentModel.Container();
32
+            this.dataGridViewItem = new System.Windows.Forms.DataGridView();
33
+            this.Context_Menu_ItemManger = new System.Windows.Forms.ContextMenuStrip(this.components);
34
+            this.MenuItem_Delete = new System.Windows.Forms.ToolStripMenuItem();
35
+            this.BtnAddCmd = new System.Windows.Forms.Button();
36
+            this.BtnDelSelectItem = new System.Windows.Forms.Button();
37
+            this.BtnRefresh = new System.Windows.Forms.Button();
38
+            this.BtnReset = new System.Windows.Forms.Button();
39
+            this.BtnImportExcel = new System.Windows.Forms.Button();
40
+            this.BtnClearAll = new System.Windows.Forms.Button();
41
+            this.CbFindType = new System.Windows.Forms.ComboBox();
42
+            this.BtnClose = new System.Windows.Forms.Button();
43
+            this.label1 = new System.Windows.Forms.Label();
44
+            this.TBInputFind = new System.Windows.Forms.TextBox();
45
+            this.BtnFind = new System.Windows.Forms.Button();
46
+            this.RtbLogInfo = new System.Windows.Forms.RichTextBox();
47
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewItem)).BeginInit();
48
+            this.Context_Menu_ItemManger.SuspendLayout();
49
+            this.SuspendLayout();
50
+            // 
51
+            // dataGridViewItem
52
+            // 
53
+            this.dataGridViewItem.AllowUserToAddRows = false;
54
+            this.dataGridViewItem.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
55
+            | System.Windows.Forms.AnchorStyles.Left) 
56
+            | System.Windows.Forms.AnchorStyles.Right)));
57
+            this.dataGridViewItem.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
58
+            this.dataGridViewItem.ContextMenuStrip = this.Context_Menu_ItemManger;
59
+            this.dataGridViewItem.Location = new System.Drawing.Point(14, 158);
60
+            this.dataGridViewItem.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
61
+            this.dataGridViewItem.MultiSelect = false;
62
+            this.dataGridViewItem.Name = "dataGridViewItem";
63
+            this.dataGridViewItem.ReadOnly = true;
64
+            this.dataGridViewItem.RowTemplate.Height = 23;
65
+            this.dataGridViewItem.Size = new System.Drawing.Size(1130, 554);
66
+            this.dataGridViewItem.TabIndex = 0;
67
+            this.dataGridViewItem.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridViewItem_CellMouseDoubleClick);
68
+            // 
69
+            // Context_Menu_ItemManger
70
+            // 
71
+            this.Context_Menu_ItemManger.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
72
+            this.MenuItem_Delete});
73
+            this.Context_Menu_ItemManger.Name = "Context_Menu_ItemManger";
74
+            this.Context_Menu_ItemManger.Size = new System.Drawing.Size(154, 26);
75
+            // 
76
+            // MenuItem_Delete
77
+            // 
78
+            this.MenuItem_Delete.Name = "MenuItem_Delete";
79
+            this.MenuItem_Delete.Size = new System.Drawing.Size(153, 22);
80
+            this.MenuItem_Delete.Text = "删除选中行(&D)";
81
+            this.MenuItem_Delete.Click += new System.EventHandler(this.MenuItem_Delete_Click);
82
+            // 
83
+            // BtnAddCmd
84
+            // 
85
+            this.BtnAddCmd.Location = new System.Drawing.Point(12, 35);
86
+            this.BtnAddCmd.Name = "BtnAddCmd";
87
+            this.BtnAddCmd.Size = new System.Drawing.Size(75, 23);
88
+            this.BtnAddCmd.TabIndex = 1;
89
+            this.BtnAddCmd.Text = "添加指令";
90
+            this.BtnAddCmd.UseVisualStyleBackColor = true;
91
+            this.BtnAddCmd.Click += new System.EventHandler(this.BtnAddCmd_Click);
92
+            // 
93
+            // BtnDelSelectItem
94
+            // 
95
+            this.BtnDelSelectItem.Location = new System.Drawing.Point(93, 35);
96
+            this.BtnDelSelectItem.Name = "BtnDelSelectItem";
97
+            this.BtnDelSelectItem.Size = new System.Drawing.Size(75, 23);
98
+            this.BtnDelSelectItem.TabIndex = 1;
99
+            this.BtnDelSelectItem.Text = "删除选中";
100
+            this.BtnDelSelectItem.UseVisualStyleBackColor = true;
101
+            this.BtnDelSelectItem.Click += new System.EventHandler(this.BtnDelSelectItem_Click);
102
+            // 
103
+            // BtnRefresh
104
+            // 
105
+            this.BtnRefresh.Location = new System.Drawing.Point(174, 35);
106
+            this.BtnRefresh.Name = "BtnRefresh";
107
+            this.BtnRefresh.Size = new System.Drawing.Size(75, 23);
108
+            this.BtnRefresh.TabIndex = 1;
109
+            this.BtnRefresh.Text = "刷新数据";
110
+            this.BtnRefresh.UseVisualStyleBackColor = true;
111
+            this.BtnRefresh.Click += new System.EventHandler(this.BtnRefresh_Click);
112
+            // 
113
+            // BtnReset
114
+            // 
115
+            this.BtnReset.Location = new System.Drawing.Point(255, 35);
116
+            this.BtnReset.Name = "BtnReset";
117
+            this.BtnReset.Size = new System.Drawing.Size(107, 23);
118
+            this.BtnReset.TabIndex = 1;
119
+            this.BtnReset.Text = "重置用户数据";
120
+            this.BtnReset.UseVisualStyleBackColor = true;
121
+            this.BtnReset.Click += new System.EventHandler(this.BtnReset_Click);
122
+            // 
123
+            // BtnImportExcel
124
+            // 
125
+            this.BtnImportExcel.Location = new System.Drawing.Point(368, 35);
126
+            this.BtnImportExcel.Name = "BtnImportExcel";
127
+            this.BtnImportExcel.Size = new System.Drawing.Size(107, 23);
128
+            this.BtnImportExcel.TabIndex = 1;
129
+            this.BtnImportExcel.Text = "从Excel导入";
130
+            this.BtnImportExcel.UseVisualStyleBackColor = true;
131
+            this.BtnImportExcel.Click += new System.EventHandler(this.BtnImportExcel_Click);
132
+            // 
133
+            // BtnClearAll
134
+            // 
135
+            this.BtnClearAll.Location = new System.Drawing.Point(481, 35);
136
+            this.BtnClearAll.Name = "BtnClearAll";
137
+            this.BtnClearAll.Size = new System.Drawing.Size(75, 23);
138
+            this.BtnClearAll.TabIndex = 1;
139
+            this.BtnClearAll.Text = "清空数据";
140
+            this.BtnClearAll.UseVisualStyleBackColor = true;
141
+            this.BtnClearAll.Click += new System.EventHandler(this.BtnClearAll_Click);
142
+            // 
143
+            // CbFindType
144
+            // 
145
+            this.CbFindType.FormattingEnabled = true;
146
+            this.CbFindType.Items.AddRange(new object[] {
147
+            "ID-10进制",
148
+            "ID-16进制",
149
+            "名字-IDInfo",
150
+            "描述-Desp"});
151
+            this.CbFindType.Location = new System.Drawing.Point(705, 35);
152
+            this.CbFindType.Name = "CbFindType";
153
+            this.CbFindType.Size = new System.Drawing.Size(89, 25);
154
+            this.CbFindType.TabIndex = 2;
155
+            // 
156
+            // BtnClose
157
+            // 
158
+            this.BtnClose.Location = new System.Drawing.Point(562, 35);
159
+            this.BtnClose.Name = "BtnClose";
160
+            this.BtnClose.Size = new System.Drawing.Size(75, 23);
161
+            this.BtnClose.TabIndex = 1;
162
+            this.BtnClose.Text = "关闭";
163
+            this.BtnClose.UseVisualStyleBackColor = true;
164
+            this.BtnClose.Click += new System.EventHandler(this.BtnClose_Click);
165
+            // 
166
+            // label1
167
+            // 
168
+            this.label1.AutoSize = true;
169
+            this.label1.Location = new System.Drawing.Point(643, 38);
170
+            this.label1.Name = "label1";
171
+            this.label1.Size = new System.Drawing.Size(56, 17);
172
+            this.label1.TabIndex = 3;
173
+            this.label1.Text = "查找类型";
174
+            // 
175
+            // TBInputFind
176
+            // 
177
+            this.TBInputFind.Location = new System.Drawing.Point(800, 35);
178
+            this.TBInputFind.Name = "TBInputFind";
179
+            this.TBInputFind.Size = new System.Drawing.Size(265, 23);
180
+            this.TBInputFind.TabIndex = 4;
181
+            // 
182
+            // BtnFind
183
+            // 
184
+            this.BtnFind.Location = new System.Drawing.Point(1071, 35);
185
+            this.BtnFind.Name = "BtnFind";
186
+            this.BtnFind.Size = new System.Drawing.Size(75, 23);
187
+            this.BtnFind.TabIndex = 1;
188
+            this.BtnFind.Text = "查找数据";
189
+            this.BtnFind.UseVisualStyleBackColor = true;
190
+            this.BtnFind.Click += new System.EventHandler(this.BtnFind_Click);
191
+            // 
192
+            // RtbLogInfo
193
+            // 
194
+            this.RtbLogInfo.Location = new System.Drawing.Point(14, 64);
195
+            this.RtbLogInfo.Name = "RtbLogInfo";
196
+            this.RtbLogInfo.ReadOnly = true;
197
+            this.RtbLogInfo.Size = new System.Drawing.Size(1136, 87);
198
+            this.RtbLogInfo.TabIndex = 5;
199
+            this.RtbLogInfo.Text = "";
200
+            // 
201
+            // ItemManagerForm
202
+            // 
203
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
204
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
205
+            this.ClientSize = new System.Drawing.Size(1158, 729);
206
+            this.Controls.Add(this.RtbLogInfo);
207
+            this.Controls.Add(this.TBInputFind);
208
+            this.Controls.Add(this.label1);
209
+            this.Controls.Add(this.CbFindType);
210
+            this.Controls.Add(this.BtnFind);
211
+            this.Controls.Add(this.BtnClose);
212
+            this.Controls.Add(this.BtnClearAll);
213
+            this.Controls.Add(this.BtnImportExcel);
214
+            this.Controls.Add(this.BtnReset);
215
+            this.Controls.Add(this.BtnRefresh);
216
+            this.Controls.Add(this.BtnDelSelectItem);
217
+            this.Controls.Add(this.BtnAddCmd);
218
+            this.Controls.Add(this.dataGridViewItem);
219
+            this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
220
+            this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
221
+            this.Name = "ItemManagerForm";
222
+            this.ShowIcon = false;
223
+            this.ShowInTaskbar = false;
224
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
225
+            this.Text = "ItemManagerForm";
226
+            this.Load += new System.EventHandler(this.ItemManagerForm_Load);
227
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewItem)).EndInit();
228
+            this.Context_Menu_ItemManger.ResumeLayout(false);
229
+            this.ResumeLayout(false);
230
+            this.PerformLayout();
231
+
232
+        }
233
+
234
+        #endregion
235
+
236
+        private System.Windows.Forms.DataGridView dataGridViewItem;
237
+        private System.Windows.Forms.ContextMenuStrip Context_Menu_ItemManger;
238
+        private System.Windows.Forms.ToolStripMenuItem MenuItem_Delete;
239
+        private System.Windows.Forms.Button BtnAddCmd;
240
+        private System.Windows.Forms.Button BtnDelSelectItem;
241
+        private System.Windows.Forms.Button BtnRefresh;
242
+        private System.Windows.Forms.Button BtnReset;
243
+        private System.Windows.Forms.Button BtnImportExcel;
244
+        private System.Windows.Forms.Button BtnClearAll;
245
+        private System.Windows.Forms.ComboBox CbFindType;
246
+        private System.Windows.Forms.Button BtnClose;
247
+        private System.Windows.Forms.Label label1;
248
+        private System.Windows.Forms.TextBox TBInputFind;
249
+        private System.Windows.Forms.Button BtnFind;
250
+        private System.Windows.Forms.RichTextBox RtbLogInfo;
251
+    }
252
+}

+ 104 - 0
DotNettyFrom/form/ItemManagerForm.cs Zobrazit soubor

@@ -0,0 +1,104 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+using DotNettyFrom.db;
11
+
12
+namespace DotNettyFrom.form
13
+{
14
+    public partial class ItemManagerForm : Form
15
+    {
16
+        public ItemManagerForm()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void ItemManagerForm_Load(object sender, EventArgs e)
22
+        {
23
+            CbFindType.SelectedIndex = 0;
24
+            DataTable dataSource = DbHelper.GetInstance().SelectCmds();
25
+            dataGridViewItem.DataSource = dataSource;
26
+        }
27
+
28
+
29
+        #region 事件
30
+
31
+        private void MenuItem_Delete_Click(object sender, EventArgs e)
32
+        {
33
+        }
34
+
35
+        private void dataGridViewItem_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
36
+        {
37
+            int col = dataGridViewItem.ColumnCount;
38
+            int row = dataGridViewItem.RowCount;
39
+            int x = e.RowIndex;
40
+            int y = e.ColumnIndex;
41
+            if (x >= 0 && y >= 0 && x < row && y < col)
42
+            {
43
+                int id = int.Parse(dataGridViewItem[0, x].Value + "");
44
+//                int index = int.Parse(dataGridViewItem[1, x].Value + "");
45
+
46
+                ItemEditorForm ief = new ItemEditorForm(id);
47
+                ief.ItemHandler += (action, message) =>
48
+                {
49
+                    Console.WriteLine("reload");
50
+//                    InfoEditorTip.Text = topmost;
51
+//                    dataGridView1.DataSource = AccessDbLoader.getInstance().reloadAccessDb().getDataTable();
52
+                };
53
+
54
+                ief.ShowDialog();
55
+            }
56
+        }
57
+
58
+
59
+        private void BtnAddCmd_Click(object sender, EventArgs e)
60
+        {
61
+            ItemEditorForm ief = new ItemEditorForm();
62
+            ief.ItemHandler += (action, message) =>
63
+            {
64
+                //Conso
65
+            };
66
+            ief.ShowDialog();
67
+        }
68
+
69
+        private void Ief_ItemHandler(int action, string message)
70
+        {
71
+            throw new NotImplementedException();
72
+        }
73
+
74
+        private void BtnDelSelectItem_Click(object sender, EventArgs e)
75
+        {
76
+        }
77
+
78
+        private void BtnRefresh_Click(object sender, EventArgs e)
79
+        {
80
+        }
81
+
82
+        private void BtnReset_Click(object sender, EventArgs e)
83
+        {
84
+        }
85
+
86
+        private void BtnImportExcel_Click(object sender, EventArgs e)
87
+        {
88
+        }
89
+
90
+        private void BtnClearAll_Click(object sender, EventArgs e)
91
+        {
92
+        }
93
+
94
+        private void BtnClose_Click(object sender, EventArgs e)
95
+        {
96
+        }
97
+
98
+        private void BtnFind_Click(object sender, EventArgs e)
99
+        {
100
+        }
101
+
102
+        #endregion
103
+    }
104
+}

+ 123 - 0
DotNettyFrom/form/ItemManagerForm.resx Zobrazit soubor

@@ -0,0 +1,123 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+  <metadata name="Context_Menu_ItemManger.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
+    <value>17, 17</value>
122
+  </metadata>
123
+</root>

+ 12 - 14
DotNettyFrom/netty/NettyClient.cs Zobrazit soubor

@@ -30,7 +30,7 @@ namespace DotNettyFrom.netty
30 30
             _isSendLoginCmd = isSendLoginCmd;
31 31
             IPAddress hostIp = IPAddress.Parse(host);
32 32
             RunClientAsync(hostIp, port);
33
-            DataModel.ReceCollection.Add(new UIInfoModel("StartNetty:开始尝试连接"));
33
+            DataModel.ReceCollection.Add(new UIInfoModel("StartNetty:开始尝试连接").setSendType(SystemConfig.DebugType));
34 34
         }
35 35
 
36 36
         private async void RunClientAsync(IPAddress HostIP, int Port)
@@ -63,7 +63,8 @@ namespace DotNettyFrom.netty
63 63
             {
64 64
                 //连接出错,服务器没开启....
65 65
                 //Console.WriteLine(e);
66
-                DataModel.ReceCollection.Add(new UIInfoModel("远程服务器连接失败." + e.Message).setAction(-1));
66
+                DataModel.ReceCollection.Add(new UIInfoModel("远程服务器连接失败." + e.Message).setAction(-1)
67
+                    .setSendType(SystemConfig.DebugType));
67 68
                 await _group.ShutdownGracefullyAsync(TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(1));
68 69
             }
69 70
         }
@@ -75,11 +76,11 @@ namespace DotNettyFrom.netty
75 76
             {
76 77
                 IByteBuffer msg = AryUtil.Hex2IByteBuffer(hex);
77 78
                 NettyClientHandler.Context.WriteAndFlushAsync(msg);
78
-                DataModel.ReceCollection.Add(new UIInfoModel("发送", hex).setIsSend(true));
79
+                DataModel.ReceCollection.Add(new UIInfoModel("发送", hex).setSendType(SystemConfig.SendType));
79 80
             }
80 81
             else
81 82
             {
82
-                DataModel.ReceCollection.Add(new UIInfoModel("SendData:连接已经断开"));
83
+                DataModel.ReceCollection.Add(new UIInfoModel("SendData:连接已经断开").setSendType(SystemConfig.DebugType));
83 84
             }
84 85
         }
85 86
 
@@ -102,7 +103,8 @@ namespace DotNettyFrom.netty
102 103
             public override void ChannelActive(IChannelHandlerContext context)
103 104
             {
104 105
                 Context = context;
105
-                DataModel.ReceCollection.Add(new UIInfoModel("ChannelActive:连接成功").setAction(1));
106
+                DataModel.ReceCollection.Add(new UIInfoModel("ChannelActive:连接成功").setAction(1)
107
+                    .setSendType(SystemConfig.DebugType));
106 108
 
107 109
                 if (_isSendLoginCmd)
108 110
                 {
@@ -112,7 +114,7 @@ namespace DotNettyFrom.netty
112 114
                     context.WriteAndFlushAsync(cmd);
113 115
                     DataModel.ReceCollection.Add(
114 116
                         new UIInfoModel("发送登录", "7e7e7e0000000000018200143839383630324731313931353530333339393137e3")
115
-                            .setAction(1).setIsSend(true));
117
+                            .setAction(1).setSendType(SystemConfig.SendType));
116 118
                 }
117 119
             }
118 120
 
@@ -121,12 +123,7 @@ namespace DotNettyFrom.netty
121 123
             {
122 124
                 if (message is IByteBuffer buffer)
123 125
                 {
124
-                    //string recCmd = AryUtil.ByteBuffer2Hex(buffer);
125
-
126
-                    byte[] byteBufferArray = new byte[buffer.ReadableBytes];
127
-                    buffer.ReadBytes(byteBufferArray);
128
-                    string recCmd = AryUtil.Bytes2Hex(byteBufferArray);
129
-
126
+                    string recCmd = AryUtil.ByteBuffer2Hex(buffer);
130 127
                     DataModel.ReceCollection.Add(new UIInfoModel("收到", recCmd));
131 128
                 }
132 129
             }
@@ -145,14 +142,15 @@ namespace DotNettyFrom.netty
145 142
             {
146 143
                 base.ExceptionCaught(context, exception);
147 144
                 Console.WriteLine(exception.Message);
148
-                DataModel.ReceCollection.Add(new UIInfoModel("ExceptionCaught:" + exception.Message).setAction(3));
145
+                DataModel.ReceCollection.Add(new UIInfoModel("ExceptionCaught:" + exception.Message).setAction(3)
146
+                    .setSendType(SystemConfig.DebugType));
149 147
             }
150 148
 
151 149
             public override void ChannelInactive(IChannelHandlerContext context)
152 150
             {
153 151
                 base.ChannelInactive(context);
154 152
                 DataModel.ReceCollection.Add(new UIInfoModel("ChannelInactive:" + context.Channel)
155
-                    .setAction(2));
153
+                    .setAction(2).setSendType(SystemConfig.DebugType));
156 154
             }
157 155
         }
158 156
     }

+ 33 - 0
DotNettyFrom/util/CheckUtil.cs Zobrazit soubor

@@ -0,0 +1,33 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.IO;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+using System.Windows.Forms;
8
+using DotNettyFrom.config;
9
+
10
+namespace DotNettyFrom.util
11
+{
12
+    public class CheckUtil
13
+    {
14
+        public static bool CheckDbFileIsExits()
15
+        {
16
+            string filepath = Application.StartupPath + @"\" + DBConfig.DbFileName;
17
+            return File.Exists(filepath);
18
+        }
19
+
20
+
21
+        public static string StringIsEmpty(string ojb)
22
+        {
23
+            if (ojb == null)
24
+                return "";
25
+
26
+            if (ojb.Trim().Equals(""))
27
+            {
28
+                return "";
29
+            }
30
+            return ojb.Trim();
31
+        }
32
+    }
33
+}

+ 66 - 0
DotNettyFrom/util/CmdUtil.cs Zobrazit soubor

@@ -0,0 +1,66 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Globalization;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Text.RegularExpressions;
7
+using System.Threading.Tasks;
8
+
9
+namespace DotNettyFrom.util
10
+{
11
+    public class CmdUtil
12
+    {
13
+        public static string FilterCmd(string msg)
14
+        {
15
+            Regex reg = new Regex(@"\[\w+\]"); //注意里面的引号 要用双引号表示,而不是用反斜
16
+            Match match = reg.Match(msg);
17
+            string its = match.ToString();
18
+            its = its.Replace("[", "").Replace("]", "");
19
+            return its;
20
+        }
21
+
22
+        public static string GenetorCcid()
23
+        {
24
+            Random random = new Random();
25
+
26
+            int[] ccids = new int[20];
27
+
28
+            ccids[0] = random.Next(31, 40);
29
+            for (int i = 1; i < ccids.Length; i++)
30
+            {
31
+                ccids[i] = random.Next(30, 40);
32
+            }
33
+
34
+            return string.Join("", ccids);
35
+        }
36
+
37
+
38
+        public static string FrontWithZero(string str, int len)
39
+        {
40
+            int delta = len - str.Length;
41
+            string sb = "";
42
+            for (int i = 0; i < delta; i++)
43
+            {
44
+                sb += "0";
45
+            }
46
+            return sb + str;
47
+        }
48
+
49
+        public static string Des2Hex(int dec)
50
+        {
51
+            return "";
52
+        }
53
+
54
+
55
+        public static int Hex2Dec(string hex)
56
+        {
57
+            return int.Parse(hex, NumberStyles.HexNumber);
58
+        }
59
+
60
+        public static string HexToBin(string hex)
61
+        {
62
+            int res = Hex2Dec(hex);
63
+            return FrontWithZero(Convert.ToString(res, 2), 8);
64
+        }
65
+    }
66
+}

+ 5 - 0
DotNettyFromTests/DotNettyFromTests.csproj Zobrazit soubor

@@ -39,6 +39,9 @@
39 39
     <WarningLevel>4</WarningLevel>
40 40
   </PropertyGroup>
41 41
   <ItemGroup>
42
+    <Reference Include="dotMemory.Unit, Version=109.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
43
+      <HintPath>..\packages\JetBrains.dotMemoryUnit.2.4.20170830.172630\lib\dotMemory.Unit.dll</HintPath>
44
+    </Reference>
42 45
     <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
43 46
       <HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
44 47
     </Reference>
@@ -58,8 +61,10 @@
58 61
   <ItemGroup>
59 62
     <Compile Include="common\UIInfoModelTests.cs" />
60 63
     <Compile Include="Properties\AssemblyInfo.cs" />
64
+    <Compile Include="util\CmdUtilTests.cs" />
61 65
   </ItemGroup>
62 66
   <ItemGroup>
67
+    <None Include="app.config" />
63 68
     <None Include="packages.config" />
64 69
   </ItemGroup>
65 70
   <ItemGroup>

+ 11 - 0
DotNettyFromTests/app.config Zobrazit soubor

@@ -0,0 +1,11 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<configuration>
3
+  <runtime>
4
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5
+      <dependentAssembly>
6
+        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
7
+        <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
8
+      </dependentAssembly>
9
+    </assemblyBinding>
10
+  </runtime>
11
+</configuration>

+ 1 - 0
DotNettyFromTests/packages.config Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <packages>
3
+  <package id="JetBrains.dotMemoryUnit" version="2.4.20170830.172630" targetFramework="net461" />
3 4
   <package id="MSTest.TestAdapter" version="1.1.18" targetFramework="net461" />
4 5
   <package id="MSTest.TestFramework" version="1.1.18" targetFramework="net461" />
5 6
 </packages>

+ 22 - 0
DotNettyFromTests/util/CmdUtilTests.cs Zobrazit soubor

@@ -0,0 +1,22 @@
1
+using Microsoft.VisualStudio.TestTools.UnitTesting;
2
+using DotNettyFrom.util;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.Linq;
6
+using System.Text;
7
+using System.Threading.Tasks;
8
+
9
+namespace DotNettyFrom.util.Tests
10
+{
11
+    [TestClass()]
12
+    public class CmdUtilTests
13
+    {
14
+        [TestMethod()]
15
+        public void FrontWithZeroTest()
16
+        {
17
+            string atest = CmdUtil.FrontWithZero("1211", 8);
18
+            Console.WriteLine("----------");
19
+            Console.WriteLine(atest);
20
+        }
21
+    }
22
+}