星火微课系统客户端
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 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 Model_WKData WKData = null;
  28. /// <summary>
  29. /// 微课视频列表
  30. /// </summary>
  31. public static List<Model_Video> VideoList = null;
  32. /// <summary>
  33. /// 主页面
  34. /// </summary>
  35. public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
  36. /// <summary>
  37. /// 录屏工具
  38. /// </summary>
  39. public static FFMpeg FFmpeg = new FFMpeg();
  40. /// <summary>
  41. /// 开始录像
  42. /// </summary>
  43. public static CountdownWindow W_CountdownWindow = null;
  44. /// <summary>
  45. /// 录像工具栏
  46. /// </summary>
  47. public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
  48. /// <summary>
  49. /// 登陆
  50. /// </summary>
  51. public static LoginWindow W_LoginWindow = null;
  52. /// <summary>
  53. /// 截图
  54. /// </summary>
  55. public static JieTuWindow W_JieTuWindow = null;
  56. /// <summary>
  57. /// 批注
  58. /// </summary>
  59. public static PracticeWindow W_PracticeWindow = null;
  60. /// <summary>
  61. /// 登陆状态 false 未登录 true已登陆
  62. /// </summary>
  63. public static bool IsLoginType = false;
  64. public static readonly Model_Page pageData = new Model.Model_Page();
  65. /// <summary>
  66. /// 防止图片地址重复
  67. /// </summary>
  68. public static long num = 9999;
  69. /// <summary>
  70. /// 导入图片路径
  71. /// </summary>
  72. public static string[] Paths = new string[] { };
  73. /// <summary>
  74. /// 截图图片路径
  75. /// </summary>
  76. public static string[] JPaths = new string[999];
  77. public static string ImgPath = string.Empty;
  78. #endregion
  79. [STAThread]
  80. private static void Main()
  81. {
  82. // 定义Application对象作为整个应用程序入口
  83. Application app = new Application();
  84. UserInfo = new Model_UserInfo();
  85. WKData = new Model_WKData();
  86. VideoList = new List<Model_Video>();
  87. //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
  88. CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
  89. app.Run(win);
  90. //LogHelper.WriteInfoLog("启动项目");
  91. StopSameProcess();
  92. }
  93. /// <summary>
  94. /// 结束已运行的程序
  95. /// </summary>
  96. private static void StopSameProcess()
  97. {
  98. Process current = Process.GetCurrentProcess();
  99. Process[] processList = Process.GetProcesses();
  100. foreach (Process process in processList)
  101. {
  102. if (process.ProcessName.ToUpper() == "XHSCHOOL")
  103. {
  104. if (process.Id != current.Id) //忽略当前进程
  105. {
  106. try
  107. {
  108. process.Kill(); //结束进程
  109. }
  110. catch (Exception)
  111. {
  112. }
  113. }
  114. }
  115. }
  116. }
  117. /// <summary>
  118. /// 错误处理
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  123. {
  124. LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
  125. MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
  126. e.Handled = true;
  127. }
  128. /// <summary>
  129. /// 保存微课信息
  130. /// </summary>
  131. public static void SaveWkData()
  132. {
  133. if(UserInfo == null)
  134. {
  135. return;
  136. }
  137. if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
  138. {
  139. WKData.VideoList = VideoList;
  140. //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
  141. string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKData);
  142. string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
  143. FileToolsCommon.CreateDirectory(SavePath);
  144. }
  145. //if(APP.UserInfo)
  146. //APP.UserInfo.Wkdata.Add(APP.WKData);
  147. }
  148. #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  149. /// <summary>
  150. /// 内存释放压缩
  151. /// </summary>
  152. /// <param name="e"></param>
  153. protected override void OnStartup(StartupEventArgs e)
  154. {
  155. //private LierdaCracker cracker = new LierdaCracker();
  156. //cracker.Cracker(5000);//间隔时间
  157. //base.OnStartup(e);
  158. new Thread(o =>
  159. {
  160. while (true)
  161. {
  162. try
  163. {
  164. //FreeMemoryHelper.SetDate();
  165. FreeMemoryHelper.ReallocateMemory();
  166. Thread.Sleep(20000);//暂定每20秒释放一次
  167. }
  168. catch (Exception ex)
  169. {
  170. LogHelper.WriteErrLog("【释放内存(MyApp)" + ex.Message, ex);
  171. }
  172. }
  173. }).Start();
  174. }
  175. #endregion 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  176. }
  177. }