| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using System.Threading.Tasks;
- using System.Web.Mvc;
- using Abp.Auditing;
- using Abp.Authorization;
- using Abp.Domain.Repositories;
- using IwbZero.ToolCommon.StringModel;
- using WeApp.BaseSystem.Query;
- using WeApp.Configuration;
- using WeApp.TrainingCamp;
- using WeApp.TrainingCamp.Dto;
- using WeApp.Views.Shared.Camp;
- namespace WeApp.Controllers
- {
- /// <summary>
- /// 演练实施
- /// </summary>
- [AbpAllowAnonymous, DisableAuditing]
- public class PlayController : IwbControllerBase
- {
- protected IRepository<CampInfo, string> CampRepository { get; }
- protected QueryAppService QueryApp { get; }
- private int TimeOut = 60 * 5;
- public PlayController(QueryAppService queryApp, IRepository<CampInfo, string> campRepository)
- {
- QueryApp = queryApp;
- CampRepository = campRepository;
- }
- /// <summary>
- /// 主屏页面
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<ActionResult> Index(string id)
- {
- CampInfo camp;
- if (id == "1")
- {
- camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
- if (camp == null)
- {
- CheckErrors("未查询到正在运行的培训营!");
- return Content("Error");
- }
- }
- else
- {
- string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
- if (campNo.IsEmpty())
- {
- TempData[ExerciseController.SelectDataKey] = new SelectCampModel
- {
- PageUrl = "/Play/Index",
- PageTitle = "演示屏选择培训营",
- HasGroup = false
- };
- return RedirectToAction("SelectCamp", "Exercise");
- }
- camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
- if (camp == null)
- {
- CheckErrors($"未查到到编号为【{campNo}】的培训营!");
- return null;
- }
- Session["CampNo"] = campNo;
- Session.Timeout = TimeOut;
- }
- ViewBag.Camp = ObjectMapper.Map<CampDto>(camp);
- if (camp.CampState != CampStateDefinition.Run)
- {
- return View("Wait");
- }
- ViewBag.Groups = await QueryApp.GetCampGroups(id);
- return View();
- }
- /// <summary>
- /// 主屏页面
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<ActionResult> IndexWithScore(string id)
- {
- CampInfo camp;
- if (id == "1")
- {
- camp = await CampRepository.FirstOrDefaultAsync(a => a.CampState == CampStateDefinition.Run);
- if (camp == null)
- {
- CheckErrors("未查询到正在运行的培训营!");
- return Content("Error");
- }
- }
- else
- {
- string campNo = id.IsEmpty() ? (string)Session["CampNo"] : id;
- if (campNo.IsEmpty())
- {
- TempData[ExerciseController.SelectDataKey] = new SelectCampModel
- {
- PageUrl = "/Play/IndexWithScore",
- PageTitle = "演示屏选择培训营",
- HasGroup = false
- };
- return RedirectToAction("SelectCamp", "Exercise");
- }
- camp = await CampRepository.FirstOrDefaultAsync(a => a.Id == campNo);
- if (camp == null)
- {
- CheckErrors($"未查到到编号为【{campNo}】的培训营!");
- return null;
- }
- Session["CampNo"] = campNo;
- Session.Timeout = TimeOut;
- }
- ViewBag.Camp = ObjectMapper.Map<CampDto>(camp);
- if (camp.CampState != CampStateDefinition.Run)
- {
- return View("Wait");
- }
- ViewBag.Groups = await QueryApp.GetCampGroups(id);
- return View();
- }
- }
- }
|