Browse Source

接口添加Header

优化接口请求
优化下拉菜单界面
优化窗口界面
优化上传页面
master
张剑 1 year ago
parent
commit
6a55350149

+ 13
- 18
XHWK.WKTool/AESHelper.cs View File

4
 
4
 
5
 namespace Common
5
 namespace Common
6
 {
6
 {
7
-    /// <summary>
8
-    /// AES加密
9
-    /// 创建人:赵耀
10
-    /// 创建时间:2020年9月7日
11
-    /// </summary>
12
-    public class AESHelper
7
+    public class AesHelper
13
     {
8
     {
14
         public static string QrcodeLoginKey = "zyyxhlywkdatakey";
9
         public static string QrcodeLoginKey = "zyyxhlywkdatakey";
15
 
10
 
16
         /// <summary>
11
         /// <summary>
17
         /// AES 加密
12
         /// AES 加密
18
         /// </summary>
13
         /// </summary>
19
-        /// <param name="content">Need encrypted string</param>
14
+        /// <param name="data"></param>
15
+        /// <param name="key"></param>
20
         /// <returns>Encrypted 16 hex string</returns>
16
         /// <returns>Encrypted 16 hex string</returns>
21
-        public static string AESEncrypt(string Data, string key = "")
17
+        public static string AesEncrypt(string data, string key = "")
22
         {
18
         {
23
             if (string.IsNullOrWhiteSpace(key))
19
             if (string.IsNullOrWhiteSpace(key))
24
             {
20
             {
25
                 key = QrcodeLoginKey.PadRight(16, '0');
21
                 key = QrcodeLoginKey.PadRight(16, '0');
26
             }
22
             }
27
             // 256-AES key      
23
             // 256-AES key      
28
-            byte[] keyArray = UTF8Encoding.ASCII.GetBytes(key);
29
-            byte[] toEncryptArray = UTF8Encoding.ASCII.GetBytes(Data);
30
-
24
+            byte[] keyArray = Encoding.ASCII.GetBytes(key);
25
+            byte[] toEncryptArray = Encoding.ASCII.GetBytes(data);
31
             RijndaelManaged rDel = new RijndaelManaged
26
             RijndaelManaged rDel = new RijndaelManaged
32
             {
27
             {
33
                 Key = keyArray,
28
                 Key = keyArray,
46
         /// AES 解密
41
         /// AES 解密
47
         /// </summary>
42
         /// </summary>
48
         /// <param name="hexString">Encrypted 16 hex string</param>
43
         /// <param name="hexString">Encrypted 16 hex string</param>
44
+        /// <param name="key"></param>
49
         /// <returns>Decrypted string</returns>
45
         /// <returns>Decrypted string</returns>
50
-        public static string AESDecrypt(string hexString, string key = "")
46
+        public static string AesDecrypt(string hexString, string key = "")
51
         {
47
         {
52
             if (string.IsNullOrWhiteSpace(key))
48
             if (string.IsNullOrWhiteSpace(key))
53
             {
49
             {
54
                 key = QrcodeLoginKey.PadRight(16, '0');
50
                 key = QrcodeLoginKey.PadRight(16, '0');
55
             }
51
             }
56
             // 256-AES key      
52
             // 256-AES key      
57
-            byte[] keyArray = UTF8Encoding.ASCII.GetBytes(key);
53
+            byte[] keyArray = Encoding.ASCII.GetBytes(key);
58
             byte[] toEncryptArray = HexStringToBytes(hexString);
54
             byte[] toEncryptArray = HexStringToBytes(hexString);
59
 
55
 
60
             RijndaelManaged rDel = new RijndaelManaged
56
             RijndaelManaged rDel = new RijndaelManaged
67
             ICryptoTransform cTransform = rDel.CreateDecryptor();
63
             ICryptoTransform cTransform = rDel.CreateDecryptor();
68
             byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,
64
             byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,
69
                     toEncryptArray.Length);
65
                     toEncryptArray.Length);
70
-
71
-            return UTF8Encoding.ASCII.GetString(resultArray);
66
+            return Encoding.ASCII.GetString(resultArray);
72
         }
67
         }
73
 
68
 
74
         /// <summary>
69
         /// <summary>
79
         public static string BytesToHexString(byte[] bytes)
74
         public static string BytesToHexString(byte[] bytes)
80
         {
75
         {
81
             StringBuilder returnStr = new StringBuilder();
76
             StringBuilder returnStr = new StringBuilder();
82
-            if (bytes != null || bytes.Length == 0)
77
+            if (bytes != null)
83
             {
78
             {
84
-                for (int i = 0; i < bytes.Length; i++)
79
+                foreach (var t in bytes)
85
                 {
80
                 {
86
-                    returnStr.Append(bytes[i].ToString("X2"));
81
+                    returnStr.Append(t.ToString("X2"));
87
                 }
82
                 }
88
             }
83
             }
89
             return returnStr.ToString();
84
             return returnStr.ToString();

+ 2
- 4
XHWK.WKTool/App.config View File

6
   <appSettings>
6
   <appSettings>
7
     <!--0正式 1测试-->
7
     <!--0正式 1测试-->
8
     <add key="IsDebug" value="1" />
8
     <add key="IsDebug" value="1" />
9
-    <!--参数是否加密 0不加密 1加密-->
10
-    <add key="IsParameterEncryption" value="0" />
11
     <!--版本号-->
9
     <!--版本号-->
12
-    <add key="VersionCode" value="126" />
13
-    <add key="VersionName" value="3.12.0" />
10
+    <add key="VersionCode" value="127" />
11
+    <add key="VersionName" value="3.13.0" />
14
     <!--皮肤样式 0白 1蓝 2黑色 -->
12
     <!--皮肤样式 0白 1蓝 2黑色 -->
15
     <add key="SkinStyle" value="0" />
13
     <add key="SkinStyle" value="0" />
16
     <!--是否输出视频记录日志:0否-->
14
     <!--是否输出视频记录日志:0否-->

+ 14
- 9
XHWK.WKTool/App.xaml.cs View File

17
 {
17
 {
18
     using System.Runtime.InteropServices;
18
     using System.Runtime.InteropServices;
19
     using system;
19
     using system;
20
+    using XHWK.WKTool.Utils;
20
 
21
 
21
     public partial class App
22
     public partial class App
22
     {
23
     {
29
         /// </summary>
30
         /// </summary>
30
         public static bool isDebug = FileToolsCommon.GetConfigValue("IsDebug") != "0";
31
         public static bool isDebug = FileToolsCommon.GetConfigValue("IsDebug") != "0";
31
 
32
 
32
-        /// <summary>
33
-        /// 参数是否加密
34
-        /// </summary>
35
-        public static bool IsParameterEncryption = FileToolsCommon.GetConfigValue("IsParameterEncryption") != "0";
36
-
37
         #endregion 更新需改动
33
         #endregion 更新需改动
38
 
34
 
39
         #region 接口地址
35
         #region 接口地址
316
         {
312
         {
317
             Console.WriteLine(@"初始化APP");
313
             Console.WriteLine(@"初始化APP");
318
             LogHelper.InitLog4Net();
314
             LogHelper.InitLog4Net();
319
-            bool isParameterEncryption = FileToolsCommon.GetConfigValue("IsParameterEncryption") != "0";
320
-            HttpHelper.isParameterEncryption = isParameterEncryption;
315
+            ZHttpUtil.isSt = ZConfigAppUtil.GetVaule("isSt") == "True";
316
+            ZHttpUtil.version = FileToolsCommon.GetConfigValue("VersionName");
321
             myloading = new LoadDialog();
317
             myloading = new LoadDialog();
322
             Killffmpeg();
318
             Killffmpeg();
323
             try
319
             try
369
                     }
365
                     }
370
                     //退出
366
                     //退出
371
                     //Current.Shutdown();
367
                     //Current.Shutdown();
372
-                    Environment.Exit(0);
368
+                    Application.Current.Shutdown();
373
                 }
369
                 }
374
             }
370
             }
375
             catch (Exception ex)
371
             catch (Exception ex)
405
                 int hWnd = FindWindow(null, process.MainWindowTitle);
401
                 int hWnd = FindWindow(null, process.MainWindowTitle);
406
                 SetForegroundWindow(hWnd);
402
                 SetForegroundWindow(hWnd);
407
             }
403
             }
408
-            Environment.Exit(1); //退出新打开的程序
404
+            Application.Current.Shutdown(); //退出新打开的程序
409
         }
405
         }
410
 
406
 
411
         /// <summary>
407
         /// <summary>
698
             base.OnStartup(e);
694
             base.OnStartup(e);
699
             CheckProcess();
695
             CheckProcess();
700
         }
696
         }
697
+
698
+        protected override void OnExit(ExitEventArgs e)
699
+        {
700
+            // 在应用程序退出之前执行必要的操作
701
+            ZConfigAppUtil.SetVaule("isSt", "" + ZHttpUtil.isSt);
702
+            Console.WriteLine(@"应用退出");
703
+            base.OnExit(e);
704
+            Environment.Exit(0);
705
+        }
701
     }
706
     }
702
 }
707
 }

+ 3
- 2
XHWK.WKTool/AppUpdateWin.xaml View File

91
                     <Button
91
                     <Button
92
                         Width="190"
92
                         Width="190"
93
                         Height="42"
93
                         Height="42"
94
-                        Click="gengxinClick"
94
+                        Click="GengxinClick"
95
                         Content="更新"
95
                         Content="更新"
96
                         Cursor="Hand"
96
                         Cursor="Hand"
97
                         FontSize="20"
97
                         FontSize="20"
139
                             <ProgressBar
139
                             <ProgressBar
140
                                 x:Name="Mprogress"
140
                                 x:Name="Mprogress"
141
                                 BorderThickness="0"
141
                                 BorderThickness="0"
142
+                                Cursor=""
142
                                 Foreground="#3f6fff"
143
                                 Foreground="#3f6fff"
143
                                 Maximum="100"
144
                                 Maximum="100"
144
-                                Minimum="0" Cursor="" />
145
+                                Minimum="0" />
145
                         </views:ZJClippingBorder>
146
                         </views:ZJClippingBorder>
146
                     </StackPanel>
147
                     </StackPanel>
147
                 </Grid>
148
                 </Grid>

+ 16
- 23
XHWK.WKTool/AppUpdateWin.xaml.cs View File

1
 using System;
1
 using System;
2
-using System.Diagnostics;
3
 using System.IO;
2
 using System.IO;
4
 using System.Management;
3
 using System.Management;
5
 using System.Windows;
4
 using System.Windows;
6
 using System.Windows.Input;
5
 using System.Windows.Input;
7
-
8
 using XHWK.Model;
6
 using XHWK.Model;
9
 using XHWK.WKTool.Helpers;
7
 using XHWK.WKTool.Helpers;
10
-
11
 using static XHWK.WKTool.Helpers.ZJDownloadUtil;
8
 using static XHWK.WKTool.Helpers.ZJDownloadUtil;
12
 
9
 
13
 namespace XHWK.WKTool
10
 namespace XHWK.WKTool
15
     /// <summary>
12
     /// <summary>
16
     /// AppUpdateWin.xaml 的交互逻辑
13
     /// AppUpdateWin.xaml 的交互逻辑
17
     /// </summary>
14
     /// </summary>
18
-    public partial class AppUpdateWin : Window, ZJDownloadCallback
15
+    public partial class AppUpdateWin : ZJDownloadCallback
19
     {
16
     {
20
-        private readonly AppUpdatePageModel pageData = new AppUpdatePageModel();
17
+        private readonly AppUpdatePageModel _pageData = new AppUpdatePageModel();
21
 
18
 
22
         public AppUpdateWin(Model_App app)
19
         public AppUpdateWin(Model_App app)
23
         {
20
         {
24
             InitializeComponent();
21
             InitializeComponent();
25
-            pageData.appModel = app;
26
-
27
-            DataContext = pageData;
28
-        }
29
-
30
-        private void btnDown_Click(object sender, RoutedEventArgs e)
31
-        {
32
-            Close();
22
+            _pageData.appModel = app;
23
+            DataContext = _pageData;
33
         }
24
         }
34
 
25
 
35
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
26
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
47
             Close();
38
             Close();
48
         }
39
         }
49
 
40
 
50
-        private void gengxinClick(object sender, RoutedEventArgs e)
41
+        private void GengxinClick(object sender, RoutedEventArgs e)
51
         {
42
         {
52
-            string fileUrl = App.showImageUrl + pageData.appModel.versionpath;
43
+            string fileUrl = App.showImageUrl + _pageData.appModel.versionpath;
53
             string path = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
44
             string path = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
54
             DirectoryInfo info = new DirectoryInfo(path);
45
             DirectoryInfo info = new DirectoryInfo(path);
55
             if (!info.Exists)
46
             if (!info.Exists)
56
             {
47
             {
57
                 info.Create();
48
                 info.Create();
58
             }
49
             }
59
-
60
-            string filename = fileUrl.Substring(fileUrl.LastIndexOf("/") + 1);
61
-            if (filename != null)
62
-            {
63
-                ZJDownloadUtil.downloadFileWithCallback(fileUrl, 999, Dispatcher, this);
64
-            }
50
+            ZJDownloadUtil.downloadFileWithCallback
51
+            (
52
+                fileUrl,
53
+                999,
54
+                Dispatcher,
55
+                this
56
+            );
65
         }
57
         }
66
 
58
 
67
         public void downloadBegin(int position)
59
         public void downloadBegin(int position)
96
                     var result = managementClass.InvokeMethod("Create", inParameters, null);
88
                     var result = managementClass.InvokeMethod("Create", inParameters, null);
97
                     if ((result != null) && ((uint)result.Properties["ReturnValue"].Value != 0))
89
                     if ((result != null) && ((uint)result.Properties["ReturnValue"].Value != 0))
98
                     {
90
                     {
99
-                        Console.WriteLine("Process ID: {0}", result.Properties["ProcessId"].Value);
91
+                        Console.WriteLine(@"Process ID: {0}", result.Properties["ProcessId"].Value);
100
                     }
92
                     }
101
                 }
93
                 }
102
             }
94
             }
103
             catch (Exception)
95
             catch (Exception)
104
             {
96
             {
97
+                // ignored
105
             }
98
             }
106
-            Environment.Exit(0);
99
+            Application.Current.Shutdown();
107
         }
100
         }
108
 
101
 
109
         public void downloadError(int position, string msg)
102
         public void downloadError(int position, string msg)

+ 7
- 8
XHWK.WKTool/CreateAMicroLessonWindow.xaml View File

99
                                         FontSize="12"
99
                                         FontSize="12"
100
                                         Foreground="#FF666666" />
100
                                         Foreground="#FF666666" />
101
                                     <TextBox
101
                                     <TextBox
102
-                                        x:Name="txbExplainName"
102
+                                        x:Name="TxbExplainName"
103
                                         Margin="5,5"
103
                                         Margin="5,5"
104
                                         BorderBrush="{x:Null}"
104
                                         BorderBrush="{x:Null}"
105
                                         BorderThickness="0"
105
                                         BorderThickness="0"
123
                                             <ColumnDefinition Width="45" />
123
                                             <ColumnDefinition Width="45" />
124
                                         </Grid.ColumnDefinitions>
124
                                         </Grid.ColumnDefinitions>
125
                                         <TextBox
125
                                         <TextBox
126
-                                            x:Name="txbStoragePath"
126
+                                            x:Name="TxbStoragePath"
127
                                             Grid.Column="0"
127
                                             Grid.Column="0"
128
                                             Margin="5,5"
128
                                             Margin="5,5"
129
                                             BorderBrush="{x:Null}"
129
                                             BorderBrush="{x:Null}"
132
                                             Foreground="#FF999999"
132
                                             Foreground="#FF999999"
133
                                             Text="D:\" />
133
                                             Text="D:\" />
134
                                         <Button
134
                                         <Button
135
-                                            x:Name="btnBrowse"
135
+                                            x:Name="BtnBrowse"
136
                                             Grid.Column="1"
136
                                             Grid.Column="1"
137
                                             Margin="0,5,0,5"
137
                                             Margin="0,5,0,5"
138
                                             Padding="4"
138
                                             Padding="4"
159
                                     Visibility="Hidden" />
159
                                     Visibility="Hidden" />
160
                                 <Button
160
                                 <Button
161
                                     x:Name="BtnStart"
161
                                     x:Name="BtnStart"
162
-                                    Grid.Row="3"
163
                                     Grid.ColumnSpan="2"
162
                                     Grid.ColumnSpan="2"
164
                                     Width="195"
163
                                     Width="195"
165
                                     Height="40"
164
                                     Height="40"
193
 
192
 
194
                             <Grid Grid.Row="4">
193
                             <Grid Grid.Row="4">
195
                                 <Label
194
                                 <Label
196
-                                    Name="versionLabel"
195
+                                    Name="VersionLabel"
197
                                     HorizontalAlignment="Center"
196
                                     HorizontalAlignment="Center"
198
                                     Content="版本号:"
197
                                     Content="版本号:"
199
                                     Foreground="#666666" />
198
                                     Foreground="#666666" />
203
                 </Border>
202
                 </Border>
204
             </Grid>
203
             </Grid>
205
             <Button
204
             <Button
206
-                x:Name="btnDown"
205
+                x:Name="BtnDown"
207
                 Grid.Column="1"
206
                 Grid.Column="1"
208
                 Padding="5,0"
207
                 Padding="5,0"
209
                 HorizontalAlignment="Right"
208
                 HorizontalAlignment="Right"
238
                 <!--<Button  Cursor="Hand" Grid.Row="0" x:Name="btnDown" Content="×" VerticalAlignment="Top" Foreground="#FFFFFF" FontSize="30" Padding="10,2,10,0" HorizontalAlignment="Right"  Click="BtnDown_Click" />-->
237
                 <!--<Button  Cursor="Hand" Grid.Row="0" x:Name="btnDown" Content="×" VerticalAlignment="Top" Foreground="#FFFFFF" FontSize="30" Padding="10,2,10,0" HorizontalAlignment="Right"  Click="BtnDown_Click" />-->
239
             </Grid>
238
             </Grid>
240
             <Grid
239
             <Grid
241
-                x:Name="GridTitle_Black"
240
+                x:Name="GridTitleBlack"
242
                 Grid.Row="0"
241
                 Grid.Row="0"
243
                 Margin="0,0"
242
                 Margin="0,0"
244
                 Background="#FFE9E9E9"
243
                 Background="#FFE9E9E9"
250
                     Foreground="#FF333333"
249
                     Foreground="#FF333333"
251
                     Text="创建微课" />
250
                     Text="创建微课" />
252
                 <Button
251
                 <Button
253
-                    x:Name="btnDown_Black"
252
+                    x:Name="BtnDownBlack"
254
                     Grid.Row="0"
253
                     Grid.Row="0"
255
                     Padding="10,2,10,0"
254
                     Padding="10,2,10,0"
256
                     HorizontalAlignment="Right"
255
                     HorizontalAlignment="Right"

+ 13
- 18
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

12
 namespace XHWK.WKTool
12
 namespace XHWK.WKTool
