星火微课系统客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

App.cs 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using ComeCapture;
  2. using Common.system;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Security.RightsManagement;
  7. using System.Threading;
  8. using System.Windows;
  9. using System.Windows.Threading;
  10. using XHWK.Model;
  11. namespace XHWK.WKTool
  12. {
  13. public partial class APP : Application
  14. {
  15. #region 全局变量
  16. /// <summary>
  17. /// 用户信息
  18. /// </summary>
  19. public static Model_UserInfo UserInfo=null;
  20. /// <summary>
  21. /// 接口返回消息
  22. /// </summary>
  23. public static string ServerMsg=string.Empty;
  24. /// <summary>
  25. /// 用户微课列表模型
  26. /// </summary>
  27. public static List<Model_WKData> WKDataList = null;
  28. /// <summary>
  29. /// 微课模型
  30. /// </summary>
  31. public static Model_WKData WKData = null;
  32. /// <summary>
  33. /// 微课视频列表
  34. /// </summary>
  35. public static List<Model_Video> VideoList = null;
  36. /// <summary>
  37. /// 主页面
  38. /// </summary>
  39. public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
  40. /// <summary>
  41. /// 录屏工具
  42. /// </summary>
  43. public static FFMpeg FFmpeg = new FFMpeg();
  44. /// <summary>
  45. /// 开始录像
  46. /// </summary>
  47. public static CountdownWindow W_CountdownWindow = null;
  48. /// <summary>
  49. /// 录像工具栏
  50. /// </summary>
  51. public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
  52. /// <summary>
  53. /// 登陆
  54. /// </summary>
  55. public static LoginWindow W_LoginWindow = null;
  56. /// <summary>
  57. /// 截图
  58. /// </summary>
  59. public static JieTuWindow W_JieTuWindow = null;
  60. /// <summary>
  61. /// 批注
  62. /// </summary>
  63. public static PracticeWindow W_PracticeWindow = null;
  64. /// <summary>
  65. /// 登陆状态 false 未登录 true已登陆
  66. /// </summary>
  67. public static bool IsLoginType = false;
  68. public static readonly Model_Page pageData = new Model.Model_Page();
  69. /// <summary>
  70. /// 防止图片地址重复
  71. /// </summary>
  72. public static long num = 9999;
  73. /// <summary>
  74. /// 导入图片路径
  75. /// </summary>
  76. public static string[] Paths = new string[] { };
  77. /// <summary>
  78. /// 截图图片路径
  79. /// </summary>
  80. public static string[] JPaths = new string[999];
  81. public static string ImgPath = string.Empty;
  82. #endregion
  83. [STAThread]
  84. private static void Main()
  85. {
  86. // 定义Application对象作为整个应用程序入口
  87. Application app = new Application();
  88. UserInfo = new Model_UserInfo();
  89. WKDataList = new List<Model_WKData>();
  90. WKData = new Model_WKData();
  91. VideoList = new List<Model_Video>();
  92. //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
  93. CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
  94. app.Run(win);
  95. //LogHelper.WriteInfoLog("启动项目");
  96. StopSameProcess();
  97. LatticeFileHelper.RunPrintConfig();
  98. }
  99. /// <summary>
  100. /// 结束已运行的程序
  101. /// </summary>
  102. private static void StopSameProcess()
  103. {
  104. Process current = Process.GetCurrentProcess();
  105. Process[] processList = Process.GetProcesses();
  106. foreach (Process process in processList)
  107. {
  108. if (process.ProcessName.ToUpper() == "XHSCHOOL")
  109. {
  110. if (process.Id != current.Id) //忽略当前进程
  111. {
  112. try
  113. {
  114. process.Kill(); //结束进程
  115. }
  116. catch (Exception)
  117. {
  118. }
  119. }
  120. }
  121. }
  122. }
  123. /// <summary>
  124. /// 错误处理
  125. /// </summary>
  126. /// <param name="sender"></param>
  127. /// <param name="e"></param>
  128. private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  129. {
  130. LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
  131. MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
  132. e.Handled = true;
  133. }
  134. /// <summary>
  135. /// 保存微课信息
  136. /// </summary>
  137. public static void SaveWkData()
  138. {
  139. if(UserInfo == null)
  140. {
  141. return;
  142. }
  143. if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
  144. {
  145. WKData.VideoList = VideoList;
  146. if (WKDataList != null)
  147. {
  148. WKDataList.RemoveAll(x => x.WkName == WKData.WkName);
  149. }
  150. else
  151. {
  152. WKDataList = new List<Model_WKData>();
  153. }
  154. WKDataList.Add(WKData);
  155. //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
  156. string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
  157. string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
  158. FileToolsCommon.CreateDirectory(SavePath);
  159. string SaveName = SavePath + "UserWkDate.d";
  160. FileToolsCommon.DeleteFile(SaveName);
  161. FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
  162. }
  163. }
  164. /// <summary>
  165. /// 读取微课信息
  166. /// </summary>
  167. public static void ReadWkData()
  168. {
  169. if (UserInfo == null)
  170. {
  171. return;
  172. }
  173. if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
  174. {
  175. string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
  176. FileToolsCommon.CreateDirectory(SavePath);
  177. string SaveName = SavePath + "UserWkDate.d";
  178. if (FileToolsCommon.IsExistFile(SaveName))
  179. {
  180. string WkDateXmlStr=FileToolsCommon.FileToString(SaveName);
  181. WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
  182. if (WKDataList != null)
  183. {
  184. WKDataList.RemoveAll(x => x.WkName == WKData.WkName);
  185. }
  186. }
  187. }
  188. }
  189. #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  190. /// <summary>
  191. /// 内存释放压缩
  192. /// </summary>
  193. /// <param name="e"></param>
  194. protected override void OnStartup(StartupEventArgs e)
  195. {
  196. //private LierdaCracker cracker = new LierdaCracker();
  197. //cracker.Cracker(5000);//间隔时间
  198. //base.OnStartup(e);
  199. new Thread(o =>
  200. {
  201. while (true)
  202. {
  203. try
  204. {
  205. //FreeMemoryHelper.SetDate();
  206. FreeMemoryHelper.ReallocateMemory();
  207. Thread.Sleep(20000);//暂定每20秒释放一次
  208. }
  209. catch (Exception ex)
  210. {
  211. LogHelper.WriteErrLog("【释放内存(MyApp)" + ex.Message, ex);
  212. }
  213. }
  214. }).Start();
  215. }
  216. #endregion 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  217. }
  218. }