Browse Source

Socket

ZhangXueYang
zhangxueyang 3 years ago
parent
commit
220a30bdd3

+ 52
- 1
Common/system/DataProvider.cs View File

@@ -1,4 +1,6 @@
1
-using System;
1
+using Newtonsoft.Json;
2
+using System;
3
+using System.Collections.Generic;
2 4
 using System.IO;
3 5
 using System.Security.Cryptography;
4 6
 using System.Text;
@@ -44,5 +46,54 @@ namespace Common.system
44 46
             long timestr = Convert.ToInt64(ts.TotalSeconds);
45 47
             return timestr;
46 48
         }
49
+        /// <summary>
50
+        /// 将字典类型序列化为json字符串
51
+        /// </summary>
52
+        /// <typeparam name="TKey">字典key</typeparam>
53
+        /// <typeparam name="TValue">字典value</typeparam>
54
+        /// <param name="dict">要序列化的字典数据</param>
55
+        /// <returns>json字符串</returns>
56
+        public static string SerializeDictionaryToJsonString<TKey, TValue>(Dictionary<TKey, TValue> dict)
57
+        {
58
+            if (dict.Count == 0)
59
+            {
60
+                return "";
61
+            }
62
+
63
+            string jsonStr = JsonConvert.SerializeObject(dict);
64
+            return jsonStr;
65
+        }
66
+        /// <summary>
67
+        ///调用Post接口
68
+        /// </summary>
69
+        /// <param name="request"></param>
70
+        /// <returns></returns>
71
+        public static string HttpPost(string body, string Url)
72
+        {
73
+            try
74
+            {
75
+                Encoding encoding = Encoding.UTF8;
76
+
77
+                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
78
+                request.Method = "POST";
79
+                request.Accept = "text/html,application/xhtml+xml,*/*";
80
+                request.ContentType = "application/json";
81
+
82
+                byte[] buffer = encoding.GetBytes(body);
83
+                request.ContentLength = buffer.Length;
84
+                request.GetRequestStream().Write(buffer, 0, buffer.Length);
85
+
86
+                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
87
+                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
88
+                {
89
+                    return reader.ReadToEnd();
90
+                }
91
+            }
92
+            catch (Exception ex)
93
+            {
94
+                // LogHelper.Instance.Debug($"POST接口连接失败,请求参数:{ex.Message}");
95
+                return "POST报错:" + ex.Message;
96
+            }
97
+        }
47 98
     }
48 99
 }

+ 15
- 3
XHZB.Desktop/App.config View File

@@ -1,4 +1,4 @@
1
-<?xml version="1.0" encoding="utf-8" ?>
1
+<?xml version="1.0" encoding="utf-8"?>
2 2
 <configuration>
3 3
     <startup> 
4 4
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
@@ -7,7 +7,7 @@
7 7
     <!--0正式 1测试-->
8 8
     <add key="IsDebug" value="1" />
9 9
     <!--是否输出信息日志0否-->
10
-    <add key="OutputVideoLog" value="0"/>
10
+    <add key="OutputVideoLog" value="0" />
11 11
     <!--版本号-->
12 12
     <add key="VersionCode" value="1" />
13 13
     <add key="VersionName" value="1.0.1" />
@@ -17,7 +17,7 @@
17 17
     <add key="password" value="" />
18 18
     <add key="isRemind" value="" />
19 19
     <!--流媒体服务器地址-->
20
-    <add key="ServerPath" value="live2.xhkjedu.com"/>
20
+    <add key="ServerPath" value="live2.xhkjedu.com" />
21 21
     <!--API请求地址-->
22 22
     <add key="APIRequestAddress" value="http://schoolapi.xhkjedu.com" />
23 23
     <!--文件平台请求地址-->
@@ -27,4 +27,16 @@
27 27
     <!--认证请求地址-->
28 28
     <add key="CertapiRequestAddress" value="http://certapi.xhkjedu.com" />
29 29
   </appSettings>
30
+  <runtime>
31
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
32
+      <dependentAssembly>
33
+        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
34
+        <bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0" />
35
+      </dependentAssembly>
36
+      <dependentAssembly>
37
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
38
+        <bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
39
+      </dependentAssembly>
40
+    </assemblyBinding>
41
+  </runtime>
30 42
 </configuration>

+ 19
- 0
XHZB.Desktop/App.cs View File

@@ -54,6 +54,9 @@ namespace XHZB.Desktop
54 54
         /// 数据存放目录
55 55
         /// </summary>
56 56
         public static string dataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XHZB\\";
57
+        public static string basePath = AppDomain.CurrentDomain.BaseDirectory;
58
+        //缓存图片地址
59
+        public static string tempPath = basePath + "temp\\";
57 60
         /// <summary>
58 61
         /// 签名
59 62
         /// </summary>
@@ -203,6 +206,22 @@ namespace XHZB.Desktop
203 206
             }
204 207
             set => _ClassStudentList = value;
205 208
         }
209
+        private static ResourceMyListModel _ResourceMyList;
210
+        /// <summary>
211
+        /// 我的备课列表 出参
212
+        /// </summary>
213
+        public static ResourceMyListModel ResourceMyList
214
+        {
215
+            get
216
+            {
217
+                if (_ResourceMyList == null)
218
+                {
219
+                    _ResourceMyList = new ResourceMyListModel();
220
+                }
221
+                return _ResourceMyList;
222
+            }
223
+            set => _ResourceMyList = value;
224
+        }
206 225
         #region 页面
207 226
         public static LoadDialog myloading;
208 227
         /// <summary>

+ 5
- 168
XHZB.Desktop/AttendanceWindow.xaml.cs View File

@@ -6,6 +6,7 @@ using System.Windows;
6 6
 using System.Windows.Input;
7 7
 using System.Windows.Threading;
8 8
 using XHZB.Desktop.Utils;
9
+using XHZB.Desktop.WebSocket;
9 10
 using XHZB.Model;
10 11
 
11 12
 namespace XHZB.Desktop
@@ -13,7 +14,7 @@ namespace XHZB.Desktop
13 14
     /// <summary>
14 15
     /// 考勤统计
15 16
     /// </summary>
16
-    public partial class AttendanceWindow : Window/*, ZSocketCallback*/
17
+    public partial class AttendanceWindow : Window, SocketCallback
17 18
     {
18 19
         #region 字段
19 20
 
@@ -38,28 +39,15 @@ namespace XHZB.Desktop
38 39
         }
39 40
 
40 41
         /// <summary>
41
-        /// 初始化 修改人:赵耀 修改时间:2020年8月11日
42
+        /// 初始化 
42 43
         /// </summary>
43 44
         public void Initialize()
44 45
         {
45
-            //try
46
-            //{
47
-            //    GetAddressIP();
48
-            //}
49
-            //catch (Exception ex)
50
-            //{
51
-
52
-            //    LogHelper.WriteErrLog("【AttendanceWindow】(Initialize)" + ex.Message, ex);
53
-            //}
54 46
             pageData = new ToolbarAttendenceModel();
55 47
             int onlineUsersnum = APP.ClassStudentList.Count;
56 48
             txbTotalPeople.Text = onlineUsersnum.ToString();
57 49
             renderView();
58
-            //ZSocketServer.getInstance().addWin(this);
59
-            //if (gridImg.Visibility == Visibility.Visible)
60
-            //{
61
-            //    gridImg.Visibility = Visibility.Collapsed;
62
-            //}
50
+            SocketClient.getInstance().addWin(this);
63 51
             DataContext = pageData;
64 52
         }
65 53
 
@@ -116,27 +104,13 @@ namespace XHZB.Desktop
116 104
             if (APP.OnlineUserList.Count > 0)