13
 {
13
 {
14
     using system;
14
     using system;
15
+    using Application = System.Windows.Application;
15
 
16
 
16
     /// <summary>
17
     /// <summary>
17
     /// 创建微课
18
     /// 创建微课
32
         {
33
         {
33
             InitializeComponent();
34
             InitializeComponent();
34
             ResizeMode = ResizeMode.NoResize;
35
             ResizeMode = ResizeMode.NoResize;
35
-
36
-            txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
37
-
36
+            TxbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
38
             var versionCode = FileToolsCommon.GetConfigValue("VersionCode");
37
             var versionCode = FileToolsCommon.GetConfigValue("VersionCode");
39
             var versionName = FileToolsCommon.GetConfigValue("VersionName");
38
             var versionName = FileToolsCommon.GetConfigValue("VersionName");
40
             var isDebug = FileToolsCommon.GetConfigValue("IsDebug");
39
             var isDebug = FileToolsCommon.GetConfigValue("IsDebug");
47
             {
46
             {
48
                 debugStr = "正式版";
47
                 debugStr = "正式版";
49
             }
48
             }
50
-
51
-            versionLabel.Content = debugStr + " v" + versionName + "(" + versionCode + ")";
52
-
49
+            VersionLabel.Content = debugStr + " v" + versionName + "(" + versionCode + ")";
53
             LoadingCarouseImg();
50
             LoadingCarouseImg();
54
         }
51
         }
55
 
52
 
161
             MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
158
             MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
162
             if (dr == MessageBoxResult.OK)
159
             if (dr == MessageBoxResult.OK)
163
             {
160
             {
164
-                Environment.Exit(0);
161
+                Application.Current.Shutdown();
165
             }
162
             }
166
         }
163
         }
167
 
164
 
182
             {
179
             {
183
                 if (_ofd.SelectedPath != "")
180
                 if (_ofd.SelectedPath != "")
184
                 {
181
                 {
185
-                    txbStoragePath.Text = _ofd.SelectedPath;
182
+                    TxbStoragePath.Text = _ofd.SelectedPath;
186
                 }
183
                 }
187
             }
184
             }
188
         }
185
         }
218
 
215
 
219
             #region 合法性判断
216
             #region 合法性判断
220
 
217
 
221
-            if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
218
+            if (string.IsNullOrWhiteSpace(TxbExplainName.Text.Trim()))
222
             {
219
             {
223
                 MessageWindow.Show("讲解名称不可为空!");
220
                 MessageWindow.Show("讲解名称不可为空!");
224
                 return;
221
                 return;
225
             }
222
             }
226
-
227
-            if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
223
+            if (string.IsNullOrWhiteSpace(TxbStoragePath.Text.Trim()))
228
             {
224
             {
229
                 MessageWindow.Show("路径不可为空!");
225
                 MessageWindow.Show("路径不可为空!");
230
                 return;
226
                 return;
231
             }
227
             }
232
-
233
             try
228
             try
234
             {
229
             {
235
-                FileToolsCommon.CreateDirectory(txbStoragePath.Text.Trim());
230
+                FileToolsCommon.CreateDirectory(TxbStoragePath.Text.Trim());
236
             }
231
             }
237
             catch (Exception)
232
             catch (Exception)
