Quellcode durchsuchen

接口添加Header

优化接口请求
优化下拉菜单界面
优化窗口界面
优化上传页面
master
张剑 vor 1 Jahr
Ursprung
Commit
6a55350149
33 geänderte Dateien mit 1028 neuen und 1008 gelöschten Zeilen
  1. 13
    18
      XHWK.WKTool/AESHelper.cs
  2. 2
    4
      XHWK.WKTool/App.config
  3. 14
    9
      XHWK.WKTool/App.xaml.cs
  4. 3
    2
      XHWK.WKTool/AppUpdateWin.xaml
  5. 16
    23
      XHWK.WKTool/AppUpdateWin.xaml.cs
  6. 7
    8
      XHWK.WKTool/CreateAMicroLessonWindow.xaml
  7. 13
    18
      XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs
  8. 22
    9
      XHWK.WKTool/DAL/DAL_Upload.cs
  9. 13
    15
      XHWK.WKTool/DAL/XHApi.cs
  10. 16
    22
      XHWK.WKTool/DeviceWindow.xaml
  11. 5
    5
      XHWK.WKTool/DeviceWindow.xaml.cs
  12. 1
    1
      XHWK.WKTool/KeyVerification.xaml.cs
  13. 15
    61
      XHWK.WKTool/LoginWindow.xaml
  14. 17
    28
      XHWK.WKTool/LoginWindow.xaml.cs
  15. 13
    22
      XHWK.WKTool/MainWindow.xaml
  16. 3
    3
      XHWK.WKTool/MainWindow.xaml.cs
  17. 7
    4
      XHWK.WKTool/ProductVerification.xaml.cs
  18. 11
    5
      XHWK.WKTool/Resources/OverwrideDefaultControlStyles.xaml
  19. 133
    0
      XHWK.WKTool/Resources/StyleComboBox.xaml
  20. 5
    5
      XHWK.WKTool/Resources/StyleScrolllview.xaml
  21. 40
    0
      XHWK.WKTool/Resources/StyleZRoundButton.xaml
  22. 5
    8
      XHWK.WKTool/UControl/Uc_VideoItem.xaml
  23. 1
    1
      XHWK.WKTool/UControl/Uc_VideoItem.xaml.cs
  24. 16
    21
      XHWK.WKTool/UploadWindow.xaml
  25. 8
    3
      XHWK.WKTool/UploadWindow.xaml.cs
  26. 81
    0
      XHWK.WKTool/Utils/ZConfigAppUtil.cs
  27. 26
    0
      XHWK.WKTool/View/ZRoundButton.cs
  28. 11
    1
      XHWK.WKTool/XHWK.WKTool.csproj
  29. 8
    4
      XHWK.WKTool/system/DownloadManager.cs
  30. 7
    2
      XHWK.WKTool/system/DownloadService.cs
  31. 0
    705
      XHWK.WKTool/system/HttpHelper.cs
  32. 495
    0
      XHWK.WKTool/system/ZHttpUtil.cs
  33. 1
    1
      星火微课/星火微课-测试.iss

+ 13
- 18
XHWK.WKTool/AESHelper.cs Datei anzeigen

@@ -4,30 +4,25 @@ using System.Text;
4 4
 
5 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 9
         public static string QrcodeLoginKey = "zyyxhlywkdatakey";
15 10
 
16 11
         /// <summary>
17 12
         /// AES 加密
18 13
         /// </summary>
19
-        /// <param name="content">Need encrypted string</param>
14
+        /// <param name="data"></param>
15
+        /// <param name="key"></param>
20 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 19
             if (string.IsNullOrWhiteSpace(key))
24 20
             {
25 21
                 key = QrcodeLoginKey.PadRight(16, '0');
26 22
             }
27 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 26
             RijndaelManaged rDel = new RijndaelManaged