117 105
             {
118 106
                 var userList = APP.OnlineUserList.ToArray();
119
-
120 107
                 string userlistStr = JsonHelper.ToJson(userList);
121 108
                 List<OnlineUserModel> userListNew = ZCache.JsonToList<OnlineUserModel>(userlistStr);
122
-
123 109
                 List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
124
-       
125
-                //if (APP.outputInforLog)
126
-                //{//OrderbyDescending  倒叙    OrderBy 顺序
127
-                //    userListNew = userListNew.OrderBy(x => x.userid).ToList();
128
-                //}
129 110
                 for (int i = 0; i < classStudentList.Count; i++)
130 111
                 {
131 112
                     classStudentList[i].status = 0;
132 113
                 }
133
-
134
-
135
-                //if (userListNew.Count > 1)
136
-                //{
137
-                //    userListNew[1] = null;
138
-                //}
139
-                //userListNew[0] = null;
140 114
                 foreach (OnlineUserModel user in userListNew)
141 115
                 {
142 116
                     if (user != null)
@@ -202,7 +176,6 @@ namespace XHZB.Desktop
202 176
             else
203 177
             {
204 178
                 List<ClassStudentListModel> classStudentList = APP.ClassStudentList;
205
-                //userListNew.Sort();
206 179
 
207 180
                 for (int i = 0; i < classStudentList.Count; i++)
208 181
                 {
@@ -235,148 +208,12 @@ namespace XHZB.Desktop
235 208
 
236 209
         private void Window_Unloaded(object sender, RoutedEventArgs e)
237 210
         {
238
-            //ZSocketServer.getInstance().removedWin(this);
211
+            SocketClient.getInstance().removedWin(this);
239 212
         }
240 213
 
241 214
         private void Window_Closed(object sender, EventArgs e)
242 215
         {
243 216
         }
244
-
245
-        public void Dispose()
246
-        {
247
-            Dispose(true);
248
-            GC.SuppressFinalize(this);
249
-        }
250
-        protected virtual void Dispose(bool disposing)
251
-        {
252
-            if (!m_disposed)
253
-            {
254
-                if (disposing)
255
-                {
256
-                    //Release managed resources
257
-                }
258
-                //Release unmanaged resources
259
-                m_disposed = true;
260
-            }
261
-        }
262
-
263
-        //C#的Finalize()方法
264
-        ~AttendanceWindow()
265
-        {
266
-            Dispose(false);
267
-        }
268
-
269
-        private bool m_disposed;
270
-        /// <summary>
271
-        /// 二维码
272
-        /// </summary>
273
-        /// <param name="sender"></param>
274
-        /// <param name="e"></param>
275
-        private void Button_Click(object sender, RoutedEventArgs e)
276
-        {
277
-            try
278
-            {
279
-                if (gridImg.Visibility == Visibility.Visible)
280
-                {
281
-                    gridImg.Visibility = Visibility.Collapsed;
282
-                }
283
-                else
284
-                {
285
-                    gridImg.Visibility = Visibility.Visible;
286
-                }
287
-            }
288
-            catch (Exception ex)
289
-            {
290
-
291
-                LogHelper.WriteErrLog("【AttendanceWindow】" + ex.Message, ex);
292
-            }
293
-
294
-        }
295
-        /// <summary>
296
-        /// 获取文件的绝对路径
297
-        /// </summary>
298
-        /// <param name="Path">相对路径</param>
299
-        /// <returns></returns>
300
-        public string GetFileAbsolutePath(string Path = "")
301
-        {
302
-            try
303
-            {
304
-                if (!string.IsNullOrWhiteSpace(Path))
305
-                {
306
-                    Path = Path.Replace("\\", "/");
307
-                    if (Path != "/")
308
-                    {
309
-                        if (Path.Substring(1, 1) == ":")
310
-                            return Path;
311
-                        if (Path.Substring(0, 1) != "/")
312
-                            Path = "/" + Path;
313
-                    }
314
-                }
315
-                string AbsolutePath = System.Windows.Forms.Application.StartupPath.ToString().Replace("\\", "/") + Path;
316
-                return AbsolutePath;
317
-            }
318
-            catch (Exception)
319
-            {
320
-                return Path;
321
-            }
322
-        }
323
-        //private void CreateQR(int pixelsPerModule, string info, System.Drawing.Color qrColor, System.Drawing.Color qrBackgroundColor, int iconSizePercent = 15, int iconBorderWidth = 6)
324
-        //{
325
-        //    try
326
-        //    {
327
-        //        gridImg.Visibility = Visibility.Visible;
328
-        //        QRCodeGenerator qrGenerator = new QRCodeGenerator();
329
-        //        QRCodeData qrCodeData = qrGenerator.CreateQrCode(info, QRCodeGenerator.ECCLevel.Q);
330
-        //        QRCode qrCode = new QRCode(qrCodeData);
331
-        //        //Bitmap qrCodeImage = qrCode.GetGraphic(pixelsPerModule, qrColor, qrBackgroundColor, logo, iconSizePercent, iconBorderWidth, true);
332
-        //        Bitmap qrCodeImage = qrCode.GetGraphic(pixelsPerModule, qrColor, qrBackgroundColor, true);
333
-
334
-        //        IntPtr hBitmap = qrCodeImage.GetHbitmap();
335
-        //        ImageSource wpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
336
-        //            hBitmap,
337
-        //            IntPtr.Zero,
338
-        //            Int32Rect.Empty,
339
-        //            BitmapSizeOptions.FromEmptyOptions());
340
-
341
-        //        img.Source = wpfBitmap;
342
-        //    }
343
-        //    catch (Exception ex)
344
-        //    {
345
-        //        LogHelper.WriteErrLog("【AttendanceWindow】(CreateQR)" + ex.Message, ex);
346
-        //    }
347
-
348
-        //}
349
-        //string localIp = string.Empty;
350
-        ///// <summary>
351
-        ///// 获取本地IP地址信息
352
-        ///// </summary>
353
-        //void GetAddressIP()
354
-        //{
355
-        //    try
356
-        //    {
357
-        //        ///获取本地的IP地址
358
-        //        string AddressIP = string.Empty;
359
-        //        foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
360
-        //        {
361
-        //            if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
362
-        //            {
363
-        //                AddressIP = _IPAddress.ToString();
364
-        //            }
365
-        //        }
366
-        //        txtLocalIP.Text = AddressIP + ":10077";
367
-        //        if (!string.IsNullOrWhiteSpace(txtLocalIP.Text) && !txtLocalIP.Text.Equals(localIp))
368
-        //        {
369
-        //            localIp = txtLocalIP.Text;
370
-        //            CreateQR(100, txtLocalIP.Text, System.Drawing.Color.Black, System.Drawing.Color.White);
371
-        //        }
372
-        //    }
373
-        //    catch (Exception ex)
374
-        //    {
375
-
376
-        //        LogHelper.WriteErrLog("【AttendanceWindow】" + ex.Message, ex);
377
-        //    }
378
-
379
-        //}
380 217
     }
381 218
 
382 219
     #region 动态数据集合

+ 16
- 0
XHZB.Desktop/ToolbarWindow.xaml.cs View File

@@ -90,6 +90,12 @@ namespace XHZB.Desktop
90 90
             });
91 91
 
92 92
             DataContext = pageData;
93
+
94
+            Thread t = new Thread(new ThreadStart(startSocket))
95
+            {
96
+                IsBackground = true
97
+            };
98
+            t.Start();
93 99
         }
94 100
         #endregion
95 101
 
@@ -792,6 +798,16 @@ namespace XHZB.Desktop
792 798
             }
793 799
         }
794 800
         #endregion
801
+
802
+        #region 方法
803
+        /// <summary>
804
+        /// 启动WS
805
+        /// </summary>
806
+        private void startSocket()
807
+        {
808
+            //ZSocketServer.getInstance().startWsServer();
809
+        }
810
+        #endregion
795 811
     }
796 812
     /// <summary>
797 813
     /// 工具栏模型

+ 881
- 28
XHZB.Desktop/UserCenterWindow.xaml.cs View File

@@ -1,97 +1,950 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Threading.Tasks;
1
+using Common.system;
2
+
3
+
4
+using System;
5
+using System.Collections.ObjectModel;
6
+using System.ComponentModel;
7
+using System.Data;
8
+using System.Diagnostics;
9
+using System.IO;
10
+using System.Threading;
6 11
 using System.Windows;
7 12
 using System.Windows.Controls;
8
-using System.Windows.Data;
9
-using System.Windows.Documents;
10 13
 using System.Windows.Input;
11 14
 using System.Windows.Media;
12
-using System.Windows.Media.Imaging;
13
-using System.Windows.Shapes;
15
+
16
+
17
+using XHZB.Desktop.Utils;
18
+using XHZB.Model;
19
+
14 20
 
15 21
 namespace XHZB.Desktop
