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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using ComeCapture;
  2. using Common.system;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Threading;
  7. using System.Windows;
  8. using System.Windows.Threading;
  9. using XHWK.Model;
  10. namespace XHWK.WKTool
  11. {
  12. public partial class APP : Application
  13. {
  14. #region 全局变量
  15. /// <summary>
  16. /// 用户信息
  17. /// </summary>
  18. public static Model_UserInfo UserInfo=null;
  19. /// <summary>
  20. /// 接口返回消息
  21. /// </summary>
  22. public static string ServerMsg=string.Empty;
  23. /// <summary>
  24. /// 微课模型
  25. /// </summary>
  26. public static Model_WKData WKData = null;
  27. /// <summary>
  28. /// 主页面
  29. /// </summary>
  30. public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
  31. /// <summary>
  32. /// 录屏工具
  33. /// </summary>
  34. public static FFMpeg FFmpeg = new FFMpeg();
  35. /// <summary>
  36. /// 开始录像
  37. /// </summary>
  38. public static CountdownWindow W_CountdownWindow = null;
  39. /// <summary>
  40. /// 录像工具栏
  41. /// </summary>
  42. public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
  43. /// <summary>
  44. /// 登陆
  45. /// </summary>
  46. public static LoginWindow W_LoginWindow = null;
  47. /// <summary>
  48. /// 截图
  49. /// </summary>
  50. public static JieTuWindow W_JieTuWindow = null;
  51. /// <summary>
  52. /// 批注
  53. /// </summary>
  54. public static PracticeWindow W_PracticeWindow = null;
  55. /// <summary>
  56. /// 登陆状态 false 未登录 true已登陆
  57. /// </summary>
  58. public static bool IsLoginType = false;
  59. public static readonly Model_Page pageData = new Model.Model_Page();
  60. /// <summary>
  61. /// 防止图片地址重复
  62. /// </summary>
  63. public static long num = 9999;
  64. /// <summary>
  65. /// 导入图片路径
  66. /// </summary>
  67. public static string[] Paths = new string[] { };
  68. /// <summary>
  69. /// 截图图片路径
  70. /// </summary>
  71. public static string[] JPaths = new string[999];
  72. public static string ImgPath = string.Empty;
  73. #endregion
  74. [STAThread]
  75. private static void Main()
  76. {
  77. // 定义Application对象作为整个应用程序入口
  78. Application app = new Application();
  79. WKData = new Model_WKData();
  80. //app.DispatcherUnhandledException += MyApp_DispatcherUnhandledException;
  81. CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
  82. app.Run(win);
  83. //LogHelper.WriteInfoLog("启动项目");
  84. StopSameProcess();
  85. }
  86. private static void StopSameProcess()
  87. {
  88. Process current = Process.GetCurrentProcess();
  89. Process[] processList = Process.GetProcesses();
  90. foreach (Process process in processList)
  91. {
  92. if (process.ProcessName.ToUpper() == "XHSCHOOL")
  93. {
  94. if (process.Id != current.Id) //忽略当前进程
  95. {
  96. try
  97. {
  98. process.Kill(); //结束进程
  99. }
  100. catch (Exception)
  101. {
  102. }
  103. }
  104. }
  105. }
  106. }
  107. private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  108. {
  109. LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
  110. MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
  111. e.Handled = true;
  112. }
  113. #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  114. /// <summary>
  115. /// 内存释放压缩
  116. /// </summary>
  117. /// <param name="e"></param>
  118. protected override void OnStartup(StartupEventArgs e)
  119. {
  120. //private LierdaCracker cracker = new LierdaCracker();
  121. //cracker.Cracker(5000);//间隔时间
  122. //base.OnStartup(e);
  123. new Thread(o =>
  124. {
  125. while (true)
  126. {
  127. try
  128. {
  129. //FreeMemoryHelper.SetDate();
  130. FreeMemoryHelper.ReallocateMemory();
  131. Thread.Sleep(20000);//暂定每20秒释放一次
  132. }
  133. catch (Exception ex)
  134. {
  135. LogHelper.WriteErrLog("【释放内存(MyApp)" + ex.Message, ex);
  136. }
  137. }
  138. }).Start();
  139. }
  140. #endregion 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  141. }
  142. }