Browse Source

验证输入密匙长度

tags/对接微服务前
张剑 2 years ago
parent
commit
82b71b7343
1 changed files with 26 additions and 11 deletions
  1. 26
    11
      XHWK.WKTool/KeyVerification.xaml.cs

+ 26
- 11
XHWK.WKTool/KeyVerification.xaml.cs View File

16
     /*
16
     /*
17
      输入code 调认证服务,成功跳登录 并且调用添加历史接口,失败继续输code
17
      输入code 调认证服务,成功跳登录 并且调用添加历史接口,失败继续输code
18
          */
18
          */
19
+
19
     public partial class KeyVerification : Window
20
     public partial class KeyVerification : Window
20
     {
21
     {
21
         private readonly XHApi registerController = new XHApi();
22
         private readonly XHApi registerController = new XHApi();
30
             Console.WriteLine("初始化KeyVerification");
31
             Console.WriteLine("初始化KeyVerification");
31
         }
32
         }
32
 
33
 
33
-
34
         private void btnEnd_Click(object sender, RoutedEventArgs e)
34
         private void btnEnd_Click(object sender, RoutedEventArgs e)
35
         {
35
         {
36
             if (string.IsNullOrWhiteSpace(txbKey.Text))
36
             if (string.IsNullOrWhiteSpace(txbKey.Text))
39
                 return;
39
                 return;
40
             }
40
             }
41
             projectcode = txbKey.Text.Trim();
41
             projectcode = txbKey.Text.Trim();
42
+            if (projectcode.Length > 8)
43
+            {
44
+                MessageWindow.Show("密匙输入过长");
45
+                txbKey.Text = projectcode.Substring(0, 8);
46
+                return;
47
+            }
42
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddServering, InvokeActivationAddServerCompate);
48
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddServering, InvokeActivationAddServerCompate);
43
         }
49
         }
44
 
50
 
45
         private string projectcode = string.Empty;
51
         private string projectcode = string.Empty;
52
+
46
         /// <summary>
53
         /// <summary>
47
         /// 认证服务-调用
54
         /// 认证服务-调用
48
         /// </summary>
55
         /// </summary>
49
-        /// <returns></returns>
56
+        /// <returns>
57
+        /// </returns>
50
         private object InvokeActivationAddServering()
58
         private object InvokeActivationAddServering()
51
         {
59
         {
52
             string device = "pcwk";
60
             string device = "pcwk";
58
         /// <summary>
66
         /// <summary>
59
         /// 认证服务-返回结果
67
         /// 认证服务-返回结果
60
         /// </summary>
68
         /// </summary>
61
-        /// <returns></returns>
69
+        /// <returns>
70
+        /// </returns>
62
         public void InvokeActivationAddServerCompate(object obj)
71
         public void InvokeActivationAddServerCompate(object obj)
63
         {
72
         {
64
             if (serverReturnCode == 0)
73
             if (serverReturnCode == 0)
72
                     //win.Topmost = true;
81
                     //win.Topmost = true;
73
                     win.Show();
82
                     win.Show();
74
 
83
 
75
-
76
                     Thread.Sleep(200);
84
                     Thread.Sleep(200);
77
                     Close();
85
                     Close();
78
                 }));
86
                 }));
82
                 MessageWindow.Show(APP.ServerMsg);
90
                 MessageWindow.Show(APP.ServerMsg);
83
             }
91
             }
84
         }
92
         }
93
+
85
         /// <summary>
94
         /// <summary>
86
         /// 激活信息--添加激活历史-调用
95
         /// 激活信息--添加激活历史-调用
87
         /// </summary>
96
         /// </summary>
88
-        /// <returns></returns>
97
+        /// <returns>
98
+        /// </returns>
89
         private object InvokeActivationAddHistoryServering()
99
         private object InvokeActivationAddHistoryServering()
90
         {
100
         {
91
             serverReturnCode = registerController.ActivationAddHistory();
101
             serverReturnCode = registerController.ActivationAddHistory();
95
         /// <summary>
105
         /// <summary>
96
         /// 激活信息--添加激活历史-返回结果
106
         /// 激活信息--添加激活历史-返回结果
97
         /// </summary>
107
         /// </summary>
98
-        /// <returns></returns>
108
+        /// <returns>
109
+        /// </returns>
99
         public void InvokeActivationAddHistoryServerCompate(object obj)
110
         public void InvokeActivationAddHistoryServerCompate(object obj)
100
         {
111
         {
101
             if (!Directory.Exists(APP.DataPath))
112
             if (!Directory.Exists(APP.DataPath))
106
             string currentTime = DateTime.Now.ToLongDateString().ToString();//当前时间
117
             string currentTime = DateTime.Now.ToLongDateString().ToString();//当前时间
107
             System.IO.File.WriteAllText(ApplicationData, currentTime, Encoding.Default);//存放签名验证日期
118
             System.IO.File.WriteAllText(ApplicationData, currentTime, Encoding.Default);//存放签名验证日期
108
         }
119
         }
109
-        /// <summary>  
110
-        /// 获取本机MAC地址  
111
-        /// </summary>  
112
-        /// <returns>本机MAC地址</returns>  
120
+
121
+        /// <summary>
122
+        /// 获取本机MAC地址
123
+        /// </summary>
124
+        /// <returns>
125
+        /// 本机MAC地址
126
+        /// </returns>
113
         public static string GetMacAddress()
127
         public static string GetMacAddress()
114
         {
128
         {
115
             try
129
             try
138
         {
152
         {
139
             closeAction();
153
             closeAction();
140
         }
154
         }
155
+
141
         private void closeAction()
156
         private void closeAction()
142
         {
157
         {
143
             APP.myloading.Show();
158
             APP.myloading.Show();
150
             }).Start();
165
             }).Start();
151
         }
166
         }
152
     }
167
     }
153
-}
168
+}

Loading…
Cancel
Save