16 22
 {
17 23
     /// <summary>
18
-    /// UserCenterWindow.xaml 的交互逻辑
24
+    /// 个人空间 LessonPreparationWindow.xaml 的交互逻辑
19 25
     /// </summary>
20
-    public partial class UserCenterWindow : Window
26
+    public partial class UserCenterWindow : Window, DownloadUtil.DownloadCallback
21 27
     {
28
+        private int serverReturnCode = 0;
29
+        private readonly RegisterController registerController = new RegisterController();
30
+        internal UserCenterPageData pageData = new UserCenterPageData();
31
+        private bool isInitial = false;
32
+        private Thread thread;
33
+        private bool initialization = true;
34
+        /// <summary>
35
+        /// 下拉框数据源
36
+        /// </summary>
37
+        public DataTable data = new DataTable();
38
+        /// <summary>
39
+        /// 是否是下载状态 默认false 不是
40
+        /// </summary>
41
+        private bool isDownloadStatus = false;
42
+        /// <summary>
43
+        /// 教材关系表id
44
+        /// </summary>
45
+        private int Lsbid = 0;
46
+        /// <summary>
47
+        /// 章节id
48
+        /// </summary>
49
+        private int Directorid = 0;
50
+        /// <summary>
51
+        /// 资源分类1音频2视频3图片4文档
52
+        /// </summary>
53
+        private int Resourceclass = 0;
54
+        /// <summary>
55
+        /// 个人空间
56
+        /// </summary>
22 57
         public UserCenterWindow()
23 58
         {
24 59
             InitializeComponent();
60
+            DataContext = pageData;
61
+            //初始化配置文件
62
+            //ZJConfigUtil.init();
63
+            isInitial = true;
64
+            Resourceclass = 0;
65
+            Lsbid = APP.REQStartClass.lsbid;
66
+            Directorid = APP.REQStartClass.directorid;
67
+            borAll.Background = new SolidColorBrush(Colors.DodgerBlue);
68
+            borAudio.Background = new SolidColorBrush(Colors.Transparent);
69
+            borVideo.Background = new SolidColorBrush(Colors.Transparent);
70
+            borImage.Background = new SolidColorBrush(Colors.Transparent);
71
+            borDoc.Background = new SolidColorBrush(Colors.Transparent);
72
+            btnAll.Foreground = new SolidColorBrush(Colors.White);
73
+            btnAudio.Foreground = new SolidColorBrush(Colors.Black);
74
+            btnVideo.Foreground = new SolidColorBrush(Colors.Black);
75
+            btnImage.Foreground = new SolidColorBrush(Colors.Black);
76
+            btnDoc.Foreground = new SolidColorBrush(Colors.Black);
77
+            initJiaocai();
25 78
         }
26 79
 
27
-        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
80
+        private void initJiaocai()
28 81
         {
82
+            System.Collections.Generic.List<TsubjectbookListModel> list = APP.TsubjectbookList;
83
+            int selectIndex = 0;
84
+            for (int i = 0; i < list.Count; i++)
85
+            {
86
+                TsubjectbookListModel book = list[i];
87
+                if (book.lsbid == APP.lsbid)
88
+                {
89
+                    selectIndex = i;
90
+                }
91
+                pageData.bookList.Add(new ComboBoxBeanModel()
92
+                {
93
+                    Key = book.lsbid,
94
+                    Value = $"{book.subjectname}  {book.bookname}"
95
+                });
96
+            }
97
+            cmbClass.SelectedIndex = selectIndex;
98
+        }
99
+        /// <summary>
100
+        /// 章节列表服务-调用
101
+        /// </summary>
102
+        /// <returns></returns>
103
+        private object InvokeDirectorListServering()
104
+        {
105
+            APP.DirectorList = null;
106
+            serverReturnCode = registerController.DirectorList(Lsbid,2,APP.LoginUser.userid);
107
+            return APP.ErrorMessage;
108
+        }
29 109
 
110
+        /// <summary>
111
+        /// 章节列表服务-返回结果
112
+        /// </summary>
113
+        /// <returns></returns>
114
+        public void InvokeServerDirectorListCompate(object obj)
115
+        {
116
+            if (serverReturnCode == APP.ServerScuessCode)
117
+            {
118
+                if (!isInitial)
119
+                {
120
+                    Directorid = 0;
121
+                    isInitial = false;
122
+                }
123
+                pageData.zhangjieList.Clear();
124
+
125
+                pageData.zhangjieList.Add(new ChapterModel()
126
+                {
127
+                    directorid = 0,
128
+                    directorname = "全部",
129
+                    level = 1,
130
+                    selected = 0
131
+                });
132
+                System.Collections.Generic.List<DirectorListModel> list = APP.DirectorList;
133
+
134
+                for (int i = 0; i < list.Count; i++)
135
+                {
136
+                    DirectorListModel item = APP.DirectorList[i];
137
+
138
+                    pageData.zhangjieList.Add(new ChapterModel()
139
+                    {
140
+                        directorid = item.directorid,
141
+                        directorname = item.directorname,
142
+                        level = item.directorlevel,
143
+                        selected = 0
144
+                    });
145
+                    addChild(item);
146
+                }
147
+                foreach (ChapterModel zhangjie in pageData.zhangjieList)
148
+                {
149
+                    if (Directorid == zhangjie.directorid)
150
+                    {
151
+                        zhangjie.selected = 1;
152
+                    }
153
+                    else
154
+                    {
155
+                        zhangjie.selected = 0;
156
+                    }
157
+                }
158
+                APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
159
+            }
160
+            else
161
+            {
162
+                MessageWindow.Show(APP.ErrorMessage);
163
+            }
30 164
         }
31 165
 
166
+        private void addChild(DirectorListModel directorList)
167
+        {
168
+            if (directorList.children != null && directorList.children.Count > 0)
169
+            {
170
+                foreach (DirectorListModel child in directorList.children)
171
+                {
172
+                    pageData.zhangjieList.Add(new ChapterModel()
173
+                    {
174
+                        directorid = child.directorid,
175
+                        directorname = getSpace(child.directorlevel) + child.directorname
176
+                    });
177
+                    if (child.children != null && child.children.Count > 0)
178
+                    {
179
+                        addChild(child);
180
+                    }
181
+                }
182
+            }
183
+        }
184
+
185
+        private string getSpace(int num)
186
+        {
187
+            string str = "";
188
+            for (int i = 0; i < num; i++)
189
+            {
190
+                str += "  ";
191
+            }
192
+            return str;
193
+        }
194
+
195
+        private void zhangjieClick(object sender, RoutedEventArgs e)
196
+        {
197
+            ChapterModel item = ((Button)sender).Tag as ChapterModel;
198
+            foreach (ChapterModel zhangjie in pageData.zhangjieList)
199
+            {
200
+                if (item.directorid == zhangjie.directorid)
201
+                {
202
+                    zhangjie.selected = 1;
203
+                }
204
+                else
205
+                {
206
+                    zhangjie.selected = 0;
207
+                }
208
+            }
209
+
210
+            Directorid = item.directorid;
211
+            APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
212
+        }
213
+        /// <summary>
214
+        /// 我的备课列表服务-调用
215
+        /// </summary>
216
+        /// <returns></returns>
217
+        private object InvokeResourceMyListServering()
218
+        {
219
+            Dispatcher.Invoke(new Action(() =>
220
+            {
221
+                APP.myloading.Show();
222
+            }));
223
+
224
+            APP.ResourceMyList = null;
225
+            serverReturnCode = registerController.ResourceMyList(Lsbid, Directorid, Resourceclass);
226
+            return APP.ErrorMessage;
227
+        }
228
+
229
+        /// <summary>
230
+        /// 我的备课列表服务-返回结果
231
+        /// </summary>
232
+        /// <returns></returns>
233
+        public void InvokeServerResourceMyListCompate(object obj)
234
+        {
235
+            Dispatcher.Invoke(new Action(() =>
236
+            {
237
+                APP.myloading.Hide();
238
+            }));
239
+
240
+            if (serverReturnCode == APP.ServerScuessCode)
241
+            {
242
+                if (pageData.menuList.Count > 0)
243
+                {
244
+                    pageData.menuList.Clear();
245
+                    DataContext = pageData;
246
+                }
247
+
248
+                if (APP.ResourceMyList.obj != null)
249
+                {
250
+                    System.Collections.Generic.List<string> resource = new System.Collections.Generic.List<string>();
251
+                    for (int i = 0; i < APP.ResourceMyList.obj.Count; i++)
252
+                    {
253
+                        string imgSuffix = string.Empty;
254
+                        string visDuration = "Collapsed";
255
+                        string visButton = "Collapsed";
256
+                        string visDownload = "Visible";
257
+                        System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
258
+                        dateTime = dateTime.AddSeconds(APP.ResourceMyList.obj[i].createtime).ToLocalTime();
259
+                        if ("doc".Equals(APP.ResourceMyList.obj[i].suffix)
260
+                            || "docx".Equals(APP.ResourceMyList.obj[i].suffix))
261
+                        {
262
+                            imgSuffix = "../Images/Resource/DOC.png";
263
+                        }
264
+                        else if ("ppt".Equals(APP.ResourceMyList.obj[i].suffix)
265
+                            || "pptx".Equals(APP.ResourceMyList.obj[i].suffix))
266
+                        {
267
+                            imgSuffix = "../Images/Resource/PPT.png";
268
+                        }
269
+                        else if ("pdf".Equals(APP.ResourceMyList.obj[i].suffix))
270
+                        {
271
+                            imgSuffix = "../Images/Resource/PDF.png";
272
+                        }
273
+                        else if ("excel".Equals(APP.ResourceMyList.obj[i].suffix)
274
+                            || "xls".Equals(APP.ResourceMyList.obj[i].suffix) || "xlsx".Equals(APP.ResourceMyList.obj[i].suffix))
275
+                        {
276
+                            imgSuffix = "../Images/Resource/EXCEL.png";
277
+                        }
278
+                        else if ("class".Equals(APP.ResourceMyList.obj[i].suffix))
279
+                        {
280
+                            imgSuffix = "../Images/Resource/CLASS.png";
281
+                        }
282
+                        else if ("dsc".Equals(APP.ResourceMyList.obj[i].suffix))
283
+                        {
284
+                            imgSuffix = "../Images/Resource/DSC.png";
285
+                        }
286
+                        else if ("mp3".Equals(APP.ResourceMyList.obj[i].suffix))
287
+                        {
288
+                            visDuration = "Visible";
289
+                            imgSuffix = "../Images/Resource/MP3.png";
290
+                        }
291
+                        else if ("mp4".Equals(APP.ResourceMyList.obj[i].suffix)
292
+                            || "flv".Equals(APP.ResourceMyList.obj[i].suffix))
293
+                        {
294
+                            visDuration = "Visible";
295
+                            if (APP.ResourceMyList.obj[i].resourcecover != null)
296
+                            {
297
+                                imgSuffix = APP.showImageUrl + APP.ResourceMyList.obj[i].resourcecover.ToString();
298
+                            }
299
+                            else
300
+                            {
301
+                                imgSuffix = "../Images/Resource/MP4.png";
302
+                            }
303
+                        }
304
+                        else if ("png".Equals(APP.ResourceMyList.obj[i].suffix)
305
+                            || "jpg".Equals(APP.ResourceMyList.obj[i].suffix)
306
+                            || "jpeg".Equals(APP.ResourceMyList.obj[i].suffix))
307
+                        {
308
+                            imgSuffix = "../Images/Resource/PNG.png";
309
+                        }
310
+                        else if ("txt".Equals(APP.ResourceMyList.obj[i].suffix))
311
+                        {
312
+                            imgSuffix = "../Images/Resource/TXT.png";
313
+                        }
314
+                        else if ("txt".Equals(APP.ResourceMyList.obj[i].suffix))
315
+                        {
316
+                            imgSuffix = "../Images/Resource/FLV.png";
317
+                        }
318
+                        else if ("wav".Equals(APP.ResourceMyList.obj[i].suffix))
319
+                        {
320
+                            imgSuffix = "../Images/Resource/WAV.png";
321
+                        }
322
+                        string resourcesSuffix = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + APP.LoginUser.username + "\\" + APP.ResourceMyList.obj[i].resourcename + "." + APP.ResourceMyList.obj[i].suffix;
323
+                        if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
324
+                        {
325
+                            resourcesSuffix = APP.fileStorageAddress + "\\" + APP.ResourceMyList.obj[i].resourcename + "." + APP.ResourceMyList.obj[i].suffix;
326
+                        }
327
+                        if (File.Exists(resourcesSuffix))//检查资源是否已经存在
328
+                        {
329
+                            visButton = "Visible";
330
+                            visDownload = "Collapsed";
331
+                        }
332
+                        string resourcesize;
333
+                        if (APP.ResourceMyList.obj[i].resourcesize > 1024)
334
+                        {
335
+                            if (APP.ResourceMyList.obj[i].resourcesize / 1024 > 1024)
336
+                            {
337
+                                resourcesize = (APP.ResourceMyList.obj[i].resourcesize / 1024 / 1024).ToString() + "MB";
338
+                            }
339
+                            else
340
+                            {
341
+                                resourcesize = (APP.ResourceMyList.obj[i].resourcesize / 1024).ToString() + "KB";
342
+                            }
343
+                        }
344
+                        else
345
+                        {
346
+                            resourcesize = (APP.ResourceMyList.obj[i].resourcesize).ToString() + "B";
347
+                        }
348
+                        string duration = string.Empty;
349
+                        if (APP.ResourceMyList.obj[i].duration > 59)
350
+                        {
351
+                            if (APP.ResourceMyList.obj[i].duration > 3599)
352
+                            {
353
+                                if (APP.ResourceMyList.obj[i].duration % 3600 == 0)
354
+                                {
355
+                                    duration = (APP.ResourceMyList.obj[i].duration / 3600).ToString() + "时";
356
+                                }
357
+                                else
358
+                                {
359
+                                    duration = (APP.ResourceMyList.obj[i].duration / 3600).ToString() + "时" + (APP.ResourceMyList.obj[i].duration % 3600).ToString() + "分";
360
+                                }
361
+                            }
362
+                            else
363
+                            {
364
+                                if (APP.ResourceMyList.obj[i].duration % 60 == 0)
365
+                                {
366
+                                    duration = (APP.ResourceMyList.obj[i].duration / 60).ToString() + "分";
367
+                                }
368
+                                else
369
+                                {
370
+                                    duration = (APP.ResourceMyList.obj[i].duration / 60).ToString() + "分" + (APP.ResourceMyList.obj[i].duration % 60).ToString() + "秒";
371
+                                }
372
+                            }
373
+                        }
374
+                        else
375
+                        {
376
+                            duration = APP.ResourceMyList.obj[i].duration.ToString() + "秒";
377
+                        }
378
+                        pageData.menuList.Add(new ToolbarMenuTwo()
379
+                        {
380
+                            Resourcesize = resourcesize,
381
+                            ResourceName = APP.ResourceMyList.obj[i].resourcename,
382
+                            Times = dateTime.ToString("yyy-MM-dd HH:mm:ss"),
383
+                            Pic = imgSuffix,
384
+                            VisDuration = visDuration,
385
+                            Duration = duration,
386
+                            VisButton = visButton,
387
+                            VisDownload = visDownload,
388
+                            Resourceid = APP.ResourceMyList.obj[i].resourceid
389
+                        });
390
+                    }
391
+                }
392
+                DataContext = pageData;
393
+            }
394
+            else
395
+            {
396
+                MessageWindow.Show(APP.ErrorMessage);
397
+            }
398
+        }
399
+        private void DownLoadTwo(string httpurls, int position, string savepath)
400
+        {
401
+            thread = DownloadUtil.downloadFileWithCallback(
402
+                httpurls,
403
+                position,
404
+                savepath,
405
+                Dispatcher,
406
+                this
407
+                );
408
+        }
409
+
410
+        /// <summary>
411
+        /// 下载
412
+        /// </summary>
413
+        /// <param name="sender"></param>
414
+        /// <param name="e"></param>
415
+        private void btnDownload_Click(object sender, RoutedEventArgs e)
416
+        {
417
+            if (!isDownloadStatus)
418
+            {
419
+                int clickindex = 0;
420
+                Button btn = (Button)sender;
421
+                for (int i = 0; i < APP.ResourceMyList.obj.Count; i++)
422
+                {
423
+
424
+                    if (APP.ResourceMyList.obj[i].resourceid == Convert.ToInt32(btn.Tag))
425
+                    {
426
+                        clickindex = i;
427
+                        break;
428
+                    }
429
+                }
430
+                string fileAddress = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + APP.LoginUser.username + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
431
+                if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
432
+                {
433
+                    fileAddress = APP.fileStorageAddress + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
434
+                }
435
+                //if (APP.outputInforLog)
436
+                //{
437
+                //    LogHelper.WriteInfoLog("UserCenterWindow(btnDownload_Click 下载)" + fileAddress);
438
+                //}
439
+                if (Directory.Exists(fileAddress))//存在就打开 不存在就下载
440
+                {
441
+                    ProcessStartInfo psi = new ProcessStartInfo(fileAddress);
442
+                    Process pro = new Process
443
+                    {
444
+                        StartInfo = psi
445
+                    };
446
+                    pro.Start();
447
+                }
448
+                else
449
+                {
450
+                    if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
451
+                    {
452
+                        fileAddress = APP.fileStorageAddress;
453
+                    }
454
+                    if (!Directory.Exists(fileAddress))
455
+                    {
456
+                        Directory.CreateDirectory(fileAddress);
457
+                    }
458
+                    string userHeadPic = APP.showImageUrl + APP.ResourceMyList.obj[clickindex].resourceurl.ToString();
459
+                    DownLoadTwo(userHeadPic, 9999 + clickindex, fileAddress + "\\");
460
+                }
461
+            }
462
+        }
463
+
464
+        /// <summary>
465
+        /// 打开
466
+        /// </summary>
467
+        /// <param name="sender"></param>
468
+        /// <param name="e"></param>
32 469
         private void btnTurnOn_Click(object sender, RoutedEventArgs e)
33 470
         {
471
+            if (!isDownloadStatus)
472
+            {
473
+                int clickindex = 0;
474
+                Button btn = (Button)sender;
475
+                for (int i = 0; i < APP.ResourceMyList.obj.Count; i++)
476
+                {
477
+
478
+                    if (APP.ResourceMyList.obj[i].resourceid == Convert.ToInt32(btn.Tag))
479
+                    {
480
+                        clickindex = i;
481
+                        break;
482
+                    }
483
+                }
34 484
 
485
+                string fileAddress = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + APP.LoginUser.username + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
486
+                if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
487
+                {
488
+                    fileAddress = APP.fileStorageAddress + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
489
+                }
490
+                //if (APP.outputInforLog)
491
+                //{
492
+                //    LogHelper.WriteInfoLog("UserCenterWindow(btnTurnOn_Click 打开)" + fileAddress);
493
+                //}
494
+                if (Directory.Exists(fileAddress))//存在就打开 不存在就下载
495
+                {
496
+                    try
497
+                    {
498
+                        ProcessStartInfo psi = new ProcessStartInfo(fileAddress);
499
+                        Process pro = new Process
500
+                        {
501
+                            StartInfo = psi
502
+                        };
503
+                        pro.Start();
504
+                    }
505
+                    catch (Exception ex)
506
+                    {
507
+                        LogHelper.WriteErrLog("UserCenterWindow【btnTurnOn_Click】" + ex.Message, ex);
508
+                        MessageWindow.Show(ex.Message);
509
+                        return;
510
+                    }
511
+                }
512
+                else
513
+                {
514
+                    if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
515
+                    {
516
+                        fileAddress = APP.fileStorageAddress;
517
+                    }
518
+                    if (!Directory.Exists(fileAddress))
519
+                    {
520
+                        Directory.CreateDirectory(fileAddress);
521
+                    }
522
+                    string userHeadPic = APP.showImageUrl + APP.ResourceMyList.obj[clickindex].resourceurl.ToString();
523
+                    DownLoadTwo(userHeadPic, 9999 + clickindex, fileAddress + "\\");
524
+                }
525
+            }
35 526
         }
36 527
 
37
-        private void Window_MouseMove(object sender, MouseEventArgs e)
528
+        /// <summary>
529
+        /// 全部
530
+        /// </summary>
531
+        /// <param name="sender"></param>
532
+        /// <param name="e"></param>
533
+        private void btnAll_Click(object sender, RoutedEventArgs e)
534
+        {
535
+            pageData.menuList.Clear();
536
+            DataContext = pageData;
537
+            Resourceclass = 0;
538
+            borAll.Background = new SolidColorBrush(Colors.DodgerBlue);
539
+            borAudio.Background = new SolidColorBrush(Colors.Transparent);
540
+            borVideo.Background = new SolidColorBrush(Colors.Transparent);
541
+            borImage.Background = new SolidColorBrush(Colors.Transparent);
542
+            borDoc.Background = new SolidColorBrush(Colors.Transparent);
543
+            btnAll.Foreground = new SolidColorBrush(Colors.White);
544
+            btnAudio.Foreground = new SolidColorBrush(Colors.Black);
545
+            btnVideo.Foreground = new SolidColorBrush(Colors.Black);
546
+            btnImage.Foreground = new SolidColorBrush(Colors.Black);
547
+            btnDoc.Foreground = new SolidColorBrush(Colors.Black);
548
+            APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
549
+        }
550
+
551
+        private void Window_Closing(object sender, CancelEventArgs e)
552
+        {
553
+            if (pageData.menuList.Count > 0)
554
+            {
555
+                pageData.menuList.Clear();
556
+                DataContext = null;
557
+            }
558
+        }
559
+
560
+        /// <summary>
561
+        /// 音频
562
+        /// </summary>
563
+        /// <param name="sender"></param>
564
+        /// <param name="e"></param>
565
+        private void btnAudio_Click(object sender, RoutedEventArgs e)
566
+        {
567
+            pageData.menuList.Clear();
568
+            DataContext = pageData;
569
+            Resourceclass = 1;
570
+            borAll.Background = new SolidColorBrush(Colors.Transparent);
571
+            borAudio.Background = new SolidColorBrush(Colors.DodgerBlue);
572
+            borVideo.Background = new SolidColorBrush(Colors.Transparent);
573
+            borImage.Background = new SolidColorBrush(Colors.Transparent);
574
+            borDoc.Background = new SolidColorBrush(Colors.Transparent);
575
+            btnAll.Foreground = new SolidColorBrush(Colors.Black);
576
+            btnAudio.Foreground = new SolidColorBrush(Colors.White);
577
+            btnVideo.Foreground = new SolidColorBrush(Colors.Black);
578
+            btnImage.Foreground = new SolidColorBrush(Colors.Black);
579
+            btnDoc.Foreground = new SolidColorBrush(Colors.Black);
580
+            APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
581
+        }
582
+
583
+        /// <summary>
584
+        /// 视频
585
+        /// </summary>
586
+        /// <param name="sender"></param>
587
+        /// <param name="e"></param>
588
+        private void btnVideo_Click(object sender, RoutedEventArgs e)
38 589
         {
590
+            pageData.menuList.Clear();
591
+            DataContext = pageData;
592
+            Resourceclass = 2;
593
+            borAll.Background = new SolidColorBrush(Colors.Transparent);
594
+            borAudio.Background = new SolidColorBrush(Colors.Transparent);
595
+            borVideo.Background = new SolidColorBrush(Colors.DodgerBlue);
596
+            borImage.Background = new SolidColorBrush(Colors.Transparent);
597
+            borDoc.Background = new SolidColorBrush(Colors.Transparent);
598
+            btnAll.Foreground = new SolidColorBrush(Colors.Black);
599
+            btnAudio.Foreground = new SolidColorBrush(Colors.Black);
600
+            btnVideo.Foreground = new SolidColorBrush(Colors.White);
601
+            btnImage.Foreground = new SolidColorBrush(Colors.Black);
602
+            btnDoc.Foreground = new SolidColorBrush(Colors.Black);
603
+            APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
604
+        }
39 605
 
606
+        /// <summary>
607
+        /// 图片
608
+        /// </summary>
609
+        /// <param name="sender"></param>
610
+        /// <param name="e"></param>
611
+        private void btnImage_Click(object sender, RoutedEventArgs e)
612
+        {
613
+            pageData.menuList.Clear();
614
+            DataContext = pageData;
615
+            Resourceclass = 3;
616
+            borAll.Background = new SolidColorBrush(Colors.Transparent);
617
+            borAudio.Background = new SolidColorBrush(Colors.Transparent);
618
+            borVideo.Background = new SolidColorBrush(Colors.Transparent);
619
+            borImage.Background = new SolidColorBrush(Colors.DodgerBlue);
620
+            borDoc.Background = new SolidColorBrush(Colors.Transparent);
621
+            btnAll.Foreground = new SolidColorBrush(Colors.Black);
622
+            btnAudio.Foreground = new SolidColorBrush(Colors.Black);
623
+            btnVideo.Foreground = new SolidColorBrush(Colors.Black);
624
+            btnImage.Foreground = new SolidColorBrush(Colors.White);
625
+            btnDoc.Foreground = new SolidColorBrush(Colors.Black);
626
+            APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
40 627
         }
628
+
41 629
         /// <summary>
42
-        /// 关闭事件
630
+        /// 文档
43 631
         /// </summary>
44 632
         /// <param name="sender"></param>
45 633
         /// <param name="e"></param>
634
+        private void btnDoc_Click(object sender, RoutedEventArgs e)
635
+        {
636
+            pageData.menuList.Clear();
637
+            DataContext = pageData;
638
+            Resourceclass = 4;
639
+            borAll.Background = new SolidColorBrush(Colors.Transparent);
640
+            borAudio.Background = new SolidColorBrush(Colors.Transparent);
641
+            borVideo.Background = new SolidColorBrush(Colors.Transparent);
642
+            borImage.Background = new SolidColorBrush(Colors.Transparent);
643
+            borDoc.Background = new SolidColorBrush(Colors.DodgerBlue);
644
+            btnAll.Foreground = new SolidColorBrush(Colors.Black);
645
+            btnAudio.Foreground = new SolidColorBrush(Colors.Black);
646
+            btnVideo.Foreground = new SolidColorBrush(Colors.Black);
647
+            btnImage.Foreground = new SolidColorBrush(Colors.Black);
648
+            btnDoc.Foreground = new SolidColorBrush(Colors.White);
649
+            APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
650
+        }
651
+
652
+        private void Refresh()
653
+        {
654
+            pageData.menuList.Clear();
655
+        }
656
+        /// <summary>
657
+        /// 科目教材选择改变事件
658
+        /// </summary>
659
+        /// <param name="sender"></param>
660
+        /// <param name="e"></param>
661
+        private void cmbClass_SelectionChanged(object sender, SelectionChangedEventArgs e)
662
+        {
663
+            if (initialization)
664
+            {
665
+                initialization = false;
666
+            }
667
+            else
668
+            {
669
+                Directorid = 0;
670
+                borAll.Background = new SolidColorBrush(Colors.DodgerBlue);
671
+                borAudio.Background = new SolidColorBrush(Colors.Transparent);
672
+                borVideo.Background = new SolidColorBrush(Colors.Transparent);
673
+                borImage.Background = new SolidColorBrush(Colors.Transparent);
674
+                borDoc.Background = new SolidColorBrush(Colors.Transparent);
675
+                btnAll.Foreground = new SolidColorBrush(Colors.White);
676
+                btnAudio.Foreground = new SolidColorBrush(Colors.Black);
677
+                btnVideo.Foreground = new SolidColorBrush(Colors.Black);
678
+                btnImage.Foreground = new SolidColorBrush(Colors.Black);
679
+                btnDoc.Foreground = new SolidColorBrush(Colors.Black);
680
+            }
681
+
682
+            if (cmbClass.SelectedValue != null)
683
+            {
684
+                Lsbid = Convert.ToInt32(cmbClass.SelectedValue.ToString());
685
+                Refresh();
686
+                APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeDirectorListServering, InvokeServerDirectorListCompate);
687
+            }
688
+            else
689
+            {
690
+                Refresh();
691
+            }
692
+        }
693
+
694
+        private void Window_MouseMove(object sender, MouseEventArgs e)
695
+        {
696
+            if (e.LeftButton == MouseButtonState.Pressed)
697
+            {
698
+                //执行移动方法
699
+                DragMove();
700
+            }
701
+        }
702
+
46 703
         private void btnDown_Click(object sender, RoutedEventArgs e)
47 704
         {
48
-            //if (thread != null)
49
-            //{
50
-            //    thread.Abort();
51
-            //}
52
-            //MyApp.myloading.Hide();
705
+            if (thread != null)
706
+            {
707
+                thread.Abort();
708
+            }
709
+            APP.myloading.Hide();
53 710
             Close();
54 711
             //ToolbarWindow.IsOpenUserCenterWindow = false;
55 712
         }
56 713
 
57
-        private void cmbClass_SelectionChanged(object sender, SelectionChangedEventArgs e)
714
+        public void downloadBegin(int position)
58 715
         {
716
+            isDownloadStatus = true;
717
+            if (position >= 9999)
718
+            {
719
+                tip_outer.Visibility = Visibility.Visible;
720
+            }
721
+        }
59 722
 
723
+        public void downloadProgress(int position, int progress)
724
+        {
725
+            if (position >= 9999)
726
+            {
727
+                pgbProcess.Value = progress * 100 / 100;
728
+                lbProcess.Content = string.Format("{0}% / {1}%", progress, 100);
729
+            }
60 730
         }
61 731
 
62
-        private void btnAudio_Click(object sender, RoutedEventArgs e)
732
+        public void downloadEnd(int position, string filepath)
63 733
         {
734
+            isDownloadStatus = false;
735
+            thread = null;
736
+            if (pageData.menuList.Count > 0)
737
+            {
738
+                //if (APP.outputInforLog)
739
+                //{
740
+                //    LogHelper.WriteInfoLog("UserCenterWindow(downloadEnd 下载完成)" + filepath);
741
+                //}
742
+                if (position < 9999)
743
+                {
744
+                    if (pageData.menuList.Count < position)
745
+                    {
746
+                        pageData.menuList[position].Pic = filepath;
747
+                    }
748
+                }
749
+                else if (filepath.Contains(pageData.menuList[position - 9999].ResourceName))
750
+                {
751
+                    pageData.menuList[position - 9999].VisDownload = "Collapsed";
752
+                    pageData.menuList[position - 9999].VisButton = "Visible";
753
+                    tip_outer.Visibility = Visibility.Hidden;
754
+                    try
755
+                    {
756
+                        ProcessStartInfo psi = new ProcessStartInfo(filepath);
757
+                        Process pro = new Process
758
+                        {
759
+                            StartInfo = psi
760
+                        };
761
+                        pro.Start();
762
+                    }
763
+                    catch (Exception ex)
764
+                    {
765
+                        LogHelper.WriteErrLog("UserCenterWindow【downloadEnd】" + ex.Message, ex);
766
+                        MessageWindow.Show(ex.Message);
767
+                        return;
768
+                    }
769
+                }
770
+                else
771
+                {
772
+                    tip_outer.Visibility = Visibility.Hidden;
773
+                    try
774
+                    {
775
+                        ProcessStartInfo psi = new ProcessStartInfo(filepath);
776
+                        Process pro = new Process
777
+                        {
778
+                            StartInfo = psi
779
+                        };
780
+                        pro.Start();
781
+                    }
782
+                    catch (Exception ex)
783
+                    {
784
+                        LogHelper.WriteErrLog("UserCenterWindow【downloadEnd】" + ex.Message, ex);
785
+                        MessageWindow.Show(ex.Message);
786
+                        return;
787
+                    }
788
+                }
789
+            }
790
+            else
791
+            {
792
+                tip_outer.Visibility = Visibility.Hidden;
64 793
 
794
+                try
795
+                {
796
+                    ProcessStartInfo psi = new ProcessStartInfo(filepath);
797
+                    Process pro = new Process
798
+                    {
799
+                        StartInfo = psi
800
+                    };
801
+                    pro.Start();
802
+                }
803
+                catch (Exception ex)
804
+                {
805
+                    LogHelper.WriteErrLog("UserCenterWindow【downloadEnd】" + ex.Message, ex);
806
+                    MessageWindow.Show(ex.Message);
807
+                    return;
808
+                }
809
+            }
65 810
         }
66 811
 
67
-        private void btnVideo_Click(object sender, RoutedEventArgs e)
812
+        public void downloadError(int position, string msg)
68 813
         {
69
-
814
+            Dispatcher.Invoke(new Action(() =>
815
+            {
816
+                tip_outer.Visibility = Visibility.Collapsed;
817
+            }));
818
+            isDownloadStatus = false;
819
+            if (!msg.Equals("远程服务器返回错误: (404) 未找到。") && !msg.Equals("正在中止线程。"))
820
+            {
821
+                MessageWindow.Show(msg);
822
+            }
70 823
         }
71 824
 
72
-        private void btnImage_Click(object sender, RoutedEventArgs e)
825
+        public class ButtonBrush
73 826
         {
827
+            public static readonly DependencyProperty ButtonPressBackgroundProperty = DependencyProperty.RegisterAttached(
828
+                "ButtonPressBackground", typeof(Brush), typeof(ButtonBrush), new PropertyMetadata(default(Brush)));
74 829
 
830
+            public static void SetButtonPressBackground(DependencyObject element, Brush value)
831
+            {
832
+                element.SetValue(ButtonPressBackgroundProperty, value);
833
+            }
834
+
835
+            public static Brush GetButtonPressBackground(DependencyObject element)
836
+            {
837
+                return (Brush)element.GetValue(ButtonPressBackgroundProperty);
838
+            }
75 839
         }
840
+    }
76 841
 