32 27
             {
33 28
                 Key = keyArray,
@@ -46,15 +41,16 @@ namespace Common
46 41
         /// AES 解密
47 42
         /// </summary>
48 43
         /// <param name="hexString">Encrypted 16 hex string</param>
44
+        /// <param name="key"></param>
49 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 48
             if (string.IsNullOrWhiteSpace(key))
53 49
             {
54 50
                 key = QrcodeLoginKey.PadRight(16, '0');
55 51
             }
56 52
             // 256-AES key      
57
-            byte[] keyArray = UTF8Encoding.ASCII.GetBytes(key);
53
+            byte[] keyArray = Encoding.ASCII.GetBytes(key);
58 54
             byte[] toEncryptArray = HexStringToBytes(hexString);
59 55
 
60 56
             RijndaelManaged rDel = new RijndaelManaged
@@ -67,8 +63,7 @@ namespace Common
67 63
             ICryptoTransform cTransform = rDel.CreateDecryptor();
68 64
             byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0,
69 65
                     toEncryptArray.Length);
70
-
71
-            return UTF8Encoding.ASCII.GetString(resultArray);
66
+            return Encoding.ASCII.GetString(resultArray);
72 67
         }
73 68
 
74 69
         /// <summary>
@@ -79,11 +74,11 @@ namespace Common
79 74
         public static string BytesToHexString(byte[] bytes)
80 75
         {
81 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 84
             return returnStr.ToString();

+ 2
- 4
XHWK.WKTool/App.config Datei anzeigen

@@ -6,11 +6,9 @@
6 6
   <appSettings>
7 7
     <!--0正式 1测试-->
8 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 12
     <!--皮肤样式 0白 1蓝 2黑色 -->
15 13
     <add key="SkinStyle" value="0" />
16 14
     <!--是否输出视频记录日志:0否-->

+ 14
- 9
XHWK.WKTool/App.xaml.cs Datei anzeigen

@@ -17,6 +17,7 @@ namespace XHWK.WKTool
17 17
 {
18 18
     using System.Runtime.InteropServices;
19 19
     using system;
20
+    using XHWK.WKTool.Utils;
20 21
 
21 22
     public partial class App
22 23
     {
@@ -29,11 +30,6 @@ namespace XHWK.WKTool
29 30
         /// </summary>
30 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 33
         #endregion 更新需改动
38 34
 
39 35
         #region 接口地址
@@ -316,8 +312,8 @@ namespace XHWK.WKTool
316 312
         {
317 313
             Console.WriteLine(@"初始化APP");
318 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 317
             myloading = new LoadDialog();
322 318
             Killffmpeg();
323 319
             try
@@ -369,7 +365,7 @@ namespace XHWK.WKTool
369 365
                     }
370 366
                     //退出
371 367
                     //Current.Shutdown();
372
-                    Environment.Exit(0);
368
+                    Application.Current.Shutdown();
373 369
                 }
374 370
             }
375 371
             catch (Exception ex)
@@ -405,7 +401,7 @@ namespace XHWK.WKTool
405 401
                 int hWnd = FindWindow(null, process.MainWindowTitle);
406 402
                 SetForegroundWindow(hWnd);
407 403
             }
408
-            Environment.Exit(1); //退出新打开的程序
404
+            Application.Current.Shutdown(); //退出新打开的程序
409 405
         }
410 406
 
411 407
         /// <summary>
@@ -698,5 +694,14 @@ namespace XHWK.WKTool
698 694
             base.OnStartup(e);
699 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 Datei anzeigen

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

+ 16
- 23
XHWK.WKTool/AppUpdateWin.xaml.cs Datei anzeigen

@@ -1,13 +1,10 @@
1 1
 using System;
2
-using System.Diagnostics;
3 2
 using System.IO;
4 3
 using System.Management;
5 4
 using System.Windows;
6 5
 using System.Windows.Input;
7
-
8 6
 using XHWK.Model;
9 7
 using XHWK.WKTool.Helpers;
