ExerciseController.cs 26 KB

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