| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- using System.Threading.Tasks;
- using System.Web.Mvc;
- using System.Web.WebPages;
- using Abp.Web.Mvc.Authorization;
- using WeOnlineApp.BaseSystem.Query;
- using WeOnlineApp.Configuration;
- using WeOnlineApp.Models.Play;
- using WeOnlineApp.TrainingCampPlay;
- namespace WeOnlineApp.Controllers
- {
- [AbpMvcAuthorize]
- public class PlayController : IwbControllerBase
- {
- public PlayController(CampPlayAppService playApp, QueryAppService queryApp)
- {
- PlayApp = playApp;
- QueryApp = queryApp;
- }
- public CampPlayAppService PlayApp { get; }
- public QueryAppService QueryApp { get; }
- [AbpMvcAuthorize]
- public ActionResult Index()
- {
- CheckAccount();
- return View();
- }
- [AbpMvcAuthorize]
- public async Task<ActionResult> Start()
- {
- CheckAccount();
- var playNo = await PlayApp.GetRunPlay();
- if (playNo.IsEmpty())
- {
- return RedirectToAction("PlayList");
- }
- return RedirectToAction("Ready", new { id = playNo });
- }
- [AbpMvcAuthorize]
- public async Task<ActionResult> Ready(string id)
- {
- CheckAccount();
- if (id.IsEmpty())
- {
- id = await PlayApp.GetRunPlay();
- }
- if (id.IsEmpty())
- {
- CheckErrors("未查询到您正在演练,请选择一个演练加入或自己创建一个演练再开始!");
- }
- var play = await QueryApp.QueryPlay(id);
- if (play == null)
- {
- CheckErrors("未查询到演练,无法加入!");
- return View();
- }
- var playUser = await PlayApp.GetPlayUser(play.Id);
- if (play.PlayModel == CampPlayModelDefinition.Single)
- {
- if (playUser == null)
- {
- CheckErrors("单人演练,其他人无法加入!");
- }
- }
- else if ((!await PlayApp.CheckIsRun(id)) && !play.IsPublic)
- {
- //CheckErrors("演练未公开,无法加入!");
- return View("Code");
- }
- CampPlayModel campPlay = new CampPlayModel()
- {
- Play = play,
- Camp = await QueryApp.QueryCamp(play.CampNo),
- PlayUser = playUser
- };
- ViewBag.CampPlay = campPlay;
- if (play.PlayState == CampPlayStateDefinition.New)
- {
- return View("_Run/Ready", campPlay);
- }
- return View("_Run/Run", campPlay);
- //return View("Run", campPlay);
- }
- [AllowAnonymous]
- [AccessOriginal]
- public async Task<ActionResult> Display(string id)
- {
- var play = await QueryApp.QueryPlay(id);
- var playUser = await PlayApp.GetPlayUser(play.Id);
- CampPlayModel campPlay = new CampPlayModel()
- {
- Play = play,
- Camp = await QueryApp.QueryCamp(play.CampNo),
- PlayUser = playUser
- };
- ViewBag.CampPlay = campPlay;
- return View("_Run/Display", campPlay);
- }
- public ActionResult Code()
- {
- return View();
- }
- public async Task<ActionResult> Run(string id)
- {
- if (id.IsEmpty())
- {
- CheckErrors("未查询演练,请重新选择一个演练加入或自己创建一个演练再开始!");
- }
- var play = await PlayApp.GetPlayByCode(id);
- if (play == null)
- {
- CheckErrors("未查询到演练,无法加入!");
- return View("Index");
- }
- CampPlayModel campPlay = new CampPlayModel()
- {
- Play = play,
- Camp = await QueryApp.QueryCamp(play.CampNo),
- PlayUser = await PlayApp.GetPlayUser(play.Id)
- };
- ViewBag.CampPlay = campPlay;
- if (play.PlayState == CampPlayStateDefinition.New)
- {
- return View("_Run/Ready", campPlay);
- }
- return View("_Run/Run", campPlay);
- //return View();
- }
- [AbpMvcAuthorize]
- public ActionResult PlayList()
- {
- CheckAccount();
- return View();
- }
- [AbpMvcAuthorize]
- public async Task<ActionResult> Create(string id)
- {
- CheckAccount();
- if (id.IsEmpty())
- {
- CheckErrors("课程编号不能为空!");
- }
- ViewBag.PageId = "start";
- ViewBag.Camp = await QueryApp.QueryCamp(id);
- return View();
- }
- [AbpMvcAuthorize]
- public async Task<ActionResult> Detail(string id)
- {
- CheckAccount();
- if (id.IsEmpty())
- {
- CheckErrors("课程编号不能为空!");
- }
- ViewBag.PageId = "start";
- ViewBag.Camp = await QueryApp.QueryCamp(id);
- return View();
- }
- [AbpMvcAuthorize]
- public async Task<ActionResult> DetailByPlay(string id)
- {
- CheckAccount();
- if (id.IsEmpty())
- {
- CheckErrors("课程编号不能为空!");
- }
- ViewBag.PageId = "start";
- ViewBag.Camp = await QueryApp.QueryCampByPlay(id);
- return View("Detail");
- }
- public async Task<ActionResult> Study(string id)
- {
- CheckAccount();
- ViewBag.Camp = await QueryApp.QueryCampWithStudy(id);
- return View();
- }
- public ActionResult History()
- {
- CheckAccount();
- return View();
- }
- public ActionResult Medal()
- {
- CheckAccount();
- return View();
- }
- public ActionResult Team()
- {
- CheckAccount();
- return View();
- }
- public async Task<ActionResult> Report(string id)
- {
- CheckAccount();
- if (id.IsEmpty())
- {
- CheckErrors("演练编号不能为空!");
- }
- var play = await PlayApp.GetReportPlay(id);
- if (play == null)
- {
- CheckErrors("未查询到演练!");
- }
- ViewBag.Play = play;
- return View();
- }
- }
- }
|