private void GetPrize(HttpContext context) { context.Response.ContentType = "application/json"; StringBuilder builder = new StringBuilder("{"); string str = context.Request["gameid"]; if (string.IsNullOrEmpty(str)) { builder.Append("\"status\":\"0\",\"Desciption\":\"参数错误!\"}"); context.Response.Write(builder.ToString()); } else { GameInfo modelByGameId = GameHelper.GetModelByGameId(str); if (modelByGameId == null) { builder.Append("\"status\":\"0\",\"Desciption\":\"参数错误!\"}"); context.Response.Write(builder.ToString()); } else if (DateTime.Now < modelByGameId.BeginTime) { builder.Append("\"status\":\"0\",\"Desciption\":\"活动还没开始!\"}"); context.Response.Write(builder.ToString()); } else if ((DateTime.Now > modelByGameId.EndTime) || (modelByGameId.Status == GameStatus.结束)) { builder.Append("\"status\":\"0\",\"Desciption\":\"活动已结束!\"}"); context.Response.Write(builder.ToString()); } else { int userid = 0; try { userid = MemberProcessor.GetCurrentMember().UserId; } catch (Exception) { builder.Append("\"status\":\"0\",\"Desciption\":\"请先登录!\"}"); context.Response.Write(builder.ToString()); return; } try { if (MemberProcessor.CheckCurrentMemberIsInRange(modelByGameId.ApplyMembers, modelByGameId.DefualtGroup, modelByGameId.CustomGroup)) { GameHelper.IsCanPrize(modelByGameId.GameId, userid); } else { builder.Append("\"status\":\"0\",\"Desciption\":\"当前会员不在活动的适用会员范围内\"}"); context.Response.Write(builder.ToString()); return; } } catch (Exception exception) { builder.Append("\"status\":\"0\",\"Desciption\":\"" + exception.Message + "!\"}"); context.Response.Write(builder.ToString()); return; } lock (objLock) { try { List <GameWinningPool> winningPoolList = GameHelper.GetWinningPoolList(Globals.ToNum(modelByGameId.GameId)); int maxValue = winningPoolList.Count <GameWinningPool>(); string prizeName = ""; if (maxValue > 0) { int num3 = new Random().Next(0, maxValue); GameWinningPool pool = winningPoolList[num3]; if (pool != null) { int prizeId = 0; if (pool.GamePrizeId > 0) { GamePrizeInfo gamePrizeInfoById = GameHelper.GetGamePrizeInfoById(pool.GamePrizeId); if (gamePrizeInfoById != null) { prizeId = gamePrizeInfoById.PrizeId; prizeName = gamePrizeInfoById.PrizeName; } builder.Append(string.Concat(new object[] { "\"status\":\"1\",\"Desciption\":\"\",\"prizeName\":\"", prizeName, "\",\"prizeState\":\"ok\",\"prizeId\":\"", pool.GamePrizeId, "\",\"prize\":\"", gamePrizeInfoById.Prize, "\",\"prizeGrade\":\"", this.GetPrizeName(gamePrizeInfoById.PrizeGrade), "\"}" })); } else { prizeName = modelByGameId.NotPrzeDescription; builder.Append("\"status\":\"1\",\"Desciption\":\"\",\"prizeName\":\"" + prizeName + "\",\"prizeState\":\"fail\",\"prizeId\":\"0\",\"prizeGrade\":\"0\"}"); } PrizeResultInfo model = new PrizeResultInfo { GameId = modelByGameId.GameId, PrizeId = prizeId, UserId = userid }; GameHelper.AddPrizeLog(model); GameHelper.UpdateWinningPoolIsReceive(pool.WinningPoolId); } } else { builder.Append("\"status\":\"1\",\"Desciption\":\"\",\"prizeName\":\"" + (string.IsNullOrEmpty(modelByGameId.NotPrzeDescription) ? "谢谢参与!" : modelByGameId.NotPrzeDescription) + "\",\"prizeState\":\"fail\",\"prizeId\":\"0\",\"prizeGrade\":\"0\"}"); PrizeResultInfo info5 = new PrizeResultInfo { GameId = modelByGameId.GameId, PrizeId = 0, UserId = userid }; GameHelper.AddPrizeLog(info5); context.Response.Write(builder.ToString()); return; } context.Response.Write(builder.ToString()); } catch (Exception exception2) { Globals.Debuglog(exception2.ToString(), "_GameDebuglog.txt"); } } } } }
private void GetPrize(System.Web.HttpContext context) { context.Response.ContentType = "application/json"; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("{"); string text = context.Request["gameid"]; if (string.IsNullOrEmpty(text)) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"参数错误!\"}"); context.Response.Write(stringBuilder.ToString()); return; } GameInfo modelByGameId = GameHelper.GetModelByGameId(text); if (modelByGameId == null) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"参数错误!\"}"); context.Response.Write(stringBuilder.ToString()); return; } if (System.DateTime.Now < modelByGameId.BeginTime) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"活动还没开始!\"}"); context.Response.Write(stringBuilder.ToString()); return; } if (System.DateTime.Now > modelByGameId.EndTime || modelByGameId.Status == GameStatus.结束) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"活动已结束!\"}"); context.Response.Write(stringBuilder.ToString()); return; } int num = 0; try { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); num = currentMember.UserId; } catch (System.Exception) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"请先登录!\"}"); context.Response.Write(stringBuilder.ToString()); return; } try { if (!MemberProcessor.CheckCurrentMemberIsInRange(modelByGameId.ApplyMembers, modelByGameId.DefualtGroup, modelByGameId.CustomGroup)) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"当前会员不在活动的适用会员范围内\"}"); context.Response.Write(stringBuilder.ToString()); return; } GameHelper.IsCanPrize(modelByGameId.GameId, num); } catch (System.Exception ex) { stringBuilder.Append("\"status\":\"0\",\"Desciption\":\"" + ex.Message + "!\"}"); context.Response.Write(stringBuilder.ToString()); return; } lock (Hi_Ajax_Game.objLock) { try { System.Collections.Generic.List <GameWinningPool> winningPoolList = GameHelper.GetWinningPoolList(Globals.ToNum(modelByGameId.GameId)); int num2 = winningPoolList.Count <GameWinningPool>(); string text2 = ""; if (num2 > 0) { System.Random random = new System.Random(); int index = random.Next(0, num2); GameWinningPool gameWinningPool = winningPoolList[index]; if (gameWinningPool != null) { int prizeId = 0; if (gameWinningPool.GamePrizeId > 0) { GamePrizeInfo gamePrizeInfoById = GameHelper.GetGamePrizeInfoById(gameWinningPool.GamePrizeId); if (gamePrizeInfoById != null) { prizeId = gamePrizeInfoById.PrizeId; text2 = gamePrizeInfoById.PrizeName; } stringBuilder.Append(string.Concat(new object[] { "\"status\":\"1\",\"Desciption\":\"\",\"prizeName\":\"", text2, "\",\"prizeState\":\"ok\",\"prizeId\":\"", gameWinningPool.GamePrizeId, "\",\"prize\":\"", gamePrizeInfoById.Prize, "\",\"prizeGrade\":\"", this.GetPrizeName(gamePrizeInfoById.PrizeGrade), "\"}" })); } else { text2 = modelByGameId.NotPrzeDescription; stringBuilder.Append("\"status\":\"1\",\"Desciption\":\"\",\"prizeName\":\"" + text2 + "\",\"prizeState\":\"fail\",\"prizeId\":\"0\",\"prizeGrade\":\"0\"}"); } GameHelper.AddPrizeLog(new PrizeResultInfo { GameId = modelByGameId.GameId, PrizeId = prizeId, UserId = num }); GameHelper.UpdateWinningPoolIsReceive(gameWinningPool.WinningPoolId); } context.Response.Write(stringBuilder.ToString()); } else { text2 = (string.IsNullOrEmpty(modelByGameId.NotPrzeDescription) ? "谢谢参与!" : modelByGameId.NotPrzeDescription); stringBuilder.Append("\"status\":\"1\",\"Desciption\":\"\",\"prizeName\":\"" + text2 + "\",\"prizeState\":\"fail\",\"prizeId\":\"0\",\"prizeGrade\":\"0\"}"); GameHelper.AddPrizeLog(new PrizeResultInfo { GameId = modelByGameId.GameId, PrizeId = 0, UserId = num }); context.Response.Write(stringBuilder.ToString()); } } catch (System.Exception ex2) { Globals.Debuglog(ex2.ToString(), "_GameDebuglog.txt"); } } }