PlayController.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System.Threading.Tasks;
  2. using System.Web.Mvc;
  3. using Abp.Auditing;
  4. using Abp.Authorization;
  5. using Abp.Domain.Repositories;
  6. using IwbZero.ToolCommon.StringModel;
  7. using WeApp.BaseSystem.Query;
  8. using WeApp.Configuration;
  9. using WeApp.TrainingCamp;
  10. using WeApp.TrainingCamp.Dto;
  11. using WeApp.Views.Shared.Camp;
  12. namespace WeApp.Controllers
  13. {
  14. /// <summary>
  15. /// 演练实施
  16. /// </summary>
  17. [AbpAllowAnonymous, DisableAuditing]
  18. public class PlayController : IwbControllerBase
  19. {
  20. protected IRepository<CampInfo, string> CampRepository { get; }
  21. protected QueryAppService QueryApp { get; }
  22. private int TimeOut = 60 * 5;
  23. public PlayController(QueryAppService queryApp, IRepository<CampInfo, string> campRepository)
  24. {
  25. QueryApp = queryApp;
  26. CampRepository = campRepository;
  27. }
  28. /// <summary>
  29. /// 专家屏页面
  30. /// </summary>
  31. /// <param name="id"></param>
  32. /// <returns></returns>
  33. public async Task<ActionResult> Index(string id)
  34. {
  35. CampInfo camp;
  36. if (id == "1")
  37. {
  38. camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
  39. if (camp == null)
  40. {
  41. CheckErrors("未查询到正在运行的培训营!");
  42. return Content("Error");
  43. }
  44. }
  45. else
  46. {
  47. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  48. if (campNo.IsEmpty())
  49. {
  50. TempData[ExerciseController.SelectDataKey] = new SelectCampModel
  51. {
  52. PageUrl = "/Play/Index",
  53. PageTitle = "演示屏选择培训营",
  54. HasGroup = false
  55. };
  56. return RedirectToAction("SelectCamp", "Exercise");
  57. }
  58. camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
  59. if (camp == null)
  60. {
  61. CheckErrors($"未查到到编号为【{campNo}】的培训营!");
  62. return null;
  63. }
  64. Session["CampNo"] = campNo;
  65. Session.Timeout = TimeOut;
  66. }
  67. ViewBag.Camp = ObjectMapper.Map<CampDto>(camp);
  68. if (camp.CampState != CampStateDefinition.Run)
  69. {
  70. return View("Wait");
  71. }
  72. ViewBag.Groups = await QueryApp.GetCampGroups(id);
  73. return View();
  74. } /// <summary>
  75. /// 专家屏页面
  76. /// </summary>
  77. /// <param name="id"></param>
  78. /// <returns></returns>
  79. public async Task<ActionResult> IndexWithScore(string id)
  80. {
  81. CampInfo camp;
  82. if (id == "1")
  83. {
  84. camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
  85. if (camp == null)
  86. {
  87. CheckErrors("未查询到正在运行的培训营!");
  88. return Content("Error");
  89. }
  90. }
  91. else
  92. {
  93. string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
  94. if (campNo.IsEmpty())
  95. {
  96. TempData[ExerciseController.SelectDataKey] = new SelectCampModel
  97. {
  98. PageUrl = "/Play/IndexWithScore",
  99. PageTitle = "演示屏选择培训营",
  100. HasGroup = false
  101. };
  102. return RedirectToAction("SelectCamp", "Exercise");
  103. }
  104. camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
  105. if (camp == null)
  106. {
  107. CheckErrors($"未查到到编号为【{campNo}】的培训营!");
  108. return null;
  109. }
  110. Session["CampNo"] = campNo;
  111. Session.Timeout = TimeOut;
  112. }
  113. ViewBag.Camp = ObjectMapper.Map<CampDto>(camp);
  114. if (camp.CampState != CampStateDefinition.Run)
  115. {
  116. return View("Wait");
  117. }
  118. ViewBag.Groups = await QueryApp.GetCampGroups(id);
  119. return View();
  120. }
  121. }
  122. }