77
-        private void btnDoc_Click(object sender, RoutedEventArgs e)
842
+    public class ToolbarMenuTwo : NotifyModel
843
+    {
844
+        internal string _resourceName;
845
+
846
+        public string ResourceName
78 847
         {
848
+            get => _resourceName;
849
+            set { _resourceName = value; OnPropertyChanged("ResourceName"); }
850
+        }
851
+
852
+        internal string _times;
79 853
 
854
+        public string Times
855
+        {
856
+            get => _times;
857
+            set { _times = value; OnPropertyChanged("Times"); }
80 858
         }
81 859
 
82
-        private void zhangjieClick(object sender, RoutedEventArgs e)
860
+        internal string _Pic;
861
+
862
+        public string Pic
83 863
         {
864
+            get => _Pic;
865
+            set { _Pic = value; OnPropertyChanged("Pic"); }
866
+        }
84 867
 
868
+        /// <summary>
869
+        /// 视频时长秒
870
+        /// </summary>
871
+        public string Duration { get; set; }
872
+
873
+        /// <summary>
874
+        /// 视频时长是否显示
875
+        /// </summary>
876
+        public string VisDuration { get; set; }
877
+
878
+        /// <summary>
879
+        /// 文件大小
880
+        /// </summary>
881
+        public string Resourcesize { get; set; }
882
+
883
+        internal string _VisButton;
884
+
885
+        /// <summary>
886
+        /// 打开按钮是否显示
887
+        /// </summary>
888
+        public string VisButton
889
+        {
890
+            get => _VisButton;
891
+            set { _VisButton = value; OnPropertyChanged("VisButton"); }
85 892
         }
86 893
 
87
-        private void btnDownload_Click(object sender, RoutedEventArgs e)
894
+        internal string _VisDownload;
895
+
896
+        /// <summary>
897
+        /// 下载按钮是否显示
898
+        /// </summary>
899
+        public string VisDownload
88 900
         {
901
+            get => _VisDownload;
902
+            set { _VisDownload = value; OnPropertyChanged("VisDownload"); }
903
+        }
89 904
 
905
+        internal int _Resourceid;
906
+
907
+        /// <summary>
908
+        /// 资源id
909
+        /// </summary>
910
+        public int Resourceid
911
+        {
912
+            get => _Resourceid;
913
+            set { _Resourceid = value; OnPropertyChanged("Resourceid"); }
90 914
         }
915
+    }
91 916
 
