星火微课系统客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

App.cs 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. using ComeCapture;
  2. using Common.system;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Security.Principal;
  10. using System.Threading;
  11. using System.Windows;
  12. using System.Windows.Threading;
  13. using TStudyDigitalPen.HID;
  14. using XHWK.Model;
  15. using XHWK.WKTool.Helpers;
  16. namespace XHWK.WKTool
  17. {
  18. public partial class APP : Application
  19. {
  20. #region 全局变量
  21. /// <summary>
  22. /// 是否为测试版
  23. /// </summary>
  24. public static bool isDebug = FileToolsCommon.GetConfigValue("IsDebug") != "0";
  25. /// <summary>
  26. /// 参数是否加密
  27. /// </summary>
  28. public static bool IsParameterEncryption = FileToolsCommon.GetConfigValue("IsParameterEncryption") != "0";
  29. /// <summary>
  30. /// 是否输出测试记录日志
  31. /// </summary>
  32. public static bool IsOutputInfoLog = FileToolsCommon.GetConfigValue("IsOutputInfoLog") != "0";
  33. /// <summary>
  34. /// 是否隐藏录屏工具栏
  35. /// </summary>
  36. public static bool IsHideSRTool = FileToolsCommon.GetConfigValue("IsHideSRTool") != "0";
  37. /// <summary>
  38. /// 皮肤样式 Blue蓝 Black黑色
  39. /// </summary>
  40. public static string SkinStyle = FileToolsCommon.GetConfigValue("SkinStyle");
  41. /// <summary>
  42. /// 接口地址
  43. /// </summary>
  44. public static string apiUrl = isDebug ? "http://schoolapitest.xhkjedu.com" : FileToolsCommon.GetConfigValue("APIRequestAddress");
  45. /// <summary>
  46. /// 图片地址
  47. /// </summary>
  48. public static string uploadUrl = isDebug ? "http://schoolfiletest.xhkjedu.com/" : FileToolsCommon.GetConfigValue("FileRequestAddress");
  49. /// <summary>
  50. /// 展示文件
  51. /// </summary>
  52. public static string showImageUrl = isDebug ? "http://schoolfiletest.xhkjedu.com/static/" : FileToolsCommon.GetConfigValue("SchoolfileRequestAddress") + "/static/";
  53. /// <summary>
  54. /// 认证接口地址
  55. /// </summary>
  56. public static string certapiUrl = isDebug ? "http://certapitest.xhkjedu.com" : FileToolsCommon.GetConfigValue("CertapiRequestAddress");
  57. /// <summary>
  58. /// TQL铺码服务地址
  59. /// </summary>
  60. public static string TmatrixCodeURL = FileToolsCommon.GetConfigValue("TmatrixCode");
  61. /// <summary>
  62. /// 数据存放目录
  63. /// </summary>
  64. public static string dataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XHMicroLesson\\";
  65. /// <summary>
  66. /// 后台线程帮助类
  67. /// </summary>
  68. public static BackgroundWorkerHelper BackgroundWorkerHelper => BackgroundWorkerHelper.GetInstance();
  69. /// <summary>
  70. /// 签名
  71. /// </summary>
  72. public static string Signature = "";
  73. public static string secretKey = "nanhuakaizhangjianwangni";
  74. /// <summary>
  75. /// 用户信息
  76. /// </summary>
  77. public static Model_UserInfo UserInfo = null;
  78. /// <summary>
  79. /// 接口返回消息
  80. /// </summary>
  81. public static string ServerMsg = string.Empty;
  82. /// <summary>
  83. /// 用户微课列表模型
  84. /// </summary>
  85. public static List<Model_WKData> WKDataList = null;
  86. /// <summary>
  87. /// 微课模型
  88. /// </summary>
  89. public static Model_WKData WKData = null;
  90. /// <summary>
  91. /// 微课视频列表
  92. /// </summary>
  93. public static List<Model_Video> VideoList = null;
  94. /// <summary>
  95. /// 画板模型
  96. /// </summary>
  97. public static List<Model_DrawData> PageDrawList = null;
  98. /// <summary>
  99. /// 录屏工具
  100. /// </summary>
  101. public static FFMpeg FFmpeg = new FFMpeg();
  102. /// <summary>
  103. /// 登录状态 false 未登录 true已登录
  104. /// </summary>
  105. public static bool IsLoginType = false;
  106. public static readonly Model_Page pageData = new Model.Model_Page();
  107. /// <summary>
  108. /// 防止图片地址重复
  109. /// </summary>
  110. public static long num = 9999;
  111. /// <summary>
  112. /// 导入图片路径
  113. /// </summary>
  114. public static string[] Paths = new string[] { };
  115. /// <summary>
  116. /// 截图图片路径
  117. /// </summary>
  118. public static string[] JPaths = new string[999];
  119. public static string ImgPath = string.Empty;
  120. /// <summary>
  121. /// 页码IP
  122. /// </summary>
  123. public static string[] OutPut = new string[] { };
  124. public static string CameraPosition = string.Empty;
  125. /// <summary>
  126. /// 数据存放目录
  127. /// </summary>
  128. public static string DataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XHMicroLesson\\";
  129. /// <summary>
  130. /// 教材列表
  131. /// </summary>
  132. public static List<Model_TsubjectbookList> TsubjectbookList = null;
  133. /// <summary>
  134. /// 章节列表
  135. /// </summary>
  136. public static List<Model_DirectorList> DirectorList = null;
  137. /// <summary>
  138. /// 上传个人空间 入参
  139. /// </summary>
  140. public static Model_ResourceAddTwo ResourceAddTwo = null;
  141. /// <summary>
  142. /// 是否正在上传
  143. /// </summary>
  144. public static bool IsUpLoad = false;
  145. /// <summary>
  146. /// 摄像头名
  147. /// </summary>
  148. public static string CameraName = "";
  149. /// <summary>
  150. /// 麦克风名
  151. /// </summary>
  152. public static string MicrophoneName = "";
  153. #region 点阵笔
  154. /// <summary>
  155. /// 点阵笔
  156. /// </summary>
  157. public static DigitalPenHID digitalPen;
  158. /// <summary>
  159. /// 笔序号
  160. /// </summary>
  161. public static string PenSerial;
  162. /// <summary>
  163. /// 笔状态,是否已连接
  164. /// </summary>
  165. public static bool PenStatus = false;
  166. /// <summary>
  167. /// 手写板状态,是否已连接
  168. /// </summary>
  169. public static bool BoardStatus = false;
  170. #endregion
  171. #region 腾千里手写笔
  172. ///// <summary>
  173. ///// 铺码服务请求
  174. ///// </summary>
  175. //public static DAL_TmatrixCode dAL_TmatrixCode;
  176. /// <summary>
  177. /// 腾千里手写笔事件
  178. /// </summary>
  179. public static PenEvents TQLPenevents;
  180. /// <summary>
  181. /// 腾千里手写笔是否已连接
  182. /// </summary>
  183. public static bool TQLPenStatus = false;
  184. #region 打印
  185. public static bool gbGenerateBGWithVImage = false;
  186. public static bool gbGenerateVImage = false;
  187. public static bool gbGenerateBGWithoutVImage = false;
  188. public static bool gbGenerateBGWithImage = false;
  189. public static bool gbGenPageSet = false;
  190. public static int[] gPointType = new int[4];
  191. public static int[] gPointDPI = new int[4];
  192. public static string gTMXElementFileName;
  193. public static string gNewProjectDirectory;
  194. public static bool gbElementFileExist { get; set; }
  195. #endregion
  196. #endregion
  197. #region 页面
  198. /// <summary>
  199. /// 主页面
  200. /// </summary>
  201. public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
  202. /// <summary>
  203. /// 创建微课页面
  204. /// </summary>
  205. public static CreateAMicroLessonWindow W_CreateAMicroLessonWindow = null;
  206. /// <summary>
  207. /// 开始录像
  208. /// </summary>
  209. public static CountdownWindow W_CountdownWindow = null;
  210. /// <summary>
  211. /// 录像工具栏
  212. /// </summary>
  213. public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
  214. /// <summary>
  215. /// 登录
  216. /// </summary>
  217. public static LoginWindow W_LoginWindow = null;
  218. /// <summary>
  219. /// 截图
  220. /// </summary>
  221. public static JieTuWindow W_JieTuWindow = null;
  222. /// <summary>
  223. /// 批注
  224. /// </summary>
  225. public static PracticeWindow W_PracticeWindow = null;
  226. /// <summary>
  227. /// 我的视频
  228. /// </summary>
  229. public static FileDirectoryWindow fileDirectoryWindow = null;
  230. /// <summary>
  231. /// 打印
  232. /// </summary>
  233. public static PrintWindow W_PrintWindow = null;
  234. /// <summary>
  235. /// 提示窗口
  236. /// </summary>
  237. public static PromptWindow W_PromptWindow = null;
  238. /// <summary>
  239. /// loding页面
  240. /// </summary>
  241. public static LoadDialog myloading;
  242. /// <summary>
  243. /// 上传页面
  244. /// </summary>
  245. public static UploadWindow W_UploadWindow = null;
  246. /// <summary>
  247. /// 最小化工具栏
  248. /// </summary>
  249. public static MinToolbar W_MinToolbar = null;
  250. /// <summary>
  251. /// 视频剪辑
  252. /// </summary>
  253. public static VideoClipWindow W_VideoClipWindow = null;
  254. /// <summary>
  255. /// 设备检测
  256. /// </summary>
  257. public static DeviceWindow W_DeviceWindow = null;
  258. #endregion
  259. #endregion
  260. [STAThread]
  261. private static void Main()
  262. {
  263. myloading = new LoadDialog();
  264. StopSameProcess();
  265. Killffmpeg();
  266. LatticeFileHelper.RunPrintConfig();
  267. try
  268. {
  269. UserInfo = new Model_UserInfo();
  270. WKDataList = new List<Model_WKData>();
  271. VideoList = new List<Model_Video>();
  272. #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
  273. WindowsIdentity identity = WindowsIdentity.GetCurrent();
  274. WindowsPrincipal principal = new WindowsPrincipal(identity);
  275. //判断当前登录用户是否为管理员
  276. //if (principal.IsInRole(WindowsBuiltInRole.Administrator))
  277. //{
  278. // //如果是管理员,则直接运行
  279. // W_CreateAMicroLessonWindow = new CreateAMicroLessonWindow();
  280. // // 定义Application对象作为整个应用程序入口
  281. // Application app = new Application();
  282. // app.Run(W_CreateAMicroLessonWindow);
  283. // //Application.Run(W_CreateAMicroLessonWindow);
  284. //}
  285. //else
  286. //{
  287. // //创建启动对象
  288. // System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo
  289. // {
  290. // UseShellExecute = true,
  291. // WorkingDirectory = Environment.CurrentDirectory,
  292. // FileName = Assembly.GetExecutingAssembly().Location,
  293. // //设置启动动作,确保以管理员身份运行
  294. // Verb = "runas"
  295. // };
  296. // try
  297. // {
  298. // System.Diagnostics.Process.Start(startInfo);
  299. // }
  300. // catch
  301. // {
  302. // return;
  303. // }
  304. // //退出
  305. // //Current.Shutdown();
  306. // Environment.Exit(0);
  307. //}
  308. #endregion
  309. try
  310. {
  311. if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "temp"))//清除临时文件
  312. {
  313. Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + "temp", true);
  314. }
  315. }
  316. catch (Exception)
  317. {
  318. }
  319. //如果本地文件为空,弹出弹窗 输密匙
  320. //本地文件不为空, 解析
  321. if (!File.Exists(APP.dataPath + "signature.txt"))//上次登录时间为空 或者签名为空 或者上次登录时间不是今天 都需要输入密匙验证 ,否则只验证本地的签名
  322. {
  323. if (principal.IsInRole(WindowsBuiltInRole.Administrator))
  324. {
  325. //如果是管理员,则直接运行
  326. KeyVerification wins = new KeyVerification();
  327. // 定义Application对象作为整个应用程序入口
  328. Application app = new Application();
  329. app.Run(wins);
  330. }
  331. else
  332. {
  333. //创建启动对象
  334. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo
  335. {
  336. UseShellExecute = true,
  337. WorkingDirectory = Environment.CurrentDirectory,
  338. FileName = Assembly.GetExecutingAssembly().Location,
  339. //设置启动动作,确保以管理员身份运行
  340. Verb = "runas"
  341. };
  342. try
  343. {
  344. System.Diagnostics.Process.Start(startInfo);
  345. }
  346. catch
  347. {
  348. return;
  349. }
  350. //退出
  351. //Current.Shutdown();
  352. Environment.Exit(0);
  353. }
  354. }
  355. else
  356. {
  357. if (principal.IsInRole(WindowsBuiltInRole.Administrator))
  358. {
  359. ProductVerification wins = new ProductVerification();
  360. Application app = new Application();
  361. app.Run(wins);
  362. }
  363. else
  364. {
  365. //创建启动对象
  366. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo
  367. {
  368. UseShellExecute = true,
  369. WorkingDirectory = Environment.CurrentDirectory,
  370. FileName = Assembly.GetExecutingAssembly().Location,
  371. //设置启动动作,确保以管理员身份运行
  372. Verb = "runas"
  373. };
  374. try
  375. {
  376. System.Diagnostics.Process.Start(startInfo);
  377. }
  378. catch
  379. {
  380. return;
  381. }
  382. //退出
  383. //Current.Shutdown();
  384. Environment.Exit(0);
  385. }
  386. }
  387. }
  388. catch (Exception ex)
  389. {
  390. string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
  391. LogHelper.WriteErrLog(ErrMessage, ex);
  392. }
  393. }
  394. #region 杀死已存在的进程
  395. /// <summary>
  396. /// 结束已运行的程序
  397. /// </summary>
  398. private static void StopSameProcess()
  399. {
  400. Process current = Process.GetCurrentProcess();
  401. Process[] processList = Process.GetProcesses();
  402. foreach (Process process in processList)
  403. {
  404. if (process.ProcessName.ToUpper() == "星火微课")
  405. {
  406. if (process.Id != current.Id) //忽略当前进程
  407. {
  408. try
  409. {
  410. process.Kill(); //结束进程
  411. }
  412. catch (Exception)
  413. {
  414. }
  415. }
  416. }
  417. }
  418. }
  419. /// <summary>
  420. /// 杀死正在运行的ffmpeg
  421. /// </summary>
  422. public static void Killffmpeg()
  423. {
  424. Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
  425. foreach (Process KillProcess in KillProcessArray)
  426. {
  427. KillProcess.Kill();
  428. }
  429. }
  430. #endregion
  431. /// <summary>
  432. /// 错误处理
  433. /// </summary>
  434. /// <param name="sender"></param>
  435. /// <param name="e"></param>
  436. private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
  437. {
  438. LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
  439. MessageWindow.Show("程序异常." + Environment.NewLine + e.Exception.Message);
  440. e.Handled = true;
  441. }
  442. #region 数据保存和读取
  443. /// <summary>
  444. /// 保存微课信息
  445. /// </summary>
  446. public static void SaveWkData()
  447. {
  448. try
  449. {
  450. VideoList = VideoList.Where((x, i) => VideoList.FindIndex(z => z.FileGuid == x.FileGuid) == i).ToList();
  451. WKData.VideoList = VideoList;
  452. if (WKDataList != null)
  453. {
  454. WKDataList.RemoveAll(x => x.WkPath == WKData.WkPath);
  455. }
  456. else
  457. {
  458. WKDataList = new List<Model_WKData>();
  459. }
  460. WKDataList.Add(WKData);
  461. //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
  462. string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
  463. string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
  464. FileToolsCommon.CreateDirectory(SavePath);
  465. string SaveName = SavePath + "WkDate.d";
  466. FileToolsCommon.DeleteFile(SaveName);
  467. FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
  468. }
  469. catch (Exception ex)
  470. {
  471. LogHelper.WriteErrLog("【微课数据保存】(SaveWkData)保存失败:" + ex.Message, ex);
  472. }
  473. }
  474. /// <summary>
  475. /// 读取微课信息
  476. /// </summary>
  477. public static void ReadWkData(string WkPath)
  478. {
  479. try
  480. {
  481. string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
  482. FileToolsCommon.CreateDirectory(SavePath);
  483. string SaveName = SavePath + "WkDate.d";
  484. //文件若存在则读取
  485. if (FileToolsCommon.IsExistFile(SaveName))
  486. {
  487. string WkDateXmlStr = FileToolsCommon.FileToString(SaveName);
  488. WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
  489. foreach (Model_WKData wklist in WKDataList)
  490. {
  491. //移除找不到视频的微课数据
  492. wklist.VideoList.RemoveAll(x => !FileToolsCommon.IsExistFile(x.VideoPath));
  493. }
  494. if (WKDataList.Exists(x => x.WkPath == WkPath))
  495. {
  496. WKData = WKDataList.Find(x => x.WkPath == WkPath);
  497. VideoList = new List<Model_Video>();
  498. WKData.VideoList = WKData.VideoList.Where((x, i) => WKData.VideoList.FindIndex(z => z.FileGuid == x.FileGuid) == i).ToList();
  499. VideoList = WKData.VideoList;
  500. //List<Model_Video> companyList = WKData.VideoList;
  501. //VideoList = companyList.Where((x, i) => companyList.FindIndex(z => z.FileGuid == x.FileGuid) == i).ToList();
  502. //VideoList = companyList.Distinct().ToList();
  503. }
  504. }
  505. }
  506. catch (Exception ex)
  507. {
  508. LogHelper.WriteErrLog("【微课数据读取】(ReadWkData)读取失败:" + ex.Message, ex);
  509. }
  510. }
  511. /// <summary>
  512. /// 保存画板数据
  513. /// </summary>
  514. public static void SaveDraw()
  515. {
  516. try
  517. {
  518. if (PageDrawList == null)
  519. {
  520. return;
  521. }
  522. if (PageDrawList.Count < 1)
  523. {
  524. return;
  525. }
  526. FileToolsCommon.CreateDirectory(WKData.WkPath);
  527. string SavePath = WKData.WkPath + "PageData.d";
  528. FileToolsCommon.DeleteFile(SavePath);
  529. string PageDataXmlStr = XmlUtilHelper.XmlSerialize(PageDrawList);
  530. FileToolsCommon.WriteText(SavePath, PageDataXmlStr);
  531. }
  532. catch (Exception ex)
  533. {
  534. LogHelper.WriteErrLog("【画板数据保存】(SaveDraw)保存失败:" + ex.Message, ex);
  535. }
  536. }
  537. /// <summary>
  538. /// 读取文件
  539. /// </summary>
  540. public static void ReadDrawData()
  541. {
  542. try
  543. {
  544. PageDrawList = new List<Model_DrawData>();
  545. string SavePath = WKData.WkPath + "PageData.d";
  546. if (FileToolsCommon.IsExistFile(SavePath))
  547. {
  548. string PageDataXmlStr = FileToolsCommon.FileToString(SavePath);
  549. PageDrawList = XmlUtilHelper.DESerializer<List<Model_DrawData>>(PageDataXmlStr);
  550. }
  551. }
  552. catch (Exception ex)
  553. {
  554. LogHelper.WriteErrLog("【画板数据读取】(ReadDraw)读取失败:" + ex.Message, ex);
  555. }
  556. }
  557. #endregion
  558. #region 检测安装Screen Capturer Recorder
  559. /// <summary>
  560. /// 检测是否安装了Screen Capturer Recorder
  561. /// </summary>
  562. /// <returns></returns>
  563. public static bool CheckScreenCapturerRecorder()
  564. {
  565. if (FileToolsCommon.CheckSoftWartInstallState("Screen Capturer Recorder"))
  566. {
  567. //已经安装
  568. return true;
  569. }
  570. else
  571. {
  572. return false;
  573. }
  574. }
  575. /// <summary>
  576. /// 安装Screen Capturer Recorder
  577. /// </summary>
  578. /// <returns></returns>
  579. public static bool InstallScreenCapturerRecorder()
  580. {
  581. Process InstallProcess = new Process();
  582. string StandardError = "";
  583. string StandardOutput = "";
  584. try
  585. {
  586. InstallProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/SSCR/Setup Screen Capturer Recorder v0.12.10.exe"); //绝对路径
  587. InstallProcess.StartInfo.UseShellExecute = false; //不使用操作系统外壳程序启动
  588. InstallProcess.StartInfo.RedirectStandardError = true; //重定向标准错误输出
  589. InstallProcess.StartInfo.RedirectStandardOutput = true;
  590. InstallProcess.StartInfo.CreateNoWindow = true; //不显示程序窗口
  591. InstallProcess.StartInfo.RedirectStandardInput = true; //用于模拟该进程控制台的输入
  592. //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
  593. InstallProcess.ErrorDataReceived += new DataReceivedEventHandler(InstallProcess_ErrorDataReceived);
  594. InstallProcess.Start(); //启动线程
  595. InstallProcess.WaitForExit(); //阻塞等待进程结束
  596. StandardError = InstallProcess.StandardError.ReadToEnd();
  597. StandardOutput = InstallProcess.StandardOutput.ReadToEnd();
  598. int ExitCode = InstallProcess.ExitCode;
  599. InstallProcess.Close(); //关闭进程
  600. InstallProcess.Dispose(); //释放资源
  601. if (ExitCode == 0) //非0则为安装失败 1为取消安装
  602. {
  603. return true;
  604. }
  605. else
  606. {
  607. MessageBoxResult br = MessageWindow.Show("不安装环境将无法使用微课录制系统,是否现在安装?", "安装", MessageBoxButton.OKCancel);
  608. if (br == MessageBoxResult.OK)
  609. {
  610. return InstallScreenCapturerRecorder();
  611. }
  612. else
  613. {
  614. return false;
  615. }
  616. }
  617. }
  618. catch (Exception ex)
  619. {
  620. LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装失败:" + ex.Message, ex);
  621. if (string.IsNullOrWhiteSpace(StandardError))
  622. {
  623. LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装失败:" + StandardError, null);
  624. }
  625. if (string.IsNullOrWhiteSpace(StandardOutput))
  626. {
  627. LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装返回信息:" + StandardOutput, null);
  628. }
  629. return false;
  630. }
  631. }
  632. /// <summary>
  633. /// 安装失败信息
  634. /// </summary>
  635. /// <param name="sender"></param>
  636. /// <param name="e"></param>
  637. private static void InstallProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
  638. {
  639. LogHelper.WriteErrLog("【ScreenCapturerRecorder安装】(installScreenCapturerRecorder)安装失败:" + e.Data, null);
  640. //MessageWindow.Show(e.Data);
  641. }
  642. #endregion
  643. #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  644. /// <summary>
  645. /// 内存释放压缩
  646. /// </summary>
  647. /// <param name="e"></param>
  648. protected override void OnStartup(StartupEventArgs e)
  649. {
  650. //private LierdaCracker cracker = new LierdaCracker();
  651. //cracker.Cracker(5000);//间隔时间
  652. //base.OnStartup(e);
  653. new Thread(o =>
  654. {
  655. while (true)
  656. {
  657. try
  658. {
  659. //FreeMemoryHelper.SetDate();
  660. FreeMemoryHelper.ReallocateMemory();
  661. Thread.Sleep(20000);//暂定每20秒释放一次
  662. }
  663. catch (Exception ex)
  664. {
  665. LogHelper.WriteErrLog("【释放内存(MyApp)" + ex.Message, ex);
  666. }
  667. }
  668. }).Start();
  669. }
  670. #endregion 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
  671. }
  672. }