public bool CanBuyItem(KFBoCaiShopDB Item, int maxNum) { try { KFBoCaiShopDB temp = null; lock (this.mutex) { temp = this.DBShopList.Find((KFBoCaiShopDB x) => x.ID == Item.ID && x.WuPinID.Equals(Item.WuPinID) && x.RoleID == Item.RoleID); if (null == temp) { temp = Item; this.DBShopList.Add(Item); } else { if (temp.BuyNum + Item.BuyNum > maxNum) { return(false); } temp.BuyNum += Item.BuyNum; } } this.InsertBocaiShop(temp); return(true); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩商店]{0}", ex.ToString()), null, true); } return(false); }
private bool AddItem(KFBoCaiShopDB Item) { try { lock (this.mutex) { KFBoCaiShopDB data = this.cacheList.Find((KFBoCaiShopDB x) => x.ID == Item.ID && Item.WuPinID == x.WuPinID); if (null == data) { data = Item; this.cacheList.Add(Item); } else { data.BuyNum += Item.BuyNum; } KFBoCaiDbManager.ReplaceBoCaiShop(data); } return(true); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩商店]{0}", ex.ToString()), null, true); } return(false); }
public static ReturnValue <bool> BoCaiBuyItem(KFBoCaiShopDB Item, int maxNum) { AutoWaitReturnValue <KfCall._p10> _wait_ = AutoWaitReturnValue <KfCall._p10> .Pop(); try { AutoCSer.Net.TcpInternalServer.ClientSocketSender _socket_ = KfCall.TcpClient.Sender; if (_socket_ != null) { KfCall._p9 _inputParameter_ = new KfCall._p9 { p0 = Item, p1 = maxNum }; KfCall._p10 _outputParameter_ = default(KfCall._p10); ReturnType _returnType_ = _socket_.WaitGet <KfCall._p9, KfCall._p10>(TcpCall.KFBoCaiManager._c5, 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 static void SelectBoCaiShop(string Periods, out List <KFBoCaiShopDB> dList) { dList = null; MySqlDataReader sdr = null; try { string sql = string.Format("SELECT `ID`,`BuyNum`,`WuPinID` FROM t_bocai_shop WHERE `Periods`={0}", Periods); sdr = DbHelperMySQL.ExecuteReader(sql, false); dList = new List <KFBoCaiShopDB>(); while (sdr != null && sdr.Read()) { KFBoCaiShopDB data = new KFBoCaiShopDB(); data.ID = Convert.ToInt32(sdr["ID"]); data.BuyNum = Convert.ToInt32(sdr["BuyNum"]); data.WuPinID = sdr["WuPinID"].ToString(); data.Periods = Convert.ToInt32(Periods); dList.Add(data); } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.Message); } finally { if (sdr != null) { sdr.Close(); } } }
public static bool BoCaiBuyItem(KFBoCaiShopDB Item, int maxNum) { try { return(KFBoCaiShopManager.GetInstance().BuyItem(Item, maxNum)); } catch (Exception ex) { LogManager.WriteException(ex.Message); } return(false); }
public void InsertBocaiShop(KFBoCaiShopDB data) { try { if (!Global.Send2DB <KFBoCaiShopDB>(2086, data, 0).Equals(true.ToString())) { LogManager.WriteLog(LogTypes.Warning, "[ljl_博彩商店] InsertBocaiShop fail", null, true); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩商店]{0}", ex.ToString()), null, true); } }
public static bool ReplaceBoCaiShop(KFBoCaiShopDB data) { try { string sql = string.Format("REPLACE INTO t_bocai_shop(ID, BuyNum, Periods, WuPinID) VALUES({0},{1},{2},'{3}');", new object[] { data.ID, data.BuyNum, data.Periods, data.WuPinID }); return(DbHelperMySQL.ExecuteSql(sql) > -1); } catch (Exception ex) { LogManager.WriteException(ex.Message); } return(false); }
public bool BuyItem(KFBoCaiShopDB Item, int maxNum) { try { lock (this.mutex) { KFBoCaiShopDB data = this.cacheList.Find((KFBoCaiShopDB x) => x.ID == Item.ID && Item.WuPinID == x.WuPinID); if (null == data) { return(this.AddItem(Item)); } if (data.BuyNum + Item.BuyNum <= maxNum) { return(this.AddItem(Item)); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩商店]{0}", ex.ToString()), null, true); } return(false); }
private string BuyItem(GameClient client, int nID, string[] cmdParams) { string msgInfo = ""; try { if (GameManager.systemParamsList.GetParamValueIntByName("HuanLeDuiHuan", -1) < 1L) { return(string.Format("{0}{1}", msgInfo, 7)); } int ID = Convert.ToInt32(cmdParams[1]); int BuyNum = Convert.ToInt32(cmdParams[2]); string WuPinID = cmdParams[3]; msgInfo = string.Format("{0}:{1}:{2}:", cmdParams[1], cmdParams[2], cmdParams[3]); DuiHuanShangChengConfig cfg = BoCaiConfigMgr.GetBoCaiShopConfig(ID, WuPinID); if (null == cfg) { return(string.Format("{0}{1}", msgInfo, 14)); } int useItemNum = cfg.DaiBiJiaGe * BuyNum; GoodsData Goods = GlobalNew.ParseGoodsData(WuPinID); if (null == Goods) { return(string.Format("{0}{1}", msgInfo, 14)); } if (!HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, useItemNum)) { return(string.Format("{0}{1}", msgInfo, 4)); } if (!Global.CanAddGoods3(client, Goods.GoodsID, BuyNum, Goods.Binding, "1900-01-01 12:00:00", true)) { return(string.Format("{0}{1}", msgInfo, 13)); } KFBoCaiShopDB item = new KFBoCaiShopDB(); item.BuyNum = BuyNum; item.ID = ID; item.WuPinID = WuPinID; item.RoleID = client.ClientData.RoleID; item.Periods = Convert.ToInt32(TimeUtil.NowDataTimeString("yyMMdd")); if (cfg.MeiRiShangXianDan > -1) { if (BuyNum > cfg.MeiRiShangXianDan) { return(string.Format("{0}{1}", msgInfo, 17)); } if (!BoCaiShopManager.GetInstance().CanBuyItem(item, cfg.MeiRiShangXianDan)) { return(string.Format("{0}{1}", msgInfo, 18)); } } if (!HuanLeDaiBiManager.GetInstance().UseHuanledaibi(client, useItemNum)) { return(string.Format("{0}{1}", msgInfo, 4)); } int ret = Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, Goods.GoodsID, BuyNum, Goods.Quality, Goods.Props, Goods.Forge_level, Goods.Binding, Goods.Site, Goods.Jewellist, true, 1, "博彩商店购买", "1900-01-01 12:00:00", 0, 0, 0, 0, 0, 0, 0, null, null, 0, true); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl_博彩] 博彩商店购买 放在背包ret={1},RoleID={0},WuPinID={2},name={3}", new object[] { client.ClientData.RoleID, ret, WuPinID, client.ClientData.RoleName }), null, true); return(string.Format("{0}{1}", msgInfo, 0)); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl_博彩]{0}", ex.ToString()), null, true); } return(string.Format("{0}{1}", msgInfo, 100)); }
public static bool _M5(KFBoCaiShopDB Item, int maxNum) { return(KFBoCaiManager.BoCaiBuyItem(Item, maxNum)); }