92
-        private void btnAll_Click(object sender, RoutedEventArgs e)
917
+    public class UserCenterPageData : NotifyModel
918
+    {
919
+        public ObservableCollection<ComboBoxBeanModel> bookList { get; set; }
920
+
921
+        public ObservableCollection<ChapterModel> zhangjieList { get; set; }
922
+        public ObservableCollection<ToolbarMenuTwo> menuList { get; set; }
923
+
924
+        public UserCenterPageData()
93 925
         {
926
+            bookList = new ObservableCollection<ComboBoxBeanModel>();
927
+            zhangjieList = new ObservableCollection<ChapterModel>();
928
+            menuList = new ObservableCollection<ToolbarMenuTwo>();
929
+        }
930
+    }
931
+
932
+    public class ChapterModel : NotifyModel
933
+    {
934
+        public int directorid { get; set; }
935
+        public string directorname { get; set; }
936
+        public int level { get; set; }
94 937
 
938
+        private int _selected;
939
+
940
+        public int selected
941
+        {
942
+            get => _selected;
943
+            set
944
+            {
945
+                _selected = value;
946
+                OnPropertyChanged("selected");
947
+            }
95 948
         }
96 949
     }
97 950
 }

+ 184
- 0
XHZB.Desktop/Utils/DownloadUtil.cs View File

