public static void UpdateBingoResultLog(int userID, BingoResult result) { var sql = "UPDATE AcnClub_LogBingo SET Result = @result, ResultDetail = @resultDetail WHERE [ID] = (SELECT TOP 1 [ID] FROM AcnClub_LogBingo WHERE UserID = @userID AND Result is NULL ORDER BY ActionDate DESC)"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); object tempValue = null; com.Parameters.Add(new SqlParameter("@userID", userID)); if (result.Result == BingoResultType.Null) { tempValue = DBNull.Value; } else { tempValue = (int)result.Result; } com.Parameters.Add(new SqlParameter("@result", tempValue)); com.Parameters.Add(new SqlParameter("@resultDetail", ClubLogic.ParseNullableParam(result.ResultDetail))); con.Open(); com.ExecuteNonQuery(); //con.Close(); } }
public static string ShowBothBingoDetail(string formatString, BingoResult br) { if ((br.Result == BingoResultType.Strip) && (br.ResultDetail != "strips")) { return(string.Format(formatString, AnalyzeStripDetail(br.ResultDetail))); } if (br.Result == BingoResultType.Both) { var stripResult = br.ResultDetail.Substring(0, br.ResultDetail.IndexOf("+")); var cashResult = br.ResultDetail.Substring(br.ResultDetail.IndexOf("(") + 1, (br.ResultDetail.IndexOf(")") - br.ResultDetail.IndexOf("(") - 1)); return(string.Format(formatString, AnalyzeStripDetail(stripResult), cashResult)); } return(string.Empty); }
protected void gvClubStrip_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var bh = e.Row.DataItem as BingoHistory; var br = new BingoResult(bh.Result, bh.ResultDetail); var finalResult = string.Empty; switch (br.Result) { case BingoResultType.Strip: if (br.ResultDetail == "strip") finalResult = "<span class=\"ClubSys_Strip SHIRT\">球衣</span><span class=\"ClubSys_Strip SHORTS\">球裤</span><span class=\"ClubSys_Strip SOCK\">球袜</span>"; else if (br.ResultDetail.Contains("strips")) finalResult = "<span class=\"ClubSys_Strip SHIRT\">球衣</span><span class=\"ClubSys_Strip SHORTS\">球裤</span><span class=\"ClubSys_Strip SOCK\">球袜</span><span class=\"ClubSys_Strip RATE\">×5</span>"; else finalResult = BingoUtil.ShowBothBingoDetail( ("<span class=\"ClubSys_Strip " + br.ResultDetail.ToUpper() + "\">{0}</span>"), br); break; case BingoResultType.Card: if (br.ResultDetail == "legend") finalResult = "<span class=\"ClubSys_Strip VIDEO\">视频</span>"; else finalResult = $"<span class=\"ClubSys_Strip CARD\">{Player.Cache.Load(new Guid(br.ResultDetail)).DisplayName}</span>"; break; case BingoResultType.Cash: finalResult = "<span class=\"ClubSys_Strip CASH\">枪手币: " + br.ResultDetail + "</span>"; break; case BingoResultType.Both: finalResult = BingoUtil.ShowBothBingoDetail( "<span class=\"ClubSys_Strip " + br.ResultDetail.Substring(0, br.ResultDetail.IndexOf("+")).ToUpper() + "\">{0}</span> <span class=\"ClubSys_Strip CASH\">枪手币: {1}</span>", br); break; } var ltrlStrip = e.Row.FindControl("ltrlStrip") as Literal; ltrlStrip.Text = finalResult; } }
public static string UpdateBingoResult(int userID, string userName, BingoResult result, string resultType) { if (result.Result != BingoResultType.Null) { var sql = string.Empty; if ((resultType == "card") && (result.Result == BingoResultType.Card) && (result.ResultDetail.Length == 36)) { try { var guid = result.ResultDetail; sql = "INSERT INTO dbo.AcnClub_Card (UserID, UserName, IsActive, IsInUse, GainDate, ActiveDate, ArsenalPlayerGuid) VALUES (@userID, @userName, 0, 0, getdate(), null, @guid)"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); com.Parameters.Add(new SqlParameter("@userID", userID)); com.Parameters.Add(new SqlParameter("@userName", userName)); com.Parameters.Add(new SqlParameter("@guid", new Guid(guid))); con.Open(); com.ExecuteNonQuery(); //con.Close(); } UpdateBingoResultLog(userID, result); return("a card of " + Player.Cache.Load(new Guid(guid)).DisplayName); } catch { //throw new Exception("Invalid Arsenal Player Guid."); return("-1"); } } if ((resultType == "card") && (result.Result == BingoResultType.Card) && (result.ResultDetail == "legend")) { try { sql = "INSERT INTO dbo.AcnClub_Card (UserID, UserName, IsActive, IsInUse, GainDate, ActiveDate, ArsenalPlayerGuid) VALUES (@userID, @userName, 0, 0, getdate(), null, null)"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); com.Parameters.Add(new SqlParameter("@userID", userID)); com.Parameters.Add(new SqlParameter("@userName", userName)); con.Open(); com.ExecuteNonQuery(); //con.Close(); } UpdateBingoResultLog(userID, result); return("a legend card"); } catch { return("-1"); } } if (result.Result == BingoResultType.Cash) { try { var bonusCash = Convert.ToSingle(result.ResultDetail); var finalResult = string.Empty; var info = Users.GetUserInfo(userID); info.Extcredits2 += bonusCash; if (AdminUsers.UpdateUserAllInfo(info)) { finalResult = ("Cash(QSB):" + bonusCash); UpdateBingoResultLog(userID, result); return(finalResult); } return("-1"); } catch { return("-1"); } } try { // Strip Bonus var shirt = 0; var shorts = 0; var sock = 0; var bonusCash = 0f; var bonusRate = ConfigGlobal.BingoBonusRate; var finalResult = string.Empty; var player = GetPlayerInfo(userID); if ((result.Result == BingoResultType.Strip) || (result.Result == BingoResultType.Both)) { if (result.ResultDetail == "shirt") { shirt++; } else if (result.ResultDetail == "shorts") { shorts++; } else if (result.ResultDetail == "sock") { sock++; } else if (result.ResultDetail == "strips") { shirt += 5; shorts += 5; sock += 5; } if (player == null) { sql = "INSERT INTO dbo.AcnClub_Player VALUES (@userID, @userName, @shirt, @shorts, @sock, null, 1, null)"; } else { shirt = player.Shirt + shirt; shorts = player.Shorts + shorts; sock = player.Sock + sock; sql = "UPDATE dbo.AcnClub_Player SET Shirt = @shirt, Shorts = @shorts, Sock = @sock WHERE UserID = @userID AND UserName = @userName"; } using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); com.Parameters.Add(new SqlParameter("@userID", userID)); com.Parameters.Add(new SqlParameter("@userName", userName)); com.Parameters.Add(new SqlParameter("@shirt", shirt)); com.Parameters.Add(new SqlParameter("@shorts", shorts)); com.Parameters.Add(new SqlParameter("@sock", sock)); con.Open(); com.ExecuteNonQuery(); //con.Close(); } if (result.ResultDetail == "strips") { finalResult += ("5 " + result.ResultDetail); } else { finalResult += ("a " + result.ResultDetail); } } //Cash Bonus if (result.Result == BingoResultType.Both) { if (player != null) { if (result.ResultDetail == "shirt") { bonusCash = Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Shirt)) * bonusRate)); } else if (result.ResultDetail == "shorts") { bonusCash = Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Shorts)) * bonusRate)); } else if (result.ResultDetail == "sock") { bonusCash = Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Sock)) * bonusRate)); } } else { bonusCash = 0f; } bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) + Convert.ToSingle(ConfigGlobal.BingoCost); var info = Users.GetUserInfo(userID); info.Extcredits2 += bonusCash; if (AdminUsers.UpdateUserAllInfo(info)) { finalResult += (" and Cash(QSB):" + bonusCash); } result.ResultDetail += string.Format("+({0})", bonusCash); } UpdateBingoResultLog(userID, result); return(finalResult); } catch { return("-1"); } } return("-1"); }
public static BingoResult AnalyzeFlashResult(int userID, string result, string resultType) { var br = new BingoResult(); switch (resultType) { case "strip": br.Result = BingoResultType.Strip; if (result == "strip") { br.ResultDetail = "strips"; } else { br.ResultDetail = result; } return(br); case "card": br.Result = BingoResultType.Card; if (result.Length == 36) { br.ResultDetail = result; } else { br.ResultDetail = "legend"; } return(br); case "cash": br.Result = BingoResultType.Cash; var bonusCash = 0f; var bonusRate = ConfigGlobal.BingoBonusRate; if (result == "cash") { var videoActiveCount = Entity.UserVideo.GetUserVideosByUserID(userID).Count; var items = PlayerStrip.GetMyNumbers(userID); items.RemoveAll(delegate(Card un) { return(!un.IsActive); }); var cardActiveCount = items.Count; // Video & Card Cash Bonus bonusCash += (videoActiveCount * 5 + cardActiveCount) * bonusRate; bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) + Convert.ToSingle(ConfigGlobal.BingoCost); } else { // Player Cash Bonus bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) * bonusRate; bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) + Convert.ToSingle(ConfigGlobal.BingoCost); } br.ResultDetail = Math.Floor(bonusCash).ToString(); return(br); case "both": br.Result = BingoResultType.Both; br.ResultDetail = result; return(br); default: br.Result = BingoResultType.Null; br.ResultDetail = null; return(br); } }
public static BingoResult AnalyzeFlashResult(int userID, string result, string resultType) { var br = new BingoResult(); switch (resultType) { case "strip": br.Result = BingoResultType.Strip; if (result == "strip") br.ResultDetail = "strips"; else br.ResultDetail = result; return br; case "card": br.Result = BingoResultType.Card; if (result.Length == 36) { br.ResultDetail = result; } else { br.ResultDetail = "legend"; } return br; case "cash": br.Result = BingoResultType.Cash; var bonusCash = 0f; var bonusRate = ConfigGlobal.BingoBonusRate; if (result == "cash") { var videoActiveCount = Entity.UserVideo.GetUserVideosByUserID(userID).Count; var items = PlayerStrip.GetMyNumbers(userID); items.RemoveAll(delegate(Card un) { return !un.IsActive; }); var cardActiveCount = items.Count; // Video & Card Cash Bonus bonusCash += (videoActiveCount*5 + cardActiveCount)*bonusRate; bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) + Convert.ToSingle(ConfigGlobal.BingoCost); } else { // Player Cash Bonus bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost)*bonusRate; bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) + Convert.ToSingle(ConfigGlobal.BingoCost); } br.ResultDetail = Math.Floor(bonusCash).ToString(); return br; case "both": br.Result = BingoResultType.Both; br.ResultDetail = result; return br; default: br.Result = BingoResultType.Null; br.ResultDetail = null; return br; } }
public static string ShowBothBingoDetail(string formatString, BingoResult br) { if ((br.Result == BingoResultType.Strip) && (br.ResultDetail != "strips")) return string.Format(formatString, AnalyzeStripDetail(br.ResultDetail)); if (br.Result == BingoResultType.Both) { var stripResult = br.ResultDetail.Substring(0, br.ResultDetail.IndexOf("+")); var cashResult = br.ResultDetail.Substring(br.ResultDetail.IndexOf("(") + 1, (br.ResultDetail.IndexOf(")") - br.ResultDetail.IndexOf("(") - 1)); return string.Format(formatString, AnalyzeStripDetail(stripResult), cashResult); } return string.Empty; }
public static void UpdateBingoResultLog(int userID, BingoResult result) { var sql = "UPDATE AcnClub_LogBingo SET Result = @result, ResultDetail = @resultDetail WHERE [ID] = (SELECT TOP 1 [ID] FROM AcnClub_LogBingo WHERE UserID = @userID AND Result is NULL ORDER BY ActionDate DESC)"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); object tempValue = null; com.Parameters.Add(new SqlParameter("@userID", userID)); if (result.Result == BingoResultType.Null) tempValue = DBNull.Value; else tempValue = (int) result.Result; com.Parameters.Add(new SqlParameter("@result", tempValue)); com.Parameters.Add(new SqlParameter("@resultDetail", ClubLogic.ParseNullableParam(result.ResultDetail))); con.Open(); com.ExecuteNonQuery(); //con.Close(); } }
public static string UpdateBingoResult(int userID, string userName, BingoResult result, string resultType) { if (result.Result != BingoResultType.Null) { var sql = string.Empty; if ((resultType == "card") && (result.Result == BingoResultType.Card) && (result.ResultDetail.Length == 36)) { try { var guid = result.ResultDetail; sql = "INSERT INTO dbo.AcnClub_Card (UserID, UserName, IsActive, IsInUse, GainDate, ActiveDate, ArsenalPlayerGuid) VALUES (@userID, @userName, 0, 0, getdate(), null, @guid)"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); com.Parameters.Add(new SqlParameter("@userID", userID)); com.Parameters.Add(new SqlParameter("@userName", userName)); com.Parameters.Add(new SqlParameter("@guid", new Guid(guid))); con.Open(); com.ExecuteNonQuery(); //con.Close(); } UpdateBingoResultLog(userID, result); return ("a card of " + Player.Cache.Load(new Guid(guid)).DisplayName); } catch { //throw new Exception("Invalid Arsenal Player Guid."); return "-1"; } } if ((resultType == "card") && (result.Result == BingoResultType.Card) && (result.ResultDetail == "legend")) { try { sql = "INSERT INTO dbo.AcnClub_Card (UserID, UserName, IsActive, IsInUse, GainDate, ActiveDate, ArsenalPlayerGuid) VALUES (@userID, @userName, 0, 0, getdate(), null, null)"; using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); com.Parameters.Add(new SqlParameter("@userID", userID)); com.Parameters.Add(new SqlParameter("@userName", userName)); con.Open(); com.ExecuteNonQuery(); //con.Close(); } UpdateBingoResultLog(userID, result); return "a legend card"; } catch { return "-1"; } } if (result.Result == BingoResultType.Cash) { try { var bonusCash = Convert.ToSingle(result.ResultDetail); var finalResult = string.Empty; var info = Users.GetUserInfo(userID); info.Extcredits2 += bonusCash; if (AdminUsers.UpdateUserAllInfo(info)) { finalResult = ("Cash(QSB):" + bonusCash); UpdateBingoResultLog(userID, result); return finalResult; } return "-1"; } catch { return "-1"; } } try { // Strip Bonus var shirt = 0; var shorts = 0; var sock = 0; var bonusCash = 0f; var bonusRate = ConfigGlobal.BingoBonusRate; var finalResult = string.Empty; var player = GetPlayerInfo(userID); if ((result.Result == BingoResultType.Strip) || (result.Result == BingoResultType.Both)) { if (result.ResultDetail == "shirt") shirt++; else if (result.ResultDetail == "shorts") shorts++; else if (result.ResultDetail == "sock") sock++; else if (result.ResultDetail == "strips") { shirt += 5; shorts += 5; sock += 5; } if (player == null) { sql = "INSERT INTO dbo.AcnClub_Player VALUES (@userID, @userName, @shirt, @shorts, @sock, null, 1, null)"; } else { shirt = player.Shirt + shirt; shorts = player.Shorts + shorts; sock = player.Sock + sock; sql = "UPDATE dbo.AcnClub_Player SET Shirt = @shirt, Shorts = @shorts, Sock = @sock WHERE UserID = @userID AND UserName = @userName"; } using (var con = SQLConn.GetConnection()) { var com = new SqlCommand(sql, con); com.Parameters.Add(new SqlParameter("@userID", userID)); com.Parameters.Add(new SqlParameter("@userName", userName)); com.Parameters.Add(new SqlParameter("@shirt", shirt)); com.Parameters.Add(new SqlParameter("@shorts", shorts)); com.Parameters.Add(new SqlParameter("@sock", sock)); con.Open(); com.ExecuteNonQuery(); //con.Close(); } if (result.ResultDetail == "strips") finalResult += ("5 " + result.ResultDetail); else finalResult += ("a " + result.ResultDetail); } //Cash Bonus if (result.Result == BingoResultType.Both) { if (player != null) { if (result.ResultDetail == "shirt") bonusCash = Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Shirt))*bonusRate)); else if (result.ResultDetail == "shorts") bonusCash = Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Shorts))*bonusRate)); else if (result.ResultDetail == "sock") bonusCash = Convert.ToSingle(Math.Floor(Math.Sqrt(Convert.ToDouble(player.Sock))*bonusRate)); } else { bonusCash = 0f; } bonusCash += Convert.ToSingle(ConfigGlobal.BingoGetCost) + Convert.ToSingle(ConfigGlobal.BingoCost); var info = Users.GetUserInfo(userID); info.Extcredits2 += bonusCash; if (AdminUsers.UpdateUserAllInfo(info)) { finalResult += (" and Cash(QSB):" + bonusCash); } result.ResultDetail += string.Format("+({0})", bonusCash); } UpdateBingoResultLog(userID, result); return finalResult; } catch { return "-1"; } } return "-1"; }
private void BindStripHistory() { if (_list == null) { _list = PlayerStrip.GetClubBingoHistory(ClubID); foreach (var bh in _list) { var br = new BingoResult(bh.Result, bh.ResultDetail); switch (br.Result) { case BingoResultType.Strip: if (br.ResultDetail == "strip") bh.AdditionalData = "<span class=\"ClubSys_Strip SHIRT\">球衣</span><span class=\"ClubSys_Strip SHORTS\">球裤</span><span class=\"ClubSys_Strip SOCK\">球袜</span>"; else if (br.ResultDetail.Contains("strips")) bh.AdditionalData = "<span class=\"ClubSys_Strip SHIRT\">球衣</span><span class=\"ClubSys_Strip SHORTS\">球裤</span><span class=\"ClubSys_Strip SOCK\">球袜</span><span class=\"ClubSys_Strip RATE\">×5</span>"; else bh.AdditionalData = BingoUtil.ShowBothBingoDetail( ("<span class=\"ClubSys_Strip " + br.ResultDetail.ToUpper() + "\">{0}</span>"), br); break; case BingoResultType.Card: if (br.ResultDetail == "legend") bh.AdditionalData = "<span class=\"ClubSys_Strip VIDEO\">视频</span>"; else bh.AdditionalData = $"<span class=\"ClubSys_Strip CARD\">{Player.Cache.Load(new Guid(br.ResultDetail)).DisplayName}</span>"; break; case BingoResultType.Cash: bh.AdditionalData = "<span class=\"ClubSys_Strip CASH\">枪手币: " + br.ResultDetail + "</span>"; break; case BingoResultType.Both: bh.AdditionalData = BingoUtil.ShowBothBingoDetail( "<span class=\"ClubSys_Strip " + br.ResultDetail.Substring(0, br.ResultDetail.IndexOf("+")).ToUpper() + "\">{0}</span><span class=\"ClubSys_Strip CASH\">枪手币: {1}</span>", br); break; } } } gvClubStrip.DataSource = _list; gvClubStrip.DataBind(); }
private void BindClubHistory() { if (history == null) { history = ClubLogic.GetUserClubHistory(username); foreach (var ch in history) { var actionType = (ClubHistoryActionType) Enum.Parse(typeof (ClubHistoryActionType), ch.ActionType); switch (actionType) { case ClubHistoryActionType.JoinClub: ch.AdditionalData = "ClubSys_Agree"; break; case ClubHistoryActionType.RejectJoinClub: ch.AdditionalData = "ClubSys_Disagree"; break; case ClubHistoryActionType.LeaveClub: ch.AdditionalData = "ClubSys_Disagree"; break; case ClubHistoryActionType.MandatoryLeaveClub: ch.AdditionalData = "ClubSys_Disagree"; break; case ClubHistoryActionType.Nominated: ch.AdditionalData = "ClubSys_Agree"; break; case ClubHistoryActionType.Dismiss: ch.AdditionalData = "ClubSys_Disagree"; break; case ClubHistoryActionType.LuckyPlayer: ch.AdditionalData = "ClubSys_Agree"; ch.ActionDescription = $"<em>{ch.ActionDescription}</em>"; break; case ClubHistoryActionType.TransferExtcredit: ch.AdditionalData = "ClubSys_Agree"; ch.ActionDescription = $"<em>{ch.ActionDescription}</em>"; break; default: ch.AdditionalData = "ClubSys_Agree"; break; } ch.AdditionalData2 = ClubLogic.TranslateClubHistoryActionType(actionType); } var bingoHistory = PlayerStrip.GetUserBingoHistory(userid); foreach (var bh in bingoHistory) { var current = new Entity.ClubHistory(); var br = new BingoResult(bh.Result, bh.ResultDetail); current.OperatorUserName = username; current.ClubID = bh.ClubID; current.AdditionalData2 = string.Empty; current.ActionDate = bh.ActionDate; switch (br.Result) { case BingoResultType.Strip: current.AdditionalData = "ClubSys_Agree"; if (br.ResultDetail == "strip") current.ActionDescription = "获得一套球衣装备"; else if (br.ResultDetail == "strips") current.ActionDescription = "获得五套球衣装备"; else current.ActionDescription = BingoUtil.ShowBothBingoDetail("获得一件{0}", br); break; case BingoResultType.Card: current.AdditionalData = "ClubSys_Agree"; if (br.ResultDetail == "legend") current.ActionDescription = "获得一张视频卡"; else current.ActionDescription = $"获得球员卡: {Player.Cache.Load(new Guid(br.ResultDetail)).DisplayName}"; break; case BingoResultType.Cash: current.AdditionalData = "ClubSys_Agree"; current.ActionDescription = "获得枪手币: " + br.ResultDetail; break; case BingoResultType.Both: current.AdditionalData = "ClubSys_Agree"; current.ActionDescription = BingoUtil.ShowBothBingoDetail("获得一件{0}和枪手币: {1}", br); break; default: current.AdditionalData = "ClubSys_Disagree"; current.ActionDescription = "什么都没获得"; break; } if (br.Result != BingoResultType.Null) { current.ActionDescription = $"<em>{current.ActionDescription}</em>"; } history.Add(current); } var playerHistory = PlayerLog.GetUserPlayerHistory(userid); foreach (var ph in playerHistory) { var current = new Entity.ClubHistory(); current.OperatorUserName = username; current.ClubID = ClubLogic.GetActiveUserClubs(userid)[0].ID.Value; current.AdditionalData = "ClubSys_Star"; current.ActionDescription = $"<em>{ph.TypeDesc}</em>"; current.ActionDate = ph.ActionDate; history.Add(current); } history.Sort(new ClubHistoryComparer()); } gvHistoryLog.DataSource = history; gvHistoryLog.DataBind(); }