public static ReturnValue <bool> BuyBoCai(KFBuyBocaiData data) { AutoWaitReturnValue <KfCall._p10> _wait_ = AutoWaitReturnValue <KfCall._p10> .Pop(); try { AutoCSer.Net.TcpInternalServer.ClientSocketSender _socket_ = KfCall.TcpClient.Sender; if (_socket_ != null) { KfCall._p11 _inputParameter_ = new KfCall._p11 { p0 = data }; KfCall._p10 _outputParameter_ = default(KfCall._p10); ReturnType _returnType_ = _socket_.WaitGet <KfCall._p11, KfCall._p10>(TcpCall.KFBoCaiManager._c6, ref _wait_, ref _inputParameter_, ref _outputParameter_); return(new ReturnValue <bool> { Type = _returnType_, Value = _outputParameter_.Return }); } } finally { if (_wait_ != null) { AutoWaitReturnValue <KfCall._p10> .PushNotNull(_wait_); } } return(new ReturnValue <bool> { Type = ReturnType.ClientException }); }
public bool BuyBoCai(KFBuyBocaiData data) { bool result; lock (this.mutex) { string str = this.SetWinInfo(data.BuyValue, data.BuyNum); if (string.IsNullOrEmpty(str)) { result = false; } else { bool flag = true; List <KFBuyBocaiData> itemList; if (this.RoleBuyDict.TryGetValue(data.GetKey(), out itemList)) { KFBuyBocaiData temp = itemList.Find((KFBuyBocaiData x) => x.BuyValue.Equals(data.BuyValue)); if (temp == null) { if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data)) { this.OpenData.WinInfo = str; itemList.Add(data); } else { flag = false; } } else { data.BuyNum += temp.BuyNum; if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data)) { this.OpenData.WinInfo = str; temp.BuyNum = data.BuyNum; } else { flag = false; } } } else if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data)) { itemList = new List <KFBuyBocaiData>(); itemList.Add(data); this.OpenData.WinInfo = str; this.RoleBuyDict.Add(data.GetKey(), itemList); } else { flag = false; } result = flag; } } return(result); }
public bool BuyBoCai(KFBuyBocaiData data) { bool result; lock (this.mutex) { bool flag = false; List <KFBuyBocaiData> itemList; if (this.RoleBuyDict.TryGetValue(data.GetKey(), out itemList)) { KFBuyBocaiData temp = itemList.Find((KFBuyBocaiData x) => x.BuyValue.Equals(data.BuyValue)); if (temp == null) { if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data)) { itemList.Add(data); flag = true; } } else { data.BuyNum += temp.BuyNum; if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data)) { temp.BuyNum = data.BuyNum; flag = true; } } } else if (KFBoCaiDbManager.InserBuyBocai(this.OpenData.DataPeriods, data)) { itemList = new List <KFBuyBocaiData>(); itemList.Add(data); this.RoleBuyDict.Add(data.GetKey(), itemList); flag = true; } if (flag) { this.OpenData.AllBalance += (long)((double)(data.BuyNum * this.OpenData.XiaoHaoDaiBi) * (1.0 - this.Config.XiTongChouCheng)); } result = flag; } return(result); }
public static bool BuyBoCai(KFBuyBocaiData data) { try { if (1 == data.BocaiType) { return(KFBoCaiCaiDaXiao.GetInstance().BuyBoCai(data)); } if (2 == data.BocaiType) { return(KFBoCaiCaiShuzi.GetInstance().BuyBoCai(data)); } } catch (Exception ex) { LogManager.WriteException(ex.Message); } return(false); }
public static bool UpdateBuyBocai(long DataPeriods, KFBuyBocaiData buyDaya) { try { string sql = string.Format("UPDATE t_bocai_buy_history SET BuyNum='{0}' WHERE rid='{1}' AND BocaiType='{2}' AND DataPeriods='{3}' AND ServerID='{4}' AND BuyValue='{5}'", new object[] { buyDaya.BuyNum, buyDaya.RoleID, buyDaya.BocaiType, DataPeriods, buyDaya.ServerID, buyDaya.BuyValue }); return(DbHelperMySQL.ExecuteSql(sql) > -1); } catch (Exception ex) { LogManager.WriteException(ex.Message); } return(false); }
public static bool InserBuyBocai(long DataPeriods, KFBuyBocaiData buyDaya) { try { string sql = string.Format("REPLACE INTO t_bocai_buy_history(`rid`, `BocaiType`, `DataPeriods`, `ServerID`, `RoleName`, `ZoneID`, `BuyNum`, `BuyValue`) VALUES({0},{1},{2},{3},'{4}',{5},{6},'{7}');", new object[] { buyDaya.RoleID, buyDaya.BocaiType, DataPeriods, buyDaya.ServerID, buyDaya.RoleName, buyDaya.ZoneID, buyDaya.BuyNum, buyDaya.BuyValue }); return(DbHelperMySQL.ExecuteSql(sql) > -1); } catch (Exception ex) { LogManager.WriteException(ex.Message); } return(false); }
public static bool LoadBuyHistory(int BocaiType, long DataPeriods, out List <KFBuyBocaiData> HistoryList) { bool flag = false; MySqlDataReader sdr = null; HistoryList = new List <KFBuyBocaiData>(); try { string sql = string.Format("SELECT `rid`, `BocaiType`,`ServerID`,`RoleName`,`ZoneID`,`BuyNum`,`BuyValue`FROM t_bocai_buy_history WHERE `DataPeriods`={0};", DataPeriods); sdr = DbHelperMySQL.ExecuteReader(sql, false); while (sdr != null && sdr.Read()) { KFBuyBocaiData data = new KFBuyBocaiData(); data.RoleID = Convert.ToInt32(sdr["rid"]); data.ZoneID = Convert.ToInt32(sdr["ZoneID"]); data.ServerID = Convert.ToInt32(sdr["ServerID"]); data.RoleName = sdr["RoleName"].ToString(); data.BuyNum = Convert.ToInt32(sdr["BuyNum"]); data.BocaiType = Convert.ToInt32(sdr["BocaiType"]); data.BuyValue = sdr["BuyValue"].ToString(); HistoryList.Add(data); } flag = true; } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.Message); } finally { if (sdr != null) { sdr.Close(); } } return(flag); }
private void StartServerSamePeriods(DateTime time) { try { OpenLottery data; KFBoCaiDbManager.SelectOpenLottery(this.MaxPeriods, (int)this.BoCaiType, out data); List <KFBuyBocaiData> HistoryList; if (null == data) { KFBoCaiDbManager.StopServer(string.Format("[ljl_CaiShuZi_猜数字] 开奖记录读取失败 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType)); } else if (!string.IsNullOrEmpty(data.strWinNum)) { if (data.XiaoHaoDaiBi < 1) { data.XiaoHaoDaiBi = this.OpenData.XiaoHaoDaiBi; } this.OpenData = data; this.SetUpToDBOpenData(); this.PeriodsStartTime = DateTime.Parse(TimeUtil.DataTimeToString(time, "yyyy-MM-dd HH:mm:ss")); this.Stage = BoCaiStageEnum.Stage_End; base.KFSendStageData(); base.KFSendPeriodsData(); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 并且已经开奖 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true); } else if (!KFBoCaiDbManager.LoadBuyHistory((int)this.BoCaiType, this.MaxPeriods, out HistoryList)) { KFBoCaiDbManager.StopServer(string.Format("[ljl_CaiShuZi_猜数字]读取购买记录失败 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType)); } else { this.RoleBuyDict = new Dictionary <string, List <KFBuyBocaiData> >(); using (List <KFBuyBocaiData> .Enumerator enumerator = HistoryList.GetEnumerator()) { while (enumerator.MoveNext()) { KFBuyBocaiData item = enumerator.Current; List <KFBuyBocaiData> itemList; if (this.RoleBuyDict.TryGetValue(item.GetKey(), out itemList)) { KFBuyBocaiData temp = itemList.Find((KFBuyBocaiData x) => x.BuyValue.Equals(item.BuyValue)); if (temp == null) { itemList.Add(item); } else { temp.BuyNum += item.BuyNum; } } else { itemList = new List <KFBuyBocaiData>(); itemList.Add(item); this.RoleBuyDict.Add(item.GetKey(), itemList); } } } if (data.XiaoHaoDaiBi < 1) { data.XiaoHaoDaiBi = this.OpenData.XiaoHaoDaiBi; } this.OpenData = data; this.PeriodsStartTime = DateTime.Parse(TimeUtil.DataTimeToString(time, "yyyy-MM-dd HH:mm:ss")); this.SetUpToDBOpenData(); if (DateTime.Parse(this.Config.KaiJiangShiJian) >= time) { this.Stage = BoCaiStageEnum.Stage_Buy; LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 并且没开奖 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true); } else if ((DateTime.Parse("23:59:59") - time).TotalMinutes < 2.0) { this.Stage = BoCaiStageEnum.Stage_Open; this.SetUpToDBOpenData(); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 状态设置开奖 &&强制开奖 不足2分钟 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true); this.Thread(); } else { this.Stage = BoCaiStageEnum.Stage_Open; LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_CaiShuZi_猜数字] 和上期是一期 状态设置开奖 BoCaiType={1},DataPeriods={0}", this.MaxPeriods, this.BoCaiType), null, true); } base.KFSendStageData(); base.KFSendPeriodsData(); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_CaiShuZi_猜数字]{0}", ex.ToString()), null, true); } }
public static bool _M6(KFBuyBocaiData data) { return(KFBoCaiManager.BuyBoCai(data)); }