238
             {
233
             {
243
             #endregion 合法性判断
238
             #endregion 合法性判断
244
 
239
 
245
             LblCreate.Visibility = Visibility.Visible;
240
             LblCreate.Visibility = Visibility.Visible;
246
-            string wkpath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
247
-            string storagePath = txbStoragePath.Text;
248
-            string wkName = txbExplainName.Text;
241
+            string wkpath = FileToolsCommon.GetLegalPath(TxbStoragePath.Text) + TxbExplainName.Text.Trim() + "/";
242
+            string storagePath = TxbStoragePath.Text;
243
+            string wkName = TxbExplainName.Text;
249
             await Task.Run(() =>
244
             await Task.Run(() =>
250
             {
245
             {
251
                 try
246
                 try
322
                     return;
317
                     return;
323
                 }
318
                 }
324
                 string url = App.apiUrl + "/sapi/apprecord/get_new";
319
                 string url = App.apiUrl + "/sapi/apprecord/get_new";
325
-                string result = HttpHelper.PostAndRespStr(url, "{}");
320
+                string result = ZHttpUtil.PostStr(url, "{}");
326
                 var resultObj = JsonHelper.JsonToObj<ResultVo<Model_App>>(result);
321
                 var resultObj = JsonHelper.JsonToObj<ResultVo<Model_App>>(result);
327
                 if (result != null && resultObj.code == 0)
322
                 if (result != null && resultObj.code == 0)
328
                 {
323
                 {
372
 
367
 
373
         private void Window_Closed(object sender, EventArgs e)
368
         private void Window_Closed(object sender, EventArgs e)
374
         {
369
         {
375
-            Environment.Exit(0);
370
+            Application.Current.Shutdown();
376
         }
371
         }
377
     }
372
     }
378
 }
373
 }

+ 22
- 9
XHWK.WKTool/DAL/DAL_Upload.cs View File

40
             {
40
             {
41
                 try
41
                 try
42
                 {
42
                 {
43
-                    JObject jo = HttpHelper.PostFunction(_fileRequestAddress + @"/chunkdb/isexist",
44
-                        @"application/x-www-form-urlencoded", @"md5=" + md5, "");
43
+                    JObject jo = ZHttpUtil.PostFunction
44
+                    (
45
+                        _fileRequestAddress + @"/chunkdb/isexist",
46
+                        @"application/x-www-form-urlencoded",
47
+                        @"md5=" + md5,
48
+                        ""
49
+                    );
45
                     if (jo == null)
50
                     if (jo == null)
46
                     {
51
                     {
47
                         message = "无法访问文件服务器,请检查网络或文件服务器地址。";
52
                         message = "无法访问文件服务器,请检查网络或文件服务器地址。";
101
             {
106
             {
102
                 try
107
                 try
103
                 {
108
                 {
104
-                    JObject jo = HttpHelper.PostFunction(_fileRequestAddress + @"/chunkdb/mergechunk",
105
-                        @"application/x-www-form-urlencoded", @"savefolder=" + savefolder + "&identifier=" + fileCode,
106
-                        "");
109
+                    JObject jo = ZHttpUtil.PostFunction
110
+                    (
111
+                        _fileRequestAddress + @"/chunkdb/mergechunk",
112
+                        @"application/x-www-form-urlencoded",
113
+                        @"savefolder=" + savefolder + "&identifier=" + fileCode,
114
+                        ""
115
+                    );
107
                     if (jo == null)
116
                     if (jo == null)
108
                     {
117
                     {
109
                         message = "无法访问文件服务器,请检查网络或文件服务器地址。";
118
                         message = "无法访问文件服务器,请检查网络或文件服务器地址。";
238
                 {
247
                 {
239
                     if (string.IsNullOrWhiteSpace(videoInfo.FileMD5))
248
                     if (string.IsNullOrWhiteSpace(videoInfo.FileMD5))
240
                     {
249
                     {
241
-                        videoInfo.FileMD5 =
242
-                            AESHelper.AESEncrypt(FileToolsCommon.ReadBigFileStr(videoInfo.VideoPath, 1024));
250
+                        videoInfo.FileMD5 = AesHelper.AesEncrypt(FileToolsCommon.ReadBigFileStr(videoInfo.VideoPath, 1024));
243
                     }
251
                     }
244
 
252
 
245
                     //视频长度
253
                     //视频长度
332
                             //{
340
                             //{
333
                             //    formFields.Add();
341
                             //    formFields.Add();
334
                             //}
342
                             //}
335
-
336
-                            JObject jo = HttpHelper.UploadRequestflow(uploadUrl, byteArray, fileName, formFields);
343
+                            JObject jo = ZHttpUtil.UploadRequestflow
344
+                            (
345
+                                uploadUrl,
346
+                                byteArray,
347
+                                fileName,
348
+                                formFields
349
+                            );
337
                             //0成功,1失败
350
                             //0成功,1失败
338
                             if (jo["code"]?.ToString() != "0")
351
                             if (jo["code"]?.ToString() != "0")
339
                             {
352
                             {

+ 13
- 15
XHWK.WKTool/DAL/XHApi.cs View File

12
 namespace XHWK.WKTool.DAL
12
 namespace XHWK.WKTool.DAL
13
 {
13
 {
14
     using system;
14
     using system;
15
+    using VisioForge.Tools.TagLib;
15
 
16
 
16
     public class XhApi
17
     public class XhApi
17
     {
18
     {
37
                     { "projectcode", projectcode }
38
                     { "projectcode", projectcode }
38
                 };
39
                 };
39
                 string body = JsonHelper.ToJson(dic);
40
                 string body = JsonHelper.ToJson(dic);
40
-
41
-                string xmlDoc = HttpHelper.HttpPost(body, url);
42
-
41
+                string xmlDoc = ZHttpUtil.PostStr(url, body);
43
                 if (string.IsNullOrEmpty(xmlDoc))
42
                 if (string.IsNullOrEmpty(xmlDoc))
44
                 {
43
                 {
45
                     App.ServerMsg = "网络异常!";
44
                     App.ServerMsg = "网络异常!";
88
                 string url = App.certapiUrl + "/activation/add_history";
87
                 string url = App.certapiUrl + "/activation/add_history";
89
                 Dictionary<string, object> dic = new Dictionary<string, object> { { "sign", App.Signature } };
88
                 Dictionary<string, object> dic = new Dictionary<string, object> { { "sign", App.Signature } };
90
                 string body = JsonHelper.ToJson(dic);
89
                 string body = JsonHelper.ToJson(dic);
91
-                string xmlDoc = HttpHelper.HttpPost(body, url);
92
-
90
+                string xmlDoc = ZHttpUtil.PostStr(url, body);
93
                 if (string.IsNullOrEmpty(xmlDoc))
91
                 if (string.IsNullOrEmpty(xmlDoc))
94
                 {
92
                 {
95
                     return 1;
93
                     return 1;
121
 
119
 
122
             //1.193.37.200
120
             //1.193.37.200
123
             const string address = ""; //河南 郑州
121
             const string address = ""; //河南 郑州
124
-            HttpHelper.GetAddressIp(out string addressIp, out addressIp);
122
+            ZHttpUtil.GetAddressIp(out string addressIp, out addressIp);
125
             Dictionary<string, object> dic = new Dictionary<string, object>
123
             Dictionary<string, object> dic = new Dictionary<string, object>
126
             {
124
             {
127
                 { "loginname", loginname },
125
                 { "loginname", loginname },
132
                 { "versionnum", FileToolsCommon.GetConfigValue("VersionName") }
130
                 { "versionnum", FileToolsCommon.GetConfigValue("VersionName") }
133
             };
131
             };
134
             string body = JsonHelper.ToJson(dic);
132
             string body = JsonHelper.ToJson(dic);
135
-            ResultVo<ModelUserInfo> result = HttpHelper.PostAndRespSignle<ResultVo<ModelUserInfo>>(url, postData: body);
133
+            ResultVo<ModelUserInfo> result = ZHttpUtil.PostSignle<ResultVo<ModelUserInfo>>(url, postData: body);
136
             if (result != null)
134
             if (result != null)
137
             {
135
             {
138
                 App.UserInfo = new ModelUserInfo();
136
                 App.UserInfo = new ModelUserInfo();
140
                 if (result.obj != null)
138
                 if (result.obj != null)
141
                 {
139
                 {
142
                     App.UserInfo = result.obj;
140
                     App.UserInfo = result.obj;
143
-                    HttpHelper.tokenKey = result.obj.token_key;
144
-                    HttpHelper.tokenValue = result.obj.token_value;
145
-                    HttpHelper.userId = result.obj.Userid + "";
141
+                    ZHttpUtil.tokenKey = result.obj.token_key;
142
+                    ZHttpUtil.tokenValue = result.obj.token_value;
143
+                    ZHttpUtil.userId = result.obj.Userid + "";
146
                 }
144
                 }
147
                 return result.code;
145
                 return result.code;
148
             }
146
             }
163
         public bool DownloadAvatar(string headPortrait, string savePath)
161
         public bool DownloadAvatar(string headPortrait, string savePath)
164
         {
162
         {
165
             string url = App.showImageUrl + headPortrait;
163
             string url = App.showImageUrl + headPortrait;
166
-            bool result = HttpHelper.GetDataGetHtml
164
+            bool result = ZHttpUtil.GetDataGetHtml
167
             (
165
             (
168
                 url,
166
                 url,
169
                 savePath,
167
                 savePath,
185
                 string url = App.apiUrl + "/sstudy/tsubjectbook/list"; //地址
183
                 string url = App.apiUrl + "/sstudy/tsubjectbook/list"; //地址
186
                 Dictionary<string, int> dic = new Dictionary<string, int> { { "teacherid", App.UserInfo.Userid } };
184
                 Dictionary<string, int> dic = new Dictionary<string, int> { { "teacherid", App.UserInfo.Userid } };
187
                 string body = JsonHelper.ToJson(dic);
185
                 string body = JsonHelper.ToJson(dic);
188
-                ResultVo<List<Model_TsubjectbookList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_TsubjectbookList>>>(url, postData: body);
186
+                ResultVo<List<Model_TsubjectbookList>> result = ZHttpUtil.PostSignle<ResultVo<List<Model_TsubjectbookList>>>(url, postData: body);
189
                 if (result != null)
187
                 if (result != null)
190
                 {
188
                 {
191
                     App.ServerMsg = result.msg;
189
                     App.ServerMsg = result.msg;
228
                     { "createid", createid.ToString() }
226
                     { "createid", createid.ToString() }
229
                 };
227
                 };
230
                 string body = JsonHelper.ToJson(dic);
228
                 string body = JsonHelper.ToJson(dic);
231
-                ResultVo<List<Model_DirectorList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_DirectorList>>>(url, postData: body);
229
+                ResultVo<List<Model_DirectorList>> result = ZHttpUtil.PostSignle<ResultVo<List<Model_DirectorList>>>(url, postData: body);
232
                 if (result != null)
230
                 if (result != null)
233
                 {
231
                 {
234
                     App.ServerMsg = result.msg;
232
                     App.ServerMsg = result.msg;
304
                 //dic.Add("uid", model.uid);
302
                 //dic.Add("uid", model.uid);
305
 
303
 
306
                 string body = JsonHelper.ToJson(dic);
304
                 string body = JsonHelper.ToJson(dic);
307
-                string xmlDoc = HttpHelper.HttpPost(body, url);
305
+                string xmlDoc = ZHttpUtil.PostStr(url, body);
308
                 JObject obj = JObject.Parse(xmlDoc);
306
                 JObject obj = JObject.Parse(xmlDoc);
309
                 App.ServerMsg = obj["msg"]?.ToString();
307
                 App.ServerMsg = obj["msg"]?.ToString();
310
                 return Convert.ToInt32(obj["code"]?.ToString());
308
                 return Convert.ToInt32(obj["code"]?.ToString());
330
             string url = App.certapiUrl + "/school/find_code"; //地址
328
             string url = App.certapiUrl + "/school/find_code"; //地址
331
             Dictionary<string, object> dic = new Dictionary<string, object> { { "schoolcode", schoolcode } };
329
             Dictionary<string, object> dic = new Dictionary<string, object> { { "schoolcode", schoolcode } };
332
             string body = JsonHelper.ToJson(dic);
330
             string body = JsonHelper.ToJson(dic);
333
-            ResultVo<Model_ServiceAddress> result = HttpHelper.PostAndRespSignle<ResultVo<Model_ServiceAddress>>(url, postData: body);
331
+            ResultVo<Model_ServiceAddress> result = ZHttpUtil.PostSignle<ResultVo<Model_ServiceAddress>>(url, postData: body);
334
             if (result != null)
332
             if (result != null)
335
             {
333
             {
336
                 if (result.code == 0)
334
                 if (result.code == 0)

+ 16
- 22
XHWK.WKTool/DeviceWindow.xaml View File

4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
     xmlns:gif="http://wpfanimatedgif.codeplex.com"
6
     xmlns:gif="http://wpfanimatedgif.codeplex.com"
7
-    xmlns:local="clr-namespace:XHWK.WKTool"
8
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9
     xmlns:view="clr-namespace:XHWK.WKTool.View"
8
     xmlns:view="clr-namespace:XHWK.WKTool.View"
10
     Title="设备检测"
9
     Title="设备检测"
18
 
17
 
19
     <Window.Resources>
18
     <Window.Resources>
20
         <!--  摄像头样式  -->
19
         <!--  摄像头样式  -->
21
-        <Style x:Key="stlToggleButton" TargetType="ToggleButton">
20
+        <Style x:Key="StlToggleButton" TargetType="ToggleButton">
22
             <Setter Property="Foreground" Value="White" />
21
             <Setter Property="Foreground" Value="White" />
23
             <Setter Property="Template">
22
             <Setter Property="Template">
24
                 <Setter.Value>
23
                 <Setter.Value>
58
                 </Setter.Value>
57
                 </Setter.Value>
59
             </Setter>
58
             </Setter>
60
         </Style>
59
         </Style>
61
-        <Style x:Key="stlComboBox" TargetType="ComboBox">
60
+        <Style x:Key="StlComboBox" TargetType="ComboBox">
62
             <Setter Property="SnapsToDevicePixels" Value="True" />
61
             <Setter Property="SnapsToDevicePixels" Value="True" />
63
             <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
62
             <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
64
             <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
63
             <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
93
                                 <ToggleButton
92
                                 <ToggleButton
94
                                     ClickMode="Press"
93
                                     ClickMode="Press"
95
                                     IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
94
                                     IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
96
-                                    Style="{StaticResource stlToggleButton}" />
95
+                                    Style="{StaticResource StlToggleButton}" />
97
                             </Border>
96
                             </Border>
98
                             <Popup
97
                             <Popup
99
                                 x:Name="Popup"
98
                                 x:Name="Popup"
99
+                                Grid.Column="0"
100
                                 AllowsTransparency="True"
100
                                 AllowsTransparency="True"
101
                                 Focusable="False"
101
                                 Focusable="False"
102
                                 IsOpen="{TemplateBinding IsDropDownOpen}"
102
                                 IsOpen="{TemplateBinding IsDropDownOpen}"
143
             <RowDefinition Height="*" />
143
             <RowDefinition Height="*" />
144
         </Grid.RowDefinitions>
144
         </Grid.RowDefinitions>
145
         <Grid
145
         <Grid
146
-            x:Name="GridTitle_Black"
146
+            x:Name="GridTitleBlack"
147
             Grid.Row="0"
147
             Grid.Row="0"
148
             Margin="0,0"
148
             Margin="0,0"
149
             Background="#3f6fff"
149
             Background="#3f6fff"
156
                 Foreground="White"
156
                 Foreground="White"
157
                 Text="设备检测" />
157
                 Text="设备检测" />
158
             <Button
158
             <Button
159
-                x:Name="btnDown_Black"
159
+                x:Name="BtnDownBlack"
160
                 Grid.Row="0"
160
                 Grid.Row="0"
161
                 Width="46"
161
                 Width="46"
162
                 HorizontalAlignment="Right"
162
                 HorizontalAlignment="Right"
288
                         Width="236"
288
                         Width="236"
289
                         Margin="16,0,0,0"
289
                         Margin="16,0,0,0"
290
                         Padding="30,0,0,0"
290
                         Padding="30,0,0,0"
291
-                        HorizontalAlignment="Left"
292
                         VerticalAlignment="Center"
291
                         VerticalAlignment="Center"
293
                         HorizontalContentAlignment="Center"
292
                         HorizontalContentAlignment="Center"
294
                         VerticalContentAlignment="Center"
293
                         VerticalContentAlignment="Center"
298
                         DisplayMemberPath="Name"
297
                         DisplayMemberPath="Name"
299
                         FontSize="14"
298
                         FontSize="14"
300
                         SelectionChanged="CmbCameraList_SelectionChanged"
299
                         SelectionChanged="CmbCameraList_SelectionChanged"
301
-                        Style="{StaticResource stlComboBox}"
300
+                        Style="{StaticResource StlComboBox}"
302
                         Text="请选择" />
301
                         Text="请选择" />
303
                 </StackPanel>
302
                 </StackPanel>
304
                 <Grid
303
                 <Grid
309
                     HorizontalAlignment="Left"
308
                     HorizontalAlignment="Left"
310
                     VerticalAlignment="Top">
309
                     VerticalAlignment="Top">
311
                     <Image
310
                     <Image
312
-                        x:Name="imgPlayer"
311
+                        x:Name="ImgPlayer"
313
                         RenderTransformOrigin="0.5,0.5"
312
                         RenderTransformOrigin="0.5,0.5"
314
                         Stretch="Fill"
313
                         Stretch="Fill"
315
                         Visibility="Visible">
314
                         Visibility="Visible">
324
                     HorizontalAlignment="Right"
323
                     HorizontalAlignment="Right"
325
                     Orientation="Horizontal">
324
                     Orientation="Horizontal">
326
                     <Button
325
                     <Button
327
-                        x:Name="btn_camera_good"
326
+                        x:Name="BtnCameraGood"
328
                         Width="100"
327
                         Width="100"
329
                         Height="30"
328
                         Height="30"
330
                         Margin="0,0,10,0"
329
                         Margin="0,0,10,0"
338
                         Foreground="White"
337
                         Foreground="White"
339
                         IsDefault="True" />
338
                         IsDefault="True" />
340
                     <Button
339
                     <Button
341
-                        x:Name="btn_camera_bad"
340
+                        x:Name="BtnCameraBad"
342
                         Width="100"
341
                         Width="100"
343
                         Height="30"
342
                         Height="30"
344
                         Margin="0,0,10,0"
343
                         Margin="0,0,10,0"
370
                         Orientation="Horizontal">
369
                         Orientation="Horizontal">
371
                         <Button
370
                         <Button
372
                             x:Name="BtnSpeakerDetection"
371
                             x:Name="BtnSpeakerDetection"
373
-                            Grid.Row="2"
374
                             Width="100"
372
                             Width="100"
375
                             Height="30"
373
                             Height="30"
376
                             Margin="0"
374
                             Margin="0"
432
                 </Grid>
430
                 </Grid>
433
                 <Grid Grid.Row="2">
431
                 <Grid Grid.Row="2">
434
                     <StackPanel
432
                     <StackPanel
435
-                        Grid.Row="2"
436
                         Margin="30,0,0,0"
433
                         Margin="30,0,0,0"
437
                         HorizontalAlignment="Right"
434
                         HorizontalAlignment="Right"
438
                         Orientation="Horizontal">
435
                         Orientation="Horizontal">
439
                         <Button
436
                         <Button
440
-                            x:Name="btn_speaker_good"
437
+                            x:Name="BtnSpeakerGood"
441
                             Width="100"
438
                             Width="100"
442
                             Height="30"
439
                             Height="30"
443
                             Margin="0,0,10,0"
440
                             Margin="0,0,10,0"
451
                             Foreground="White"
448
                             Foreground="White"
452
                             IsDefault="True" />
449
                             IsDefault="True" />
453
                         <Button
450
                         <Button
454
-                            x:Name="btn_speaker_bad"
451
+                            x:Name="BtnSpeakerBad"
455
                             Width="100"
452
                             Width="100"
456
                             Height="30"
453
                             Height="30"
457
                             Margin="0,0,10,0"
454
                             Margin="0,0,10,0"
494
                         Width="236"
491
                         Width="236"
495
                         Margin="16,0,0,0"
492
                         Margin="16,0,0,0"
496
                         Padding="30,0,0,0"
493
                         Padding="30,0,0,0"
497
-                        HorizontalAlignment="Left"
498
                         VerticalAlignment="Top"
494
                         VerticalAlignment="Top"
499
                         HorizontalContentAlignment="Center"
495
                         HorizontalContentAlignment="Center"
500
                         VerticalContentAlignment="Center"
496
                         VerticalContentAlignment="Center"
505
                         FontSize="14"
501
                         FontSize="14"
506
                         SelectedValuePath="Key"
502
                         SelectedValuePath="Key"
507
                         SelectionChanged="CmbMicrophoneList_SelectionChanged"
503
                         SelectionChanged="CmbMicrophoneList_SelectionChanged"
508
-                        Style="{StaticResource stlComboBox}"
504
+                        Style="{StaticResource StlComboBox}"
509
                         Text="请选择" />
505
                         Text="请选择" />
510
 
506
 
511
                     <Button
507
                     <Button
535
                         CornerRadius="10"
531
                         CornerRadius="10"
536
                         Visibility="Visible">
532
                         Visibility="Visible">
537
                         <ProgressBar
533
                         <ProgressBar
538
-                            x:Name="volumeProgressBar"
534
+                            x:Name="VolumeProgressBar"
539
                             BorderThickness="0"
535
                             BorderThickness="0"
540
                             Maximum="100" />
536
                             Maximum="100" />
541
                     </view:ZClippingBorder>
537
                     </view:ZClippingBorder>
543
 
539
 
544
                 <Grid Grid.Row="2">
540
                 <Grid Grid.Row="2">
545
                     <StackPanel
541
                     <StackPanel
546
-                        Grid.Row="2"
547
                         Margin="30,0,0,0"
542
                         Margin="30,0,0,0"
548
                         HorizontalAlignment="Right"
543
                         HorizontalAlignment="Right"
549
                         Orientation="Horizontal">
544
                         Orientation="Horizontal">
550
                         <Button
545
                         <Button
551
-                            x:Name="btn_microphone_good"
546
+                            x:Name="BtnMicrophoneGood"
552
                             Width="100"
547
                             Width="100"
553
                             Height="30"
548
                             Height="30"
554
                             Margin="0,0,10,0"
549
                             Margin="0,0,10,0"
562
                             Foreground="White"
557
                             Foreground="White"
563
                             IsDefault="True" />
558
                             IsDefault="True" />
564
                         <Button
559
                         <Button
565
-                            x:Name="btn_microphone_bad"
560
+                            x:Name="BtnMicrophoneBad"
566
                             Width="100"
561
                             Width="100"
567
                             Height="30"
562
                             Height="30"
568
                             Margin="0,0,10,0"
563
                             Margin="0,0,10,0"
670
                 <Grid Grid.Row="6" Grid.Column="1">
665
                 <Grid Grid.Row="6" Grid.Column="1">
671
                     <Button
666
                     <Button
672
                         x:Name="BtnDetection"
667
                         x:Name="BtnDetection"
673
-                        Grid.Row="2"
674
                         Width="116"
668
                         Width="116"
675
                         Height="30"
669
                         Height="30"
676
                         Margin="0"
670
                         Margin="0"

+ 5
- 5
XHWK.WKTool/DeviceWindow.xaml.cs View File

70
         /// </param>
70
         /// </param>
71
         private void BtnDown_Click(object sender, RoutedEventArgs e)
71
         private void BtnDown_Click(object sender, RoutedEventArgs e)
72
         {
72
         {
73
-            imgPlayer.Visibility = Visibility.Hidden;
73
+            ImgPlayer.Visibility = Visibility.Hidden;
74
             CloseCamera();
74
             CloseCamera();
75
             if (_waveIn != null)
75
             if (_waveIn != null)
76
             {
76
             {
114
             try
114
             try
115
             {
115
             {
116
                 CloseCamera();
116
                 CloseCamera();
117
-                imgPlayer.Visibility = Visibility.Visible;
117
+                ImgPlayer.Visibility = Visibility.Visible;
118
                 if (CmbCameraList.SelectedIndex >= 0)
118
                 if (CmbCameraList.SelectedIndex >= 0)
119
                 {
119
                 {
120
                     var info = CmbCameraList.SelectedItem as FilterInfo;
120
                     var info = CmbCameraList.SelectedItem as FilterInfo;
164
                     image.StreamSource = new MemoryStream(ms.GetBuffer());
164
                     image.StreamSource = new MemoryStream(ms.GetBuffer());
165
                     ms.Close();
165
                     ms.Close();
166
                     image.EndInit();
166
                     image.EndInit();
167
-                    imgPlayer.Source = image;
167
+                    ImgPlayer.Source = image;
168
                 }
168
                 }
169
             ); //同步显示
169
             ); //同步显示
170
         }
170
         }
289
             {
289
             {
290
                 _waveIn.StopRecording();
290
                 _waveIn.StopRecording();
291
             }
291
             }
292
-            volumeProgressBar.Value = 0;
292
+            VolumeProgressBar.Value = 0;
293
             if (CmbMicrophoneList.SelectedIndex >= 0)
293
             if (CmbMicrophoneList.SelectedIndex >= 0)
294
             {
294
             {
295
                 var selectIndex = CmbMicrophoneList.SelectedIndex;
295
                 var selectIndex = CmbMicrophoneList.SelectedIndex;
319
                             (
319
                             (
320
                                 () =>
320
                                 () =>
321
                                 {
321
                                 {
322
-                                    volumeProgressBar.Value = maxNumber * 100;
322
+                                    VolumeProgressBar.Value = maxNumber * 100;
323
                                 }
323
                                 }
324
                             );
324
                             );
325
                         };
325
                         };

+ 1
- 1
XHWK.WKTool/KeyVerification.xaml.cs View File

162
         private void CloseAction()
162
         private void CloseAction()
163
         {
163
         {
164
             App.myloading.Show();
164
             App.myloading.Show();
165
-            new Thread(o => { Dispatcher.Invoke(() => { Environment.Exit(0); }); }).Start();
165
+            Application.Current.Shutdown();
166
         }
166
         }
167
     }
167
     }
168
 }
168
 }

+ 15
- 61
XHWK.WKTool/LoginWindow.xaml View File

3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
-    xmlns:local="clr-namespace:XHWK.WKTool"
7
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    xmlns:view="clr-namespace:XHWK.WKTool.View"
8
     Title="LoginWindow"
8
     Title="LoginWindow"
9
     Width="312"
9
     Width="312"
10
     Height="497"
10
     Height="497"
11
-    AllowsTransparency="True"
12
     BorderBrush="#eeeeee"
11
     BorderBrush="#eeeeee"
13
-    BorderThickness="1"
14
     ShowInTaskbar="False"
12
     ShowInTaskbar="False"
13
+    Style="{StaticResource ZWinStyle}"
15
     WindowStartupLocation="CenterOwner"
14
     WindowStartupLocation="CenterOwner"
16
-    WindowStyle="None"
15
+    WindowStyle="SingleBorderWindow"
17
     mc:Ignorable="d">
16
     mc:Ignorable="d">
18
 
17
 
19
     <Window.Resources>
18
     <Window.Resources>
117
                             <TextBox
116
                             <TextBox
118
                                 x:Name="TxbAccountNumber"
117
                                 x:Name="TxbAccountNumber"
119
                                 Margin="5,5"
118
                                 Margin="5,5"
119
+                                AcceptsReturn="False"
120
                                 BorderBrush="{x:Null}"
120
                                 BorderBrush="{x:Null}"
121
                                 BorderThickness="0"
121
                                 BorderThickness="0"
122
                                 FontSize="14"
122
                                 FontSize="14"
123
                                 Foreground="#FF999999"
123
                                 Foreground="#FF999999"
124
                                 InputMethod.IsInputMethodEnabled="False"
124
                                 InputMethod.IsInputMethodEnabled="False"
125
-                                PreviewTextInput="TxbAccountNumberPreviewTextInput"
126
                                 Text="" />
125
                                 Text="" />
127
                             <Label Height="1.5" Background="#3F6FFF" />
126
                             <Label Height="1.5" Background="#3F6FFF" />
128
                         </StackPanel>
127
                         </StackPanel>
135
                                 FontSize="12"
134
                                 FontSize="12"
136
                                 Foreground="#FF666666" />
135
                                 Foreground="#FF666666" />
137
                             <PasswordBox
136
                             <PasswordBox
138
-                                x:Name="pobPassword"
137
+                                x:Name="PobPassword"
139
                                 Margin="5,5"
138
                                 Margin="5,5"
140
                                 BorderBrush="{x:Null}"
139
                                 BorderBrush="{x:Null}"
141
                                 BorderThickness="0"
140
                                 BorderThickness="0"
144
                                 PasswordChar="*" />
143
                                 PasswordChar="*" />
145
                             <Label Height="1.5" Background="#3F6FFF" />
144
                             <Label Height="1.5" Background="#3F6FFF" />
146
                         </StackPanel>
145
                         </StackPanel>
147
-                        <!--<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="30,0,30,1" Grid.ColumnSpan="2">
148
-                                <Label Content="*" FontSize="18" Padding="0,27,0,0" Foreground="#FF0000"/>
149
-                                <TextBlock Text="存放路径" FontSize="18" Padding="2,23,10,0"/>
150
-                        -->
151
-                        <!--  输入框  -->
152
-                        <!--
153
-                                <Border Background="#CDD6E0" Width="200" Height="43" CornerRadius="3">
154
-                                    <TextBox x:Name="txbStoragePath" Text="D:\" FontSize="16" Foreground="#333333" Padding="5,12,2,2" Width="198" Height="41" BorderBrush="{x:Null}" BorderThickness="0"/>
155
-                                </Border>
156
-                        -->
157
-                        <!--  浏览按钮  -->
158
-                        <!--
159
-                                <Button Cursor="Hand" x:Name="btnBrowse" FontSize="18" Width="80" Height="43" BorderBrush="#cccccc" BorderThickness="1" Click="BtnBrowse_Click" Content="浏览" Style="{StaticResource Button_Menu}"
160
-                                Background="#F7F7F7" Margin="11,0,0,0"/>
161
-                            </StackPanel>-->
146
+
162
                     </Grid>
147
                     </Grid>
163
                     <!--  记住密码 切换网络  -->
148
                     <!--  记住密码 切换网络  -->
164
                     <Grid Grid.Row="3">
149
                     <Grid Grid.Row="3">
197
                             <RowDefinition Height="25*" />
182
                             <RowDefinition Height="25*" />
198
                             <RowDefinition Height="5*" />
183
                             <RowDefinition Height="5*" />
199
                         </Grid.RowDefinitions>
184
                         </Grid.RowDefinitions>
200
-                        <Button
185
+                        <view:ZRoundButton
201
                             x:Name="BtnStart"
186
                             x:Name="BtnStart"
202
                             Grid.Row="1"
187
                             Grid.Row="1"
203
                             Grid.ColumnSpan="2"
188
                             Grid.ColumnSpan="2"
205
                             VerticalAlignment="Stretch"
190
                             VerticalAlignment="Stretch"
206
                             HorizontalContentAlignment="Center"
191
                             HorizontalContentAlignment="Center"
207
                             VerticalContentAlignment="Center"
192
                             VerticalContentAlignment="Center"
208
-                            Click="BtnStart_Click"
193
+                            Background="#3F6FFF"
194
+                            BorderRadius="18"
195
+                            Click="LoginClick"
209
                             Content="登录"
196
                             Content="登录"
210
-                            Cursor="Hand"
211
                             FontSize="18"
197
                             FontSize="18"
212
                             Foreground="#FFFFFF"
198
                             Foreground="#FFFFFF"
213
-                            IsDefault="True">
214
-                            <Button.Template>
215
-                                <ControlTemplate TargetType="{x:Type Button}">
216
-                                    <Border
217
-                                        BorderBrush="{TemplateBinding Control.BorderBrush}"
218
-                                        BorderThickness="1"
219
-                                        CornerRadius="20">
220
-                                        <Border.Background>#3F6FFF</Border.Background>
221
-                                        <ContentPresenter
222
-                                            Margin="0,5"
223
-                                            HorizontalAlignment="Center"
224
-                                            VerticalAlignment="Center"
225
-                                            Content="{TemplateBinding ContentControl.Content}" />
226
-                                    </Border>
227
-                                </ControlTemplate>
228
-                            </Button.Template>
229
-                        </Button>
230
-                        <Button
199
+                            IsDefault="True" />
200
+                        <view:ZRoundButton
231
                             x:Name="BtnStop"
201
                             x:Name="BtnStop"
232
                             Grid.Row="3"
202
                             Grid.Row="3"
233
                             Grid.ColumnSpan="2"
203
                             Grid.ColumnSpan="2"
237
                             VerticalAlignment="Stretch"
207
                             VerticalAlignment="Stretch"
238
                             HorizontalContentAlignment="Center"
208
                             HorizontalContentAlignment="Center"
239
                             VerticalContentAlignment="Center"
209
                             VerticalContentAlignment="Center"
210
+                            Background="#FFC3C3C3"
211
+                            BorderRadius="18"
240
                             Click="BtnDown_Click"
212
                             Click="BtnDown_Click"
241
                             Content="关闭"
213
                             Content="关闭"
242
                             Cursor="Hand"
214
                             Cursor="Hand"
243
                             FontSize="18"
215
                             FontSize="18"
244
                             Foreground="#FFFFFF"
216
                             Foreground="#FFFFFF"
245
-                            IsDefault="True">
246
-                            <Button.Template>
247
-                                <ControlTemplate TargetType="{x:Type Button}">
248
-                                    <Border
249
-                                        BorderBrush="{TemplateBinding Control.BorderBrush}"
250
-                                        BorderThickness="1"
251
-                                        CornerRadius="20">
252
-                                        <Border.Background>#FFC3C3C3</Border.Background>
253
-                                        <ContentPresenter
254
-                                            Margin="0,5"
255
-                                            HorizontalAlignment="Center"
256
-                                            VerticalAlignment="Center"
257
-                                            Content="{TemplateBinding ContentControl.Content}" />
258
-                                    </Border>
259
-                                </ControlTemplate>
260
-                            </Button.Template>
261
-                        </Button>
217
+                            IsDefault="True" />
262
 
218
 
263
                         <Button
219
                         <Button
264
                             x:Name="BtnServiceAddress"
220
                             x:Name="BtnServiceAddress"
274
                                     <Grid>
230
                                     <Grid>
275
                                         <Label
231
                                         <Label
276
                                             x:Name="Word"
232
                                             x:Name="Word"
277
-                                            Grid.Column="1"
278
                                             HorizontalAlignment="Center"
233
                                             HorizontalAlignment="Center"
279
                                             VerticalAlignment="Center"
234
                                             VerticalAlignment="Center"
280
                                             Content="服务地址设置"
235
                                             Content="服务地址设置"
347
                                 FontSize="12"
302
                                 FontSize="12"
348
                                 Foreground="#FF666666" />
303
                                 Foreground="#FF666666" />
349
                             <StackPanel
304
                             <StackPanel
350
-                                Grid.Row="6"
351
                                 Margin="0,10,0,0"
305
                                 Margin="0,10,0,0"
352
                                 HorizontalAlignment="Left"
306
                                 HorizontalAlignment="Left"
353
                                 Orientation="Horizontal">
307
                                 Orientation="Horizontal">

+ 17
- 28
XHWK.WKTool/LoginWindow.xaml.cs View File

1
-using Common.system;
2
-
3
-using System;
1
+using System;
4
 using System.Configuration;
2
 using System.Configuration;
5
 using System.Text;
3
 using System.Text;
6
 using System.Text.RegularExpressions;
4
 using System.Text.RegularExpressions;
8
 //using System.Text.RegularExpressions;
6
 //using System.Text.RegularExpressions;
9
 using System.Windows;
7
 using System.Windows;
10
 using System.Windows.Input;
8
 using System.Windows.Input;
11
-
12
 using XHWK.WKTool.DAL;
9
 using XHWK.WKTool.DAL;
13
 
10
 
14
 namespace XHWK.WKTool
11
 namespace XHWK.WKTool
18
     /// <summary>
15
     /// <summary>
19
     /// LoginWindow.xaml 的交互逻辑
16
     /// LoginWindow.xaml 的交互逻辑
20
     /// </summary>
17
     /// </summary>
21
-    public partial class LoginWindow : Window
18
+    public partial class LoginWindow
22
     {
19
     {
23
         /// <summary>
20
         /// <summary>
24
         /// 调用接口
21
         /// 调用接口
25
         /// </summary>
22
         /// </summary>
26
-        private readonly XhApi xhapi = new XhApi();
23
+        private readonly XhApi _xhapi = new XhApi();
27
 
24
 
28
         public LoginWindow()
25
         public LoginWindow()
29
         {
26
         {
56
         private void BtnDown_Click(object sender, RoutedEventArgs e)
53
         private void BtnDown_Click(object sender, RoutedEventArgs e)
57
         {
54
         {
58
             TxbAccountNumber.Text = string.Empty;
55
             TxbAccountNumber.Text = string.Empty;
59
-            pobPassword.Password = string.Empty;
56
+            PobPassword.Password = string.Empty;
60
             Hide();
57
             Hide();
61
         }
58
         }
62
 
59
 
67
         /// </param>
64
         /// </param>
68
         /// <param name="e">
65
         /// <param name="e">
69
         /// </param>
66
         /// </param>
70
-        private void BtnStart_Click(object sender, RoutedEventArgs e)
67
+        private void LoginClick(object sender, RoutedEventArgs e)
71
         {
68
         {
72
-            #region 获取服务接口地址 --2021年7月9日赵耀
73
-
74
             if (App.ServiceAddress == null)
69
             if (App.ServiceAddress == null)
75
             {
70
             {
76
                 MessageWindow.Show("首次使用需设置服务地址。");
71
                 MessageWindow.Show("首次使用需设置服务地址。");
77
                 BtnServiceAddress_Click(null, null);
72
                 BtnServiceAddress_Click(null, null);
78
                 return;
73
                 return;
79
             }
74
             }
80
-
81
-            #endregion 获取服务接口地址 --2021年7月9日赵耀
82
-
83
             if (string.IsNullOrEmpty(TxbAccountNumber.Text))
75
             if (string.IsNullOrEmpty(TxbAccountNumber.Text))
84
             {
76
             {
85
                 MessageWindow.Show("账号未输入");
77
                 MessageWindow.Show("账号未输入");
90
                 MessageWindow.Show("账号长度不能高于18位");
82
                 MessageWindow.Show("账号长度不能高于18位");
91
                 return;
83
                 return;
92
             }
84
             }
93
-            if (string.IsNullOrEmpty(pobPassword.Password))
85
+            if (string.IsNullOrEmpty(PobPassword.Password))
94
             {
86
             {
95
                 MessageWindow.Show("密码未输入");
87
                 MessageWindow.Show("密码未输入");
96
                 return;
88
                 return;
97
             }
89
             }
98
-            if (pobPassword.Password.Length > 16)
90
+            if (PobPassword.Password.Length > 16)
99
             {
91
             {
100
                 MessageWindow.Show("密码长度不能高于16位");
92
                 MessageWindow.Show("密码长度不能高于16位");
101
                 return;
93
                 return;
109
         /// </summary>
101
         /// </summary>
110
         private void Login()
102
         private void Login()
111
         {
103
         {
112
-            string accountNumber = string.Empty;
113
-            string password = string.Empty;
114
-            accountNumber = TxbAccountNumber.Text.Replace(" ", "").Trim();
115
-            password = pobPassword.Password.Replace(" ", "").Trim();
116
-
117
-            int code = xhapi.Login(accountNumber, password);
104
+            var accountNumber = TxbAccountNumber.Text.Replace(" ", "").Trim();
105
+            var password = PobPassword.Password.Replace(" ", "").Trim();
106
+            int code = _xhapi.Login(accountNumber, password);
118
             if (code == 0)
107
             if (code == 0)
119
             {
108
             {
120
                 FileToolsCommon.CreateDirectory(App.DataPath);
109
                 FileToolsCommon.CreateDirectory(App.DataPath);
143
                 //UpdateSettingString("userName", txbAccountNumber.Text);
132
                 //UpdateSettingString("userName", txbAccountNumber.Text);
144
                 App.IsLoginType = true;
133
                 App.IsLoginType = true;
145
                 TxbAccountNumber.Text = string.Empty;
134
                 TxbAccountNumber.Text = string.Empty;
146
-                pobPassword.Password = string.Empty;
135
+                PobPassword.Password = string.Empty;
147
 
136
 
148
                 #region 下载头像
137
                 #region 下载头像
149
 
138
 
150
-                string HeadpicPath = FileToolsCommon.GetFileAbsolutePath("/Data/" + App.UserInfo.Username + ".png");
139
+                string headpicPath = FileToolsCommon.GetFileAbsolutePath("/Data/" + App.UserInfo.Username + ".png");
151
                 if (!string.IsNullOrWhiteSpace(App.UserInfo.Headpic))
140
                 if (!string.IsNullOrWhiteSpace(App.UserInfo.Headpic))
152
                 {
141
                 {
153
                     //FileToolsCommon.
142
                     //FileToolsCommon.
154
-                    xhapi.DownloadAvatar(App.UserInfo.Headpic, HeadpicPath);
143
+                    _xhapi.DownloadAvatar(App.UserInfo.Headpic, headpicPath);
155
                 }
144
                 }
156
 
145
 
157
                 #endregion 下载头像
146
                 #endregion 下载头像
188
         {
177
         {
189
             try
178
             try
190
             {
179
             {
191
-                string settingString = ConfigurationManager.AppSettings[settingName].ToString();
180
+                string settingString = ConfigurationManager.AppSettings[settingName];
192
                 return settingString;
181
                 return settingString;
193
             }
182
             }
194
             catch (Exception)
183
             catch (Exception)
245
             }
234
             }
246
             catch (Exception)
235
             catch (Exception)
247
             {
236
             {
237
+                // ignored
248
             }
238
             }
249
         }
239
         }
250
 
240
 
294
 
284
 
295
             if (!string.IsNullOrWhiteSpace(TbxServiceAddress.Text))
285
             if (!string.IsNullOrWhiteSpace(TbxServiceAddress.Text))
296
             {
286
             {
297
-                if (xhapi.GetServiceAddress(TbxServiceAddress.Text, out string Message))
287
+                if (_xhapi.GetServiceAddress(TbxServiceAddress.Text, out string message))
298
                 {
288
                 {
299
                     App.SaveServiceAddressData();
289
                     App.SaveServiceAddressData();
300
                     App.SwitchAddress();
290
                     App.SwitchAddress();
303
                 }
293
                 }
304
                 else
294
                 else
305
                 {
295
                 {
306
-                    MessageWindow.Show(Message);
307
-                    return;
296
+                    MessageWindow.Show(message);
308
                 }
297
                 }
309
             }
298
             }
310
 
299
 

+ 13
- 22
XHWK.WKTool/MainWindow.xaml View File

4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    xmlns:view="clr-namespace:XHWK.WKTool.View"
7
     Title="星火微课系统"
8
     Title="星火微课系统"
8
     Width="950"
9
     Width="950"
9
     Height="700"
10
     Height="700"
293
                                     </Grid>
294
                                     </Grid>
294
                                     <ControlTemplate.Triggers>
295
                                     <ControlTemplate.Triggers>
295
                                         <Trigger Property="IsMouseOver" Value="True">
296
                                         <Trigger Property="IsMouseOver" Value="True">
296
-                                            <Setter TargetName="ImgSetUp" Property="Source"
297
-                                                    Value="/SkinImages/TechnologyBlue/HM_Close_MI.png" />
297
+                                            <Setter TargetName="ImgSetUp" Property="Source" Value="/SkinImages/TechnologyBlue/HM_Close_MI.png" />
298
                                             <Setter TargetName="Word" Property="Foreground" Value="#FFFFFFFF" />
298
                                             <Setter TargetName="Word" Property="Foreground" Value="#FFFFFFFF" />
299
                                         </Trigger>
299
                                         </Trigger>
300
                                     </ControlTemplate.Triggers>
300
                                     </ControlTemplate.Triggers>
333
                         <!--  头像  -->
333
                         <!--  头像  -->
334
                         <Grid Grid.Row="0">
334
                         <Grid Grid.Row="0">
335
                             <!--  登录状态  -->
335
                             <!--  登录状态  -->
336
-                            <Button
336
+                            <view:ZRoundButton
337
                                 x:Name="BtnLoginType"
337
                                 x:Name="BtnLoginType"
338
                                 HorizontalAlignment="Center"
338
                                 HorizontalAlignment="Center"
339
                                 VerticalAlignment="Center"
339
                                 VerticalAlignment="Center"
367
                                         Style="{DynamicResource LoginTypeColor}"
367
                                         Style="{DynamicResource LoginTypeColor}"
368
                                         Text="未登录" />
368
                                         Text="未登录" />
369
                                 </StackPanel>
369
                                 </StackPanel>
370
-                            </Button>
370
+                            </view:ZRoundButton>
371
                         </Grid>
371
                         </Grid>
372
                         <!--  录屏  -->
372
                         <!--  录屏  -->
373
                         <Grid Grid.Row="1">
373
                         <Grid Grid.Row="1">
496
                                         </Grid>
496
                                         </Grid>
497
                                         <ControlTemplate.Triggers>
497
                                         <ControlTemplate.Triggers>
498
                                             <Trigger Property="IsMouseOver" Value="True">
498
                                             <Trigger Property="IsMouseOver" Value="True">
499
-                                                <Setter TargetName="ImgScreenRecording" Property="Source"
500
-                                                        Value="/SkinImages/White/Toolbar_LP_MI.png" />
499
+                                                <Setter TargetName="ImgScreenRecording" Property="Source" Value="/SkinImages/White/Toolbar_LP_MI.png" />
501
                                             </Trigger>
500
                                             </Trigger>
502
                                             <Trigger Property="IsPressed" Value="True">
501
                                             <Trigger Property="IsPressed" Value="True">
503
-                                                <Setter TargetName="ImgScreenRecording" Property="Source"
504
-                                                        Value="/SkinImages/White/Toolbar_LP_CL.png" />
505
-                                                <Setter TargetName="WordScreenRecording" Property="Foreground"
506
-                                                        Value="#FFFFFFFF" />
502
+                                                <Setter TargetName="ImgScreenRecording" Property="Source" Value="/SkinImages/White/Toolbar_LP_CL.png" />
503
+                                                <Setter TargetName="WordScreenRecording" Property="Foreground" Value="#FFFFFFFF" />
507
                                             </Trigger>
504
                                             </Trigger>
508
                                             <Trigger Property="IsEnabled" Value="False">
505
                                             <Trigger Property="IsEnabled" Value="False">
509
-                                                <Setter TargetName="ImgScreenRecording" Property="Source"
510
-                                                        Value="/SkinImages/White/Toolbar_LP_N.png" />
511
-                                                <Setter TargetName="WordScreenRecording" Property="Foreground"
512
-                                                        Value="#FFC3C3C3" />
506
+                                                <Setter TargetName="ImgScreenRecording" Property="Source" Value="/SkinImages/White/Toolbar_LP_N.png" />
507
+                                                <Setter TargetName="WordScreenRecording" Property="Foreground" Value="#FFC3C3C3" />
513
                                             </Trigger>
508
                                             </Trigger>
514
                                         </ControlTemplate.Triggers>
509
                                         </ControlTemplate.Triggers>
515
                                     </ControlTemplate>
510
                                     </ControlTemplate>
1040
                                                 <Button.Template>
1035
                                                 <Button.Template>
1041
                                                     <ControlTemplate TargetType="{x:Type Button}">
1036
                                                     <ControlTemplate TargetType="{x:Type Button}">
1042
                                                         <StackPanel>
1037
                                                         <StackPanel>
1043
-                                                            <Image x:Name="ImgRecord"
1044
-                                                                   Source="/SkinImages/Skin/Skin_White.png" />
1038
+                                                            <Image x:Name="ImgRecord" Source="/SkinImages/Skin/Skin_White.png" />
1045
                                                         </StackPanel>
1039
                                                         </StackPanel>
1046
                                                         <ControlTemplate.Triggers>
1040
                                                         <ControlTemplate.Triggers>
1047
                                                             <Trigger Property="IsMouseOver" Value="True">
1041
                                                             <Trigger Property="IsMouseOver" Value="True">
1048
-                                                                <Setter TargetName="ImgRecord" Property="Source"
1049
-                                                                        Value="/SkinImages/Skin/Skin_White_MI.png" />
1042
+                                                                <Setter TargetName="ImgRecord" Property="Source" Value="/SkinImages/Skin/Skin_White_MI.png" />
1050
                                                             </Trigger>
1043
                                                             </Trigger>
1051
                                                         </ControlTemplate.Triggers>
1044
                                                         </ControlTemplate.Triggers>
1052
                                                     </ControlTemplate>
1045
                                                     </ControlTemplate>
1072
                                                 <Button.Template>
1065
                                                 <Button.Template>
1073
                                                     <ControlTemplate TargetType="{x:Type Button}">
1066
                                                     <ControlTemplate TargetType="{x:Type Button}">
1074
                                                         <StackPanel>
1067
                                                         <StackPanel>
1075
-                                                            <Image x:Name="ImgRecord"
1076
-                                                                   Source="/SkinImages/Skin/Skin_TechnologyBlue.png" />
1068
+                                                            <Image x:Name="ImgRecord" Source="/SkinImages/Skin/Skin_TechnologyBlue.png" />
1077
                                                         </StackPanel>
1069
                                                         </StackPanel>
1078
                                                         <ControlTemplate.Triggers>
1070
                                                         <ControlTemplate.Triggers>
1079
                                                             <Trigger Property="IsMouseOver" Value="True">
1071
                                                             <Trigger Property="IsMouseOver" Value="True">
1080
-                                                                <Setter TargetName="ImgRecord" Property="Source"
1081
-                                                                        Value="/SkinImages/Skin/Skin_TechnologyBlue_MI.png" />
1072
+                                                                <Setter TargetName="ImgRecord" Property="Source" Value="/SkinImages/Skin/Skin_TechnologyBlue_MI.png" />
1082
                                                             </Trigger>
1073
                                                             </Trigger>
1083
                                                         </ControlTemplate.Triggers>
1074
                                                         </ControlTemplate.Triggers>
1084
                                                     </ControlTemplate>
1075
                                                     </ControlTemplate>

+ 3
- 3
XHWK.WKTool/MainWindow.xaml.cs View File

744
                         App.SaveWkData();
744
                         App.SaveWkData();
745
                         App.SaveDraw();
745
                         App.SaveDraw();
746
                         _tmc.TmatrixUninitialize();
746
                         _tmc.TmatrixUninitialize();
747
-                        Environment.Exit(0);
747
+                        Application.Current.Shutdown();
748
                     }
748
                     }
749
                 }
749
                 }
750
                 catch (Exception ex)
750
                 catch (Exception ex)
753
                     Close();
753
                     Close();
754
                     Application.Current.Shutdown();
754
                     Application.Current.Shutdown();
755
                     _tmc.TmatrixUninitialize();
755
                     _tmc.TmatrixUninitialize();
756
-                    Environment.Exit(0);
756
+                    Application.Current.Shutdown();
757
                 }
757
                 }
758
             }
758
             }
759
             else
759
             else
4102
 
4102
 
4103
         private void Window_Closed(object sender, EventArgs e)
4103
         private void Window_Closed(object sender, EventArgs e)
4104
         {
4104
         {
4105
-            Environment.Exit(0);
4105
+            Application.Current.Shutdown();
4106
         }
4106
         }
4107
     }
4107
     }
4108
 }
4108
 }

+ 7
- 4
XHWK.WKTool/ProductVerification.xaml.cs View File

142
         /// </summary>
142
         /// </summary>
143
         private void CloseAction()
143
         private void CloseAction()
144
         {
144
         {
145
-            Dispatcher.Invoke(new Action(() =>
146
-            {
147
-                System.Environment.Exit(0);
148
-            }));
145
+            Dispatcher.Invoke
146
+            (
147
+                () =>
148
+                {
149
+                    Application.Current.Shutdown();
150
+                }
151
+            );
149
         }
152
         }
150
 
153
 
151
         ~ProductVerification()
154
         ~ProductVerification()

+ 11
- 5
XHWK.WKTool/Resources/OverwrideDefaultControlStyles.xaml View File

1
-<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
1
+<ResourceDictionary
2
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+    xmlns:view="clr-namespace:XHWK.WKTool.View">
2
 
5
 
3
     <ResourceDictionary.MergedDictionaries>
6
     <ResourceDictionary.MergedDictionaries>
4
         <ResourceDictionary Source="pack://application:,,,/Resources/StyleScrolllview.xaml" />
7
         <ResourceDictionary Source="pack://application:,,,/Resources/StyleScrolllview.xaml" />
5
         <ResourceDictionary Source="pack://application:,,,/Resources/StyleButton.xaml" />
8
         <ResourceDictionary Source="pack://application:,,,/Resources/StyleButton.xaml" />
9
+        <ResourceDictionary Source="pack://application:,,,/Resources/StyleComboBox.xaml" />
10
+        <ResourceDictionary Source="pack://application:,,,/Resources/StyleZRoundButton.xaml" />
6
     </ResourceDictionary.MergedDictionaries>
11
     </ResourceDictionary.MergedDictionaries>
7
 
12
 
8
-    <Style BasedOn="{StaticResource for_scrollbar}" TargetType="ScrollBar" />
9
-    <Style BasedOn="{StaticResource for_scrollviewer}" TargetType="ScrollViewer" />
10
-
13
+    <Style BasedOn="{StaticResource ForScrollbar}" TargetType="ScrollBar" />
14
+    <Style BasedOn="{StaticResource ForScrollviewer}" TargetType="ScrollViewer" />
15
+    <Style BasedOn="{StaticResource ZRoundButtonStyle}" TargetType="view:ZRoundButton" />
11
     <Style BasedOn="{StaticResource MyButton}" TargetType="Button" />
16
     <Style BasedOn="{StaticResource MyButton}" TargetType="Button" />
12
 
17
 
13
     <Style x:Key="ZWinStyle" TargetType="Window">
18
     <Style x:Key="ZWinStyle" TargetType="Window">
33
             </Trigger>
38
             </Trigger>
34
         </Style.Triggers>
39
         </Style.Triggers>
35
     </Style>
40
     </Style>
36
-</ResourceDictionary>
41
+
42
+</ResourceDictionary>

+ 133
- 0
XHWK.WKTool/Resources/StyleComboBox.xaml View File

1
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2
+    <!--  ComBoBox项鼠标经过背景色  -->
3
+    <SolidColorBrush x:Key="ComboBoxMouseOverBackground" Color="#f0f0f0" />
4
+    <!--  Combox右侧下拉按钮  -->
5
+    <Style x:Key="ComboxStyleBtn" TargetType="ToggleButton">
6
+        <Setter Property="Template">
7
+            <Setter.Value>
8
+                <ControlTemplate>
9
+                    <!--  下拉按钮内部背景色  -->
10
+                    <Border
11
+                        x:Name="Back"
12
+                        Background="Transparent"
13
+                        BorderBrush="Transparent"
14
+                        BorderThickness="1">
15
+                        <!--  下拉按钮内边框  -->
16
+                        <Label
17
+                            Name="PathFill"
18
+                            Height="30"
19
+                            HorizontalAlignment="Right"
20
+                            VerticalAlignment="Center"
21
+                            VerticalContentAlignment="Center"
22
+                            Content="ˇ"
23
+                            FontSize="30" />
24
+                    </Border>
25
+                    <ControlTemplate.Triggers>
26
+                        <Trigger Property="IsMouseOver" Value="True">
27
+                            <Setter TargetName="Back" Property="Background" Value="Transparent" />
28
+                            <Setter TargetName="Back" Property="BorderBrush" Value="Transparent" />
29
+                        </Trigger>
30
+                    </ControlTemplate.Triggers>
31
+                </ControlTemplate>
32
+            </Setter.Value>
33
+        </Setter>
34
+    </Style>
35
+    <!--  Combox  -->
36
+    <Style x:Key="ComboBoxStyle" TargetType="ComboBox">
37
+        <Setter Property="ItemContainerStyle">
38
+            <Setter.Value>
39
+                <!--  ComBoxItem  -->
40
+                <Style TargetType="{x:Type ComboBoxItem}">
41
+                    <Setter Property="MinHeight" Value="32" />
42
+                    <Setter Property="MinWidth" Value="60" />
43
+                    <Setter Property="Template">
44
+                        <Setter.Value>
45
+                            <ControlTemplate TargetType="{x:Type ComboBoxItem}">
46
+                                <Border
47
+                                    Name="_back"
48
+                                    Background="Transparent"
49
+                                    BorderBrush="#f3f3f3"
50
+                                    BorderThickness="0,0,0,0">
51
+                                    <ContentPresenter Margin="10,0,10,0" VerticalAlignment="Center" />
52
+                                </Border>
53
+                                <ControlTemplate.Triggers>
54
+                                    <Trigger Property="IsMouseOver" Value="True">
55
+                                        <Setter TargetName="_back" Property="Background" Value="{StaticResource ComboBoxMouseOverBackground}" />
56
+                                    </Trigger>
57
+                                    <!--  下拉框背景色  -->
58
+                                    <Trigger Property="IsHighlighted" Value="True">
59
+                                        <Setter TargetName="_back" Property="Background" Value="{StaticResource ComboBoxMouseOverBackground}" />
60
+                                    </Trigger>
61
+                                </ControlTemplate.Triggers>
62
+                            </ControlTemplate>
63
+                        </Setter.Value>
64
+                    </Setter>
65
+                </Style>
66
+            </Setter.Value>
67
+        </Setter>
68
+        <Setter Property="Template">
69
+            <Setter.Value>
70
+                <ControlTemplate TargetType="ComboBox">
71
+                    <Grid>
72
+                        <!--  文字区域背景和边线样式  -->
73
+                        <TextBox
74
+                            Grid.Column="0"
75
+                            Padding="10,0,0,0"
76
+                            VerticalAlignment="Center"
77
+                            Background="Transparent"
78
+                            BorderBrush="#c0c0c0"
79
+                            BorderThickness="0"
80
+                            Foreground="Black"
81
+                            IsReadOnly="{TemplateBinding IsReadOnly}"
82
+                            Text="{TemplateBinding Text}" />
83
+                        <Border
84
+                            Grid.Column="0"
85
+                            BorderBrush="#c0c0c0"
86
+                            BorderThickness="0.6"
87
+                            CornerRadius="1,0,0,1" />
88
+                        <!--  右侧下拉button设置  -->
89
+                        <Border BorderThickness="0">
90
+                            <ToggleButton
91
+                                BorderBrush="Black"
92
+                                BorderThickness="3"
93
+                                ClickMode="Press"
94
+                                IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
95
+                                Style="{StaticResource ComboxStyleBtn}" />
96
+                        </Border>
97
+                        <!--  弹出popup整体设置  -->
98
+                        <Popup
99
+                            x:Name="Popup"
100
+                            AllowsTransparency="True"
101
+                            Focusable="False"
102
+                            IsOpen="{TemplateBinding IsDropDownOpen}"
103
+                            Placement="Bottom"
104
+                            PopupAnimation="Slide">
105
+                            <Grid
106
+                                x:Name="DropDown"
107
+                                Width="{TemplateBinding ActualWidth}"
108
+                                MaxHeight="200"
109
+                                SnapsToDevicePixels="True">
110
+                                <Border
111
+                                    x:Name="DropDownBorder"
112
+                                    BorderBrush="#e8e8e8"
113
+                                    BorderThickness="1,0,1,1" />
114
+                                <ScrollViewer
115
+                                    Margin="1"
116
+                                    CanContentScroll="True"
117
+                                    HorizontalScrollBarVisibility="Disabled"
118
+                                    SnapsToDevicePixels="True"
119
+                                    VerticalScrollBarVisibility="Auto">
120
+                                    <!--  StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True  -->
121
+                                    <StackPanel
122
+                                        Background="White"
123
+                                        IsItemsHost="True"
124
+                                        KeyboardNavigation.DirectionalNavigation="Contained" />
125
+                                </ScrollViewer>
126
+                            </Grid>
127
+                        </Popup>
128
+                    </Grid>
129
+                </ControlTemplate>
130
+            </Setter.Value>
131
+        </Setter>
132
+    </Style>
133
+</ResourceDictionary>

+ 5
- 5
XHWK.WKTool/Resources/StyleScrolllview.xaml View File

67
             </Setter.Value>
67
             </Setter.Value>
68
         </Setter>
68
         </Setter>
69
     </Style>
69
     </Style>
70
-    <Style x:Key="for_scrollbar" TargetType="{x:Type ScrollBar}">
70
+    <Style x:Key="ForScrollbar" TargetType="{x:Type ScrollBar}">
71
         <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
71
         <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
72
         <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
72
         <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
73
         <Setter Property="Background" Value="Transparent" />
73
         <Setter Property="Background" Value="Transparent" />
141
             </Trigger>
141
             </Trigger>
142
         </Style.Triggers>
142
         </Style.Triggers>
143
     </Style>
143
     </Style>
144
-    <Style x:Key="for_scrollviewer" TargetType="{x:Type ScrollViewer}">
144
+    <Style x:Key="ForScrollviewer" TargetType="{x:Type ScrollViewer}">
145
         <Setter Property="BorderBrush" Value="LightGray" />
145
         <Setter Property="BorderBrush" Value="LightGray" />
146
         <Setter Property="BorderThickness" Value="0" />
146
         <Setter Property="BorderThickness" Value="0" />
147
         <Setter Property="Template">
147
         <Setter Property="Template">
163
                                 HorizontalAlignment="Right"
163
                                 HorizontalAlignment="Right"
164
                                 Maximum="{TemplateBinding ScrollableHeight}"
164
                                 Maximum="{TemplateBinding ScrollableHeight}"
165
                                 Orientation="Vertical"
165
                                 Orientation="Vertical"
166
-                                Style="{StaticResource for_scrollbar}"
166
+                                Style="{StaticResource ForScrollbar}"
167
                                 ViewportSize="{TemplateBinding ViewportHeight}"
167
                                 ViewportSize="{TemplateBinding ViewportHeight}"
168
                                 Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
168
                                 Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
169
                                 Value="{TemplateBinding VerticalOffset}" />
169
                                 Value="{TemplateBinding VerticalOffset}" />
172
                                 VerticalAlignment="Bottom"
172
                                 VerticalAlignment="Bottom"
173
                                 Maximum="{TemplateBinding ScrollableWidth}"
173
                                 Maximum="{TemplateBinding ScrollableWidth}"
174
                                 Orientation="Horizontal"
174
                                 Orientation="Horizontal"
175
-                                Style="{StaticResource for_scrollbar}"
175
+                                Style="{StaticResource ForScrollbar}"
176
                                 ViewportSize="{TemplateBinding ViewportWidth}"
176
                                 ViewportSize="{TemplateBinding ViewportWidth}"
177
                                 Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
177
                                 Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
178
                                 Value="{TemplateBinding HorizontalOffset}" />
178
                                 Value="{TemplateBinding HorizontalOffset}" />
256
             </Setter.Value>
256
             </Setter.Value>
257
         </Setter>
257
         </Setter>
258
     </Style>
258
     </Style>
259
-</ResourceDictionary>
259
+</ResourceDictionary>

+ 40
- 0
XHWK.WKTool/Resources/StyleZRoundButton.xaml View File

1
+<ResourceDictionary
2
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
+    xmlns:view="clr-namespace:XHWK.WKTool.View">
5
+    <Style x:Key="ZRoundButtonStyle" TargetType="{x:Type view:ZRoundButton}">
6
+        <Setter Property="OverridesDefaultStyle" Value="True" />
7
+        <Setter Property="Cursor" Value="Hand" />
8
+        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
9
+        <Setter Property="HorizontalContentAlignment" Value="Center" />
10
+        <Setter Property="VerticalContentAlignment" Value="Center" />
11
+        <Setter Property="Template">
12
+            <Setter.Value>
13
+                <ControlTemplate TargetType="Button">
14
+                    <Grid Background="Transparent">
15
+                        <Border
16
+                            Name="border"
17
+                            Padding="{TemplateBinding Padding}"
18
+                            HorizontalAlignment="Stretch"
19
+                            VerticalAlignment="Stretch"
20
+                            Background="{TemplateBinding Background}"
21
+                            BorderBrush="{TemplateBinding BorderBrush}"
22
+                            BorderThickness="{TemplateBinding BorderThickness}"
23
+                            CornerRadius="{Binding Path=BorderRadius, RelativeSource={RelativeSource TemplatedParent}}"
24
+                            IsHitTestVisible="True">
25
+                            <ContentPresenter
26
+                                Margin="{TemplateBinding Padding}"
27
+                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
28
+                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
29
+                        </Border>
30
+                    </Grid>
31
+                    <ControlTemplate.Triggers>
32
+                        <Trigger Property="IsMouseOver" Value="True">
33
+                            <Setter Property="Opacity" Value="0.8" />
34
+                        </Trigger>
35
+                    </ControlTemplate.Triggers>
36
+                </ControlTemplate>
37
+            </Setter.Value>
38
+        </Setter>
39
+    </Style>
40
+</ResourceDictionary>

+ 5
- 8
XHWK.WKTool/UControl/Uc_VideoItem.xaml View File

3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
-    xmlns:local="clr-namespace:XHWK.WKTool.UControl"
7
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8
     Width="250"
7
     Width="250"
9
     Height="260"
8
     Height="260"
30
                             HorizontalAlignment="Stretch"
29
                             HorizontalAlignment="Stretch"
31
                             VerticalAlignment="Stretch"
30
                             VerticalAlignment="Stretch"
32
                             Click="BtnVideoPlay_Click"
31
                             Click="BtnVideoPlay_Click"
33
-                            Cursor="Hand"
34
-                            >
32
+                            Cursor="Hand">
35
                             <Image
33
                             <Image
36
                                 x:Name="ImgVideo"
34
                                 x:Name="ImgVideo"
37
                                 Cursor="Hand"
35
                                 Cursor="Hand"
54
                             Grid.Column="2"
52
                             Grid.Column="2"
55
                             Visibility="Hidden">
53
                             Visibility="Hidden">
56
                             <Button
54
                             <Button
57
-                                x:Name="btnSetUp"
55
+                                x:Name="BtnSetUp"
58
                                 Margin="0,0,4,0"
56
                                 Margin="0,0,4,0"
59
                                 HorizontalAlignment="Right"
57
                                 HorizontalAlignment="Right"
60
                                 VerticalAlignment="Center"
58
                                 VerticalAlignment="Center"
61
                                 Click="Button_Click"
59
                                 Click="Button_Click"
62
-                                Cursor="Hand"
63
-                                >
60
+                                Cursor="Hand">
64
                                 <Image
61
                                 <Image
65
                                     x:Name="ImgSetUp"
62
                                     x:Name="ImgSetUp"
66
                                     Source="/Images/Clip_Clip.png"
63
                                     Source="/Images/Clip_Clip.png"
126
                         </Grid>
123
                         </Grid>
127
                         <Grid Grid.Column="2">
124
                         <Grid Grid.Column="2">
128
                             <Button
125
                             <Button
129
-                                x:Name="BtnNameModifyOK"
126
+                                x:Name="BtnNameModifyOk"
130
                                 Background="White"
127
                                 Background="White"
131
                                 BorderBrush="#FFABADB3"
128
                                 BorderBrush="#FFABADB3"
132
                                 Click="BtnNameModifyOK_Click"
129
                                 Click="BtnNameModifyOK_Click"
145
                 <!--  信息  -->
142
                 <!--  信息  -->
146
                 <Grid Grid.Row="3">
143
                 <Grid Grid.Row="3">
147
                     <Label
144
                     <Label
148
-                        x:Name="lblDateSize"
145
+                        x:Name="LblDateSize"
149
                         HorizontalContentAlignment="Center"
146
                         HorizontalContentAlignment="Center"
150
                         Content="2020-10-10 10:10:00|1000.00MB"
147
                         Content="2020-10-10 10:10:00|1000.00MB"
151
                         FontSize="12"
148
                         FontSize="12"

+ 1
- 1
XHWK.WKTool/UControl/Uc_VideoItem.xaml.cs View File

72
             string videoName = FileToolsCommon.GetIoFileNameNoExtension(VideoModel.VideoPath);
72
             string videoName = FileToolsCommon.GetIoFileNameNoExtension(VideoModel.VideoPath);
73
             TbName.Text = videoName.Length > 11 ? videoName.Substring(0, 11) + "..." : videoName;
73
             TbName.Text = videoName.Length > 11 ? videoName.Substring(0, 11) + "..." : videoName;
74
             TbName.ToolTip = videoName;
74
             TbName.ToolTip = videoName;
75
-            lblDateSize.Content = VideoModel.RSTime + " " + VideoModel.VideoSize;
75
+            LblDateSize.Content = VideoModel.RSTime + " " + VideoModel.VideoSize;
76
             if (VideoModel.IsUpload)
76
             if (VideoModel.IsUpload)
77
             {
77
             {
78
                 BtnUpload.Visibility = Visibility.Hidden;
78
                 BtnUpload.Visibility = Visibility.Hidden;

+ 16
- 21
XHWK.WKTool/UploadWindow.xaml View File

2
     x:Class="XHWK.WKTool.UploadWindow"
2
     x:Class="XHWK.WKTool.UploadWindow"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
-    xmlns:Views="clr-namespace:XHWK.WKTool.Helpers"
6
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7
-    xmlns:local="clr-namespace:XHWK.WKTool"
8
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    xmlns:views="clr-namespace:XHWK.WKTool.Helpers"
9
     Title="UploadWindow"
8
     Title="UploadWindow"
10
     Width="457"
9
     Width="457"
11
     Height="346"
10
     Height="346"
12
     Margin="0"
11
     Margin="0"
13
-    AllowsTransparency="True"
14
-    BorderBrush="#eeeeee"
15
-    BorderThickness="1"
16
     Loaded="Window_Loaded"
12
     Loaded="Window_Loaded"
13
+    Style="{StaticResource ZWinStyle}"
17
     WindowStartupLocation="CenterScreen"
14
     WindowStartupLocation="CenterScreen"
18
-    WindowStyle="None"
15
+    WindowStyle="SingleBorderWindow"
19
     mc:Ignorable="d">
16
     mc:Ignorable="d">
20
 
17
 
21
-    <Grid>
18
+    <Grid Background="White">
22
         <!--  分4行  -->
19
         <!--  分4行  -->
23
         <Grid.RowDefinitions>
20
         <Grid.RowDefinitions>
24
             <RowDefinition Height="45" />
21
             <RowDefinition Height="45" />
49
                 Content="×"
46
                 Content="×"
50
                 Cursor="Hand"
47
                 Cursor="Hand"
51
                 FontSize="25"
48
                 FontSize="25"
52
-                Foreground="#FFFFFF"
53
-                 />
49
+                Foreground="#FFFFFF" />
54
         </Grid>
50
         </Grid>
55
         <Grid
51
         <Grid
56
             x:Name="GridTitle_Black"
52
             x:Name="GridTitle_Black"
73
                 Content="×"
69
                 Content="×"
74
                 Cursor="Hand"
70
                 Cursor="Hand"
75
                 FontSize="25"
71
                 FontSize="25"
76
-                Foreground="#FF333333"
77
-                 />
72
+                Foreground="#FF333333" />
78
         </Grid>
73
         </Grid>
79
         <!--  第三行 教材  -->
74
         <!--  第三行 教材  -->
80
         <ComboBox
75
         <ComboBox
93
             Foreground="Black"
88
             Foreground="Black"
94
             ItemsSource="{Binding bookList}"
89
             ItemsSource="{Binding bookList}"
95
             SelectedValuePath="Key"
90
             SelectedValuePath="Key"
96
-            SelectionChanged="ToolbarListSelectionChanged">
91
+            SelectionChanged="ToolbarListSelectionChanged"
92
+            Style="{StaticResource ComboBoxStyle}">
97
             <ComboBox.Resources>
93
             <ComboBox.Resources>
98
                 <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="White" />
94
                 <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="White" />
99
                 <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Gray" />
95
                 <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Gray" />
113
             FontSize="16"
109
             FontSize="16"
114
             Foreground="Black"
110
             Foreground="Black"
115
             ItemsSource="{Binding zhangjieList}"
111
             ItemsSource="{Binding zhangjieList}"
116
-            SelectedValuePath="Key">
112
+            SelectedValuePath="Key"
113
+            Style="{StaticResource ComboBoxStyle}">
117
             <ComboBox.Resources>
114
             <ComboBox.Resources>
118
                 <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="White" />
115
                 <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="White" />
119
                 <!--<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green" />-->
116
                 <!--<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green" />-->
131
             Cursor="Hand"
128
             Cursor="Hand"
132
             FontSize="18"
129
             FontSize="18"
133
             Foreground="#FFFFFF"
130
             Foreground="#FFFFFF"
134
-            IsDefault="True"
135
-            >
131
+            IsDefault="True">
136
             <Button.Template>
132
             <Button.Template>
137
                 <ControlTemplate TargetType="{x:Type Button}">
133
                 <ControlTemplate TargetType="{x:Type Button}">
138
                     <Border
134
                     <Border
148
                 </ControlTemplate>
144
                 </ControlTemplate>
149
             </Button.Template>
145
             </Button.Template>
150
         </Button>
146
         </Button>
151
-        <Views:ZJClippingBorder
147
+        <views:ZJClippingBorder
152
             x:Name="tip_outer"
148
             x:Name="tip_outer"
153
             Grid.Row="0"
149
             Grid.Row="0"
154
             Grid.RowSpan="2"
150
             Grid.RowSpan="2"
155
             Margin="0"
151
             Margin="0"
156
-            Background="#FFE6EAF0"
157
-            CornerRadius="4"
152
+            Background="#f3f3f3"
158
             Visibility="Collapsed">
153
             Visibility="Collapsed">
159
             <Grid>
154
             <Grid>
160
                 <Label
155
                 <Label
161
                     Height="35"
156
                     Height="35"
162
-                    Margin="0,7,0,0"
157
+                    Margin="0,6,0,0"
163
                     HorizontalAlignment="Center"
158
                     HorizontalAlignment="Center"
164
                     VerticalAlignment="Top"
159
                     VerticalAlignment="Top"
165
                     Content="上传中..."
160
                     Content="上传中..."
166
-                    FontSize="20" />
161
+                    FontSize="16" />
167
                 <ProgressBar
162
                 <ProgressBar
168
                     x:Name="pgbProcess"
163
                     x:Name="pgbProcess"
169
                     Grid.Row="0"
164
                     Grid.Row="0"
184
                     Foreground="White"
179
                     Foreground="White"
185
                     Visibility="Visible" />
180
                     Visibility="Visible" />
186
             </Grid>
181
             </Grid>
187
-        </Views:ZJClippingBorder>
182
+        </views:ZJClippingBorder>
188
     </Grid>
183
     </Grid>
189
 </Window>
184
 </Window>

+ 8
- 3
XHWK.WKTool/UploadWindow.xaml.cs View File

232
 
232
 
233
         private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
233
         private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
234
         {
234
         {
235
+            if (e.LeftButton == MouseButtonState.Pressed)
236
+            {
237
+                DragMove();
238
+            }
235
         }
239
         }
236
 
240
 
237
         /// <summary>
241
         /// <summary>
393
                                 _times.Stop();
397
                                 _times.Stop();
394
                                 pgbProcess.Value = 100;
398
                                 pgbProcess.Value = 100;
395
                                 lbProcess.Content = "100%";
399
                                 lbProcess.Content = "100%";
396
-                                MessageWindow.Show("视频上传成功!");
400
+                                Hide();
397
                                 tip_outer.Visibility = Visibility.Collapsed;
401
                                 tip_outer.Visibility = Visibility.Collapsed;
402
+                                MessageWindow.Show("视频上传成功!");
398
                                 if (ChangeTextEvents != null)
403
                                 if (ChangeTextEvents != null)
399
                                 {
404
                                 {
400
                                     ChangeTextEvents("上传成功", _i);
405
                                     ChangeTextEvents("上传成功", _i);
401
                                 }
406
                                 }
402
-                                Hide();
403
                             }
407
                             }
404
                         );
408
                         );
405
                     }
409
                     }
466
             Dispatcher.Invoke(() =>
470
             Dispatcher.Invoke(() =>
467
             {
471
             {
468
                 pgbProcess.Value = _num;
472
                 pgbProcess.Value = _num;
469
-                lbProcess.Content = _num.ToString() + "%";
473
+                lbProcess.Content = _num + "%";
470
                 if (_num < 99)
474
                 if (_num < 99)
471
                 {
475
                 {
472
                     _num++;
476
                     _num++;
477
+                    // ReSharper disable once PossibleLossOfFraction
473
                     _times.Interval += _num / 2;
478
                     _times.Interval += _num / 2;
474
                 }
479
                 }
475
                 else
480
                 else

+ 81
- 0
XHWK.WKTool/Utils/ZConfigAppUtil.cs View File

1
+namespace XHWK.WKTool.Utils
2
+{
3
+    using System;
4
+    using System.Configuration;
5
+
6
+    public static class ZConfigAppUtil
7
+    {
8
+        ///<summary>
9
+        ///返回app.config文件中appSettings配置节的value项
10
+        ///</summary>
11
+        ///<param name="strKey"></param>
12
+        ///<returns></returns>
13
+        public static string GetVaule(string strKey)
14
+        {
15
+            return GetVaule(strKey, "app.config");
16
+        }
17
+
18
+        public static string GetVaule(string strKey, string filepath)
19
+        {
20
+            ExeConfigurationFileMap file = new ExeConfigurationFileMap { ExeConfigFilename = filepath };
21
+            Configuration config = ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None);
22
+            foreach (string key in config.AppSettings.Settings.AllKeys)
23
+            {
24
+                if (key == strKey)
25
+                {
26
+                    return config.AppSettings.Settings[strKey].Value;
27
+                }
28
+            }
29
+            return null;
30
+        }
31
+
32
+        ///<summary>
33
+        ///在app.config文件中appSettings配置节增加一对键值对
34
+        ///</summary>
35
+        ///<param name="newKey"></param>
36
+        ///<param name="newValue"></param>
37
+        public static void SetVaule(string newKey, string newValue)
38
+        {
39
+            SetVaule
40
+            (
41
+                newKey,
42
+                newValue,
43
+                "app.config"
44
+            );
45
+        }
46
+
47
+        public static void SetVaule
48
+        (
49
+            string newKey,
50
+            string newValue,
51
+            string filepath
52
+        )
53
+        {
54
+            ExeConfigurationFileMap file = new ExeConfigurationFileMap { ExeConfigFilename = filepath };
55
+            Configuration config = ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None);
56
+            bool exist = false;
57
+            foreach (string key in config.AppSettings.Settings.AllKeys)
58
+            {
59
+                if (key == newKey)
60
+                {
61
+                    exist = true;
62
+                }
63
+            }
64
+            if (exist)
65
+            {
66
+                config.AppSettings.Settings.Remove(newKey);
67
+            }
68
+            config.AppSettings.Settings.Add(newKey, newValue);
69
+            config.Save(ConfigurationSaveMode.Modified);
70
+            ConfigurationManager.RefreshSection("appSettings");
71
+        }
72
+
73
+        public static void Test()
74
+        {
75
+            SetVaule("ServerIp", "127.0.0.1");
76
+            SetVaule("ServerPort", "10088");
77
+            Console.WriteLine("ServerIp:" + GetVaule("ServerIp"));
78
+            Console.WriteLine("ServerXXX:" + (GetVaule("ServerXXX") == null));
79
+        }
80
+    }
81
+}

+ 26
- 0
XHWK.WKTool/View/ZRoundButton.cs View File

1
+namespace XHWK.WKTool.View
2
+{
3
+    using System.Windows;
4
+    using System.Windows.Controls;
5
+
6
+    public class ZRoundButton : Button
7
+    {
8
+        #region 属性
9
+
10
+        public int BorderRadius
11
+        {
12
+            get { return (int)GetValue(BorderRadiusProperty); }
13
+            set { SetValue(BorderRadiusProperty, value); }
14
+        }
15
+
16
+        public static readonly DependencyProperty BorderRadiusProperty = DependencyProperty.Register
17
+        (
18
+            "BorderRadius",
19
+            typeof(int),
20
+            typeof(ZRoundButton),
21
+            new FrameworkPropertyMetadata()
22
+        );
23
+
24
+        #endregion 属性
25
+    }
26
+}

+ 11
- 1
XHWK.WKTool/XHWK.WKTool.csproj View File

299
     <Compile Include="system\FFMpeg.cs" />
299
     <Compile Include="system\FFMpeg.cs" />
300
     <Compile Include="system\FileToolsCommon.cs" />
300
     <Compile Include="system\FileToolsCommon.cs" />
301
     <Compile Include="system\FreeMemoryHelper.cs" />
301
     <Compile Include="system\FreeMemoryHelper.cs" />
302
-    <Compile Include="system\HttpHelper.cs" />
302
+    <Compile Include="system\ZHttpUtil.cs" />
303
     <Compile Include="system\ImageHelper.cs" />
303
     <Compile Include="system\ImageHelper.cs" />
304
     <Compile Include="system\JsonHelper.cs" />
304
     <Compile Include="system\JsonHelper.cs" />
305
     <Compile Include="system\KeyboardHookCommon.cs" />
305
     <Compile Include="system\KeyboardHookCommon.cs" />
327
     <Compile Include="Utils\pen\luobo\LuoBoPenUtil.cs" />
327
     <Compile Include="Utils\pen\luobo\LuoBoPenUtil.cs" />
328
     <Compile Include="Utils\pen\PenEventI.cs" />
328
     <Compile Include="Utils\pen\PenEventI.cs" />
329
     <Compile Include="Utils\ZAsposeUtil.cs" />
329
     <Compile Include="Utils\ZAsposeUtil.cs" />
330
+    <Compile Include="Utils\ZConfigAppUtil.cs" />
330
     <Compile Include="Utils\ZVideoRecordHelper.cs" />
331
     <Compile Include="Utils\ZVideoRecordHelper.cs" />
331
     <Compile Include="Utils\ZAudioRecordHelper.cs" />
332
     <Compile Include="Utils\ZAudioRecordHelper.cs" />
332
     <Compile Include="Utils\ZPrintUtils.cs" />
333
     <Compile Include="Utils\ZPrintUtils.cs" />
334
       <DependentUpon>VideoClipWindow.xaml</DependentUpon>
335
       <DependentUpon>VideoClipWindow.xaml</DependentUpon>
335
     </Compile>
336
     </Compile>
336
     <Compile Include="View\ZClippingBorder.cs" />
337
     <Compile Include="View\ZClippingBorder.cs" />
338
+    <Compile Include="View\ZRoundButton.cs" />
337
     <Compile Include="Welcome.xaml.cs">
339
     <Compile Include="Welcome.xaml.cs">
338
       <DependentUpon>Welcome.xaml</DependentUpon>
340
       <DependentUpon>Welcome.xaml</DependentUpon>
339
     </Compile>
341
     </Compile>
408
       <SubType>Designer</SubType>
410
       <SubType>Designer</SubType>
409
       <Generator>MSBuild:Compile</Generator>
411
       <Generator>MSBuild:Compile</Generator>
410
     </Page>
412
     </Page>
413
+    <Page Include="Resources\StyleComboBox.xaml">
414
+      <SubType>Designer</SubType>
415
+      <Generator>MSBuild:Compile</Generator>
416
+    </Page>
411
     <Page Include="Resources\StyleScrolllview.xaml">
417
     <Page Include="Resources\StyleScrolllview.xaml">
412
       <SubType>Designer</SubType>
418
       <SubType>Designer</SubType>
413
       <Generator>MSBuild:Compile</Generator>
419
       <Generator>MSBuild:Compile</Generator>
414
     </Page>
420
     </Page>
421
+    <Page Include="Resources\StyleZRoundButton.xaml">
422
+      <SubType>Designer</SubType>
423
+      <Generator>MSBuild:Compile</Generator>
424
+    </Page>
415
     <Page Include="Skin\SkinDictionary_TechnologyBlue.xaml">
425
     <Page Include="Skin\SkinDictionary_TechnologyBlue.xaml">
416
       <Generator>MSBuild:Compile</Generator>
426
       <Generator>MSBuild:Compile</Generator>
417
       <SubType>Designer</SubType>
427
       <SubType>Designer</SubType>

+ 8
- 4
XHWK.WKTool/system/DownloadManager.cs View File

102
                     try
102
                     try
103
                     {
103
                     {
104
                         //第一次请求获取一小块数据,根据返回的情况判断是否支持断点续传
104
                         //第一次请求获取一小块数据,根据返回的情况判断是否支持断点续传
105
-                        using (System.Net.WebResponse rsp = HttpHelper.Download(dlInfo.downloadUrlList[0], 0, 0, dlInfo.method))
105
+                        using (System.Net.WebResponse rsp = ZHttpUtil.Download
106
+                               (
107
+                                   dlInfo.downloadUrlList[0],
108
+                                   0,
109
+                                   0,
110
+                                   dlInfo.method
111
+                               ))
106
                         {
112
                         {
107
-
108
                             //获取文件名,如果包含附件名称则取下附件,否则从url获取名称
113
                             //获取文件名,如果包含附件名称则取下附件,否则从url获取名称
109
                             string Disposition = rsp.Headers["Content-Disposition"];
114
                             string Disposition = rsp.Headers["Content-Disposition"];
110
                             try
115
                             try
118
                                     dlInfo.fileName = Path.GetFileName(rsp.ResponseUri.AbsolutePath);
123
                                     dlInfo.fileName = Path.GetFileName(rsp.ResponseUri.AbsolutePath);
119
                                 }
124
                                 }
120
                             }
125
                             }
121
-                            catch (Exception)//无法获取文件名时  使用传入保存名称
126
+                            catch (Exception) //无法获取文件名时  使用传入保存名称
122
                             {
127
                             {
123
                                 dlInfo.fileName = dlInfo.saveFileName;
128
                                 dlInfo.fileName = dlInfo.saveFileName;
124
                             }
129
                             }
140
                                 ///创建线程信息
145
                                 ///创建线程信息
141
                                 ///
146
                                 ///
142
                                 GetTaskInfo(dlInfo);
147
                                 GetTaskInfo(dlInfo);
143
-
144
                             }
148
                             }
145
                             else
149
                             else
146
                             {
150
                             {

+ 7
- 2
XHWK.WKTool/system/DownloadService.cs View File

109
                     {
109
                     {
110
                         to = fromIndex + size;
110
                         to = fromIndex + size;
111
                     }
111
                     }
112
-
113
                     try
112
                     try
114
                     {
113
                     {
115
-                        using (rsp = HttpHelper.Download(downloadUrl, fromIndex, to, method))
114
+                        using (rsp = ZHttpUtil.Download
115
+                               (
116
+                                   downloadUrl,
117
+                                   fromIndex,
118
+                                   to,
119
+                                   method
120
+                               ))
116
                         {
121
                         {
117
                             Save(filePath, rsp.GetResponseStream());
122
                             Save(filePath, rsp.GetResponseStream());
118
                         }
123
                         }

+ 0
- 705
XHWK.WKTool/system/HttpHelper.cs View File

1
-using Newtonsoft.Json.Linq;
2
-
3
-using System;
4
-using System.Collections.Generic;
5
-using System.Collections.Specialized;
6
-using System.IO;
7
-using System.Net;
8
-using System.Net.Security;
9
-using System.Security.Cryptography.X509Certificates;
10
-using System.Text;
11
-using System.Threading;
12
-
13
-namespace Common.system
14
-{
15
-    /// <summary>
16
-    /// HttpHelper
17
-    /// 创建人:赵耀
18
-    /// </summary>
19
-    public class HttpHelper
20
-    {
21
-        public static string tokenKey = "";
22
-        public static string tokenValue = "";
23
-        public static string userId = "";
24
-        public static bool isParameterEncryption = false;
25
-
26
-        public static void InitRequest(ref System.Net.HttpWebRequest request)
27
-        {
28
-            request.Accept = "text/json,*/*;q=0.5";
29
-            request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7");
30
-            request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9");
31
-            request.AutomaticDecompression = System.Net.DecompressionMethods.GZip;
32
-            request.Timeout = 8000;
33
-        }
34
-
35
-        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
36
-        {
37
-            return true; //总是接受
38
-        }
39
-
40
-        public static System.Net.HttpWebRequest GetHttpWebRequest(string url)
41
-        {
42
-            HttpWebRequest request;
43
-            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
44
-            {
45
-                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
46
-                request = WebRequest.Create(url) as HttpWebRequest;
47
-                request.ProtocolVersion = HttpVersion.Version10;
48
-            }
49
-            else
50
-            {
51
-                request = WebRequest.Create(url) as HttpWebRequest;
52
-            }
53
-            return request;
54
-        }
55
-
56
-        public static WebResponse Download(string downloadUrl, long from, long to, string method)
57
-        {
58
-            for (int i = 0; i < 10; i++)
59
-            {
60
-                try
61
-                {
62
-                    HttpWebRequest request = HttpHelper.GetHttpWebRequest(downloadUrl);
63
-                    HttpHelper.InitRequest(ref request);
64
-                    request.Accept = "text/json,*/*;q=0.5";
65
-                    request.AddRange(from, to);
66
-                    request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7");
67
-                    request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9");
68
-                    request.AutomaticDecompression = System.Net.DecompressionMethods.GZip;
69
-                    request.Timeout = 120000;
70
-                    request.Method = method;
71
-                    request.KeepAlive = false;
72
-                    request.ContentType = "application/json; charset=utf-8";
73
-                    return request.GetResponse();
74
-                }
75
-                catch (Exception)
76
-                {
77
-                    Thread.Sleep(100);
78
-                }
79
-            }
80
-            throw new Exception("已断开网络!请检查网络连接后重试下载!");
81
-        }
82
-
83
-        public static string Get(string url, IDictionary<string, string> param)
84
-        {
85
-            List<string> paramBuilder = new List<string>();
86
-            foreach (KeyValuePair<string, string> item in param)
87
-            {
88
-                paramBuilder.Add(string.Format("{0}={1}", item.Key, item.Value));
89
-            }
90
-            url = string.Format("{0}?{1}", url.TrimEnd('?'), string.Join(",", paramBuilder.ToArray()));
91
-            return Get(url);
92
-        }
93
-
94
-        public static string Get(string url)
95
-        {
96
-            try
97
-            {
98
-                HttpWebRequest request = GetHttpWebRequest(url);
99
-                if (request != null)
100
-                {
101
-                    string retval;
102
-                    InitRequest(ref request);
103
-                    using (WebResponse response = request.GetResponse())
104
-                    {
105
-                        using (StreamReader reader = new System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
106
-                        {
107
-                            retval = reader.ReadToEnd();
108
-                        }
109
-                    }
110
-                    return retval;
111
-                }
112
-            }
113
-            catch
114
-            {
115
-            }
116
-            return null;
117
-        }
118
-
119
-        public static string Post(string url, string data)
120
-        {
121
-            try
122
-            {
123
-                HttpWebRequest request = GetHttpWebRequest(url);
124
-                if (request != null)
125
-                {
126
-                    string retval = null;
127
-                    InitRequest(ref request);
128
-                    request.Method = "POST";
129
-                    request.ServicePoint.Expect100Continue = false;
130
-                    request.ContentType = "application/json; charset=utf-8";
131
-                    request.Timeout = 5000;
132
-                    byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data);
133
-                    request.ContentLength = bytes.Length;
134
-                    using (Stream stream = request.GetRequestStream())
135
-                    {
136
-                        stream.Write(bytes, 0, bytes.Length);
137
-                    }
138
-                    using (WebResponse response = request.GetResponse())
139
-                    {
140
-                        using (StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()))
141
-                        {
142
-                            retval = reader.ReadToEnd();
143
-                        }
144
-                    }
145
-                    return retval;
146
-                }
147
-            }
148
-            catch
149
-            {
150
-            }
151
-            return null;
152
-        }
153
-
154
-        ///  <summary>
155
-        /// 调用Post接口
156
-        ///  </summary>
157
-        ///  <returns></returns>
158
-        public static string HttpPost(string body, string url)
159
-        {
160
-            try
161
-            {
162
-                Encoding encoding = Encoding.UTF8;
163
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
164
-                request.Method = "POST";
165
-                request.Accept = "text/html,application/xhtml+xml,*/*";
166
-                request.ContentType = "application/json";
167
-                string postDataAes = body;
168
-                if (isParameterEncryption)
169
-                {
170
-                    postDataAes = AESHelper.AESEncrypt(body, "XINGHUOLIAOYUAN7");
171
-                    request.Headers.Add("st", "true");
172
-                }
173
-                else
174
-                {
175
-                    request.Headers.Add("st", "false");
176
-                }
177
-                if (!string.IsNullOrEmpty(tokenKey) && !string.IsNullOrEmpty(tokenValue))
178
-                {
179
-                    request.Headers.Add("Token-Key", tokenKey);
180
-                    request.Headers.Add("Token-Value", tokenValue);
181
-                }
182
-                if (!string.IsNullOrEmpty(userId))
183
-                {
184
-                    request.Headers.Add("User-Id", userId);
185
-                }
186
-                byte[] buffer = encoding.GetBytes(postDataAes);
187
-                request.ContentLength = buffer.Length;
188
-                request.GetRequestStream().Write(buffer, 0, buffer.Length);
189
-
190
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
191
-                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
192
-                {
193
-                    return reader.ReadToEnd();
194
-                }
195
-            }
196
-            catch (Exception ex)
197
-            {
198
-                // LogHelper.Instance.Debug($"POST接口连接失败,请求参数:{ex.Message}");
199
-                return "POST报错:" + ex.Message;
200
-            }
201
-        }
202
-
203
-        /// <summary>
204
-        /// Post Http请求
205
-        /// </summary>
206
-        /// <param name="url">请求地址</param>
207
-        /// <param name="postData">传输数据</param>
208
-        /// <param name="timeout">超时时间</param>
209
-        /// <param name="contentType">媒体格式</param>
210
-        /// <param name="encode">编码</param>
211
-        /// <returns>泛型集合</returns>
212
-        public static T PostAndRespSignle<T>(string url, int timeout = 5000, string postData = "", string contentType = "application/json;", string encode = "UTF-8") where T : class
213
-        {
214
-            if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(encode) && !string.IsNullOrEmpty(contentType) && postData != null)
215
-            {
216
-                try
217
-                {
218
-                    string postDataAes = postData;
219
-                    if (isParameterEncryption)
220
-                    {
221
-                        postDataAes = AESHelper.AESEncrypt(postDataAes, "XINGHUOLIAOYUAN7");
222
-                    }
223
-                    string respstr = GetStreamReader
224
-                    (
225
-                        url,
226
-                        null,
227
-                        null,
228
-                        null,
229
-                        null,
230
-                        timeout,
231
-                        encode,
232
-                        postDataAes,
233
-                        contentType
234
-                    );
235
-                    return JsonHelper.JsonToObj<T>(respstr);
236
-                }
237
-                catch (Exception)
238
-                {
239
-                    // ignored
240
-                }
241
-            }
242
-            return default(T);
243
-        }
244
-
245
-        private static string GetStreamReader(string url, Stream responseStream, Stream requestStream, StreamReader streamReader, WebResponse webResponse, int timeout, string encode, string postData, string contentType)
246
-        {
247
-            try
248
-            {
249
-                byte[] data = Encoding.GetEncoding(encode).GetBytes(postData);
250
-                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
251
-                webRequest.Method = "POST";
252
-                webRequest.ContentType = contentType + ";" + encode;
253
-                webRequest.ContentLength = data.Length;
254
-                webRequest.Timeout = timeout;
255
-                if (isParameterEncryption)
256
-                {
257
-                    webRequest.Headers.Add("st", "true");
258
-                }
259
-                else
260
-                {
261
-                    webRequest.Headers.Add("st", "false");
262
-                }
263
-                if (!string.IsNullOrEmpty(tokenKey) && !string.IsNullOrEmpty(tokenValue))
264
-                {
265
-                    webRequest.Headers.Add("Token-Key", tokenKey);
266
-                    webRequest.Headers.Add("Token-Value", tokenValue);
267
-                }
268
-                if (!string.IsNullOrEmpty(userId))
269
-                {
270
-                    webRequest.Headers.Add("User-Id", userId);
271
-                }
272
-                requestStream = webRequest.GetRequestStream();
273
-                requestStream.Write(data, 0, data.Length);
274
-                webResponse = (HttpWebResponse)webRequest.GetResponse();
275
-                responseStream = webResponse.GetResponseStream();
276
-                if (responseStream == null) { return ""; }
277
-                streamReader = new StreamReader(responseStream, Encoding.GetEncoding(encode));
278
-                return streamReader.ReadToEnd();
279
-            }
280
-            catch (Exception)
281
-            {
282
-                return null;
283
-            }
284
-        }
285
-
286
-        /// <summary>
287
-        /// Cookie
288
-        /// </summary>
289
-        public static CookieContainer cc = new CookieContainer();
290
-
291
-        /// <summary>
292
-        /// Get请求
293
-        /// </summary>
294
-        /// <param name="serviceaddress">请求地址</param>
295
-        /// <param name="strcontent">头</param>
296
-        /// <param name="contenttype">参数</param>
297
-        /// <param name="header">token</param>
298
-        /// <param name="timeout"></param>
299
-        /// <returns></returns>
300
-        public static JObject GetFunction
301
-        (
302
-            string serviceaddress,
303
-            string strcontent,
304
-            string contenttype,
305
-            string header,
306
-            int timeout = 5000
307
-        )
308
-        {
309
-            try
310
-            {
311
-                string serviceAddress = serviceaddress + strcontent;
312
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
313
-                WebHeaderCollection myWebHeaderCollection = request.Headers;
314
-                request.CookieContainer = cc;
315
-                if (header != "")
316
-                {
317
-                    myWebHeaderCollection.Add("access_token:" + header);
318
-                }
319
-
320
-                request.Method = "GET";
321
-                request.ContentType = contenttype;
322
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
323
-
324
-                string encoding = response.ContentEncoding;
325
-                if (encoding.Length < 1)
326
-                {
327
-                    encoding = "UTF-8"; //默认编码
328
-                }
329
-                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
330
-                string retString = reader.ReadToEnd();
331
-
332
-                //解析josn
333
-                JObject jo = JObject.Parse(retString);
334
-                return jo;
335
-            }
336
-            catch (Exception)
337
-            {
338
-                return null;
339
-            }
340
-        }
341
-
342
-        /// <summary>
343
-        /// Post请求
344
-        /// </summary>
345
-        /// <param name="serviceaddress">请求地址</param>
346
-        /// <param name="contenttype">头 application/x-www-form-urlencoded</param>
347
-        /// <param name="strcontent">参数</param>
348
-        /// <param name="header">token</param>
349
-        /// <returns></returns>
350
-        public static JObject PostFunction(string serviceaddress, string contenttype, string strcontent, string header, int Timeout = 5000)
351
-        {
352
-            try
353
-            {
354
-                string serviceAddress = serviceaddress;
355
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
356
-                WebHeaderCollection myWebHeaderCollection = request.Headers;
357
-
358
-                request.CookieContainer = cc;
359
-                //myWebHeaderCollection.Add("Accept", "*/*");
360
-                if (header != "")
361
-                {
362
-                    myWebHeaderCollection.Add("access_token:" + header);
363
-                }
364
-                request.Timeout = Timeout;
365
-                request.Method = "POST";
366
-                request.ContentType = contenttype;
367
-                using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
368
-                {
369
-                    dataStream.Write(strcontent);
370
-                    dataStream.Close();
371
-                }
372
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
373
-
374
-                string encoding = response.ContentEncoding;
375
-                if (encoding == null || encoding.Length < 1)
376
-                {
377
-                    encoding = "UTF-8"; //默认编码
378
-                }
379
-                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
380
-                string retString = reader.ReadToEnd();
381
-                retString = retString.Replace("\\r\\n", "");
382
-
383
-                //解析josn
384
-                JObject jo = JObject.Parse(retString);
385
-                return jo;
386
-            }
387
-            catch (Exception ex)
388
-            {
389
-                LogHelper.WriteErrLog("请求失败(若网络无问题,请重置winsock,解决方法:以管理员方式打开cmd执行 netsh winsock reset 后重启)", ex);
390
-                return null;
391
-            }
392
-        }
393
-
394
-        /// <summary>
395
-        ///  上传方法
396
-        /// </summary>
397
-        /// <param name="url">webapi地址</param>
398
-        /// <param name="files">本地文件路径,单文件默认为string[0]</param>
399
-        /// <param name="token"></param>
400
-        /// <param name="formFields">参数可不传</param>
401
-        /// <returns></returns>
402
-        public static JObject UploadFilesToRemoteUrl(string url, string[] files, string token, NameValueCollection formFields = null)
403
-        {
404
-            string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");
405
-            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
406
-            request.ContentType = "multipart/form-data; boundary=" +
407
-                                    boundary;
408
-            request.Method = "POST";
409
-            request.KeepAlive = true;
410
-
411
-            Stream memStream = new System.IO.MemoryStream();
412
-
413
-            byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" +
414
-                                                                    boundary + "\r\n");
415
-            byte[] endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" +
416
-                                                                        boundary + "--");
417
-            WebHeaderCollection myWebHeaderCollection = request.Headers;
418
-            request.CookieContainer = cc;
419
-            if (token != "")
420
-            {
421
-                myWebHeaderCollection.Add("access_token:" + token);
422
-            }
423
-
424
-            string formdataTemplate = "\r\n--" + boundary +
425
-                                        "\r\nContent-Disposition: form-data; name=\"{0}\";\r\n\r\n{1}";
426
-            if (formFields != null)
427
-            {
428
-                foreach (string key in formFields.Keys)
429
-                {
430
-                    string formitem = string.Format(formdataTemplate, key, formFields[key]);
431
-                    byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
432
-                    memStream.Write(formitembytes, 0, formitembytes.Length);
433
-                }
434
-            }
435
-
436
-            string headerTemplate =
437
-                "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n" +
438
-                "Content-Type: application/octet-stream\r\n\r\n";
439
-
440
-            for (int i = 0; i < files.Length; i++)
441
-            {
442
-                memStream.Write(boundarybytes, 0, boundarybytes.Length);
443
-                string header = string.Format(headerTemplate, "fileData", files[i]);
444
-                byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
445
-
446
-                memStream.Write(headerbytes, 0, headerbytes.Length);
447
-
448
-                using (FileStream fileStream = new FileStream(files[i], FileMode.Open, FileAccess.Read))
449
-                {
450
-                    byte[] buffer = new byte[1024];
451
-                    int bytesRead = 0;
452
-                    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
453
-                    {
454
-                        memStream.Write(buffer, 0, bytesRead);
455
-                    }
456
-                }
457
-            }
458
-
459
-            //memStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
460
-            request.ContentLength = memStream.Length;
461
-
462
-            using (Stream requestStream = request.GetRequestStream())
463
-            {
464
-                memStream.Position = 0;
465
-                byte[] tempBuffer = new byte[memStream.Length];
466
-                memStream.Read(tempBuffer, 0, tempBuffer.Length);
467
-                memStream.Close();
468
-                requestStream.Write(tempBuffer, 0, tempBuffer.Length);
469
-            }
470
-
471
-            using (WebResponse response = request.GetResponse())
472
-            {
473
-                Stream stream2 = response.GetResponseStream();
474
-                StreamReader reader2 = new StreamReader(stream2);
475
-                JObject a = JObject.Parse(reader2.ReadToEnd());
476
-                return a;
477
-            }
478
-        }
479
-
480
-        /// <summary>
481
-        /// HttpWebRequest 下载
482
-        /// </summary>
483
-        /// <param name="url">URI</param>
484
-        /// <returns></returns>
485
-        public static bool GetDataGetHtml(string url, string filePath, string header)
486
-        {
487
-            try
488
-            {
489
-                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
490
-
491
-                //httpWebRequest.ContentType = "application/x-www-form-urlencoded";
492
-                httpWebRequest.Method = "GET";
493
-                //httpWebRequest.ContentType = "image/jpeg";
494
-                //对发送的数据不使用缓存
495
-                httpWebRequest.AllowWriteStreamBuffering = false;
496
-                //httpWebRequest.Timeout = 300000;
497
-                httpWebRequest.ServicePoint.Expect100Continue = false;
498
-
499
-                WebHeaderCollection myWebHeaderCollection = httpWebRequest.Headers;
500
-                //myWebHeaderCollection.Add("Accept", "*/*");
501
-                if (header != "")
502
-                {
503
-                    myWebHeaderCollection.Add("access_token:" + header);
504
-                }
505
-
506
-                HttpWebResponse webRespon = (HttpWebResponse)httpWebRequest.GetResponse();
507
-                Stream webStream = webRespon.GetResponseStream();
508
-                long length = webRespon.ContentLength;
509
-                if (webStream == null)
510
-                {
511
-                    return false;
512
-                }
513
-                int lengthint = Convert.ToInt32(length);
514
-                //int num = lengthint / 1024;
515
-                //int count = 0;
516
-                //M_DownloadInfo.totalCount = lengthint / 1024;
517
-                //M_DownloadInfo.downloadCount = 0;
518
-
519
-                Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
520
-                byte[] bArr = new byte[1024];
521
-                int size = webStream.Read(bArr, 0, bArr.Length);
522
-                while (size > 0)
523
-                {
524
-                    stream.Write(bArr, 0, size);
525
-                    size = webStream.Read(bArr, 0, bArr.Length);
526
-                    //M_DownloadInfo.downloadCount = M_DownloadInfo.downloadCount + 1;
527
-                }
528
-                webRespon.Close();
529
-                stream.Close();
530
-                webStream.Close();
531
-                return true;
532
-            }
533
-            catch (Exception)
534
-            {
535
-                //LogHelper.WriteErrLog("请求失败:" + ex.Message, ex);
536
-                return false;
537
-            }
538
-        }
539
-
540
-        /// <summary>
541
-        /// 上传文件流
542
-        /// 创建人:赵耀
543
-        /// 创建时间:2020年9月5日
544
-        /// </summary>
545
-        /// <param name="url">URL</param>
546
-        /// <param name="databyte">文件数据流</param>
547
-        /// <param name="filename">文件名</param>
548
-        /// <param name="formFields">参数 可不传</param>
549
-        public static JObject UploadRequestflow(string url, byte[] databyte, string filename, NameValueCollection formFields = null)
550
-        {
551
-            JObject jobResult = null;
552
-            // 时间戳,用做boundary
553
-            string boundary = "-----" + DateTime.Now.Ticks.ToString("x");
554
-            byte[] boundarybytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
555
-
556
-            //根据uri创建HttpWebRequest对象
557
-            HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(url));
558
-            httpReq.ContentType = "multipart/form-data; boundary=" + boundary;
559
-            httpReq.Method = "POST";
560
-            httpReq.KeepAlive = true;
561
-            //httpReq.Timeout = 300000;
562
-            //httpReq.AllowWriteStreamBuffering = false; //对发送的数据不使用缓存
563
-            httpReq.Credentials = CredentialCache.DefaultCredentials;
564
-
565
-            try
566
-            {
567
-                Stream postStream = httpReq.GetRequestStream();
568
-                //参数
569
-                const string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
570
-                if (formFields != null)
571
-                {
572
-                    foreach (string key in formFields.Keys)
573
-                    {
574
-                        postStream.Write(boundarybytes, 0, boundarybytes.Length);
575
-                        string formitem = string.Format(formdataTemplate, key, formFields[key]);
576
-                        byte[] formitembytes = Encoding.UTF8.GetBytes(formitem);
577
-                        postStream.Write(formitembytes, 0, formitembytes.Length);
578
-                    }
579
-                }
580
-                postStream.Write(boundarybytes, 0, boundarybytes.Length);
581
-
582
-                const string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: application/octet-stream\r\n\r\n";
583
-
584
-                //文件头
585
-                string header = string.Format(headerTemplate, "file", filename);
586
-                byte[] headerbytes = Encoding.UTF8.GetBytes(header);
587
-                postStream.Write(headerbytes, 0, headerbytes.Length);
588
-
589
-                //文件流
590
-                postStream.Write(databyte, 0, databyte.Length);
591
-
592
-                //结束边界
593
-                byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
594
-                postStream.Write(boundaryBytes, 0, boundaryBytes.Length);
595
-                postStream.Close();
596
-
597
-                //获取服务器端的响应
598
-                using (HttpWebResponse response = (HttpWebResponse)httpReq.GetResponse())
599
-                {
600
-                    Stream receiveStream = response.GetResponseStream();
601
-                    StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
602
-                    string returnValue = readStream.ReadToEnd();
603
-                    jobResult = JObject.Parse(returnValue);
604
-                    response.Close();
605
-                    readStream.Close();
606
-                }
607
-                return jobResult;
608
-            }
609
-            catch (Exception ex)
610
-            {
611
-                LogHelper.WriteErrLog("【文件上传】" + ex.Message, ex);
612
-                return null;
613
-            }
614
-            finally
615
-            {
616
-                httpReq = null;
617
-            }
618
-        }
619
-
620
-        /// <summary>
621
-        /// Post Http请求
622
-        /// </summary>
623
-        /// <param name="url"></param>
624
-        /// <param name="postData"></param>
625
-        /// <param name="timeout"></param>
626
-        /// <param name="contentType"></param>
627
-        /// <param name="encode"></param>
628
-        /// <returns>响应流字符串</returns>
629
-        public static string PostAndRespStr(string url, string postData = "", int timeout = 5000, string contentType = "application/json;", string encode = "UTF-8")
630
-        {
631
-            if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(encode) && !string.IsNullOrEmpty(contentType) && postData != null)
632
-            {
633
-                try
634
-                {
635
-                    string postDataAes = postData;
636
-                    if (isParameterEncryption)
637
-                    {
638
-                        postDataAes = AESHelper.AESEncrypt(postData, "XINGHUOLIAOYUAN7");
639
-                    }
640
-                    return GetStreamReader
641
-                    (
642
-                        url,
643
-                        null,
644
-                        null,
645
-                        null,
646
-                        null,
647
-                        timeout,
648
-                        encode,
649
-                        postDataAes,
650
-                        contentType
651
-                    );
652
-                }
653
-                catch (Exception)
654
-                {
655
-                    // ignored
656
-                }
657
-            }
658
-            return null;
659
-        }
660
-
661
-        /// <summary>
662
-        /// 获取公网IP和地址,失败则获取局域网IP
663
-        /// </summary>
664
-        /// <param name="addressIp">IP地址</param>
665
-        /// <param name="address">地址</param>
666
-        /// <returns></returns>
667
-        public static bool GetAddressIp(out string addressIp, out string address)
668
-        {
669
-            addressIp = "";
670
-            address = "";
671
-            try
672
-            {
673
-                //请求搜狐获取公网IP,获取失败后获取局域网IP
674
-                WebRequest request = WebRequest.Create("http://pv.sohu.com/cityjson?ie=utf-8");
675
-                request.Timeout = 10000;
676
-                WebResponse response = request.GetResponse();
677
-                Stream resStream = response.GetResponseStream();
678
-                StreamReader sr = new StreamReader(resStream, System.Text.Encoding.UTF8);
679
-                string htmlinfo = sr.ReadToEnd();
680
-                string jsonStr = htmlinfo.Substring(htmlinfo.IndexOf("{"), htmlinfo.LastIndexOf("}") - htmlinfo.IndexOf("{") + 1);
681
-                JObject obj = JObject.Parse(jsonStr);
682
-                addressIp = obj["cip"].ToString();
683
-                address = obj["cname"].ToString();
684
-                resStream.Close();
685
-                sr.Close();
686
-                return true;
687
-                //Regex r = new Regex("((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|[1-9])", RegexOptions.None);
688
-                //Match mc = r.Match(htmlinfo);
689
-                //AddressIP = mc.Groups[0].Value;
690
-            }
691
-            catch (Exception)
692
-            {
693
-                //获取本地局域网IP
694
-                foreach (System.Net.IPAddress ipAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
695
-                {
696
-                    if (ipAddress.AddressFamily.ToString() == "InterNetwork")
697
-                    {
698
-                        addressIp = ipAddress.ToString();
699
-                    }
700
-                }
701
-                return false;
702
-            }
703
-        }
704
-    }
705
-}

+ 495
- 0
XHWK.WKTool/system/ZHttpUtil.cs View File

1
+namespace Common.system
2
+{
3
+    using Newtonsoft.Json.Linq;
4
+    using System;
5
+    using System.Collections.Specialized;
6
+    using System.IO;
7
+    using System.Net;
8
+    using System.Net.Security;
9
+    using System.Security.Cryptography.X509Certificates;
10
+    using System.Text;
11
+    using System.Threading;
12
+
13
+    public class ZHttpUtil
14
+    {
15
+        public static string tokenKey = "";
16
+        public static string tokenValue = "";
17
+        public static string userId = "";
18
+        public static string version = "";
19
+        public static bool isSt;
20
+
21
+        public static void InitRequest(ref System.Net.HttpWebRequest request)
22
+        {
23
+            request.Accept = "text/json,*/*;q=0.5";
24
+            request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7");
25
+            request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9");
26
+            request.AutomaticDecompression = System.Net.DecompressionMethods.GZip;
27
+            request.Timeout = 8000;
28
+        }
29
+
30
+        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
31
+        {
32
+            return true; //总是接受
33
+        }
34
+
35
+        public static System.Net.HttpWebRequest GetHttpWebRequest(string url)
36
+        {
37
+            HttpWebRequest request;
38
+            if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
39
+            {
40
+                ServicePointManager.ServerCertificateValidationCallback = CheckValidationResult;
41
+                request = WebRequest.Create(url) as HttpWebRequest;
42
+                if (request != null)
43
+                {
44
+                    request.ProtocolVersion = HttpVersion.Version10;
45
+                }
46
+            }
47
+            else
48
+            {
49
+                request = WebRequest.Create(url) as HttpWebRequest;
50
+            }
51
+            return request;
52
+        }
53
+
54
+        public static WebResponse Download(string downloadUrl, long from, long to, string method)
55
+        {
56
+            for (int i = 0; i < 10; i++)
57
+            {
58
+                try
59
+                {
60
+                    HttpWebRequest request = GetHttpWebRequest(downloadUrl);
61
+                    InitRequest(ref request);
62
+                    request.Accept = "text/json,*/*;q=0.5";
63
+                    request.AddRange(from, to);
64
+                    request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7");
65
+                    request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9");
66
+                    request.AutomaticDecompression = System.Net.DecompressionMethods.GZip;
67
+                    request.Timeout = 120000;
68
+                    request.Method = method;
69
+                    request.KeepAlive = false;
70
+                    request.ContentType = "application/json; charset=utf-8";
71
+                    return request.GetResponse();
72
+                }
73
+                catch (Exception)
74
+                {
75
+                    Thread.Sleep(100);
76
+                }
77
+            }
78
+            throw new Exception("已断开网络!请检查网络连接后重试下载!");
79
+        }
80
+
81
+        public static string GetStr(string url)
82
+        {
83
+            try
84
+            {
85
+                HttpWebRequest request = GetHttpWebRequest(url);
86
+                if (request != null)
87
+                {
88
+                    AddHeader(request);
89
+                    string retval;
90
+                    InitRequest(ref request);
91
+                    using (WebResponse response = request.GetResponse())
92
+                    {
93
+                        // ReSharper disable once AssignNullToNotNullAttribute
94
+                        using (StreamReader reader = new System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
95
+                        {
96
+                            retval = reader.ReadToEnd();
97
+                        }
98
+                    }
99
+                    return retval;
100
+                }
101
+            }
102
+            catch (Exception)
103
+            {
104
+                // ignored
105
+            }
106
+            return null;
107
+        }
108
+
109
+        private static void AddHeader(HttpWebRequest webRequest)
110
+        {
111
+            webRequest.Headers.Add("Xh-St", isSt ? "true" : "false");
112
+            if (!string.IsNullOrEmpty(tokenKey) && !string.IsNullOrEmpty(tokenValue))
113
+            {
114
+                webRequest.Headers.Add("Xh-Token-Key", tokenKey);
115
+                webRequest.Headers.Add("Xh-Token-Value", tokenValue);
116
+            }
117
+            if (!string.IsNullOrEmpty(userId))
118
+            {
119
+                webRequest.Headers.Add("Xh-User-Id", userId);
120
+            }
121
+            webRequest.Headers.Add("Xh-Device", "microlecture_pc_t");
122
+            webRequest.Headers.Add("Xh-Version", version);
123
+        }
124
+
125
+        ///  <summary>
126
+        /// 调用Post接口
127
+        ///  </summary>
128
+        ///  <returns></returns>
129
+        public static string PostStr(string url, string postData)
130
+        {
131
+            Stream responseStream = null;
132
+            try
133
+            {
134
+                Encoding encoding = Encoding.UTF8;
135
+                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
136
+                webRequest.Method = "POST";
137
+                webRequest.Accept = "text/html,application/xhtml+xml,*/*";
138
+                webRequest.ContentType = "application/json";
139
+                string aesPostData = postData;
140
+                if (isSt)
141
+                {
142
+                    aesPostData = AesHelper.AesEncrypt(postData, "XINGHUOLIAOYUAN7");
143
+                }
144
+                AddHeader(webRequest);
145
+                byte[] buffer = encoding.GetBytes(aesPostData);
146
+                webRequest.ContentLength = buffer.Length;
147
+                webRequest.GetRequestStream()
148
+                .Write
149
+                (
150
+                    buffer,
151
+                    0,
152
+                    buffer.Length
153
+                );
154
+                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
155
+                isSt = webResponse.GetResponseHeader("Xh-St") == "true";
156
+                responseStream = webResponse.GetResponseStream();
157
+                if (responseStream == null) { return ""; }
158
+                using (StreamReader reader = new StreamReader(responseStream, Encoding.UTF8))
159
+                {
160
+                    return reader.ReadToEnd();
161
+                }
162
+            }
163
+            catch (Exception)
164
+            {
165
+                return "";
166
+            }
167
+            finally
168
+            {
169
+                if (responseStream != null)
170
+                {
171
+                    responseStream.Dispose();
172
+                }
173
+            }
174
+        }
175
+
176
+        /// <summary>
177
+        /// Post Http请求
178
+        /// </summary>
179
+        /// <param name="url">请求地址</param>
180
+        /// <param name="postData">传输数据</param>
181
+        /// <param name="timeout">超时时间</param>
182
+        /// <param name="contentType">媒体格式</param>
183
+        /// <param name="encode">编码</param>
184
+        /// <returns>泛型集合</returns>
185
+        public static T PostSignle<T>
186
+        (
187
+            string url,
188
+            int timeout = 5000,
189
+            string postData = "",
190
+            string contentType = "application/json;",
191
+            string encode = "UTF-8"
192
+        ) where T : class
193
+        {
194
+            if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(encode) && !string.IsNullOrEmpty(contentType) && postData != null)
195
+            {
196
+                try
197
+                {
198
+                    string respstr = PostStr(url, postData);
199
+                    return JsonHelper.JsonToObj<T>(respstr);
200
+                }
201
+                catch (Exception)
202
+                {
203
+                    // ignored
204
+                }
205
+            }
206
+            return default;
207
+        }
208
+
209
+        /// <summary>
210
+        /// Cookie
211
+        /// </summary>
212
+        public static CookieContainer cc = new CookieContainer();
213
+
214
+        /// <summary>
215
+        /// Post请求
216
+        /// </summary>
217
+        /// <param name="serviceaddress">请求地址</param>
218
+        /// <param name="contenttype">头 application/x-www-form-urlencoded</param>
219
+        /// <param name="strcontent">参数</param>
220
+        /// <param name="header">token</param>
221
+        /// <param name="timeout"></param>
222
+        /// <returns></returns>
223
+        public static JObject PostFunction
224
+        (
225
+            string serviceaddress,
226
+            string contenttype,
227
+            string strcontent,
228
+            string header,
229
+            int timeout = 5000
230
+        )
231
+        {
232
+            try
233
+            {
234
+                string serviceAddress = serviceaddress;
235
+                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);
236
+                WebHeaderCollection myWebHeaderCollection = request.Headers;
237
+
238
+                request.CookieContainer = cc;
239
+                //myWebHeaderCollection.Add("Accept", "*/*");
240
+                if (header != "")
241
+                {
242
+                    myWebHeaderCollection.Add("access_token:" + header);
243
+                }
244
+                request.Timeout = timeout;
245
+                request.Method = "POST";
246
+                request.ContentType = contenttype;
247
+                using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
248
+                {
249
+                    dataStream.Write(strcontent);
250
+                    dataStream.Close();
251
+                }
252
+                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
253
+
254
+                string encoding = response.ContentEncoding;
255
+                if (encoding.Length < 1)
256
+                {
257
+                    encoding = "UTF-8"; //默认编码
258
+                }
259
+                // ReSharper disable once AssignNullToNotNullAttribute
260
+                StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
261
+                string retString = reader.ReadToEnd();
262
+                retString = retString.Replace("\\r\\n", "");
263
+
264
+                //解析josn
265
+                JObject jo = JObject.Parse(retString);
266
+                return jo;
267
+            }
268
+            catch (Exception ex)
269
+            {
270
+                LogHelper.WriteErrLog("请求失败(若网络无问题,请重置winsock,解决方法:以管理员方式打开cmd执行 netsh winsock reset 后重启)", ex);
271
+                return null;
272
+            }
273
+        }
274
+
275
+        /// <summary>
276
+        /// HttpWebRequest 下载
277
+        /// </summary>
278
+        /// <param name="url">URI</param>
279
+        /// <param name="filePath"></param>
280
+        /// <param name="header"></param>
281
+        /// <returns></returns>
282
+        public static bool GetDataGetHtml
283
+        (
284
+            string url,
285
+            string filePath,
286
+            string header
287
+        )
288
+        {
289
+            try
290
+            {
291
+                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
292
+
293
+                //httpWebRequest.ContentType = "application/x-www-form-urlencoded";
294
+                httpWebRequest.Method = "GET";
295
+                //httpWebRequest.ContentType = "image/jpeg";
296
+                //对发送的数据不使用缓存
297
+                httpWebRequest.AllowWriteStreamBuffering = false;
298
+                //httpWebRequest.Timeout = 300000;
299
+                httpWebRequest.ServicePoint.Expect100Continue = false;
300
+
301
+                WebHeaderCollection myWebHeaderCollection = httpWebRequest.Headers;
302
+                //myWebHeaderCollection.Add("Accept", "*/*");
303
+                if (header != "")
304
+                {
305
+                    myWebHeaderCollection.Add("access_token:" + header);
306
+                }
307
+
308
+                HttpWebResponse webRespon = (HttpWebResponse)httpWebRequest.GetResponse();
309
+                Stream webStream = webRespon.GetResponseStream();
310
+                if (webStream == null)
311
+                {
312
+                    return false;
313
+                }
314
+                Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
315
+                byte[] bArr = new byte[1024];
316
+                int size = webStream.Read(bArr, 0, bArr.Length);
317
+                while (size > 0)
318
+                {
319
+                    stream.Write(bArr, 0, size);
320
+                    size = webStream.Read(bArr, 0, bArr.Length);
321
+                    //M_DownloadInfo.downloadCount = M_DownloadInfo.downloadCount + 1;
322
+                }
323
+                webRespon.Close();
324
+                stream.Close();
325
+                webStream.Close();
326
+                return true;
327
+            }
328
+            catch (Exception)
329
+            {
330
+                return false;
331
+            }
332
+        }
333
+
334
+        /// <summary>
335
+        /// 上传文件流
336
+        /// 创建人:赵耀
337
+        /// 创建时间:2020年9月5日
338
+        /// </summary>
339
+        /// <param name="url">URL</param>
340
+        /// <param name="databyte">文件数据流</param>
341
+        /// <param name="filename">文件名</param>
342
+        /// <param name="formFields">参数 可不传</param>
343
+        public static JObject UploadRequestflow(string url, byte[] databyte, string filename, NameValueCollection formFields = null)
344
+        {
345
+            // 时间戳,用做boundary
346
+            string boundary = "-----" + DateTime.Now.Ticks.ToString("x");
347
+            byte[] boundarybytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
348
+
349
+            //根据uri创建HttpWebRequest对象
350
+            HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(new Uri(url));
351
+            httpReq.ContentType = "multipart/form-data; boundary=" + boundary;
352
+            httpReq.Method = "POST";
353
+            httpReq.KeepAlive = true;
354
+            //httpReq.Timeout = 300000;
355
+            //httpReq.AllowWriteStreamBuffering = false; //对发送的数据不使用缓存
356
+            httpReq.Credentials = CredentialCache.DefaultCredentials;
357
+            try
358
+            {
359
+                Stream postStream = httpReq.GetRequestStream();
360
+                //参数
361
+                const string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
362
+                if (formFields != null)
363
+                {
364
+                    foreach (string key in formFields.Keys)
365
+                    {
366
+                        postStream.Write
367
+                        (
368
+                            boundarybytes,
369
+                            0,
370
+                            boundarybytes.Length
371
+                        );
372
+                        string formitem = string.Format
373
+                        (
374
+                            formdataTemplate,
375
+                            key,
376
+                            formFields[key]
377
+                        );
378
+                        byte[] formitembytes = Encoding.UTF8.GetBytes(formitem);
379
+                        postStream.Write
380
+                        (
381
+                            formitembytes,
382
+                            0,
383
+                            formitembytes.Length
384
+                        );
385
+                    }
386
+                }
387
+                postStream.Write
388
+                (
389
+                    boundarybytes,
390
+                    0,
391
+                    boundarybytes.Length
392
+                );
393
+                const string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: application/octet-stream\r\n\r\n";
394
+
395
+                //文件头
396
+                string header = string.Format
397
+                (
398
+                    headerTemplate,
399
+                    "file",
400
+                    filename
401
+                );
402
+                byte[] headerbytes = Encoding.UTF8.GetBytes(header);
403
+                postStream.Write
404
+                (
405
+                    headerbytes,
406
+                    0,
407
+                    headerbytes.Length
408
+                );
409
+
410
+                //文件流
411
+                postStream.Write
412
+                (
413
+                    databyte,
414
+                    0,
415
+                    databyte.Length
416
+                );
417
+
418
+                //结束边界
419
+                byte[] boundaryBytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
420
+                postStream.Write
421
+                (
422
+                    boundaryBytes,
423
+                    0,
424
+                    boundaryBytes.Length
425
+                );
426
+                postStream.Close();
427
+
428
+                //获取服务器端的响应
429
+                JObject jobResult = null;
430
+                using (HttpWebResponse response = (HttpWebResponse)httpReq.GetResponse())
431
+                {
432
+                    Stream receiveStream = response.GetResponseStream();
433
+                    if (receiveStream != null)
434
+                    {
435
+                        StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
436
+                        string returnValue = readStream.ReadToEnd();
437
+                        jobResult = JObject.Parse(returnValue);
438
+                        response.Close();
439
+                        readStream.Close();
440
+                    }
441
+                }
442
+                return jobResult;
443
+            }
444
+            catch (Exception ex)
445
+            {
446
+                LogHelper.WriteErrLog("【文件上传】" + ex.Message, ex);
447
+                return null;
448
+            }
449
+        }
450
+
451
+        /// <summary>
452
+        /// 获取公网IP和地址,失败则获取局域网IP
453
+        /// </summary>
454
+        /// <param name="addressIp">IP地址</param>
455
+        /// <param name="address">地址</param>
456
+        /// <returns></returns>
457
+        public static bool GetAddressIp(out string addressIp, out string address)
458
+        {
459
+            addressIp = "";
460
+            address = "";
461
+            try
462
+            {
463
+                //请求搜狐获取公网IP,获取失败后获取局域网IP
464
+                WebRequest request = WebRequest.Create("http://pv.sohu.com/cityjson?ie=utf-8");
465
+                request.Timeout = 10000;
466
+                WebResponse response = request.GetResponse();
467
+                Stream resStream = response.GetResponseStream();
468
+                if (resStream != null)
469
+                {
470
+                    StreamReader sr = new StreamReader(resStream, System.Text.Encoding.UTF8);
471
+                    string htmlinfo = sr.ReadToEnd();
472
+                    string jsonStr = htmlinfo.Substring(htmlinfo.IndexOf("{", StringComparison.Ordinal), htmlinfo.LastIndexOf("}", StringComparison.Ordinal) - htmlinfo.IndexOf("{", StringComparison.Ordinal) + 1);
473
+                    JObject obj = JObject.Parse(jsonStr);
474
+                    addressIp = obj["cip"]?.ToString();
475
+                    address = obj["cname"]?.ToString();
476
+                    resStream.Close();
477
+                    sr.Close();
478
+                }
479
+                return true;
480
+            }
481
+            catch (Exception)
482
+            {
483
+                //获取本地局域网IP
484
+                foreach (System.Net.IPAddress ipAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
485
+                {
486
+                    if (ipAddress.AddressFamily.ToString() == "InterNetwork")
487
+                    {
488
+                        addressIp = ipAddress.ToString();
489
+                    }
490
+                }
491
+                return false;
492
+            }
493
+        }
494
+    }
495
+}

+ 1
- 1
星火微课/星火微课-测试.iss View File

3
 
3
 
4
 #define MyAppName "星火微课测试版"  
4
 #define MyAppName "星火微课测试版"  
5
 #define MyAppDir "xhwk_test"
5
 #define MyAppDir "xhwk_test"
6
-#define MyAppVersion "3.12.0"
6
+#define MyAppVersion "3.13.0"
7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8
 #define MyAppURL "http://www.xhkjedu.com/"
8
 #define MyAppURL "http://www.xhkjedu.com/"
9
 #define MySourcePath "D:\Project\CSharp\xh-wkclient\XHWK.WKTool\bin\x86\Debug\"
9
 #define MySourcePath "D:\Project\CSharp\xh-wkclient\XHWK.WKTool\bin\x86\Debug\"

Loading…
Cancel
Save