@@ -0,0 +1,184 @@
1
+using System;
2
+using System.IO;
3
+using System.Net;
4
+using System.Threading;
5
+using System.Windows.Threading;
6
+
7
+namespace XHZB.Desktop.Utils
8
+{
9
+    internal class DownloadUtil
10
+    {
11
+        public static void downloadFile(string url, string savepath)
12
+        {
13
+            string path = savepath;
14
+            string filename = url.Substring(url.LastIndexOf("/") + 1);
15
+            if (!url.StartsWith("http") || filename == null || filename == "")
16
+            {
17
+                return;
18
+            }
19
+            path += filename;
20
+            // 设置参数
21
+            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
22
+            //发送请求并获取相应回应数据
23
+            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
24
+            //直到request.GetResponse()程序才开始向目标网页发送Post请求
25
+            Stream responseStream = response.GetResponseStream();
26
+
27
+            //创建本地文件写入流
28
+            Stream stream = new FileStream(path, FileMode.Create);
29
+
30
+            byte[] bArr = new byte[1024];
31
+            int size = responseStream.Read(bArr, 0, bArr.Length);
32
+            while (size > 0)
33
+            {
34
+                stream.Write(bArr, 0, size);
35
+                size = responseStream.Read(bArr, 0, bArr.Length);
36
+            }
37
+            stream.Close();
38
+            responseStream.Close();
39
+        }
40
+
41
+        /// <summary>
42
+        /// Http下载文件
43
+        /// </summary>
44
+        public static Thread downloadFileWithCallback(
45
+            string url,
46
+            int position,
47
+            string savepath,
48
+            Dispatcher dispatcher,
49
+            DownloadCallback callback
50
+            )
51
+        {
52
+
53
+            string path = savepath;
54
+            string filename = url.Substring(url.LastIndexOf("/") + 1);
55
+            path += filename;
56
+            if (!url.StartsWith("http") || filename == null || filename == "")
57
+            {
58
+                return null;
59
+            }
60
+            Thread thread = new Thread(o =>
61
+            {
62
+                FileInfo fi = new FileInfo(path);
63
+                if (fi.Exists)
64
+                {
65
+                    dispatcher.Invoke(new Action(() =>
66
+                    {
67
+                        callback.downloadEnd(position, path);
68
+                    }));
69
+                }
70
+                else
71
+                {
72
+                    string temppath = path + ".tmp";
73
+                    if (File.Exists(temppath))
74
+                    {
75
+                        //File.Delete(temppath);
76
+                        temppath += "1";
77
+                        while (File.Exists(temppath))
78
+                        {
79
+                            temppath += "1";
80
+                            if (!File.Exists(temppath))
81
+                            {
82
+                                break;
83
+                            }
84
+                        }
85
+
86
+                    }
87
+
88
+                    dispatcher.Invoke(new Action(() =>
89
+                    {
90
+                        callback.downloadBegin(position);
91
+                    }));
92
+
93
+                    try
94
+                    {
95
+                        HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
96
+                        HttpWebResponse response = request.GetResponse() as HttpWebResponse;
97
+                        Stream responseStream = response.GetResponseStream();
98
+
99
+                        //创建本地文件写入流
100
+                        Stream stream = new FileStream(temppath, FileMode.Create);
101
+                        long totalSize = response.ContentLength;
102
+                        byte[] bArr = new byte[1024];
103
+                        int size = responseStream.Read(bArr, 0, bArr.Length);
104
+                        long readsize = 0;
105
+                        while (size > 0)
106
+                        {
107
+                            readsize += size;
108
+                            stream.Write(bArr, 0, size);
109
+                            size = responseStream.Read(bArr, 0, bArr.Length);
110
+
111
+                            dispatcher.Invoke(new Action(() =>
112
+                            {
113
+                                callback.downloadProgress(position, (int)(readsize * 100 / totalSize));
114
+                            }));
115
+                        }
116
+                        stream.Close();
117
+                        responseStream.Close();
118
+                        FileInfo fitemp = new FileInfo(temppath);
119
+                        fitemp.MoveTo(path);
120
+                        dispatcher.Invoke(new Action(() =>
121
+                        {
122
+                            callback.downloadEnd(position, path);
123
+                        }));
124
+                    }
125
+                    catch (Exception ex)
126
+                    {
127
+                        dispatcher.Invoke(new Action(() =>
128
+                        {
129
+                            callback.downloadError(position, ex.Message);
130
+                        }));
131
+
132
+                    }
133
+
134
+                }
135
+            });
136
+            thread.Start();
137
+            return thread;
138
+        }
139
+
140
+
141
+
142
+
143
+        public static void downloadFileWithCallback(
144
+            string url,
145
+            int position,
146
+            Dispatcher dispatcher,
147
+            DownloadCallback callback
148
+            )
149
+        {
150
+            string path = APP.tempPath;
151
+            downloadFileWithCallback(url, position, path, dispatcher, callback);
152
+        }
153
+
154
+        public interface DownloadCallback 
155
+        {
156
+            /// <summary>
157
+            /// 下载开始
158
+            /// </summary>
159
+            /// <param name="position"></param>
160
+            void downloadBegin(int position);
161
+
162
+            /// <summary>
163
+            /// 下载过程
164
+            /// </summary>
165
+            /// <param name="position"></param>
166
+            /// <param name="progress"></param>
167
+            void downloadProgress(int position, int progress);
168
+
169
+            /// <summary>
170
+            /// 下载结束
171
+            /// </summary>
172
+            /// <param name="position"></param>
173
+            /// <param name="filepath"></param>
174
+            void downloadEnd(int position, string filepath);
175
+            /// <summary>
176
+            /// 下载结束
177
+            /// </summary>
178
+            /// <param name="position"></param>
179
+            /// <param name="filepath"></param>
180
+            void downloadError(int position, string msg);
181
+
182
+        }
183
+    }
184
+}

+ 49
- 50
XHZB.Desktop/Utils/RegisterController.cs View File

@@ -144,57 +144,56 @@ namespace XHZB.Desktop.Utils
144 144
                 return 1;
145 145
             }
146 146
         }
147
-        ///// <summary>
148
-        ///// 我的备课--列表
149
-        ///// </summary>
150
-        ///// <param name="request"></param>
151
-        ///// <returns></returns>
152
-        //public int ResourceMyList(int _lsbid, int _directorid, int _resourceclass)
153
-        //{
154
-        //    //RESP_ResourceMyList returnObj = new RESP_ResourceMyList();
155
-        //    try
156
-        //    {
157
-        //        string url = ZConfig.apiUrl + "/resource/my_list2";//地址
158
-        //        Dictionary<string, int> dic = new Dictionary<string, int>
159
-        //        {
160
-        //            { "lsbid", _lsbid},
161
-        //            { "directorid", _directorid},
162
-        //            { "resourceclass", _resourceclass},
163
-        //            { "resourcetype", 0},
164
-        //            { "readcount", 0},
165
-        //            { "createid", ZCommonData.loginUser.userid},
166
-        //            { "schoolid", ZCommonData.loginUser.schoolid}
167
-        //        };
168
-        //        string body = DataProvider.SerializeDictionaryToJsonString(dic);
169
-        //        string xmlDoc = DataProvider.HttpPost(body, url);
147
+        /// <summary>
148
+        /// 我的备课--列表
149
+        /// </summary>
150
+        /// <param name="request"></param>
151
+        /// <returns></returns>
152
+        public int ResourceMyList(int _lsbid, int _directorid, int _resourceclass)
153
+        {
154
+            try
155
+            {
156
+                string url = APP.apiUrl + "/resource/my_list2";//地址
157
+                Dictionary<string, int> dic = new Dictionary<string, int>
158
+                {
159
+                    { "lsbid", _lsbid},
160
+                    { "directorid", _directorid},
161
+                    { "resourceclass", _resourceclass},
162
+                    { "resourcetype", 0},
163
+                    { "readcount", 0},
164
+                    { "createid", APP.LoginUser.userid},
165
+                    { "schoolid", APP.LoginUser.schoolid}
166
+                };
167
+                string body = DataProvider.SerializeDictionaryToJsonString(dic);
168
+                string xmlDoc = DataProvider.HttpPost(body, url);
170 169
 
171
-        //        if (string.IsNullOrEmpty(xmlDoc))
172
-        //        {
173
-        //            Shared.ServerMsg = "网络异常!";
174
-        //            return 1;
175
-        //        }
176
-        //        else
177
-        //        {
178
-        //            ResultListVo<RESP_ResourceMyListTwo> obj = ZJsonHelper.JsonToObj<ResultListVo<RESP_ResourceMyListTwo>>(xmlDoc);
179
-        //            if (obj != null)
180
-        //            {
181
-        //                Shared.TeachingData.RESP_ResourceMyList.obj = new List<RESP_ResourceMyListTwo>();
182
-        //                Shared.TeachingData.RESP_ResourceMyList.obj = obj.obj;
183
-        //                return 0;
184
-        //            }
185
-        //            else
186
-        //            {
187
-        //                Shared.ServerMsg = "网络异常!";
188
-        //                return 1;
189
-        //            }
190
-        //        }
191
-        //    }
192
-        //    catch (Exception ex)
193
-        //    {
194
-        //        LogHelper.WriteErrLog("我的备课接口" + ex.Message, ex);
195
-        //    }
196
-        //    return 0;
197
-        //}
170
+                if (string.IsNullOrEmpty(xmlDoc))
171
+                {
172
+                    APP.ErrorMessage = "网络异常!";
173
+                    return 1;
174
+                }
175
+                else
176
+                {
177
+                    ResultListVo<ResourceMyListsModel> obj = JsonHelper.JsonToObj<ResultListVo<ResourceMyListsModel>>(xmlDoc);
178
+                    if (obj != null)
179
+                    {
180
+                        APP.ResourceMyList.obj = new List<ResourceMyListsModel>();
181
+                        APP.ResourceMyList.obj = obj.obj;
182
+                        return 0;
183
+                    }
184
+                    else
185
+                    {
186
+                        APP.ErrorMessage = "网络异常!";
187
+                        return 1;
188
+                    }
189
+                }
190
+            }
191
+            catch (Exception ex)
192
+            {
193
+                LogHelper.WriteErrLog("我的备课接口" + ex.Message, ex);
194
+            }
195
+            return 0;
196
+        }
198 197
         ///// <summary>
199 198
         ///// 班级学生--列表
200 199
         ///// </summary>

+ 23
- 0
XHZB.Desktop/Utils/ResultListVo.cs View File

@@ -0,0 +1,23 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHZB.Desktop.Utils
8
+{
9
+    internal class ResultListVo<T>
10
+    {
11
+        public int code { get; set; }
12
+
13
+        /// <summary>
14
+        /// 题型名称
15
+        /// </summary>
16
+        public string msg { get; set; }
17
+
18
+        /// <summary>
19
+        /// 题型名称
20
+        /// </summary>
21
+        public List<T> obj { get; set; }
22
+    }
23
+}

+ 10
- 0
XHZB.Desktop/WebSocket/SocketCallback.cs View File

@@ -0,0 +1,10 @@
1
+using XHZB.Model;
2
+
3
+namespace XHZB.Desktop.WebSocket
4
+{
5
+    public interface SocketCallback
6
+    {
7
+        void receiveWsMsg(ZWsMsgVo msg);
8
+        void userListChange();
9
+    }
10
+}

+ 103
- 0
XHZB.Desktop/WebSocket/SocketClient.cs View File

