星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

App.cs 4.4KB

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