星火微课系统客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 3 gadiem
pirms 4 gadiem
pirms 3 gadiem
pirms 4 gadiem
pirms 3 gadiem
pirms 4 gadiem
pirms 3 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 1 gada
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 1 gada
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 1 gada
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 4 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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.Tasks;
  11. using System.Windows;
  12. using XHWK.Model;
  13. using XHWK.WKTool.Helpers;
  14. using XHWK.WKTool.Skin;
  15. namespace XHWK.WKTool
  16. {
  17. using System.Runtime.InteropServices;
  18. using system;
  19. using XHWK.WKTool.Utils;
  20. public partial class App
  21. {
  22. #region 全局变量
  23. #region 更新需改动
  24. /// <summary>
  25. /// 是否为测试版
  26. /// </summary>
  27. public static bool isDebug = FileToolsCommon.GetConfigValue("IsDebug") != "0";
  28. #endregion 更新需改动
  29. #region 接口地址
  30. /// <summary>
  31. /// 是否为校外接口
  32. /// </summary>
  33. public static bool IsOutsideSchool = FileToolsCommon.GetConfigValue("IsOutsideSchool") == "1";
  34. /// <summary>
  35. /// 服务地址
  36. /// </summary>
  37. public static ModelServiceAddress ServiceAddress;
  38. /// <summary>
  39. /// 接口地址
  40. /// </summary>
  41. public static string apiUrl = isDebug ? "http://schoolapitest.xhkjedu.com" : "http://schoolapi.xhkjedu.com";
  42. /// <summary>
  43. /// 图片地址
  44. /// </summary>
  45. public static string uploadUrl = isDebug ? "http://schoolfiletest.xhkjedu.com/" : "http://schoolfile.xhkjedu.com/";
  46. /// <summary>
  47. /// 展示文件
  48. /// </summary>
  49. public static string showImageUrl = isDebug ? "http://schoolstatictest.xhkjedu.com/static/" : "http://schoolstatic.xhkjedu.com/static/";
  50. /// <summary>
  51. /// 认证接口地址
  52. /// </summary>
  53. public static string certapiUrl = isDebug ? "http://scapitest.xhkjedu.com" : "http://scapi.xhkjedu.com";
  54. #endregion 接口地址
  55. #region 配置项
  56. /// <summary>
  57. /// 是否输出测试记录日志
  58. /// </summary>
  59. public static bool IsOutputInfoLog = FileToolsCommon.GetConfigValue("IsOutputInfoLog") != "0";
  60. /// <summary>
  61. /// 是否隐藏录屏工具栏
  62. /// </summary>
  63. public static bool IsHideSRTool = FileToolsCommon.GetConfigValue("IsHideSRTool") != "0";
  64. /// <summary>
  65. /// 皮肤样式 0白 1蓝 2黑色
  66. /// </summary>
  67. public static string SkinStyle = FileToolsCommon.GetConfigValue("SkinStyle");
  68. /// <summary>
  69. /// 数据存放目录
  70. /// </summary>
  71. public static string DataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XHMicroLesson\\";
  72. /// <summary>
  73. /// 摄像头位置
  74. /// </summary>
  75. public static string CameraPosition = string.Empty;
  76. /// <summary>
  77. /// 摄像头名
  78. /// </summary>
  79. public static string CameraName = "";
  80. /// <summary>
  81. /// 麦克风名
  82. /// </summary>
  83. public static string MicrophoneName = "";
  84. #endregion 配置项
  85. #region 记录数据
  86. /// <summary>
  87. /// 全局页面数据变量
  88. /// </summary>
  89. public static readonly ModelPage PageContextData = new Model.ModelPage();
  90. /// <summary>
  91. /// 录屏工具
  92. /// </summary>
  93. public static FFMpeg FFmpeg = new FFMpeg();
  94. /// <summary>
  95. /// 后台线程帮助类
  96. /// </summary>
  97. public static BackgroundWorkerHelper BackgroundWorkerHelper => BackgroundWorkerHelper.GetInstance();
  98. /// <summary>
  99. /// 签名
  100. /// </summary>
  101. public static string Signature = "";
  102. public static string secretKey = "nanhuakaizhangjianwangni";
  103. /// <summary>
  104. /// 用户信息
  105. /// </summary>
  106. public static ModelUserInfo UserInfo;
  107. /// <summary>
  108. /// 接口返回消息
  109. /// </summary>
  110. public static string ServerMsg = string.Empty;
  111. /// <summary>
  112. /// 登录状态 false 未登录 true已登录
  113. /// </summary>
  114. public static bool IsLoginType = false;
  115. /// <summary>
  116. /// 截图地址
  117. /// </summary>
  118. public static string ImgPath = string.Empty;
  119. /// <summary>
  120. /// 教材列表
  121. /// </summary>
  122. public static List<ModelTsubjectbookList> TsubjectbookList = null;
  123. /// <summary>
  124. /// 章节列表
  125. /// </summary>
  126. public static List<ModelDirectorList> DirectorList = null;
  127. /// <summary>
  128. /// 上传个人空间 入参
  129. /// </summary>
  130. public static ModelResourceAddTwo ResourceAddTwo = null;
  131. /// <summary>
  132. /// 是否正在上传
  133. /// </summary>
  134. public static bool IsUpLoad = false;
  135. #endregion 记录数据
  136. #region 微课数据记录
  137. /// <summary>
  138. /// 用户微课列表模型
  139. /// </summary>
  140. public static List<ModelWkData> WKDataList;
  141. /// <summary>
  142. /// 微课模型
  143. /// </summary>
  144. public static ModelWkData WKData;
  145. /// <summary>
  146. /// 微课视频列表
  147. /// </summary>
  148. public static List<ModelVideo> VideoList;
  149. /// <summary>
  150. /// 画板模型
  151. /// </summary>
  152. public static List<ModelDrawData> PageDrawList = new List<ModelDrawData>();
  153. #endregion 微课数据记录
  154. #region 点阵笔
  155. /// <summary>
  156. /// 笔序号
  157. /// </summary>
  158. public static string PenSerial;
  159. /// <summary>
  160. /// 笔状态,是否已连接
  161. /// </summary>
  162. public static bool PenStatus = false;
  163. /// <summary>
  164. /// 手写板状态,是否已连接
  165. /// </summary>
  166. public static bool BoardStatus = false;
  167. #endregion 点阵笔
  168. #region 腾千里手写笔
  169. ///// <summary>
  170. ///// 铺码服务请求
  171. ///// </summary>
  172. //public static DAL_TmatrixCode dAL_TmatrixCode;
  173. /// <summary>
  174. /// 腾千里手写笔事件
  175. /// </summary>
  176. public static PenEvents TQLPenevents;
  177. /// <summary>
  178. /// 腾千里手写笔是否已连接
  179. /// </summary>
  180. public static bool TQLPenStatus = false;
  181. #region 打印
  182. public static bool gbGenerateBGWithVImage = false;
  183. public static bool gbGenerateVImage = false;
  184. public static bool gbGenerateBGWithoutVImage = false;
  185. public static bool gbGenerateBGWithImage = false;
  186. public static bool gbGenPageSet = false;
  187. public static int[] gPointType = new int[5];
  188. public static int[] gPointDPI = new int[5];
  189. public static string gTMXElementFileName;
  190. public static string gNewProjectDirectory;
  191. public static bool gbElementFileExist { get; set; }
  192. #endregion 打印
  193. #endregion 腾千里手写笔
  194. #region 页面
  195. /// <summary>
  196. /// 主页面
  197. /// </summary>
  198. public static MainWindow W_XHMicroLessonSystemWindow = null;
  199. /// <summary>
  200. /// 倒计时窗口
  201. /// </summary>
  202. public static CountdownWindow W_CountdownWindow = null;
  203. /// <summary>
  204. /// 录像工具栏
  205. /// </summary>
  206. public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
  207. /// <summary>
  208. /// 登录
  209. /// </summary>
  210. public static LoginWindow W_LoginWindow = null;
  211. /// <summary>
  212. /// 截图
  213. /// </summary>
  214. public static JieTuWindow W_JieTuWindow = null;
  215. /// <summary>
  216. /// 批注
  217. /// </summary>
  218. public static PracticeWindow W_PracticeWindow = null;
  219. /// <summary>
  220. /// 提示窗口
  221. /// </summary>
  222. public static PromptWindow W_PromptWindow = null;
  223. /// <summary>
  224. /// loding页面
  225. /// </summary>
  226. public static LoadDialog myloading;
  227. /// <summary>
  228. /// 上传页面
  229. /// </summary>
  230. public static UploadWindow W_UploadWindow = null;
  231. /// <summary>
  232. /// 最小化工具栏
  233. /// </summary>
  234. public static MinToolbar W_MinToolbar = null;
  235. /// <summary>
  236. /// 视频剪辑
  237. /// </summary>
  238. public static VideoClipWindow W_VideoClipWindow = null;
  239. #endregion 页面
  240. #endregion 全局变量
  241. public App()
  242. {
  243. Console.WriteLine(@"初始化APP");
  244. LogHelper.InitLog4Net();
  245. ZHttpUtil.isSt = ZConfigAppUtil.GetVaule("isSt") == "True";
  246. ZHttpUtil.version = FileToolsCommon.GetConfigValue("VersionName");
  247. myloading = new LoadDialog();
  248. Killffmpeg();
  249. try
  250. {
  251. UserInfo = new ModelUserInfo();
  252. WKDataList = new List<ModelWkData>();
  253. VideoList = new List<ModelVideo>();
  254. #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
  255. WindowsIdentity identity = WindowsIdentity.GetCurrent();
  256. WindowsPrincipal principal = new WindowsPrincipal(identity);
  257. #endregion 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
  258. try
  259. {
  260. if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "Temp")) //清除临时文件
  261. {
  262. Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + "Temp", true);
  263. }
  264. }
  265. catch (Exception)
  266. {
  267. // ignored
  268. }
  269. if (principal.IsInRole(WindowsBuiltInRole.Administrator))
  270. {
  271. SkinConfig.InitSkin();
  272. }
  273. else
  274. {
  275. //创建启动对象
  276. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo
  277. {
  278. UseShellExecute = true,
  279. WorkingDirectory = Environment.CurrentDirectory,
  280. FileName = Assembly.GetExecutingAssembly().Location,
  281. //设置启动动作,确保以管理员身份运行
  282. Verb = "runas"
  283. };
  284. try
  285. {
  286. System.Diagnostics.Process.Start(startInfo);
  287. }
  288. catch
  289. {
  290. return;
  291. }
  292. //退出
  293. //Current.Shutdown();
  294. Application.Current.Shutdown();
  295. }
  296. }
  297. catch (Exception ex)
  298. {
  299. string errMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
  300. LogHelper.Logerror.Error(errMessage, ex);
  301. }
  302. }
  303. #region 杀死已存在的进程
  304. [DllImport("User32.dll")]
  305. private static extern int FindWindow(string className, string windowName);
  306. [DllImport("user32.dll")]
  307. public static extern bool SetForegroundWindow(int hWnd);
  308. private static void CheckProcess()
  309. {
  310. Console.WriteLine(@"程序启动");
  311. Process current = Process.GetCurrentProcess();
  312. //获取欲启动进程名
  313. string strProcessName = Process.GetCurrentProcess().ProcessName;
  314. var processList = Process.GetProcessesByName(strProcessName);
  315. if (processList.Length <= 1)
  316. {
  317. return;
  318. }
  319. MessageWindow.Show("当前程序已在运行,请勿重复运行。");
  320. foreach (var process in processList)
  321. {
  322. if (process.Id == current.Id) continue;
  323. int hWnd = FindWindow(null, process.MainWindowTitle);
  324. SetForegroundWindow(hWnd);
  325. }
  326. Application.Current.Shutdown(); //退出新打开的程序
  327. }
  328. /// <summary>
  329. /// 杀死正在运行的ffmpeg
  330. /// </summary>
  331. public static void Killffmpeg()
  332. {
  333. Process[] killProcessArray = Process.GetProcessesByName("ffmpeg");
  334. foreach (Process killProcess in killProcessArray)
  335. {
  336. killProcess.Kill();
  337. }
  338. }
  339. #endregion 杀死已存在的进程
  340. private void RegisterEvents()
  341. {
  342. //Task线程内未捕获异常处理事件
  343. TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; //Task异常
  344. //UI线程未捕获异常处理事件(UI主线程)
  345. DispatcherUnhandledException += App_DispatcherUnhandledException;
  346. //非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
  347. AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
  348. }
  349. private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
  350. {
  351. try
  352. {
  353. var exception = e.Exception as Exception;
  354. if (exception != null)
  355. {
  356. HandleException(exception);
  357. }
  358. }
  359. catch (Exception ex)
  360. {
  361. HandleException(ex);
  362. }
  363. finally
  364. {
  365. e.SetObserved();
  366. }
  367. }
  368. //非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
  369. private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
  370. {
  371. try
  372. {
  373. if (e.ExceptionObject is Exception exception)
  374. {
  375. HandleException(exception);
  376. }
  377. }
  378. catch (Exception ex)
  379. {
  380. HandleException(ex);
  381. }
  382. }
  383. //UI线程未捕获异常处理事件(UI主线程)
  384. private static void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
  385. {
  386. try
  387. {
  388. HandleException(e.Exception);
  389. }
  390. catch (Exception ex)
  391. {
  392. HandleException(ex);
  393. }
  394. finally
  395. {
  396. e.Handled = true;
  397. }
  398. }
  399. private static void HandleException(Exception ex)
  400. {
  401. //记录日志
  402. LogHelper.Logerror.Error("未捕获异常:" + ex.Message, ex);
  403. Current.Shutdown();
  404. }
  405. #region 数据保存和读取
  406. /// <summary>
  407. /// 保存微课信息
  408. /// </summary>
  409. public static void SaveWkData()
  410. {
  411. try
  412. {
  413. VideoList = VideoList.Where((x, i) => VideoList.FindIndex(z => z.FileGuid == x.FileGuid) == i).ToList();
  414. WKData.VideoList = VideoList;
  415. if (WKDataList != null)
  416. {
  417. WKDataList.RemoveAll(x => x.WkPath == WKData.WkPath);
  418. }
  419. else
  420. {
  421. WKDataList = new List<ModelWkData>();
  422. }
  423. WKDataList.Add(WKData);
  424. string wkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
  425. string savePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
  426. FileToolsCommon.CreateDirectory(savePath);
  427. string saveName = savePath + "WkDate.xml";
  428. FileToolsCommon.DeleteFile(saveName);
  429. FileToolsCommon.WriteText(saveName, wkDateXmlStr);
  430. }
  431. catch (Exception ex)
  432. {
  433. LogHelper.Logerror.Error("【微课数据保存】(SaveWkData)保存失败:" + ex.Message, ex);
  434. }
  435. }
  436. /// <summary>
  437. /// 读取微课信息
  438. /// </summary>
  439. public static void ReadWkData(string wkPath)
  440. {
  441. try
  442. {
  443. string savePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
  444. FileToolsCommon.CreateDirectory(savePath);
  445. string saveName = savePath + "WkDate.xml";
  446. //文件若存在则读取
  447. if (FileToolsCommon.IsExistFile(saveName))
  448. {
  449. string wkDateXmlStr = FileToolsCommon.FileToString(saveName);
  450. WKDataList = XmlUtilHelper.DeSerializer<List<ModelWkData>>(wkDateXmlStr);
  451. foreach (ModelWkData wklist in WKDataList)
  452. {
  453. //移除找不到视频的微课数据
  454. wklist.VideoList.RemoveAll(x => !FileToolsCommon.IsExistFile(x.VideoPath));
  455. }
  456. if (WKDataList.Exists(x => x.WkPath == wkPath))
  457. {
  458. WKData = WKDataList.Find(x => x.WkPath == wkPath);
  459. VideoList = new List<ModelVideo>();
  460. WKData.VideoList = WKData.VideoList.Where((x, i) => WKData.VideoList.FindIndex(z => z.FileGuid == x.FileGuid) == i).ToList();
  461. VideoList = WKData.VideoList;
  462. }
  463. }
  464. }
  465. catch (Exception ex)
  466. {
  467. LogHelper.Logerror.Error("【微课数据读取】(ReadWkData)读取失败:" + ex.Message, ex);
  468. }
  469. }
  470. /// <summary>
  471. /// 保存画板数据
  472. /// </summary>
  473. public static void SaveDraw()
  474. {
  475. try
  476. {
  477. if (PageDrawList == null)
  478. {
  479. return;
  480. }
  481. if (PageDrawList.Count < 1)
  482. {
  483. return;
  484. }
  485. FileToolsCommon.CreateDirectory(WKData.WkPath);
  486. string savePath = WKData.WkPath + "PageData.xml";
  487. FileToolsCommon.DeleteFile(savePath);
  488. string pageDataXmlStr = XmlUtilHelper.XmlSerialize(PageDrawList);
  489. FileToolsCommon.WriteText(savePath, pageDataXmlStr);
  490. }
  491. catch (Exception ex)
  492. {
  493. LogHelper.Logerror.Error("【画板数据保存】(SaveDraw)保存失败:" + ex.Message, ex);
  494. }
  495. }
  496. /// <summary>
  497. /// 读取文件
  498. /// </summary>
  499. public static void ReadDrawData()
  500. {
  501. try
  502. {
  503. PageDrawList = new List<ModelDrawData>();
  504. string savePath = WKData.WkPath + "PageData.xml";
  505. if (FileToolsCommon.IsExistFile(savePath))
  506. {
  507. string pageDataXmlStr = FileToolsCommon.FileToString(savePath);
  508. PageDrawList = XmlUtilHelper.DeSerializer<List<ModelDrawData>>(pageDataXmlStr);
  509. }
  510. else
  511. {
  512. PageDrawList = new List<ModelDrawData>();
  513. }
  514. }
  515. catch (Exception ex)
  516. {
  517. LogHelper.Logerror.Error("【画板数据读取】(ReadDraw)读取失败:" + ex.Message, ex);
  518. }
  519. }
  520. #endregion 数据保存和读取
  521. #region 服务地址数据
  522. /// <summary>
  523. /// 服务地址存储到本地
  524. /// </summary>
  525. public static void SaveServiceAddressData()
  526. {
  527. try
  528. {
  529. if (ServiceAddress == null)
  530. {
  531. return;
  532. }
  533. string dateXmlStr = XmlUtilHelper.XmlSerialize(ServiceAddress);
  534. string savePath = DataPath;
  535. FileToolsCommon.CreateDirectory(savePath);
  536. string saveName = savePath + (isDebug ? "ServiceAddressDebug.xml" : "ServiceAddressRelease.xml");
  537. Console.WriteLine(@"保存路径为:");
  538. FileToolsCommon.DeleteFile(saveName);
  539. FileToolsCommon.WriteText(saveName, dateXmlStr);
  540. }
  541. catch (Exception ex)
  542. {
  543. LogHelper.Logerror.Error("【服务地址存储】(SaveServiceAddressData)保存失败:" + ex.Message, ex);
  544. }
  545. }
  546. /// <summary>
  547. /// 从本地读取服务地址
  548. /// </summary>
  549. public static void ReadServiceAddressData()
  550. {
  551. try
  552. {
  553. string savePath = DataPath;
  554. FileToolsCommon.CreateDirectory(savePath);
  555. string saveName = savePath + (isDebug ? "ServiceAddressDebug.xml" : "ServiceAddressRelease.xml");
  556. Console.WriteLine(@"配置文件路径" + saveName);
  557. //文件若存在则读取
  558. if (FileToolsCommon.IsExistFile(saveName))
  559. {
  560. string dateXmlStr = FileToolsCommon.FileToString(saveName);
  561. ServiceAddress = XmlUtilHelper.DeSerializer<ModelServiceAddress>(dateXmlStr);
  562. SwitchAddress();
  563. }
  564. }
  565. catch (Exception ex)
  566. {
  567. LogHelper.Logerror.Error("【服务地址读取】(ReadServiceAddressData)读取失败:" + ex.Message, ex);
  568. }
  569. }
  570. /// <summary>
  571. /// 切换校内外网
  572. /// </summary>
  573. public static void SwitchAddress()
  574. {
  575. try
  576. {
  577. apiUrl = IsOutsideSchool ? ServiceAddress.wapi : ServiceAddress.napi;
  578. uploadUrl = (IsOutsideSchool ? ServiceAddress.wfile : ServiceAddress.nfile) + "/";
  579. showImageUrl = (IsOutsideSchool ? ServiceAddress.wdown : ServiceAddress.ndown) + "/static/";
  580. }
  581. catch (Exception ex)
  582. {
  583. LogHelper.Logerror.Error("【服务地址切换】(SwitchAddress)服务复制切换失败,请求地址为空!", ex);
  584. }
  585. }
  586. #endregion 服务地址数据
  587. /// <summary>
  588. /// 内存释放压缩
  589. /// </summary>
  590. /// <param name="e">
  591. /// </param>
  592. protected override void OnStartup(StartupEventArgs e)
  593. {
  594. RegisterEvents();
  595. base.OnStartup(e);
  596. CheckProcess();
  597. }
  598. protected override void OnExit(ExitEventArgs e)
  599. {
  600. // 在应用程序退出之前执行必要的操作
  601. ZConfigAppUtil.SetVaule("isSt", "" + ZHttpUtil.isSt);
  602. Console.WriteLine(@"应用退出");
  603. base.OnExit(e);
  604. Environment.Exit(0);
  605. }
  606. }
  607. }