/// <summary> /// 获取某一场比赛各小局列表 /// </summary> /// <param name="currentUser">忽略</param> /// <param name="request">Request.GetGameLoopDetailListFilter.Filter</param> /// <returns>Response.GameLoopDetail</returns> public Response Execute(string request) { var req = JsonConvert.DeserializeObject <Request <GetGameLoopDetailListFilter> >(request); var result = GameHelper.GetGameLoopDetailList(req.Filter); if (result.Entities.Count == 0)//假如数据为空,则根据GameOrder表WinGame胜局字段生成局数 { var entities = CreateLoopDetail(req.Filter.LoopId, req.Filter.MapId); if (entities.Count > 0) { GameLoopDetail detail = entities[0] as GameLoopDetail; bool isTeam = string.IsNullOrEmpty(req.Filter.MapId) ? false : true; int detailLoopCount = detail.WinGame * 2 - 1;//对阵总局数 List <EntityBase> resultEntity = new List <EntityBase>(); for (int i = 1; i <= detailLoopCount; i++) { GameLoopDetail newDetail = new GameLoopDetail { Id = Ext.NewId(), LoopId = req.Filter.LoopId, MapId = req.Filter.MapId, IsTeam = isTeam, Team1Id = detail.Team1Id, User1Id = detail.User1Id, Team2Id = detail.Team2Id, User2Id = detail.User2Id , OrderNo = i, CreateDate = DateTime.Now }; newDetail.RowState = RowState.Added; resultEntity.Add(newDetail); } var res = DbContext.GetInstance().Execute(CommandHelper.CreateSave(resultEntity)); if (res.IsSuccess) { result.Entities = resultEntity; } } } return(result); }
private static void SetGameLoopMapDetailList(Response result) { if (result.Entities.IsNotNullOrEmpty()) { foreach (GameLoopMap obj in result.Entities) { //获取队员的技能积分 obj.User1Score = GameHelper.GetSportScoreByUser(obj.User1Id); obj.User2Score = GameHelper.GetSportScoreByUser(obj.User2Id); var filter = new GetGameLoopDetailListFilter { LoopId = obj.LoopId, MapId = obj.Id }; var detailList = GameHelper.GetGameLoopDetailList(filter).Entities; if (detailList.IsNotNullOrEmpty()) { obj.DetailList = detailList.ToList <EntityBase, GameLoopDetail>(); } //获取头像 GetUserHeadUrl(obj); } } }
/// <summary> /// 获取某大轮次下面所有比赛场次,正赛/附加赛 /// </summary> /// <param name="request">Request.GetGameOrderLoopListFilter.Filter</param> /// <returns>Response.GameLoop</returns> public Response Execute(string request) { var req = JsonConvert.DeserializeObject <Request <GetGameOrderLoopListFilter> >(request); if (string.IsNullOrEmpty(req.Filter.GameId)) { return(ResultHelper.Fail("赛事ID未上传")); } Command cmd = null; if (req.Filter.PageIndex <= 0) { cmd = CommandHelper.CreateProcedure <GameLoop>(text: "sp_GetGameOrderLoopList"); } else { cmd = CommandHelper.CreateProcedure <GameLoop>(text: "sp_GetGameOrderLoopListPage"); cmd.CreateParamPager(req.Filter); } cmd.Params.Add(CommandHelper.CreateParam("@gameId", req.Filter.GameId)); cmd.Params.Add(CommandHelper.CreateParam("@knockOutAB", req.Filter.KnockOutAB)); cmd.Params.Add(CommandHelper.CreateParam("@orderId", req.Filter.OrderId)); cmd.Params.Add(CommandHelper.CreateParam("@groupId", req.Filter.GroupId)); cmd.Params.Add(CommandHelper.CreateParam("@isExtra", req.Filter.IsExtra)); cmd.Params.Add(CommandHelper.CreateParam("@groupOrderNo", req.Filter.GroupOrderNo)); cmd.Params.Add(CommandHelper.CreateParam("@orderNo", req.Filter.OrderNo)); cmd.Params.Add(CommandHelper.CreateParam("@startTime", req.Filter.StartTime)); string endTime = req.Filter.EndTime; if (!string.IsNullOrEmpty(endTime)) { endTime = DateTime.Parse(endTime).AddDays(1).ToString("yyyy-MM-dd"); } cmd.Params.Add(CommandHelper.CreateParam("@endTime", endTime)); cmd.Params.Add(CommandHelper.CreateParam("@team1Id", req.Filter.Team1Id)); if (req.Filter.Team1Id == req.Filter.Team2Id) { cmd.Params.Add(CommandHelper.CreateParam("@team2Id", "")); } else { cmd.Params.Add(CommandHelper.CreateParam("@team2Id", req.Filter.Team2Id)); } cmd.Params.Add(CommandHelper.CreateParam("@tableNo", req.Filter.TableNo)); var result = DbContext.GetInstance().Execute(cmd); result.SetRowCount(); GetGameLoopDetailListFilter detailFilter = new GetGameLoopDetailListFilter();//查询每次对阵的小局详情模型 foreach (var item in result.Entities) { GameLoop gl = item as GameLoop; if (gl.IsTeam) { gl.DetailList = GameHelper.GetLoopMapByLoop(gl.Id);//取LOOPMAP里的大分数据 } else { detailFilter.LoopId = gl.Id; try { var tempResut = GameHelper.GetGameLoopDetailList(detailFilter).Entities; gl.DetailList = tempResut.ToList <EntityBase, GameLoopDetail>(); } catch { } } } return(result); }