internal static SSwitch GetSwitchModel(int id) { using (var cn = new MySqlConnection(sqlconnectionString)) { cn.Open(); StringBuilder str = new StringBuilder(); str.Append("select * from " + database1 + @".S_Switch where ID = " + id + ""); IEnumerable <SSwitch> i = cn.Query <SSwitch>(str.ToString()); SSwitch mode = i.FirstOrDefault(); cn.Close(); return(mode); } }
Statement SwitchStatement() { Expect(Symbol.S_LParen); Expression dice = NumericExpression(); Expect(Symbol.S_RParen); Numeric revealCond = null, prob = null; if (Accept(Symbol.S_LBracket)) { if (Accept(Symbol.S_True)) { revealCond = new Numeric(1, 0); } else if (Accept(Symbol.S_False)) { revealCond = new Numeric(0, 0); } else { Error("IfElseStatement: reveal condition should be true or false"); } Expect(Symbol.S_Comma); double resultDouble; double.TryParse(currToken.sequence, out resultDouble); prob = new Numeric((BigInteger)(resultDouble * Math.Pow(2, Config.ScaleBits)), Config.ScaleBits); NextToken(); Expect(Symbol.S_RBracket); } Expect(Symbol.S_LBrace); SSwitch switchStat = new SSwitch(dice, revealCond, prob); var ifelseStat = CaseDefaultStatement(switchStat); Expect(Symbol.S_RBrace); switchStat.ifelseStat = ifelseStat; return(switchStat); }
Statement CaseDefaultStatement(SSwitch switchStat) { //var ret = new SSequence(new SAssignment(vars["min"], new EUnaryOperation(vars["tempCurrentValue"], OperationType.Switch)), // new SAssignment(vars["max"], new EUnaryOperation(vars["tempCurrentValue"], OperationType.Switch)), // new SAssignment(vars["increasing_or_decreasing_factor"], new EUnaryOperation(vars["tempCurrentValue"], OperationType.Switch))); //while(currToken != "}") //{ // NextToken(); //} //return ret; if (Accept(Symbol.S_Default)) { List <Statement> stats = new List <Statement>(); Expect(Symbol.S_Colon); while (!Accept(Symbol.S_Break)) { stats.Add(Statement()); } Expect(Symbol.S_Semicolon); switchStat.defaultStat = new SSequence(stats.ToArray()); return(new SSequence(stats.ToArray())); } else { Expect(Symbol.S_Case); Numeric caseKey = new Numeric(currToken.sequence, 0); Expression condition = new EUnaryOperation(new EBinaryOperation(switchStat.dice, new ENumericLiteral(currToken.sequence, 0), OperationType.Substraction), OperationType.EqualZero); NextToken(); Expect(Symbol.S_Colon); List <Statement> ifStats = new List <Statement>(); while (!Accept(Symbol.S_Break)) { ifStats.Add(Statement()); } Expect(Symbol.S_Semicolon); switchStat.caseStat.Add(caseKey, new SSequence(ifStats.ToArray())); var elseStats = CaseDefaultStatement(switchStat); return(new SIfElse(condition, new SSequence(ifStats.ToArray()), elseStats, null, null)); } }
/// <summary> /// 水浒传控制台首页 /// </summary> /// <returns></returns> public ActionResult ConfigIndex(Dictionary <string, string> queryvalues) { //从数据库中获取配置参数 //QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); //qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; //qrCodeEncoder.QRCodeScale = 4; //qrCodeEncoder.QRCodeVersion = 8; //qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; ////System.Drawing.Image image = qrCodeEncoder.Encode("4408810820 深圳-广州 小江"); //System.Drawing.Image image = qrCodeEncoder.Encode("http://www.baidu.com"); //string filename = DateTime.Now.ToString("yyyymmddhhmmssfff").ToString() + ".jpg"; //string filepath = Server.MapPath(@"~\Upload") + "\\" + filename; //System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write); //image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg); //fs.Close(); //image.Dispose(); //二维码解码 // string s = BaiDuHelper.TransLongUrlToTinyUrl("http://www.515.com/tg/?via=asdf"); string par = queryvalues.ContainsKey("par") ? queryvalues["par"].Trim(',') : ""; string type = queryvalues.ContainsKey("type") ? queryvalues["type"] : ""; string operType = queryvalues.ContainsKey("operType") ? queryvalues["operType"] : ""; if (par.Contains("'")) { return(Content("-4")); } switch (operType) { case "1": //说明是保存配置1,2,3 //type说明是保存的配置 string[] pars = par.Split('|'); List <WaterMargin> modelList = new List <WaterMargin>(); for (int i = 0; i < pars.Length - 1; i++) { WaterMargin m = new WaterMargin(); string[] ps = pars[i].Split(','); m.ColumnNO = i + 1; m.Type = Convert.ToInt32(type); m.Hatchet = Convert.ToInt32(ps[0]); m.Gun = Convert.ToInt32(ps[1]); m.Knife = Convert.ToInt32(ps[2]); m.Lu = Convert.ToInt32(ps[3]); m.Lin = Convert.ToInt32(ps[4]); m.Song = Convert.ToInt32(ps[5]); m.God = Convert.ToInt32(ps[6]); m.Hall = Convert.ToInt32(ps[7]); m.Outlaws = Convert.ToInt32(ps[8]); m.Wine = Convert.ToInt64(Convert.ToDouble(pars[pars.Length - 1]) * 1000); m.CreateTime = DateTime.Now; modelList.Add(m); } int res = WaterMarginBLL.UpdateWatermargin(modelList); if (res > 0) { //修改成功 // return Content("1"); int callback = MessageSlot(); return(Content(callback.ToString())); } else { return(Content("-3")); } case "2": //说明是修改小玛丽 Int64 uplimit = queryvalues.ContainsKey("uplimit") ? Convert.ToInt64(queryvalues["uplimit"]) : 0; Int64 downlimit = queryvalues.ContainsKey("downlimit") ? Convert.ToInt64(queryvalues["downlimit"]) : 0; Int64 bibei1 = queryvalues.ContainsKey("bibei1") ? Convert.ToInt64(queryvalues["bibei1"]) : 0; Int64 bibei2 = queryvalues.ContainsKey("bibei2") ? Convert.ToInt64(queryvalues["bibei2"]) : 0; Int64 bibei3 = queryvalues.ContainsKey("bibei3") ? Convert.ToInt64(queryvalues["bibei3"]) : 0; Int64 bibei4 = queryvalues.ContainsKey("bibei4") ? Convert.ToInt64(queryvalues["bibei4"]) : 0; Int64 bibei5 = queryvalues.ContainsKey("bibei5") ? Convert.ToInt64(queryvalues["bibei5"]) : 0; Int64 bibein = queryvalues.ContainsKey("bibein") ? Convert.ToInt64(queryvalues["bibein"]) : 0; int marryRes = WaterMarginBLL.UpdateMary(1, uplimit, downlimit, bibei1, bibei2, bibei3, bibei4, bibei5, bibein); if (marryRes > 0) { //修改成功 // return Content("1"); int marryCallback = MessageSlot(); return(Content(marryCallback.ToString())); } else { return(Content("-3")); } case "3": //修改奖池 string[] parsPot = par.Split('|'); List <SSwitch> modelListPot = new List <SSwitch>(); string potStr = ""; IEnumerable <SSwitch> potDBData = WaterMarginBLL.GetSSwitchList("'7001','7002','7003','7004','7005','7006'"); for (int i = 0; i <= parsPot.Length - 1; i++) { string[] ite = parsPot[i].Split(','); SSwitch m = new SSwitch(); m.ID = Convert.ToInt32(ite[0]); m.ISOpen = ite[1] == "1"?true:false; m.para1 = Convert.ToInt32(Convert.ToDouble(ite[2]) * 1000); m.para2 = Convert.ToInt64(ite[3]); m.para6 = Convert.ToInt64(ite[4]); SSwitch exist = potDBData.Where(k => k.ID == m.ID && k.para2 != m.para2).FirstOrDefault(); if (exist != null) //说明奖池被修改了 { potStr = potStr + m.ID + "," + m.para2 + "|"; } modelListPot.Add(m); } int resPot = WaterMarginBLL.UpdateSSwitch(modelListPot); if (resPot > 0) { int callback = MessagePot(potStr); return(Content(callback.ToString())); } else { return(Content("-3")); } case "4": //作弊 string[] parsZuobi = par.Split('|'); List <ArcadeGameStock> modelListArcade = new List <ArcadeGameStock>(); IEnumerable <ArcadeGameStock> zuobiDBData = WaterMarginBLL.GetArcadeGameStockList("'1','2','3','4','5','6'"); string zuobiStr = ""; for (int i = 0; i <= parsZuobi.Length - 1; i++) { string[] ite = parsZuobi[i].Split(','); ArcadeGameStock m = new ArcadeGameStock(); m.ID = Convert.ToInt32(ite[0]); m.StockValue = Convert.ToInt64(ite[1]); m.StockCordon = Convert.ToInt64(ite[2]); m.StockIsOpen = Convert.ToInt32(ite[3]); m.Param1 = Convert.ToInt64(ite[4]); //个人盈利控制开关 m.Param2 = Convert.ToInt64(ite[5]); //充值玩家增益开关 m.Param3 = Convert.ToInt64(ite[6]); //新手玩家增益开关 m.Param4 = Convert.ToInt64(Convert .ToDouble(ite[7]) * 1000); //小玛丽触发概率 m.Param5 = Convert.ToInt64(ite[8]); //小玛丽开关 m.Param6 = Convert.ToInt64(ite[9]); //连输局数 m.Param7 = Convert.ToInt64(ite[10]); //全盘奖开关 m.CreateTime = DateTime.Now; modelListArcade.Add(m); ArcadeGameStock zuobidbData = zuobiDBData.Where(k => k.ID == m.ID).FirstOrDefault(); if (zuobidbData != null) { zuobiStr = zuobiStr + m.ID + "," + m.StockValue + "|"; } } int resZuobi = WaterMarginBLL.UpdateArcadeGameStock(modelListArcade); if (resZuobi > 0) { int callback = MessageZuobi(zuobiStr); return(Content(callback.ToString())); } else { return(Content("-3")); } } //slot配置 IEnumerable <WaterMargin> data = WaterMarginBLL.GetWaterMarginList(); //小玛丽 MarryConfig maryConfig = WaterMarginBLL.GetMarryConfig(1); //比倍配置 IEnumerable <BiBeiConfig> bibeiConfig = WaterMarginBLL.GetBiBeiConfig(); //彩池配置 IEnumerable <SSwitch> potData = WaterMarginBLL.GetSSwitchList("'7001','7002','7003','7004','7005','7006'"); IEnumerable <ArcadeGameStock> zuobiData = WaterMarginBLL.GetArcadeGameStockList("'1','2','3','4','5','6'"); WaterMarginView model = new WaterMarginView(); model.DataOne = data; model.DataTwo = maryConfig; model.DataTwo2 = bibeiConfig; model.DataThree = potData; model.DataFour = zuobiData; return(View(model)); }