星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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