10
-
11 8
 using static XHWK.WKTool.Helpers.ZJDownloadUtil;
12 9
 
13 10
 namespace XHWK.WKTool
@@ -15,21 +12,15 @@ namespace XHWK.WKTool
15 12
     /// <summary>
16 13
     /// AppUpdateWin.xaml 的交互逻辑
17 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 19
         public AppUpdateWin(Model_App app)
23 20
         {
24 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 26
         private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
@@ -47,21 +38,22 @@ namespace XHWK.WKTool
47 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 44
             string path = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
54 45
             DirectoryInfo info = new DirectoryInfo(path);
55 46
             if (!info.Exists)
56 47
             {
57 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 59
         public void downloadBegin(int position)
@@ -96,14 +88,15 @@ namespace XHWK.WKTool
96 88
                     var result = managementClass.InvokeMethod("Create", inParameters, null);
97 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 95
             catch (Exception)
104 96
             {
97
+                // ignored
105 98
             }
106
-            Environment.Exit(0);
99
+            Application.Current.Shutdown();
107 100
         }
108 101
 
109 102
         public void downloadError(int position, string msg)

+ 7
- 8
XHWK.WKTool/CreateAMicroLessonWindow.xaml Datei anzeigen

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

+ 13
- 18
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs Datei anzeigen

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

@@ -40,8 +40,13 @@ namespace XHWK.WKTool.DAL
40 40
             {
41 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 50
                     if (jo == null)
46 51
                     {
47 52
                         message = "无法访问文件服务器,请检查网络或文件服务器地址。";
@@ -101,9 +106,13 @@ namespace XHWK.WKTool.DAL
101 106
             {
102 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 116
                     if (jo == null)
108 117
                     {
109 118
                         message = "无法访问文件服务器,请检查网络或文件服务器地址。";
@@ -238,8 +247,7 @@ namespace XHWK.WKTool.DAL
238 247
                 {
239 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,8 +340,13 @@ namespace XHWK.WKTool.DAL
332 340
                             //{
333 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 350
                             //0成功,1失败
338 351
                             if (jo["code"]?.ToString() != "0")
339 352
                             {

+ 13
- 15
XHWK.WKTool/DAL/XHApi.cs Datei anzeigen

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

+ 16
- 22
XHWK.WKTool/DeviceWindow.xaml Datei anzeigen

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

+ 5
- 5
XHWK.WKTool/DeviceWindow.xaml.cs Datei anzeigen

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

@@ -162,7 +162,7 @@ namespace XHWK.WKTool
162 162
         private void CloseAction()
163 163
         {
164 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 Datei anzeigen

@@ -3,17 +3,16 @@
3 3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4 4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5 5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
-    xmlns:local="clr-namespace:XHWK.WKTool"
7 6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    xmlns:view="clr-namespace:XHWK.WKTool.View"
8 8
     Title="LoginWindow"
9 9
     Width="312"
10 10
     Height="497"
11
-    AllowsTransparency="True"
12 11
     BorderBrush="#eeeeee"
13
-    BorderThickness="1"
14 12
     ShowInTaskbar="False"
13
+    Style="{StaticResource ZWinStyle}"
15 14
     WindowStartupLocation="CenterOwner"
16
-    WindowStyle="None"
15
+    WindowStyle="SingleBorderWindow"
17 16
     mc:Ignorable="d">
18 17
 
19 18
     <Window.Resources>
@@ -117,12 +116,12 @@
117 116
                             <TextBox
118 117
                                 x:Name="TxbAccountNumber"
119 118
                                 Margin="5,5"
119
+                                AcceptsReturn="False"
120 120
                                 BorderBrush="{x:Null}"
121 121
                                 BorderThickness="0"
122 122
                                 FontSize="14"
123 123
                                 Foreground="#FF999999"
124 124
                                 InputMethod.IsInputMethodEnabled="False"
125
-                                PreviewTextInput="TxbAccountNumberPreviewTextInput"
126 125
                                 Text="" />
127 126
                             <Label Height="1.5" Background="#3F6FFF" />
128 127
                         </StackPanel>
@@ -135,7 +134,7 @@
135 134
                                 FontSize="12"
136 135
                                 Foreground="#FF666666" />
137 136
                             <PasswordBox
138
-                                x:Name="pobPassword"
137
+                                x:Name="PobPassword"
139 138
                                 Margin="5,5"
140 139
                                 BorderBrush="{x:Null}"
141 140
                                 BorderThickness="0"
@@ -144,21 +143,7 @@
144 143
                                 PasswordChar="*" />
145 144
                             <Label Height="1.5" Background="#3F6FFF" />
146 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 147
                     </Grid>
163 148
                     <!--  记住密码 切换网络  -->
164 149
                     <Grid Grid.Row="3">
@@ -197,7 +182,7 @@
197 182
                             <RowDefinition Height="25*" />
198 183
                             <RowDefinition Height="5*" />
199 184
                         </Grid.RowDefinitions>
200
-                        <Button
185
+                        <view:ZRoundButton
201 186
                             x:Name="BtnStart"
202 187
                             Grid.Row="1"
203 188
                             Grid.ColumnSpan="2"
@@ -205,29 +190,14 @@
205 190
                             VerticalAlignment="Stretch"
206 191
                             HorizontalContentAlignment="Center"
207 192
                             VerticalContentAlignment="Center"
208
-                            Click="BtnStart_Click"
193
+                            Background="#3F6FFF"
194
+                            BorderRadius="18"
195
+                            Click="LoginClick"
209 196
                             Content="登录"
210
-                            Cursor="Hand"
211 197
                             FontSize="18"
212 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 201
                             x:Name="BtnStop"
232 202
                             Grid.Row="3"
233 203
                             Grid.ColumnSpan="2"
@@ -237,28 +207,14 @@
237 207
                             VerticalAlignment="Stretch"
238 208
                             HorizontalContentAlignment="Center"
239 209
                             VerticalContentAlignment="Center"
210
+                            Background="#FFC3C3C3"
211
+                            BorderRadius="18"
240 212
                             Click="BtnDown_Click"
241 213
                             Content="关闭"
242 214
                             Cursor="Hand"
243 215
                             FontSize="18"
244 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 219
                         <Button
264 220
                             x:Name="BtnServiceAddress"
@@ -274,7 +230,6 @@
274 230
                                     <Grid>
275 231
                                         <Label
276 232
                                             x:Name="Word"
277
-                                            Grid.Column="1"
278 233
                                             HorizontalAlignment="Center"
279 234
                                             VerticalAlignment="Center"
280 235
                                             Content="服务地址设置"
@@ -347,7 +302,6 @@
347 302
                                 FontSize="12"
348 303
                                 Foreground="#FF666666" />
349 304
                             <StackPanel
350
-                                Grid.Row="6"
351 305
                                 Margin="0,10,0,0"
352 306
                                 HorizontalAlignment="Left"
353 307
                                 Orientation="Horizontal">

+ 17
- 28
XHWK.WKTool/LoginWindow.xaml.cs Datei anzeigen

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

@@ -4,6 +4,7 @@
4 4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5 5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6 6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    xmlns:view="clr-namespace:XHWK.WKTool.View"
7 8
     Title="星火微课系统"
8 9
     Width="950"
9 10
     Height="700"
@@ -293,8 +294,7 @@
293 294
                                     </Grid>
294 295
                                     <ControlTemplate.Triggers>
295 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 298
                                             <Setter TargetName="Word" Property="Foreground" Value="#FFFFFFFF" />
299 299
                                         </Trigger>
300 300
                                     </ControlTemplate.Triggers>
@@ -333,7 +333,7 @@
333 333
                         <!--  头像  -->
334 334
                         <Grid Grid.Row="0">
335 335
                             <!--  登录状态  -->
336
-                            <Button
336
+                            <view:ZRoundButton
337 337
                                 x:Name="BtnLoginType"
338 338
                                 HorizontalAlignment="Center"
339 339
                                 VerticalAlignment="Center"
@@ -367,7 +367,7 @@
367 367
                                         Style="{DynamicResource LoginTypeColor}"
368 368
                                         Text="未登录" />
369 369
                                 </StackPanel>
370
-                            </Button>
370
+                            </view:ZRoundButton>
371 371
                         </Grid>
372 372
                         <!--  录屏  -->
373 373
                         <Grid Grid.Row="1">
@@ -496,20 +496,15 @@
496 496
                                         </Grid>
497 497
                                         <ControlTemplate.Triggers>
498 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 500
                                             </Trigger>
502 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 504
                                             </Trigger>
508 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 508
                                             </Trigger>
514 509
                                         </ControlTemplate.Triggers>
515 510
                                     </ControlTemplate>
@@ -1040,13 +1035,11 @@
1040 1035
                                                 <Button.Template>
1041 1036
                                                     <ControlTemplate TargetType="{x:Type Button}">
1042 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 1039
                                                         </StackPanel>
1046 1040
                                                         <ControlTemplate.Triggers>
1047 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 1043
                                                             </Trigger>
1051 1044
                                                         </ControlTemplate.Triggers>
1052 1045
                                                     </ControlTemplate>
@@ -1072,13 +1065,11 @@
1072 1065
                                                 <Button.Template>
1073 1066
                                                     <ControlTemplate TargetType="{x:Type Button}">
1074 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 1069
                                                         </StackPanel>
1078 1070
                                                         <ControlTemplate.Triggers>
1079 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 1073
                                                             </Trigger>
1083 1074
                                                         </ControlTemplate.Triggers>
1084 1075
                                                     </ControlTemplate>

+ 3
- 3
XHWK.WKTool/MainWindow.xaml.cs Datei anzeigen

@@ -744,7 +744,7 @@ namespace XHWK.WKTool
744 744
                         App.SaveWkData();
745 745
                         App.SaveDraw();
746 746
                         _tmc.TmatrixUninitialize();
747
-                        Environment.Exit(0);
747
+                        Application.Current.Shutdown();
748 748
                     }
749 749
                 }
750 750
                 catch (Exception ex)
@@ -753,7 +753,7 @@ namespace XHWK.WKTool
753 753
                     Close();
754 754
                     Application.Current.Shutdown();
755 755
                     _tmc.TmatrixUninitialize();
756
-                    Environment.Exit(0);
756
+                    Application.Current.Shutdown();
757 757
                 }
758 758
             }
759 759
             else
@@ -4102,7 +4102,7 @@ namespace XHWK.WKTool
4102 4102
 
4103 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 Datei anzeigen

@@ -142,10 +142,13 @@ namespace XHWK.WKTool
142 142
         /// </summary>
143 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 154
         ~ProductVerification()

+ 11
- 5
XHWK.WKTool/Resources/OverwrideDefaultControlStyles.xaml Datei anzeigen

@@ -1,13 +1,18 @@
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 6
     <ResourceDictionary.MergedDictionaries>
4 7
         <ResourceDictionary Source="pack://application:,,,/Resources/StyleScrolllview.xaml" />
5 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 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 16
     <Style BasedOn="{StaticResource MyButton}" TargetType="Button" />
12 17
 
13 18
     <Style x:Key="ZWinStyle" TargetType="Window">
@@ -33,4 +38,5 @@
33 38
             </Trigger>
34 39
         </Style.Triggers>
35 40
     </Style>
36
-</ResourceDictionary>
41
+
42
+</ResourceDictionary>

+ 133
- 0
XHWK.WKTool/Resources/StyleComboBox.xaml Datei anzeigen

@@ -0,0 +1,133 @@
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 Datei anzeigen

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

+ 40
- 0
XHWK.WKTool/Resources/StyleZRoundButton.xaml Datei anzeigen

@@ -0,0 +1,40 @@
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 Datei anzeigen

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

+ 1
- 1
XHWK.WKTool/UControl/Uc_VideoItem.xaml.cs Datei anzeigen

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

+ 16
- 21
XHWK.WKTool/UploadWindow.xaml Datei anzeigen

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

+ 8
- 3
XHWK.WKTool/UploadWindow.xaml.cs Datei anzeigen

@@ -232,6 +232,10 @@ namespace XHWK.WKTool
232 232
 
233 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 241
         /// <summary>
@@ -393,13 +397,13 @@ namespace XHWK.WKTool
393 397
                                 _times.Stop();
394 398
                                 pgbProcess.Value = 100;
395 399
                                 lbProcess.Content = "100%";
396
-                                MessageWindow.Show("视频上传成功!");
400
+                                Hide();
397 401
                                 tip_outer.Visibility = Visibility.Collapsed;
402
+                                MessageWindow.Show("视频上传成功!");
398 403
                                 if (ChangeTextEvents != null)
399 404
                                 {
400 405
                                     ChangeTextEvents("上传成功", _i);
401 406
                                 }
402
-                                Hide();
403 407
                             }
404 408
                         );
405 409
                     }
@@ -466,10 +470,11 @@ namespace XHWK.WKTool
466 470
             Dispatcher.Invoke(() =>
467 471
             {
468 472
                 pgbProcess.Value = _num;
469
-                lbProcess.Content = _num.ToString() + "%";
473
+                lbProcess.Content = _num + "%";
470 474
                 if (_num < 99)
471 475
                 {
472 476
                     _num++;
477
+                    // ReSharper disable once PossibleLossOfFraction
473 478
                     _times.Interval += _num / 2;
474 479
                 }
475 480
                 else

+ 81
- 0
XHWK.WKTool/Utils/ZConfigAppUtil.cs Datei anzeigen

@@ -0,0 +1,81 @@
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 Datei anzeigen

@@ -0,0 +1,26 @@
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 Datei anzeigen

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

+ 8
- 4
XHWK.WKTool/system/DownloadManager.cs Datei anzeigen

@@ -102,9 +102,14 @@ namespace Common.system
102 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 113
                             //获取文件名,如果包含附件名称则取下附件,否则从url获取名称
109 114
                             string Disposition = rsp.Headers["Content-Disposition"];
110 115
                             try
@@ -118,7 +123,7 @@ namespace Common.system
118 123
                                     dlInfo.fileName = Path.GetFileName(rsp.ResponseUri.AbsolutePath);
119 124
                                 }
120 125
                             }
121
-                            catch (Exception)//无法获取文件名时  使用传入保存名称
126
+                            catch (Exception) //无法获取文件名时  使用传入保存名称
122 127
                             {
123 128
                                 dlInfo.fileName = dlInfo.saveFileName;
124 129
                             }
@@ -140,7 +145,6 @@ namespace Common.system
140 145
                                 ///创建线程信息
141 146
                                 ///
142 147
                                 GetTaskInfo(dlInfo);
143
-
144 148
                             }
145 149
                             else
146 150
                             {

+ 7
- 2
XHWK.WKTool/system/DownloadService.cs Datei anzeigen

@@ -109,10 +109,15 @@ namespace Common.system
109 109
                     {
110 110
                         to = fromIndex + size;
111 111
                     }
112
-
113 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 122
                             Save(filePath, rsp.GetResponseStream());
118 123
                         }

+ 0
- 705
XHWK.WKTool/system/HttpHelper.cs Datei anzeigen

@@ -1,705 +0,0 @@
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 Datei anzeigen

@@ -0,0 +1,495 @@
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 Datei anzeigen

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

Laden…
Abbrechen
Speichern