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); }