@@ -0,0 +1,103 @@
1
+using SuperSocket.ClientEngine;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Threading;
5
+using System.Threading.Tasks;
6
+using WebSocket4Net;
7
+
8
+namespace XHZB.Desktop.WebSocket
9
+{
10
+    public class SocketClient
11
+    {
12
+        // 打开的窗口列表
13
+        private static readonly Dictionary<Type, object> WinDic = new Dictionary<Type, object>();
14
+        private static SocketClient instance;
15
+        public static SocketClient getInstance()
16
+        {
17
+            if (instance == null)
18
+            {
19
+                instance = new SocketClient();
20
+            }
21
+            return instance;
22
+        }
23
+
24
+        static void Starts() 
25
+        {
26
+            //新建客户端类 
27
+            //服务端IP地址 ws://192.168.1.13 如果服务端开启了ssl或者tsl 这里前缀应该改成 wss:/
28
+            //服务端监听端口 1234
29
+            //自定义的地址参数 可以根据地址参数来区分客户端 /lcj控制台
30
+            //WSocketClient client = new WSocketClient("wss://a.lcj888.ml:54645/lcj控制台");
31
+            WSocketClient client = new WSocketClient("ws://schoolwstest.xhkjedu.com/ws");
32
+            //注册消息接收事件,接收服务端发送的数据
33
+            client.MessageReceived += (data) => {
34
+                Console.WriteLine(data);
35
+            };
36
+            //开始链接
37
+            client.Start();
38
+
39
+            Console.WriteLine("输入“c”,退出");
40
+            var input = "";
41
+            do
42
+            {
43
+                input = Console.ReadLine();
44
+                //客户端发送消息到服务端
45
+                client.SendMessage(input);
46
+            } while (input != "c");
47
+            client.Dispose();
48
+        }
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+        /// <summary>
64
+        /// 添加要推送消息的窗口
65
+        /// </summary>
66
+        /// <param name="win"></param>
67
+        public void addWin(object win)
68
+        {
69
+            if (WinDic.ContainsKey(win.GetType()))
70
+            {
71
+                WinDic[win.GetType()] = win;
72
+            }
73
+            else
74
+            {
75
+                WinDic.Add(win.GetType(), win);
76
+            }
77
+        }
78
+        /// <summary>
79
+        /// 发送给需要接收的窗口
80
+        /// </summary>
81
+        private static void sendUserChangeToWin()
82
+        {
83
+            foreach (KeyValuePair<Type, object> kvp in WinDic)
84
+            {
85
+                if (kvp.Value is SocketCallback callback)
86
+                {
87
+                    callback.userListChange();
88
+                }
89
+            }
90
+        }
91
+        /// <summary>
92
+        /// 移除窗口
93
+        /// </summary>
94
+        /// <param name="win"></param>
95
+        public void removedWin(object win)
96
+        {
97
+            if (WinDic.ContainsKey(win.GetType()))
98
+            {
99
+                WinDic.Remove(win.GetType());
100
+            }
101
+        }
102
+    }
103
+}

+ 31
- 0
XHZB.Desktop/WebSocket/SocketMsgManger.cs View File

@@ -0,0 +1,31 @@
1
+using Newtonsoft.Json;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+using XHZB.Model;
8
+
9
+namespace XHZB.Desktop.WebSocket
10
+{
11
+    internal class SocketMsgManger
12
+    {
13
+        public static string offlineMsg(int userid)
14
+        {
15
+            SocketModel msg = new SocketModel
16
+            {
17
+                c = 1001,
18
+                rid = 1,
19
+                d = "pc",
20
+                u = 1,
21
+                b = new BodyModel
22
+                {
23
+                    
24
+                },
25
+                f = APP.LoginUser.userid,
26
+                t = new List<int>()
27
+            };
28
+            return JsonConvert.SerializeObject(msg);
29
+        }
30
+    }
31
+}

+ 162
- 0
XHZB.Desktop/WebSocket/WSocketClient.cs View File

@@ -0,0 +1,162 @@
1
+using SuperSocket.ClientEngine;
2
+using System;
3
+using System.Threading;
4
+using System.Threading.Tasks;
5
+using WebSocket4Net;
6
+
7
+namespace XHZB.Desktop.WebSocket
8
+{
9
+    public class WSocketClient : IDisposable
10
+    {
11
+        public static NLog.Logger _Logger = NLog.LogManager.GetCurrentClassLogger();
12
+
13
+        #region 向外传递数据事件
14
+        public event Action<string> MessageReceived;
15
+        #endregion
16
+
17
+        WebSocket4Net.WebSocket _webSocket;
18
+        /// <summary>
19
+        /// 检查重连线程
20
+        /// </summary>
21
+        Thread _thread;
22
+        bool _isRunning = true;
23
+        /// <summary>
24
+        /// WebSocket连接地址
25
+        /// </summary>
26
+        public string ServerPath { get; set; }
27
+
28
+        public WSocketClient(string url)
29
+        {
30
+            ServerPath = url;
31
+            this._webSocket = new WebSocket4Net.WebSocket(url);
32
+            this._webSocket.Opened += WebSocket_Opened;
33
+            this._webSocket.Error += WebSocket_Error;
34
+            this._webSocket.Closed += WebSocket_Closed;
35
+            this._webSocket.MessageReceived += WebSocket_MessageReceived;
36
+        }
37
+
38
+        #region "web socket "
39
+        /// <summary>
40
+        /// 连接方法
41
+        /// <returns></returns>
42
+        public bool Start()
43
+        {
44
+            bool result = true;
45
+            try
46
+            {
47
+                this._webSocket.Open();
48
+
49
+                this._isRunning = true;
50
+                this._thread = new Thread(new ThreadStart(CheckConnection));
51
+                this._thread.Start();
52
+            }
53
+            catch (Exception ex)
54
+            {
55
+                _Logger.Error(ex.ToString());
56
+                result = false;
57
+            }
58
+            return result;
59
+        }
60
+        /// <summary>
61
+        /// 消息收到事件
62
+        /// </summary>
63
+        /// <param name="sender"></param>
64
+        /// <param name="e"></param>
65
+        void WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
66
+        {
67
+            _Logger.Info(" Received:" + e.Message);
68
+            MessageReceived?.Invoke(e.Message);
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+        }
78
+        /// <summary>
79
+        /// Socket关闭事件
80
+        /// </summary>
81
+        /// <param name="sender"></param>
82
+        /// <param name="e"></param>
83
+        void WebSocket_Closed(object sender, EventArgs e)
84
+        {
85
+            _Logger.Info("websocket_Closed");
86
+        }
87
+        /// <summary>
88
+        /// Socket报错事件
89
+        /// </summary>
90
+        /// <param name="sender"></param>
91
+        /// <param name="e"></param>
92
+        void WebSocket_Error(object sender, ErrorEventArgs e)
93
+        {
94
+            _Logger.Info("websocket_Error:" + e.Exception.ToString());
95
+        }
96
+        /// <summary>
97
+        /// Socket打开事件
98
+        /// </summary>
99
+        /// <param name="sender"></param>
100
+        /// <param name="e"></param>
101
+        void WebSocket_Opened(object sender, EventArgs e)
102
+        {
103
+            _Logger.Info(" websocket_Opened");
104
+        }
105
+        /// <summary>
106
+        /// 检查重连线程
107
+        /// </summary>
108
+        private void CheckConnection()
109
+        {
110
+            do
111
+            {
112
+                try
113
+                {
114
+                    if (this._webSocket.State != WebSocket4Net.WebSocketState.Open && this._webSocket.State != WebSocket4Net.WebSocketState.Connecting)
115
+                    {
116
+                        _Logger.Info(" Reconnect websocket WebSocketState:" + this._webSocket.State);
117
+                        this._webSocket.Close();
118
+                        this._webSocket.Open();
119
+                        Console.WriteLine("正在重连");
120
+                    }
121
+                }
122
+                catch (Exception ex)
123
+                {
124
+                    _Logger.Error(ex.ToString());
125
+                }
126
+                System.Threading.Thread.Sleep(5000);
127
+            } while (this._isRunning);
128
+        }
129
+        #endregion
130
+
131
+        /// <summary>
132
+        /// 发送消息
133
+        /// </summary>
134
+        /// <param name="Message"></param>
135
+        public void SendMessage(string Message)
136
+        {
137
+            Task.Factory.StartNew(() =>
138
+            {
139
+                if (_webSocket != null && _webSocket.State == WebSocket4Net.WebSocketState.Open)
140
+                {
141
+                    this._webSocket.Send(Message);
142
+                }
143
+            });
144
+        }
145
+
146
+        public void Dispose()
147
+        {
148
+            this._isRunning = false;
149
+            try
150
+            {
151
+                _thread.Abort();
152
+            }
153
+            catch
154
+            {
155
+
156
+            }
157
+            this._webSocket.Close();
158
+            this._webSocket.Dispose();
159
+            this._webSocket = null;
160
+        }
161
+    }
162
+}

+ 35
- 2
XHZB.Desktop/XHZB.Desktop.csproj View File

@@ -62,25 +62,51 @@
62 62
     <Reference Include="AForge.Video.DirectShow, Version=2.2.5.0, Culture=neutral, PublicKeyToken=61ea4348d43881b7, processorArchitecture=MSIL">
63 63
       <HintPath>..\packages\AForge.Video.DirectShow.2.2.5\lib\AForge.Video.DirectShow.dll</HintPath>
64 64
     </Reference>
65
-    <Reference Include="log4net">
66
-      <HintPath>..\Common\dlls\log4net.dll</HintPath>
65
+    <Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
66
+      <HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
67 67
     </Reference>
68 68
     <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
69 69
       <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
70 70
     </Reference>
71
+    <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
72
+      <HintPath>..\packages\NLog.4.5.1\lib\net45\NLog.dll</HintPath>
73
+    </Reference>
74
+    <Reference Include="SuperSocket.ClientEngine, Version=0.10.0.0, Culture=neutral, PublicKeyToken=ee9af13f57f00acc, processorArchitecture=MSIL">
75
+      <HintPath>..\packages\SuperSocket.ClientEngine.Core.0.10.0\lib\net45\SuperSocket.ClientEngine.dll</HintPath>
76
+    </Reference>
77
+    <Reference Include="SuperSocket.Common, Version=1.6.0.4, Culture=neutral, PublicKeyToken=6c80000676988ebb, processorArchitecture=MSIL">
78
+      <HintPath>..\packages\SuperWebSocket.0.9.0.2\lib\net40\SuperSocket.Common.dll</HintPath>
79
+    </Reference>
80
+    <Reference Include="SuperSocket.SocketBase, Version=1.6.0.4, Culture=neutral, PublicKeyToken=6c80000676988ebb, processorArchitecture=MSIL">
81
+      <HintPath>..\packages\SuperWebSocket.0.9.0.2\lib\net40\SuperSocket.SocketBase.dll</HintPath>
82
+    </Reference>
83
+    <Reference Include="SuperSocket.SocketEngine, Version=1.6.0.4, Culture=neutral, PublicKeyToken=6c80000676988ebb, processorArchitecture=MSIL">
84
+      <HintPath>..\packages\SuperWebSocket.0.9.0.2\lib\net40\SuperSocket.SocketEngine.dll</HintPath>
85
+    </Reference>
86
+    <Reference Include="SuperWebSocket, Version=0.9.0.0, Culture=neutral, PublicKeyToken=7ba53b9a7cef5d1c, processorArchitecture=MSIL">
87
+      <HintPath>..\packages\SuperWebSocket.0.9.0.2\lib\net40\SuperWebSocket.dll</HintPath>
88
+    </Reference>
71 89
     <Reference Include="System" />
90
+    <Reference Include="System.Configuration" />
72 91
     <Reference Include="System.Data" />
