public static XElement CreateAuctionInfo(AuctionInfo info) { return new XElement("Item", new XAttribute("AuctionID", info.AuctionID), new XAttribute("AuctioneerID", info.AuctioneerID), new XAttribute("AuctioneerName", info.AuctioneerName == null ? "" : info.AuctioneerName), new XAttribute("BeginDate", info.BeginDate.ToString("yyyy-MM-dd HH:mm:ss")), new XAttribute("BuyerID", info.BuyerID), new XAttribute("BuyerName", info.BuyerName == null ? "" : info.BuyerName), new XAttribute("ItemID", info.ItemID), new XAttribute("Mouthful", info.Mouthful), new XAttribute("PayType", info.PayType), new XAttribute("Price", info.Price), new XAttribute("Rise", info.Rise), new XAttribute("ValidDate", info.ValidDate)); }
public GSPacketIn SendAuctionRefresh(AuctionInfo info, int auctionID, bool isExist, ItemInfo item) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.AUCTION_REFRESH); pkg.WriteInt(auctionID); pkg.WriteBoolean(isExist); if (isExist) { pkg.WriteInt(info.AuctioneerID); pkg.WriteString(info.AuctioneerName); pkg.WriteDateTime(info.BeginDate); pkg.WriteInt(info.BuyerID); pkg.WriteString(info.BuyerName); pkg.WriteInt(info.ItemID); pkg.WriteInt(info.Mouthful); pkg.WriteInt(info.PayType); pkg.WriteInt(info.Price); pkg.WriteInt(info.Rise); pkg.WriteInt(info.ValidDate); pkg.WriteBoolean(item != null); if (item != null) { pkg.WriteInt(item.Count); pkg.WriteInt(item.TemplateID); pkg.WriteInt(item.AttackCompose); pkg.WriteInt(item.DefendCompose); pkg.WriteInt(item.AgilityCompose); pkg.WriteInt(item.LuckCompose); pkg.WriteInt(item.StrengthenLevel); pkg.WriteBoolean(item.IsBinds); pkg.WriteBoolean(item.IsJudge); pkg.WriteDateTime(item.BeginDate); pkg.WriteInt(item.ValidDate); pkg.WriteString(item.Color); pkg.WriteString(item.Skin); pkg.WriteBoolean(item.IsUsed); } } pkg.Compress(); SendTCP(pkg); return pkg; }
public bool UpdateAuction(AuctionInfo info) { bool flag = false; try { SqlParameter[] SqlParameters = new SqlParameter[16] { new SqlParameter("@AuctionID", (object) info.AuctionID), new SqlParameter("@AuctioneerID", (object) info.AuctioneerID), new SqlParameter("@AuctioneerName", info.AuctioneerName == null ? (object) "" : (object) info.AuctioneerName), new SqlParameter("@BeginDate", (object) info.BeginDate), new SqlParameter("@BuyerID", (object) info.BuyerID), new SqlParameter("@BuyerName", info.BuyerName == null ? (object) "" : (object) info.BuyerName), new SqlParameter("@IsExist", (object) (int) (info.IsExist ? 1 : 0)), new SqlParameter("@ItemID", (object) info.ItemID), new SqlParameter("@Mouthful", (object) info.Mouthful), new SqlParameter("@PayType", (object) info.PayType), new SqlParameter("@Price", (object) info.Price), new SqlParameter("@Rise", (object) info.Rise), new SqlParameter("@ValidDate", (object) info.ValidDate), new SqlParameter("Name", (object) info.Name), new SqlParameter("Category", (object) info.Category), new SqlParameter("@Result", SqlDbType.Int) }; SqlParameters[15].Direction = ParameterDirection.ReturnValue; this.db.RunProcedure("SP_Auction_Update", SqlParameters); flag = (int)SqlParameters[15].Value == 0; } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"Init", ex); } return flag; }
public bool AddAuction(AuctionInfo info) { bool flag = false; try { SqlParameter[] SqlParameters = new SqlParameter[18]; SqlParameters[0] = new SqlParameter("@AuctionID", (object)info.AuctionID); SqlParameters[0].Direction = ParameterDirection.Output; SqlParameters[1] = new SqlParameter("@AuctioneerID", (object)info.AuctioneerID); SqlParameters[2] = new SqlParameter("@AuctioneerName", info.AuctioneerName == null ? (object)"" : (object)info.AuctioneerName); SqlParameters[3] = new SqlParameter("@BeginDate", (object)info.BeginDate); SqlParameters[4] = new SqlParameter("@BuyerID", (object)info.BuyerID); SqlParameters[5] = new SqlParameter("@BuyerName", info.BuyerName == null ? (object)"" : (object)info.BuyerName); SqlParameters[6] = new SqlParameter("@IsExist", (object)(int)(info.IsExist ? 1 : 0)); SqlParameters[7] = new SqlParameter("@ItemID", (object)info.ItemID); SqlParameters[8] = new SqlParameter("@Mouthful", (object)info.Mouthful); SqlParameters[9] = new SqlParameter("@PayType", (object)info.PayType); SqlParameters[10] = new SqlParameter("@Price", (object)info.Price); SqlParameters[11] = new SqlParameter("@Rise", (object)info.Rise); SqlParameters[12] = new SqlParameter("@ValidDate", (object)info.ValidDate); SqlParameters[13] = new SqlParameter("@TemplateID", (object)info.TemplateID); SqlParameters[14] = new SqlParameter("Name", (object)info.Name); SqlParameters[15] = new SqlParameter("Category", (object)info.Category); SqlParameters[16] = new SqlParameter("Random", (object)info.Random); SqlParameters[17] = new SqlParameter("goodsCount", (object)info.goodsCount); flag = this.db.RunProcedure("SP_Auction_Add", SqlParameters); info.AuctionID = (int)SqlParameters[0].Value; } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"Init", ex); } return flag; }
public GSPacketIn SendAuctionRefresh(SqlDataProvider.Data.AuctionInfo info, int auctionID, bool isExist, SqlDataProvider.Data.ItemInfo item) { throw new NotImplementedException(); }
public AuctionInfo InitAuctionInfo(SqlDataReader reader) { AuctionInfo info = new AuctionInfo(); info.AuctioneerID = (int)reader["AuctioneerID"]; info.AuctioneerName = reader["AuctioneerName"] == null ? "" : reader["AuctioneerName"].ToString(); info.AuctionID = (int)reader["AuctionID"]; info.BeginDate = (DateTime)reader["BeginDate"]; info.BuyerID = (int)reader["BuyerID"]; info.BuyerName = reader["BuyerName"] == null ? "" : reader["BuyerName"].ToString(); info.IsExist = (bool)reader["IsExist"]; info.ItemID = (int)reader["ItemID"]; info.Mouthful = (int)reader["Mouthful"]; info.PayType = (int)reader["PayType"]; info.Price = (int)reader["Price"]; info.Rise = (int)reader["Rise"]; info.ValidDate = (int)reader["ValidDate"]; info.Name = reader["Name"].ToString(); info.Category = (int)reader["Category"]; return info; }
//拼抽 public AuctionInfo[] GetAuctionPage(int page, string name, int type, int pay, ref int total, int userID, int buyID, int order, bool sort, int size, string AuctionIDs) { List<AuctionInfo> infos = new List<AuctionInfo>(); //SqlDataReader reader = null; try { //int View_flag = 1;//标识别:1代表type在1-24的视图,0代表type在其余的视图. string sWhere = " IsExist=1 "; if (!string.IsNullOrEmpty(name)) { sWhere += " and Name like '%" + name + "%' "; } if (type != -1) { //sWhere += " and Category =" + type + " "; // -美容 // 翅膀 // 眼睛 // 脸饰 // 头发 //-装备 // 套装 // 衣服 // 帽子 // 眼镜 //-饰品 // 项链 // 戒指 // 手镯 //-道具 // 特殊 // 战斗道具 // 宝石及公式 switch (type) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: sWhere += " and Category =" + type + " "; break; case 21: sWhere += " and Category in(1,2,5,8,9) "; //服装 break; case 22: sWhere += " and Category in(13,15,6,4,3) "; //美容 break; case 23: sWhere += " and Category in(16,11,10) "; //道具 break; case 24: sWhere += " and Category in(8,9) "; //首饰 break; case 25: sWhere += " and Category in (7,17) "; //武器、副武器 break; case 26: sWhere += " and TemplateId>=311000 and TemplateId<=313999"; //所有宝珠 break; case 27: sWhere += " and TemplateId>=311000 and TemplateId<=311999 ";//三角宝珠 break; case 28: sWhere += " and TemplateId>=312000 and TemplateId<=312999 ";//方形宝珠 break; case 29: sWhere += " and TemplateId>=313000 and TempLateId<=313999"; //圆形宝珠 break; case 1100: //View_flag = 0; sWhere += " and TemplateID in (11019,11021,11022,11023) "; //所有强化石 break; case 1101: //View_flag = 0; sWhere += " and TemplateID='11019' "; //强化石1 break; case 1102: //View_flag = 0; sWhere += " and TemplateID='11021' "; //强化石2 break; case 1103: //View_flag = 0; sWhere += " and TemplateID='11022' "; //强化石3 break; case 1104: //View_flag = 0; sWhere += " and TemplateID='11023' "; //强化石4 break; case 1105: //View_flag = 0; sWhere += " and TemplateID in (11001,11002,11003,11004,11005,11006,11007,11008,11009,11010,11011,11012,11013,11014,11015,11016) "; //所有合成石 break; case 1106: //View_flag = 0; sWhere += " and TemplateID in (11001,11002,11003,11004) "; //朱雀石 break; case 1107: //View_flag = 0; sWhere += " and TemplateID in (11005,11006,11007,11008) "; //玄武石 break; case 1108: //View_flag = 0; sWhere += " and TemplateID in (11009,11010,11011,11012) "; //青龙石 break; case 1109: //View_flag = 0; sWhere += " and TemplateID in (11013,11014,11015,11016) "; //白虎石 break; } } if (pay != -1) { sWhere += " and PayType =" + pay + " "; } if (userID != -1) { sWhere += " and AuctioneerID =" + userID + " "; } if (buyID != -1) { //sWhere += " and BuyerID =" + buyID + " "; //if (string.IsNullOrEmpty(AuctionIDs)) //{ // AuctionIDs = null; //} sWhere += " and (BuyerID =" + buyID + " or AuctionID in (" + AuctionIDs + ")) "; } //默认排序按照排序的优先级进行:物品类型>物品名称>当前价格(以一口价为准)>剩余时间>出售人 string sOrder = "Category,Name,Price,dd,AuctioneerID"; switch (order) { case 0: sOrder = "Name"; break; case 1: //sOrder = "Repute1"; break; case 2: //sOrder = "Count1"; sOrder = "dd"; break; case 3: sOrder = "AuctioneerName"; break; case 4: sOrder = "Price"; break; case 5: sOrder = "BuyerName"; break; } sOrder += sort ? " desc" : ""; sOrder += ",AuctionID "; SqlParameter[] para = new SqlParameter[8]; para[0] = new SqlParameter("@QueryStr", "V_Auction_Scan");//表名,视图名,查询语句 para[1] = new SqlParameter("@QueryWhere", sWhere);//查询条件 para[2] = new SqlParameter("@PageSize", size);//每页的行数 para[3] = new SqlParameter("@PageCurrent", page);//要显示页面 para[4] = new SqlParameter("@FdShow", "*");//要显示的字段列表,必须排除表识字段 para[5] = new SqlParameter("@FdOrder", sOrder);//排序字段列表 para[6] = new SqlParameter("@FdKey", "AuctionID");//强制指定主键 para[7] = new SqlParameter("@TotalRow", total);//总记录行数 para[7].Direction = ParameterDirection.Output; DataTable dt = db.GetDataTable("Auction", "SP_CustomPage", para); total = (int)para[7].Value; foreach (DataRow dr in dt.Rows) { AuctionInfo info = new AuctionInfo(); info.AuctioneerID = (int)dr["AuctioneerID"]; info.AuctioneerName = dr["AuctioneerName"].ToString(); info.AuctionID = (int)dr["AuctionID"]; info.BeginDate = (DateTime)dr["BeginDate"]; info.BuyerID = (int)dr["BuyerID"]; info.BuyerName = dr["BuyerName"].ToString(); info.Category = (int)dr["Category"]; info.IsExist = (bool)dr["IsExist"]; info.ItemID = (int)dr["ItemID"]; info.Name = dr["Name"].ToString(); info.Mouthful = (int)dr["Mouthful"]; info.PayType = (int)dr["PayType"]; info.Price = (int)dr["Price"]; info.Rise = (int)dr["Rise"]; info.ValidDate = (int)dr["ValidDate"]; infos.Add(info); } //db.GetReader(ref reader, "SP_CustomPage", para); //total = (int)para[7].Value; //while (reader.Read()) //{ // infos.Add(InitAuctionInfo(reader)); //} } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { //if (reader != null && !reader.IsClosed) // reader.Close(); } return infos.ToArray(); }
public bool UpdateAuction(AuctionInfo info) { bool result = false; try { SqlParameter[] para = new SqlParameter[16]; para[0] = new SqlParameter("@AuctionID", info.AuctionID); para[1] = new SqlParameter("@AuctioneerID", info.AuctioneerID); para[2] = new SqlParameter("@AuctioneerName", info.AuctioneerName == null ? "" : info.AuctioneerName); para[3] = new SqlParameter("@BeginDate", info.BeginDate); para[4] = new SqlParameter("@BuyerID", info.BuyerID); para[5] = new SqlParameter("@BuyerName", info.BuyerName == null ? "" : info.BuyerName); para[6] = new SqlParameter("@IsExist", info.IsExist); para[7] = new SqlParameter("@ItemID", info.ItemID); para[8] = new SqlParameter("@Mouthful", info.Mouthful); para[9] = new SqlParameter("@PayType", info.PayType); para[10] = new SqlParameter("@Price", info.Price); para[11] = new SqlParameter("@Rise", info.Rise); para[12] = new SqlParameter("@ValidDate", info.ValidDate); para[13] = new SqlParameter("Name", info.Name); para[14] = new SqlParameter("Category", info.Category); para[15] = new SqlParameter("@Result", System.Data.SqlDbType.Int); para[15].Direction = ParameterDirection.ReturnValue; db.RunProcedure("SP_Auction_Update", para); int returnValue = (int)para[15].Value; result = returnValue == 0; } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return result; }
public bool AddAuction(AuctionInfo info) { bool result = false; try { SqlParameter[] para = new SqlParameter[17]; para[0] = new SqlParameter("@AuctionID", info.AuctionID); para[0].Direction = ParameterDirection.Output; para[1] = new SqlParameter("@AuctioneerID", info.AuctioneerID); para[2] = new SqlParameter("@AuctioneerName", info.AuctioneerName == null ? "" : info.AuctioneerName); para[3] = new SqlParameter("@BeginDate", info.BeginDate); para[4] = new SqlParameter("@BuyerID", info.BuyerID); para[5] = new SqlParameter("@BuyerName", info.BuyerName == null ? "" : info.BuyerName); para[6] = new SqlParameter("@IsExist", info.IsExist); para[7] = new SqlParameter("@ItemID", info.ItemID); para[8] = new SqlParameter("@Mouthful", info.Mouthful); para[9] = new SqlParameter("@PayType", info.PayType); para[10] = new SqlParameter("@Price", info.Price); para[11] = new SqlParameter("@Rise", info.Rise); para[12] = new SqlParameter("@ValidDate", info.ValidDate); para[13] = new SqlParameter("@TemplateID", info.TemplateID); para[14] = new SqlParameter("Name", info.Name); para[15] = new SqlParameter("Category", info.Category); para[16] = new SqlParameter("Random", info.Random); result = db.RunProcedure("SP_Auction_Add", para); info.AuctionID = (int)para[0].Value; } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return result; }
public int HandlePacket(GameClient client, GSPacketIn packet) { eBageType bagType = (eBageType)packet.ReadByte(); int place = packet.ReadInt(); int payType = packet.ReadByte(); int price = packet.ReadInt(); int mouthful = packet.ReadInt(); int validDate = packet.ReadInt(); string msg = "AuctionAddHandler.Fail"; payType = 1; if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked) { client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked")); return 0; } if (price < 0 || (mouthful != 0 && mouthful < price)) return 0; int multiple = 1; if (payType != 0) { //multiple = 10; multiple = 1; payType = 1; } int needGold = (int)(multiple * price * 0.03 * (validDate == 0 ? 1 : validDate == 1 ? 3 : 6)); needGold = needGold < 1 ? 1 : needGold; ItemInfo goods = client.Player.GetItemAt(bagType, place); if (price < 0) { msg = "AuctionAddHandler.Msg1"; } else if (mouthful != 0 && mouthful < price) { msg = "AuctionAddHandler.Msg2"; } else if (needGold > client.Player.PlayerCharacter.Gold) { msg = "AuctionAddHandler.Msg3"; } else if (goods == null) { msg = "AuctionAddHandler.Msg4"; } else if (goods.IsBinds) { msg = "AuctionAddHandler.Msg5"; } else { client.Player.SaveIntoDatabase(); AuctionInfo info = new AuctionInfo(); info.AuctioneerID = client.Player.PlayerCharacter.ID;//获取物品ID info.AuctioneerName = client.Player.PlayerCharacter.NickName;//获取物品妮称 info.BeginDate = DateTime.Now; info.BuyerID = 0; info.BuyerName = ""; info.IsExist = true; info.ItemID = goods.ItemID; info.Mouthful = mouthful; info.PayType = payType; info.Price = price; info.Rise = price / 10; info.Rise = info.Rise < 1 ? 1 : info.Rise; info.Name = goods.Template.Name; info.Category = goods.Template.CategoryID; info.ValidDate = validDate == 0 ? 8 : validDate == 1 ? 24 : 48; info.TemplateID = goods.TemplateID; info.Random = Bussiness.ThreadSafeRandom.NextStatic(GameProperties.BeginAuction, GameProperties.EndAuction); using (PlayerBussiness db = new PlayerBussiness())//写数据库 { if (db.AddAuction(info)) { //client.Player.RemoveAllItem(goods, true, Game.Server.Statics.ItemRemoveType.Auction, bagType); //client.Player.up //client.Player.SaveIntoDatabase(); //client.Player.SetGold(-needGold, Game.Server.Statics.GoldRemoveType.Auction); //msg = "AuctionAddHandler.Msg6"; //client.Out.SendAuctionRefresh(info, info.AuctionID, true, goods); client.Player.RemoveItem(goods); goods.IsExist = true; client.Player.SaveIntoDatabase(); client.Player.RemoveGold(needGold); msg = "AuctionAddHandler.Msg6"; client.Out.SendAuctionRefresh(info, info.AuctionID, true, goods); } } } //client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver); client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg)); return 0; }