ExerciseV2_1Controller.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. using Abp.Auditing;
  2. using Abp.Authorization;
  3. using Abp.Domain.Repositories;
  4. using Abp.Web.Models;
  5. using Abp.Web.Mvc.Authorization;
  6. using IwbZero.ToolCommon.LogHelpers;
  7. using IwbZero.ToolCommon.StringModel;
  8. using System;
  9. using System.Data.Entity;
  10. using System.IO;
  11. using System.Speech.Synthesis;
  12. using System.Threading;
  13. using System.Threading.Tasks;
  14. using System.Web.Mvc;
  15. using WeApp.BaseSystem.Query;
  16. using WeApp.CommonManager.Export;
  17. using WeApp.Configuration;
  18. using WeApp.TrainingCamp;
  19. using WeApp.TrainingCamp.Dto;
  20. using WeApp.TrainingCampGroup.Dto;
  21. using WeApp.TrainingPortrait;
  22. using WeApp.Views.Shared.Camp;
  23. // ReSharper disable InconsistentNaming
  24. namespace WeApp.Controllers
  25. {
  26. /// <summary>
  27. /// 演练实施
  28. /// </summary>
  29. [AbpAllowAnonymous, DisableAuditing]
  30. public class ExerciseV2_1Controller : IwbControllerBase
  31. {
  32. public ExerciseV2_1Controller(QueryAppService queryApp, IRepository<CampGroupInfo, string> groupRepository, IRepository<CampInfo, string> campRepository, PortraitAppService portraitApp, ExportManger exportManger)
  33. {
  34. QueryApp = queryApp;
  35. GroupRepository = groupRepository;
  36. CampRepository = campRepository;
  37. PortraitApp = portraitApp;
  38. _exportManger = exportManger;
  39. }
  40. protected QueryAppService QueryApp { get; }
  41. public const string SelectDataKey = "SELECTDATA";
  42. private int TimeOut = 60 * 5;
  43. protected IRepository<CampInfo, string> CampRepository { get; }
  44. protected IRepository<CampGroupInfo, string> GroupRepository { get; }
  45. protected PortraitAppService PortraitApp { get; }
  46. private readonly ExportManger _exportManger;
  47. public ActionResult Index()
  48. {
  49. Session["GroupNo"] = "";
  50. Session["CampNo"] = "";
  51. return View();
  52. }
  53. public ActionResult Clear()
  54. {
  55. Session["GroupNo"] = "";
  56. Session["CampNo"] = "";
  57. return Content("");
  58. }
  59. public ActionResult Select(int? id)
  60. {
  61. if (id == null)
  62. {
  63. return RedirectToAction("Index");
  64. }
  65. switch (id)
  66. {
  67. case 1:
  68. return RedirectToAction("Student");
  69. case 2:
  70. return RedirectToAction("Leader");
  71. case 3:
  72. return RedirectToAction("Public");
  73. case 4:
  74. return RedirectToAction("Specialist");
  75. case 5:
  76. return RedirectToAction("Manual");
  77. case 6:
  78. return RedirectToAction("Gis");
  79. default:
  80. return RedirectToAction("Index");
  81. }
  82. }
  83. /// <summary>
  84. /// 学员指挥部页面
  85. /// </summary>
  86. /// <returns></returns>
  87. public ActionResult HeadquarterStu()
  88. {
  89. return RedirectToAction("Headquarter");
  90. }
  91. /// <summary>
  92. /// 指挥长组建指挥部
  93. /// </summary>
  94. /// <returns></returns>
  95. public ActionResult HeadquarterLeader()
  96. {
  97. return RedirectToAction("Headquarter", new { id = 1 });
  98. }
  99. /// <summary>
  100. /// 组建指挥部
  101. /// </summary>
  102. /// <param name="id"></param>
  103. /// <returns></returns>
  104. public async Task<ActionResult> Headquarter(int? id)
  105. {
  106. ViewBag.IsLeader = id == 1;
  107. string groupNo = (string)Session["GroupNo"];
  108. if (groupNo.IsEmpty())
  109. {
  110. if (id == 1)
  111. {
  112. TempData[SelectDataKey] = new SelectCampModel
  113. {
  114. PageUrl = "/ExerciseV2_1/Leader",
  115. PageTitle = "指挥长屏选择培训营",
  116. HasGroup = true
  117. };
  118. return RedirectToAction("SelectCamp");
  119. }
  120. TempData[SelectDataKey] = new SelectCampModel
  121. {
  122. PageUrl = "/ExerciseV2_1/Student",
  123. PageTitle = "学员屏选择培训营",
  124. HasGroup = true
  125. };
  126. return RedirectToAction("SelectCamp");
  127. }
  128. Session["GroupNo"] = groupNo;
  129. Session.Timeout = 60 * 5;
  130. var group = await GroupRepository.GetAllIncluding(a => a.CampInfo).FirstOrDefaultAsync(a => a.Id == groupNo);
  131. if (group == null)
  132. {
  133. CheckErrors($"未查到到编号为【{groupNo}】的培训营分组!");
  134. return Content("");
  135. }
  136. if (group.CampInfo.CampState == CampStateDefinition.End)
  137. {
  138. CheckErrors($"培训营已演练结束!");
  139. }
  140. if (group.CampGroupState == CampGroupStateDefinition.End)
  141. {
  142. CheckErrors($"培训营分组已演练结束!");
  143. }
  144. ViewBag.Group = ObjectMapper.Map<CampGroupDto>(group);
  145. switch (group.CampGroupState)
  146. {
  147. case CampGroupStateDefinition.New:
  148. return View("Enter");
  149. case CampGroupStateDefinition.Ready:
  150. return View("Enter");
  151. case CampGroupStateDefinition.HeadQuarterBuilding:
  152. ViewBag.HasBuilded = false;
  153. return View();
  154. case CampGroupStateDefinition.HeadQuarterBuilded:
  155. ViewBag.HasBuilded = true;
  156. return View();
  157. }
  158. if (id == 1)
  159. {
  160. return RedirectToAction("Leader");
  161. }
  162. return RedirectToAction("Student");
  163. }
  164. /// <summary>
  165. /// 学员页面
  166. /// </summary>
  167. /// <param name="id"></param>
  168. /// <returns></returns>
  169. public async Task<ActionResult> Student(string id)
  170. {
  171. string groupNo = id.IsEmpty() ? (string)Session["GroupNo"] : id;
  172. if (groupNo.IsEmpty())
  173. {
  174. TempData[SelectDataKey] = new SelectCampModel
  175. {
  176. PageUrl = "/ExerciseV2_1/Student",
  177. PageTitle = "学员屏选择培训营",
  178. HasGroup = true
  179. };
  180. return RedirectToAction("SelectCamp");
  181. }
  182. var group = await GroupRepository.GetAllIncluding(a => a.CampInfo).FirstOrDefaultAsync(a => a.Id == groupNo);
  183. if (group == null)
  184. {
  185. CheckErrors($"未查到到编号为【{groupNo}】的培训营分组!");
  186. return Content("");
  187. }
  188. Session["GroupNo"] = groupNo;
  189. Session.Timeout = TimeOut;
  190. ViewBag.ShowTip = group.CampInfo.IsShowTip;
  191. if (group.CampGroupState != CampGroupStateDefinition.Run)
  192. {
  193. string text;
  194. switch (group.CampGroupState)
  195. {
  196. case CampGroupStateDefinition.Report:
  197. text = "正在生成演练报告";
  198. break;
  199. case CampGroupStateDefinition.End:
  200. text = "演练报告已生成";
  201. break;
  202. default:
  203. return RedirectToAction("HeadquarterStu");
  204. }
  205. ViewBag.IsLeader = false;
  206. ViewBag.Group = ObjectMapper.Map<CampGroupDto>(group);
  207. ViewBag.Text = text;
  208. return View("WaitRport");
  209. }
  210. ViewBag.Group = ObjectMapper.Map<CampGroupDto>(group);
  211. return View();
  212. }
  213. /// <summary>
  214. /// 指挥长页面
  215. /// </summary>
  216. /// <param name="id"></param>
  217. /// <returns></returns>
  218. public async Task<ActionResult> Leader(string id)
  219. {
  220. string groupNo = id.IsEmpty() ? (string)Session["GroupNo"] : id;
  221. if (groupNo.IsEmpty())
  222. {
  223. TempData[SelectDataKey] = new SelectCampModel
  224. {
  225. PageUrl = "/ExerciseV2_1/Leader",
  226. PageTitle = "指挥长屏选择培训营",
  227. HasGroup = true
  228. };
  229. return RedirectToAction("SelectCamp");
  230. }
  231. var group = await GroupRepository.GetAllIncluding(a => a.CampInfo).FirstOrDefaultAsync(a => a.Id == groupNo);
  232. if (group == null)
  233. {
  234. CheckErrors($"未查到到编号为【{groupNo}】的培训营分组!");
  235. return Content("");
  236. }
  237. Session["GroupNo"] = groupNo;
  238. Session.Timeout = TimeOut;
  239. ViewBag.ShowTip = group.CampInfo.IsShowTip;
  240. if (group.CampGroupState != CampGroupStateDefinition.Run)
  241. {
  242. string text;
  243. switch (group.CampGroupState)
  244. {
  245. case CampGroupStateDefinition.Report:
  246. text = "正在生成演练报告";
  247. break;
  248. case CampGroupStateDefinition.End:
  249. text = "演练报告已生成";
  250. break;
  251. default:
  252. return RedirectToAction("HeadquarterLeader");
  253. }
  254. ViewBag.IsLeader = true;
  255. ViewBag.Group = ObjectMapper.Map<CampGroupDto>(group);
  256. ViewBag.Text = text;
  257. return View("WaitRport");
  258. }
  259. //if (group.CampGroupState != CampGroupStateDefinition.Run)
  260. //{
  261. // return RedirectToAction("HeadquarterLeader");
  262. //}
  263. ViewBag.Group = ObjectMapper.Map<CampGroupDto>(group);
  264. return View();
  265. }
  266. /// <summary>
  267. /// 公共屏页面
  268. /// </summary>
  269. /// <param name="id"></param>
  270. /// <returns></returns>
  271. public async Task<ActionResult> Public(string id)
  272. {
  273. string groupNo = id.IsEmpty() ? (string)Session["GroupNo"] : id;
  274. if (groupNo.IsEmpty())
  275. {
  276. TempData[SelectDataKey] = new SelectCampModel
  277. {
  278. PageUrl = "/ExerciseV2_1/Public",
  279. PageTitle = "公共屏选择培训营",
  280. HasGroup = true
  281. };
  282. return RedirectToAction("SelectCamp");
  283. }
  284. var group = await GroupRepository.GetAllIncluding(a => a.CampInfo).FirstOrDefaultAsync(a => a.Id == groupNo);
  285. if (group == null)
  286. {
  287. CheckErrors($"未查到到编号为【{groupNo}】的培训营分组!");
  288. return Content("");
  289. }
  290. Session["GroupNo"] = groupNo;
  291. Session.Timeout = TimeOut;
  292. ViewBag.Group = ObjectMapper.Map<CampGroupDto>(group);
  293. if (group.CampGroupState != CampGroupStateDefinition.Run)
  294. {
  295. string text = "";
  296. switch (group.CampGroupState)
  297. {
  298. case CampGroupStateDefinition.New:
  299. text = "";
  300. break;
  301. case CampGroupStateDefinition.Ready:
  302. text = "培训营已就绪";
  303. break;
  304. case CampGroupStateDefinition.HeadQuarterBuilding:
  305. text = "正在组建指挥部";
  306. break;
  307. case CampGroupStateDefinition.HeadQuarterBuilded:
  308. text = "等待演练开始";
  309. break;
  310. case CampGroupStateDefinition.Report:
  311. text = "正在生成演练报告";
  312. break;
  313. case CampGroupStateDefinition.End:
  314. return RedirectToAction("StuReport", new { id = groupNo });
  315. }
  316. ViewBag.State = group.CampGroupState;
  317. ViewBag.Text = text;
  318. return View("PublicWait");
  319. }
  320. return View();
  321. }
  322. /// <summary>
  323. /// 公共屏页面
  324. /// </summary>
  325. /// <param name="id"></param>
  326. /// <returns></returns>
  327. [AccessOriginal]
  328. public async Task<ActionResult> Display(string id)
  329. {
  330. var group = await GroupRepository.GetAllIncluding(a => a.CampInfo).FirstOrDefaultAsync(a => a.Id == id);
  331. if (group == null)
  332. {
  333. CheckErrors($"未查到到编号为【{id}】的培训营分组!");
  334. return Content("");
  335. }
  336. ViewBag.Group = ObjectMapper.Map<CampGroupDto>(group);
  337. if (group.CampGroupState != CampGroupStateDefinition.Run)
  338. {
  339. string text = "";
  340. switch (group.CampGroupState)
  341. {
  342. case CampGroupStateDefinition.New:
  343. text = "";
  344. break;
  345. case CampGroupStateDefinition.Ready:
  346. text = "培训营已就绪";
  347. break;
  348. case CampGroupStateDefinition.HeadQuarterBuilding:
  349. text = "正在组建指挥部";
  350. break;
  351. case CampGroupStateDefinition.HeadQuarterBuilded:
  352. text = "等待演练开始";
  353. break;
  354. case CampGroupStateDefinition.Report:
  355. text = "正在生成演练报告";
  356. break;
  357. case CampGroupStateDefinition.End:
  358. return RedirectToAction("StuReport", new { id });
  359. }
  360. ViewBag.State = group.CampGroupState;
  361. ViewBag.Text = text;
  362. return View("PublicWait");
  363. }
  364. return View("_Run/Display");
  365. }
  366. /// <summary>
  367. /// 专家屏页面
  368. /// </summary>
  369. /// <param name="id"></param>
  370. /// <returns></returns>
  371. public async Task<ActionResult> Specialist(string id)
  372. {
  373. CampInfo camp;
  374. if (id == "1")
  375. {
  376. camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
  377. if (camp == null)
  378. {
  379. CheckErrors("未查询到正在运行的培训营!");
  380. return Content("Error");
  381. }
  382. }
  383. else
  384. {
  385. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  386. if (campNo.IsEmpty())
  387. {
  388. TempData[SelectDataKey] = new SelectCampModel
  389. {
  390. PageUrl = "/ExerciseV2_1/Specialist",
  391. PageTitle = "专家屏选择培训营",
  392. HasGroup = false
  393. };
  394. return RedirectToAction("SelectCamp");
  395. }
  396. camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
  397. if (camp == null)
  398. {
  399. CheckErrors($"未查到到编号为【{campNo}】的培训营!");
  400. return null;
  401. }
  402. Session["CampNo"] = campNo;
  403. Session.Timeout = TimeOut;
  404. }
  405. ViewBag.Camp = ObjectMapper.Map<CampDto>(camp);
  406. ViewBag.Groups = await QueryApp.GetCampGroups(id);
  407. if (camp.CampState != CampStateDefinition.Run)
  408. {
  409. var text = camp.CampState != CampStateDefinition.End ? "等待演练开始" : "演练已结束";
  410. ViewBag.Text = text;
  411. return View("SpecWait");
  412. }
  413. return View();
  414. }
  415. /// <summary>
  416. /// 主屏页面
  417. /// </summary>
  418. /// <param name="id"></param>
  419. /// <returns></returns>
  420. public async Task<ActionResult> Play(string id)
  421. {
  422. CampInfo camp;
  423. if (id == "1")
  424. {
  425. camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
  426. if (camp == null)
  427. {
  428. CheckErrors("未查询到正在运行的培训营!");
  429. return Content("Error");
  430. }
  431. }
  432. else
  433. {
  434. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  435. if (campNo.IsEmpty())
  436. {
  437. TempData[ExerciseController.SelectDataKey] = new SelectCampModel
  438. {
  439. PageUrl = "/Play/Index",
  440. PageTitle = "演示屏选择培训营",
  441. HasGroup = false
  442. };
  443. return RedirectToAction("SelectCamp", "ExerciseV2");
  444. }
  445. camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
  446. if (camp == null)
  447. {
  448. CheckErrors($"未查到到编号为【{campNo}】的培训营!");
  449. return null;
  450. }
  451. Session["CampNo"] = campNo;
  452. Session.Timeout = TimeOut;
  453. }
  454. ViewBag.Camp = ObjectMapper.Map<CampDto>(camp);
  455. if (camp.CampState != CampStateDefinition.Run)
  456. {
  457. return View("_Play/Wait");
  458. }
  459. ViewBag.Groups = await QueryApp.GetCampGroups(id);
  460. return View("_Play/Index");
  461. }
  462. /// <summary>
  463. /// 主屏页面
  464. /// </summary>
  465. /// <param name="id"></param>
  466. /// <returns></returns>
  467. public async Task<ActionResult> PlayWithScore(string id)
  468. {
  469. CampInfo camp;
  470. if (id == "1")
  471. {
  472. camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
  473. if (camp == null)
  474. {
  475. CheckErrors("未查询到正在运行的培训营!");
  476. return Content("Error");
  477. }
  478. }
  479. else
  480. {
  481. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  482. if (campNo.IsEmpty())
  483. {
  484. TempData[ExerciseController.SelectDataKey] = new SelectCampModel
  485. {
  486. PageUrl = "/Play/IndexWithScore",
  487. PageTitle = "演示屏选择培训营",
  488. HasGroup = false
  489. };
  490. return RedirectToAction("SelectCamp", "ExerciseV2");
  491. }
  492. camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
  493. if (camp == null)
  494. {
  495. CheckErrors($"未查到到编号为【{campNo}】的培训营!");
  496. return null;
  497. }
  498. Session["CampNo"] = campNo;
  499. Session.Timeout = TimeOut;
  500. }
  501. ViewBag.Camp = ObjectMapper.Map<CampDto>(camp);
  502. if (camp.CampState != CampStateDefinition.Run)
  503. {
  504. return View("_Play/Wait");
  505. }
  506. ViewBag.Groups = await QueryApp.GetCampGroups(id);
  507. return View("_Play/IndexWithScore");
  508. }
  509. /// <summary>
  510. /// 演练报告
  511. /// </summary>
  512. /// <param name="id"></param>
  513. /// <returns></returns>
  514. public async Task<ActionResult> StuReport(string id)
  515. {
  516. string groupNo = id.IsEmpty() ? (string)Session["GroupNo"] : id;
  517. if (groupNo.IsEmpty())
  518. {
  519. TempData[SelectDataKey] = new SelectCampModel
  520. {
  521. PageUrl = "/ExerciseV2_1/StuReport",
  522. PageTitle = "演练报告选择培训营",
  523. HasGroup = true
  524. };
  525. return RedirectToAction("SelectCamp");
  526. }
  527. var group = await PortraitApp.GetGroupReportBase(id);
  528. if (group == null)
  529. {
  530. CheckErrors($"未查到到编号为【{groupNo}】的培训营分组!");
  531. return Content("");
  532. }
  533. return View(group);
  534. }
  535. /// <summary>
  536. /// 手动记录演练页面
  537. /// </summary>
  538. /// <param name="id"></param>
  539. /// <returns></returns>
  540. public async Task<ActionResult> Manual(string id)
  541. {
  542. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  543. if (campNo.IsEmpty())
  544. {
  545. TempData[SelectDataKey] = new SelectCampModel
  546. {
  547. PageUrl = "/ExerciseV2_1/Manual",
  548. PageTitle = "培训营演练情况手动记录",
  549. HasGroup = false
  550. };
  551. return RedirectToAction("SelectCamp");
  552. }
  553. var camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
  554. if (camp == null)
  555. {
  556. CheckErrors($"未查到到编号为【{campNo}】的培训营!");
  557. }
  558. if (camp?.CampState == CampStateDefinition.End)
  559. {
  560. CheckErrors($"培训营已结束!");
  561. }
  562. //if (camp?.CampState!=CampStateDefinition.Run)
  563. //{
  564. // CheckErrors($"培训营未开始!");
  565. //}
  566. Session["CampNo"] = campNo;
  567. Session.Timeout = TimeOut;
  568. ViewBag.CampName = camp?.Name;
  569. ViewBag.Groups = await QueryApp.GetCampGroups(id);
  570. return View();
  571. }
  572. /// <summary>
  573. /// GIS页面
  574. /// </summary>
  575. /// <param name="id"></param>
  576. /// <returns></returns>
  577. public async Task<ActionResult> Gis(string id)
  578. {
  579. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  580. if (campNo.IsEmpty())
  581. {
  582. TempData[SelectDataKey] = new SelectCampModel
  583. {
  584. PageUrl = "/ExerciseV2_1/Gis",
  585. PageTitle = "培训营GIS推演实时路径",
  586. HasGroup = false
  587. };
  588. return RedirectToAction("SelectCamp");
  589. }
  590. var camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
  591. if (camp == null)
  592. {
  593. CheckErrors($"未查到到编号为【{campNo}】的培训营!");
  594. }
  595. if (camp?.CampState == CampStateDefinition.End)
  596. {
  597. CheckErrors($"培训营已结束!");
  598. }
  599. //if (camp?.CampState!=CampStateDefinition.Run)
  600. //{
  601. // CheckErrors($"培训营未开始!");
  602. //}
  603. Session["CampNo"] = campNo;
  604. Session.Timeout = TimeOut;
  605. ViewBag.CampNo = camp?.Id;
  606. ViewBag.CampName = camp?.Name;
  607. //ViewBag.Groups = await QueryApp.GetCampGroups(id);
  608. return View();
  609. }
  610. [AbpMvcAuthorize]
  611. public async Task<ActionResult> ExportSql(string id)
  612. {
  613. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  614. if (campNo.IsEmpty())
  615. {
  616. TempData[SelectDataKey] = new SelectCampModel
  617. {
  618. PageUrl = "/ExerciseV2_1/ExportSql",
  619. PageTitle = "导出SQL选择培训营",
  620. HasGroup = false
  621. };
  622. return RedirectToAction("SelectCampAll");
  623. }
  624. Session["CampNo"] = campNo;
  625. Session.Timeout = TimeOut;
  626. var path = await _exportManger.ExportSql(id);
  627. return Content($"{AppDomain.CurrentDomain.BaseDirectory}{path}");
  628. }
  629. ///// <summary>
  630. ///// 选择培训营页面
  631. ///// </summary>
  632. ///// <param name="url"></param>
  633. ///// <param name="title"></param>
  634. ///// <param name="hasGroup"></param>
  635. ///// <returns></returns>
  636. //public async Task<ActionResult> Select(string url,string title,bool hasGroup)
  637. //{
  638. // string str = await QueryApp.GetCampSelectStr(CampStateDefinition.Audit, CampStateDefinition.Run);
  639. // ViewBag.Select = new SelectCampModel()
  640. // {
  641. // HasGroup = hasGroup,
  642. // PageTitle = title,
  643. // PageUrl = url,
  644. // CampSelect = str
  645. // };
  646. // return View("_Select");
  647. //}
  648. /// <summary>
  649. /// 选择培训营页面
  650. /// </summary>
  651. /// <returns></returns>
  652. public async Task<ActionResult> SelectCamp()
  653. {
  654. SelectCampModel model = (SelectCampModel)TempData[SelectDataKey];
  655. if (model == null)
  656. {
  657. return RedirectToAction("Student");
  658. }
  659. string str = await QueryApp.GetCampSelectStr(CampStateDefinition.Audit, CampStateDefinition.Run);
  660. model.CampSelect = str;
  661. ViewBag.Select = model;
  662. return View("_Select");
  663. }
  664. /// <summary>
  665. /// 选择培训营页面
  666. /// </summary>
  667. /// <returns></returns>
  668. public async Task<ActionResult> SelectCampAll()
  669. {
  670. SelectCampModel model = (SelectCampModel)TempData[SelectDataKey];
  671. if (model == null)
  672. {
  673. return RedirectToAction("Student");
  674. }
  675. string str = await QueryApp.GetCampSelectStr(CampStateDefinition.Audit, CampStateDefinition.Run, CampStateDefinition.End);
  676. model.CampSelect = str;
  677. ViewBag.Select = model;
  678. return View("_Select");
  679. }
  680. [HttpGet]
  681. [WrapResult(false)]
  682. public ActionResult Voice(string txt, int? rate = null, int? vol = null)
  683. {
  684. using (MemoryStream ms = new MemoryStream())
  685. {
  686. var t = new Thread(() =>
  687. {
  688. using (SpeechSynthesizer sp = new SpeechSynthesizer())
  689. {
  690. try
  691. {
  692. sp.Rate = rate ?? 0;
  693. sp.Volume = vol ?? 90;
  694. sp.SetOutputToWaveStream(ms);
  695. sp.Speak(txt);
  696. }
  697. catch (Exception ex)
  698. {
  699. this.LogError(ex);
  700. throw;
  701. }
  702. }
  703. });
  704. t.Start();
  705. t.Join();
  706. ms.Position = 0;
  707. var buBytes = ms.GetBuffer();
  708. return new FileStreamResult(new MemoryStream(buBytes), "application/wav");
  709. }
  710. }
  711. [HttpGet]
  712. [WrapResult(false)]
  713. public async Task<ActionResult> QueryScore(string id)
  714. {
  715. if (id.IsEmpty())
  716. {
  717. var camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
  718. if (camp == null)
  719. {
  720. CheckErrors("未查询到正在运行的培训营!");
  721. return Content("Error");
  722. }
  723. id = camp.Id;
  724. }
  725. var score = await QueryApp.GetScoreInfo(id);
  726. return Json(score, JsonRequestBehavior.AllowGet);
  727. }
  728. }
  729. }