73 92
     <Reference Include="System.Drawing" />
74 93
     <Reference Include="Microsoft.CSharp" />
75 94
     <Reference Include="System.Core" />
76 95
     <Reference Include="System.Data.DataSetExtensions" />
96
+    <Reference Include="System.IO.Compression" />
77 97
     <Reference Include="System.Net.Http" />
78 98
     <Reference Include="PresentationCore" />
79 99
     <Reference Include="PresentationFramework" />
100
+    <Reference Include="System.Runtime.Serialization" />
101
+    <Reference Include="System.ServiceModel" />
102
+    <Reference Include="System.Transactions" />
80 103
     <Reference Include="System.Windows.Forms" />
81 104
     <Reference Include="System.Xaml" />
82 105
     <Reference Include="System.XML" />
83 106
     <Reference Include="System.Xml.Linq" />
107
+    <Reference Include="WebSocket4Net, Version=0.15.2.11, Culture=neutral, PublicKeyToken=eb4e154b696bf72a, processorArchitecture=MSIL">
108
+      <HintPath>..\packages\WebSocket4Net.0.15.2\lib\net45\WebSocket4Net.dll</HintPath>
109
+    </Reference>
84 110
     <Reference Include="WindowsBase" />
85 111
     <Reference Include="WindowsFormsIntegration" />
86 112
     <Reference Include="WpfAnimatedGif, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9e7cd3b544a090dc, processorArchitecture=MSIL">
@@ -115,12 +141,18 @@
115 141
     <Compile Include="Utils\BlackboardNew.cs" />
116 142
     <Compile Include="Utils\ColorBgConverter.cs" />
117 143
     <Compile Include="Utils\ColorTextConverter.cs" />
144
+    <Compile Include="Utils\DownloadUtil.cs" />
118 145
     <Compile Include="Utils\GenericTypeConverter.cs" />
119 146
     <Compile Include="Utils\RegisterController.cs" />
147
+    <Compile Include="Utils\ResultListVo.cs" />
120 148
     <Compile Include="Utils\ResultVo.cs" />
121 149
     <Compile Include="Utils\VTHelper.cs" />
122 150
     <Compile Include="Utils\ZCache.cs" />
123 151
     <Compile Include="Utils\ZDelayUtil.cs" />
152
+    <Compile Include="WebSocket\SocketCallback.cs" />
153
+    <Compile Include="WebSocket\SocketClient.cs" />
154
+    <Compile Include="WebSocket\SocketMsgManger.cs" />
155
+    <Compile Include="WebSocket\WSocketClient.cs" />
124 156
     <Compile Include="ZBlackboardWindow.xaml.cs">
125 157
       <DependentUpon>ZBlackboardWindow.xaml</DependentUpon>
126 158
     </Compile>
@@ -308,5 +340,6 @@
308 340
   <ItemGroup>
309 341
     <Resource Include="Images\RollCall\rollCall_2_1.png" />
310 342
   </ItemGroup>
343
+  <ItemGroup />
311 344
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
312 345
 </Project>

+ 5
- 0
XHZB.Desktop/packages.config View File

@@ -6,6 +6,11 @@
6 6
   <package id="AForge.Math" version="2.2.5" targetFramework="net452" />
7 7
   <package id="AForge.Video" version="2.2.5" targetFramework="net452" />
8 8
   <package id="AForge.Video.DirectShow" version="2.2.5" targetFramework="net452" />
9
+  <package id="log4net" version="2.0.3" targetFramework="net452" />
9 10
   <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net452" />
11
+  <package id="NLog" version="4.5.1" targetFramework="net452" />
12
+  <package id="SuperSocket.ClientEngine.Core" version="0.10.0" targetFramework="net452" />
13
+  <package id="SuperWebSocket" version="0.9.0.2" targetFramework="net452" />
14
+  <package id="WebSocket4Net" version="0.15.2" targetFramework="net452" />
10 15
   <package id="WpfAnimatedGif" version="2.0.0" targetFramework="net452" />
11 16
 </packages>

+ 19
- 0
XHZB.Model/BodyModel.cs View File

@@ -0,0 +1,19 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHZB.Model
8
+{
9
+    public class BodyModel
10
+    {
11
+        public string rtmp { get; set; }
12
+        public string cn { get; set; }
13
+        public string mac { get; set; }
14
+        public int stnum { get; set; }
15
+        public string stname { get; set; }
16
+        public int stid { get; set; }
17
+        public string stpic { get; set; }
18
+    }
19
+}

+ 49
- 0
XHZB.Model/ResourceMyListModel.cs View File

@@ -0,0 +1,49 @@
1
+using System.Collections.Generic;
2
+
3
+namespace XHZB.Model
4
+{
5
+    public class ResourceMyListModel
6
+    {
7
+        public List<ResourceMyListsModel> obj { get; set; }
8
+
9
+        /// <summary>
10
+        /// 总条数
11
+        /// </summary>
12
+        public int total { get; set; }
13
+
14
+        /// <summary>
15
+        /// 资源id
16
+        /// </summary>
17
+        public int resourceid { get; set; }
18
+
19
+        /// <summary>
20
+        /// 资源名称
21
+        /// </summary>
22
+        public string resourcename { get; set; }
23
+
24
+        /// <summary>
25
+        /// 创建人名称
26
+        /// </summary>
27
+        public string createname { get; set; }
28
+
29
+        /// <summary>
30
+        /// 创建时间
31
+        /// </summary>
32
+        public int createtime { get; set; }
33
+
34
+        /// <summary>
35
+        /// 文件后缀
36
+        /// </summary>
37
+        public string suffix { get; set; }
38
+
39
+        /// <summary>
40
+        /// 文件地址
41
+        /// </summary>
42
+        public string resourceurl { get; set; }
43
+
44
+        /// <summary>
45
+        /// 封面图地址
46
+        /// </summary>
47
+        public string resourcecover { get; set; }
48
+    }
49
+}

+ 114
- 0
XHZB.Model/ResourceMyListsModel.cs View File

@@ -0,0 +1,114 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHZB.Model
8
+{
9
+    public class ResourceMyListsModel
10
+    {
11
+        /// <summary>
12
+        /// 资源id
13
+        /// </summary>
14
+        public int resourceid { get; set; }
15
+
16
+        /// <summary>
17
+        /// 资源名称
18
+        /// </summary>
19
+        public string resourcename { get; set; }
20
+
21
+        /// <summary>
22
+        /// 创建人名称
23
+        /// </summary>
24
+        public string createname { get; set; }
25
+
26
+        /// <summary>
27
+        /// 创建时间
28
+        /// </summary>
29
+        public int createtime { get; set; }
30
+
31
+        /// <summary>
32
+        /// 文件后缀
33
+        /// </summary>
34
+        public string suffix { get; set; }
35
+
36
+        /// <summary>
37
+        /// 文件地址
38
+        /// </summary>
39
+        public string resourceurl { get; set; }
40
+
41
+        /// <summary>
42
+        /// 封面图地址
43
+        /// </summary>
44
+        public string resourcecover { get; set; }
45
+
46
+        /// <summary>
47
+        /// 封面图地址
48
+        /// </summary>
49
+        public int? lsbid { get; set; }
50
+
51
+        /// <summary>
52
+        /// 封面图地址
53
+        /// </summary>
54
+        public int? directorid { get; set; }
55
+
56
+        /// <summary>
57
+        /// 封面图地址
58
+        /// </summary>
59
+        public int? resourceclass { get; set; }
60
+
61
+        /// <summary>
62
+        /// 封面图地址
63
+        /// </summary>
64
+        public int? resourcetype { get; set; }
65
+
66
+        /// <summary>
67
+        /// 封面图地址
68
+        /// </summary>
69
+        public int? downcount { get; set; }
70
+
71
+        /// <summary>
72
+        /// 封面图地址
73
+        /// </summary>
74
+        public int? readcount { get; set; }
75
+
76
+        /// <summary>
77
+        ///
78
+        /// </summary>
79
+        public string comm { get; set; }
80
+
81
+        /// <summary>
82
+        ///
83
+        /// </summary>
84
+        public string pdfurl { get; set; }
85
+
86
+        /// <summary>
87
+        ///
88
+        /// </summary>
89
+        public int? converted { get; set; }
90
+
91
+        /// <summary>
92
+        ///
93
+        /// </summary>
94
+        public int? classid { get; set; }
95
+
96
+        /// <summary>
97
+        ///
98
+        /// </summary>
99
+        public int? groupid { get; set; }
100
+        /// <summary>
101
+        ///视频时长(秒)
102
+        /// </summary>
103
+        public int? duration { get; set; }
104
+        /// <summary>
105
+        ///文件大小
106
+        /// </summary>
107
+        public int? resourcesize { get; set; }
108
+
109
+        public override string ToString()
110
+        {
111
+            return $"{nameof(resourceid)}: {resourceid}, {nameof(resourcename)}: {resourcename}, {nameof(createname)}: {createname}, {nameof(createtime)}: {createtime},{nameof(suffix)}: {suffix}, {nameof(resourceurl)}: {resourceurl}, {nameof(resourcecover)}: {resourcecover}, {nameof(lsbid)}: {lsbid}, {nameof(directorid)}: {directorid}, {nameof(resourceclass)}: {resourceclass}, {nameof(resourcetype)}: {resourcetype}, {nameof(downcount)}: {downcount}, {nameof(readcount)}: {readcount}, {nameof(comm)}: {comm}, {nameof(pdfurl)}: {pdfurl}, {nameof(converted)}: {converted}, {nameof(classid)}: {classid}, {nameof(groupid)}: {groupid}, {nameof(duration)}: {duration}, {nameof(resourcesize)}: {resourcesize}";
112
+        }
113
+    }
114
+}

+ 48
- 0
XHZB.Model/SocketModel.cs View File

@@ -0,0 +1,48 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace XHZB.Model
8
+{
9
+    public class SocketModel
10
+    {
11
+        /// <summary>
12
+        /// 互动类型
13
+        /// </summary>
14
+       public int c { get; set; }
15
+        /// <summary>
16
+        /// 直播间编号
17
+        /// </summary>
18
+        public int rid { get; set; }
19
+        /// <summary>
20
+        /// 发送者ID
21
+        /// </summary>
22
+        public int f { get; set; }
23
+        /// <summary>
24
+        /// 接收者id
25
+        /// </summary>
26
+        public List<int> t { set; get; }//对象 
27
+        /// <summary>
28
+        /// 设备类型
29
+        /// </summary>
30
+        public string d { get; set; }
31
+        /// <summary>
32
+        /// 用户类型 1老师 2学生
33
+        /// </summary>
34
+        public int u { get; set; }
35
+        /// <summary>
36
+        /// 错误信息
37
+        /// </summary>
38
+        public int m { get; set; }
39
+        /// <summary>
40
+        /// 是否群发 0不发 1发
41
+        /// </summary>
42
+        public int s { get; set; }
43
+        /// <summary>
44
+        /// 消息内容
45
+        /// </summary>
46
+        public BodyModel b { get; set; }
47
+    }
48
+}

Loading…
Cancel
Save