public bool UpdatePrice(GoldAuctionItem _item) { bool flag = false; try { lock (this.AuctionMutex) { GoldAuctionItem item = this.getGoldAuctionItem(_item.ProductionTime, _item.AuctionSource); if (item == null || item.AuctionType != _item.AuctionType) { return(flag); } CopyData.Copy <AuctionRoleData>(_item.BuyerData, ref item.BuyerData); item.Lock = false; item.UpDBWay = 3; item.OldAuctionType = item.AuctionType; flag = this.SendUpdate2DB(item); if (flag) { this.S2CCache.Clear(); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(flag); }
public bool SendUpdate2DB(GoldAuctionItem AuctionItem) { try { lock (this.AuctionMutex) { if (AuctionItem == null) { return(false); } GoldAuctionDBItem dbinfo; CopyData.CopyAuctionItem2DB(AuctionItem, out dbinfo); string msg = Global.Send2DB <GoldAuctionDBItem>(2081, dbinfo, 0); if ("True".Equals(msg)) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]AuctionItem SendUpdate2DB true up type = {0},ProductionTime={1}, AuctionSource={2}", (DBAuctionUpEnum)dbinfo.UpDBWay, dbinfo.ProductionTime, dbinfo.AuctionSource), null, true); return(true); } LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]AuctionItem SendUpdate2DB false up type = {0},ProductionTime={1}, AuctionSource={2}", (DBAuctionUpEnum)dbinfo.UpDBWay, dbinfo.ProductionTime, dbinfo.AuctionSource), null, true); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(false); }
public static void CopyAuctionDB2Item(GoldAuctionDBItem sData, out GoldAuctionItem rData) { try { rData = new GoldAuctionItem(); rData.ProductionTime = sData.ProductionTime; rData.AuctionTime = sData.AuctionTime; rData.AuctionSource = sData.AuctionSource; rData.StrGoods = sData.StrGoods; rData.BuyerData = new AuctionRoleData(); CopyData.Copy <AuctionRoleData>(sData.BuyerData, ref rData.BuyerData); foreach (AuctionRoleData item in sData.RoleList) { AuctionRoleData temp = new AuctionRoleData(); CopyData.Copy <AuctionRoleData>(item, ref temp); rData.RoleList.Add(temp); } rData.BossLife = sData.BossLife; rData.KillBossRoleID = sData.KillBossRoleID; rData.UpDBWay = sData.UpDBWay; rData.AuctionType = sData.AuctionType; rData.OldAuctionType = sData.OldAuctionType; rData.Lock = false; } catch (Exception ex) { rData = null; LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
private GoldAuctionItem getGoldAuctionItem(string ProductionTime, int AuctionSource) { GoldAuctionItem item = null; try { item = this.AuctionItemList.Find((GoldAuctionItem x) => x.ProductionTime == ProductionTime && x.AuctionSource == AuctionSource); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(item); }
private void SendMoney(GoldAuctionItem AuctionItem, long averageNum, AuctionConfig AuctionCfg) { try { Dictionary <AuctionRoleData, long> sendMsg = new Dictionary <AuctionRoleData, long>(); if (averageNum >= 1L) { foreach (AuctionRoleData temp in AuctionItem.RoleList) { long num = averageNum; if (AuctionItem.BuyerData.Value > 0L && AuctionItem.BossLife > 0L && temp.Value <= AuctionItem.BossLife) { num += (long)((double)temp.Value / (double)AuctionItem.BossLife * (double)AuctionItem.BuyerData.Value); } sendMsg.Add(temp, num); } foreach (KeyValuePair <AuctionRoleData, long> temp2 in sendMsg) { AuctionRoleData roleData = temp2.Key; int sendNum = (int)temp2.Value; try { if (sendNum > 0) { if (!Global.UseMailGivePlayerAward3(roleData.m_RoleID, null, AuctionCfg.SuccessTitle, string.Format(AuctionCfg.SuccessIntro, this.GetItemName(AuctionItem.StrGoods), sendNum), sendNum, 0, 0)) { GameManager.logDBCmdMgr.AddMessageLog(-1, "钻石", "邮件发放金团结算失败", roleData.m_RoleName, roleData.m_RoleName, "增加", sendNum, roleData.ZoneID, roleData.strUserID, -1, roleData.ServerId, ""); LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]邮件发放金团结算失败 send email roleid={0}, money={1}", roleData.m_RoleID, sendNum), null, true); } else { GameManager.logDBCmdMgr.AddDBLogInfo(-1, "钻石", "邮件发放金团结算", "系统", roleData.m_RoleName, "增加", sendNum, roleData.ZoneID, roleData.strUserID, -1, roleData.ServerId, null); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]发放奖励 send email roleid={0}, money={1}, {2}", roleData.m_RoleID, sendNum, ex.ToString()), null, true); } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
private bool SetOutTimeItem(GoldAuctionItem AuctionItem) { try { if (AuctionItem.Lock || DateTime.Parse(AuctionItem.AuctionTime).AddHours((double)AuctionItem.LifeTime) > TimeUtil.NowDateTime()) { return(true); } if (AuctionItem.BuyerData.m_RoleID != 0) { return(this.DisposeAward(AuctionItem)); } AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(AuctionItem.AuctionSource); if (null == AuctionCfg) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]null == config AuctionSource = {0}", AuctionItem.AuctionSource), null, true); return(false); } int NextAuctiontype = AuctionCfg.GetNextAuction(AuctionItem.AuctionType); if (NextAuctiontype <= -1) { return(this.DisposeAward(AuctionItem)); } AuctionItem.OldAuctionType = AuctionItem.AuctionType; AuctionItem.AuctionType = NextAuctiontype; AuctionItem.AuctionTime = TimeUtil.NowDataTimeString("yyyy-MM-dd HH:mm:ss"); AuctionItem.UpDBWay = 3; AuctionItem.LifeTime = AuctionCfg.GetTimeByAuction(NextAuctiontype); this.S2CCache.Clear(); if (this.SendUpdate2DB(AuctionItem)) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]超时换拍卖行ProductionTime = {0}, AuctionSource={1},AuctionType={2}", AuctionItem.ProductionTime, AuctionItem.AuctionSource, AuctionItem.AuctionType), null, true); return(true); } LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]超时换拍卖行 db失败 ProductionTime = {0}, AuctionSource={1}", AuctionItem.ProductionTime, AuctionItem.AuctionSource), null, true); if (AuctionItem.LifeTime == -1) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetTimeByAuction =-1 AuctionOrderEnum={0}", NextAuctiontype), null, true); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(false); }
public void DelGoldAuction(GoldAuctionItem Item, string info) { try { lock (this.AuctionMutex) { if (this.AuctionItemList.RemoveAll((GoldAuctionItem x) => x.ProductionTime == Item.ProductionTime && x.AuctionSource == Item.AuctionSource) > 0) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]{0} DelGoldAuction time={1}, AuctionSource={2}", info, Item.ProductionTime, (AuctionEnum)Item.AuctionSource), null, true); this.S2CCache.Clear(); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
public void UnLock(string ProductionTime, int AuctionSource) { try { lock (this.AuctionMutex) { GoldAuctionItem item = this.getGoldAuctionItem(ProductionTime, AuctionSource); if (null != item) { item.Lock = false; } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
private void InitFromDB() { try { for (int i = 1; i < 3; i++) { LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]InitFromDB AuctionID={0}", i), null, true); GetAuctionDBData DBData = Global.sendToDB <GetAuctionDBData, string>(2080, i.ToString(), 0); if (DBData == null || !DBData.Flag) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GoldAuctionManager.InitFromDB DBData={0}, type={1}", null == DBData, i), null, true); } else { foreach (GoldAuctionDBItem item in DBData.ItemList) { GoldAuctionItem temp = new GoldAuctionItem(); CopyData.CopyAuctionDB2Item(item, out temp); AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(item.AuctionSource); if (null == AuctionCfg) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetAuctionConfig null == config AuctionSource ={0}", ((AuctionEnum)item.AuctionSource).ToString()), null, true); } else { temp.LifeTime = AuctionCfg.GetTimeByAuction(i); if (temp.LifeTime == -1) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetTimeByAuction =-1 AuctionOrderEnum={0}", i), null, true); } else { this.AddNewAuctionItem(temp); } } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
public static void CopyGoldAuctionItem(GoldAuctionItem sData, ref GoldAuctionItem rData) { try { rData = new GoldAuctionItem(); CopyData.Copy <GoldAuctionItem>(sData, ref rData); rData.RoleList = new List <AuctionRoleData>(); foreach (AuctionRoleData item in sData.RoleList) { AuctionRoleData temp = new AuctionRoleData(); CopyData.Copy <AuctionRoleData>(item, ref temp); rData.RoleList.Add(temp); } } catch (Exception ex) { rData = null; LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
public static bool Copy2AuctionItemS2C(GoldAuctionItem sData, out AuctionItemS2C rData, string Seach, int Color) { rData = new AuctionItemS2C(); try { rData.Goods = GlobalNew.ParseGoodsData(sData.StrGoods); int goodsID = rData.Goods.GoodsID; if (!string.IsNullOrEmpty(Seach)) { List <int> goodsIDs = Global.StringToIntList(Seach, '#'); if (goodsIDs.Find((int x) => x == goodsID) < 1) { return(false); } } int color = Global.GetEquipColor(rData.Goods); if (Color > 0 && (1 << color - 1 & Color) == 0) { return(false); } rData.BuyRoleId = sData.BuyerData.m_RoleID; rData.Price = sData.BuyerData.Value; rData.AuctionItemKey = string.Format("{0}|{1}", sData.ProductionTime.Replace(':', ','), sData.AuctionSource); AuctionConfig cfg = GoldAuctionConfigModel.GetAuctionConfig(sData.AuctionSource); if (null != cfg) { rData.MaxPrice = (long)cfg.MaxPrice; rData.UnitPrice = (long)cfg.UnitPrice; } rData.LastTime = TimeUtil.GetDiffTimeSeconds(DateTime.Parse(sData.AuctionTime).AddHours((double)sData.LifeTime), TimeUtil.NowDateTime(), false); return(true); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(false); }
public GoldAuctionItem GetGoldAuctionItem(int type, string ProductionTime, int AuctionSource, bool isLock) { GoldAuctionItem temp = null; try { lock (this.AuctionMutex) { GoldAuctionItem item = this.getGoldAuctionItem(ProductionTime, AuctionSource); if (item == null || item.AuctionType != type) { return(null); } item.Lock = isLock; CopyData.CopyGoldAuctionItem(item, ref temp); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(temp); }
public void AddNewAuctionItem(GoldAuctionItem AuctionItem) { try { lock (this.AuctionMutex) { GoldAuctionItem item = this.getGoldAuctionItem(AuctionItem.ProductionTime, AuctionItem.AuctionSource); if (null != item) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]AddNewGoldAuction same time={0}, AuctionSource={1}", AuctionItem.ProductionTime, (AuctionEnum)AuctionItem.AuctionSource), null, true); } else { this.AuctionItemList.Add(AuctionItem); this.S2CCache.Clear(); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]AddNewGoldAuction su time={0}, AuctionSource={1}", AuctionItem.ProductionTime, (AuctionEnum)AuctionItem.AuctionSource), null, true); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
public bool DisposeAward(GoldAuctionItem Item) { try { lock (this.AuctionMutex) { if (null == Item) { return(false); } AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(Item.AuctionSource); if (null == AuctionCfg) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GoldAuctionConfigModel.GetAuctionConfig({0}) null == config", (AuctionEnum)Item.AuctionSource), null, true); return(false); } long averageNum = 0L; int minNum = (int)GameManager.systemParamsList.GetParamValueIntByName("AngelTempleAuctionMin", 0); if (minNum < 0) { LogManager.WriteLog(LogTypes.Error, "[ljl]AngelTempleAuctionMin < 0", null, true); minNum = 1; } long delNum = 0L; if (0 == Item.BuyerData.m_RoleID) { averageNum = 0L; delNum = Item.BuyerData.Value; } else if (Item.RoleList.Count < 1) { averageNum = 0L; } else if ((long)(minNum * Item.RoleList.Count) < Item.BuyerData.Value) { averageNum = (long)minNum; delNum = (long)Item.RoleList.Count * averageNum; } else if ((long)(minNum * Item.RoleList.Count) >= Item.BuyerData.Value) { averageNum = Item.BuyerData.Value / (long)Item.RoleList.Count; delNum = Item.BuyerData.Value; } Item.UpDBWay = 1; Item.OldAuctionType = Item.AuctionType; this.S2CCache.Clear(); if (!this.SendUpdate2DB(Item)) { Item.UpDBWay = 3; return(false); } Item.BuyerData.Value -= delNum; int AwardRole = Item.BuyerData.m_RoleID; if (AwardRole > 0) { this.SendMoney(Item, averageNum, AuctionCfg); this.SendItem(AwardRole, Item.BuyerData, Item, AuctionCfg); } else { AwardRole = Item.GetMaxmDamageID(); this.SendItem(AwardRole, Item.RoleList.Find((AuctionRoleData x) => x.m_RoleID == AwardRole), Item, AuctionCfg); } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); return(false); } return(true); }
public static bool Copy2AuctionItemS2C(AuctionItemS2C sData, out AuctionItemS2C rData, GoldAuctionItem AuctionItem) { rData = new AuctionItemS2C(); try { CopyData.Copy <AuctionItemS2C>(sData, ref rData); rData.Goods = new GoodsData(); if (null != AuctionItem) { rData.LastTime = TimeUtil.GetDiffTimeSeconds(DateTime.Parse(AuctionItem.AuctionTime).AddHours((double)AuctionItem.LifeTime), TimeUtil.NowDateTime(), false); } CopyData.Copy <GoodsData>(sData.Goods, ref rData.Goods); return(true); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(false); }
public void KillBossAddAuction(int KillBossRole, long BossLife, List <AuctionRoleData> PointInfoList, AuctionEnum AuctionSource) { try { lock (this.AuctionMsgMutex) { AuctionAwardConfig AuctionAwardCfg = GoldAuctionConfigModel.RandAuctionAwardConfig(); if (null == AuctionAwardCfg) { LogManager.WriteLog(LogTypes.Error, "[ljl]KillBossAddAuction RandAuctionAwardConfig null == config", null, true); } else { AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig((int)AuctionSource); if (null == AuctionCfg) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GoldAuctionConfigModel.GetAuctionConfig({0}) null == config", AuctionSource), null, true); } else { GoldAuctionItem item = new GoldAuctionItem(); item.AuctionSource = (int)AuctionSource; item.KillBossRoleID = KillBossRole; item.UpDBWay = 2; item.ProductionTime = TimeUtil.NowDataTimeString("yyyy-MM-dd HH:mm:ss.fff"); item.BuyerData = new AuctionRoleData(); item.BuyerData.m_RoleID = 0; item.BuyerData.Value = (long)AuctionCfg.OriginPrice; int index = Global.GetRandomNumber(AuctionAwardCfg.StartValues, AuctionAwardCfg.EndValues) - 1; index = Math.Min(index, AuctionAwardCfg.strGoodsList.Count - 1); item.StrGoods = AuctionAwardCfg.strGoodsList[index]; if (null == GlobalNew.ParseGoodsData(AuctionAwardCfg.strGoodsList[index])) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]null == item.Goods index={0} , GoodsList.Count = {1}", index, AuctionAwardCfg.strGoodsList.Count), null, true); } else { item.BossLife = 0L; foreach (AuctionRoleData PointInfo in PointInfoList) { item.BossLife += PointInfo.Value; if (PointInfo.Value >= GameManager.systemParamsList.GetParamValueIntByName("AngelTempleAuction", -1)) { AuctionRoleData RoleData = new AuctionRoleData(); CopyData.Copy <AuctionRoleData>(PointInfo, ref RoleData); item.RoleList.Add(RoleData); } } if (item.BossLife < 1L) { item.BossLife = BossLife; } bool addFlag = false; for (int i = 0; i < AuctionCfg.OrderList.Count; i++) { if (GoldAuctionManager.IsOpenAuction((AuctionOrderEnum)AuctionCfg.OrderList[i])) { item.AuctionType = AuctionCfg.OrderList[i]; item.LifeTime = AuctionCfg.TimeList[i]; if (item.AuctionType > 0 && item.AuctionType < 3) { if (this.GoldAuctionMgr.SendUpdate2DB(item)) { this.GoldAuctionMgr.AddNewAuctionItem(item); } else { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]新拍卖物品存库失败 未加入 time={0},AuctionSource={1}", item.ProductionTime, AuctionSource), null, true); } addFlag = true; break; } LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]AuctionType ={1} err,AuctionSource={0}", AuctionSource, item.AuctionType), null, true); } } if (!addFlag) { int roleID = item.GetMaxmDamageID(); this.GoldAuctionMgr.SendItem(roleID, item.RoleList.Find((AuctionRoleData x) => x.m_RoleID == roleID), item, AuctionCfg); LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]新拍卖物品未加入 直接邮件发送给玩家第一名 time={0},AuctionSource={1}", item.ProductionTime, AuctionSource), null, true); } } } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
private void SetGlodAuction(GameClient client, int nID, byte[] bytes, string[] cmdParams, ref int Info) { GoldAuctionItem item = null; Info = 0; try { int type = Convert.ToInt32(cmdParams[1]); string[] itemKey = cmdParams[2].Split(new char[] { '|' }); int Price = Convert.ToInt32(cmdParams[3]); if (itemKey == null || itemKey.Length != 2) { Info = 3; } else { string ProductionTime = itemKey[0].Replace(',', ':'); int AuctionSource = Convert.ToInt32(itemKey[1]); if (type == 1 && client.ClientData.Faction < 1) { Info = 1; } AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(AuctionSource); if (null == AuctionCfg) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]SetGlodAuction ({0}) null == config", AuctionSource), null, true); Info = 4; } else { item = this.GoldAuctionMgr.GetGoldAuctionItem(type, ProductionTime, AuctionSource, true); if (item == null || item.AuctionType != type) { Info = 9; } else if (client.ClientData.RoleID == item.BuyerData.m_RoleID) { Info = 11; } else if (item.BuyerData.m_RoleID == 0 && Price < AuctionCfg.OriginPrice) { Info = 5; } else if (Price < AuctionCfg.UnitPrice) { Info = 6; } else if ((long)Price <= item.BuyerData.Value) { Info = 10; } else if (!GameManager.ClientMgr.SubUserMoney(client, Price, "金团拍卖购买", false, false, false, false, DaiBiSySType.None)) { Info = 7; } if (Info != 0) { this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource); } else { AuctionRoleData oldBuyerData = new AuctionRoleData(); CopyData.Copy <AuctionRoleData>(item.BuyerData, ref oldBuyerData); bool upFlag = false; int newBuyer = client.ClientData.RoleID; item.BuyerData.Value = (long)Price; item.BuyerData.m_RoleID = client.ClientData.RoleID; item.BuyerData.m_RoleName = client.ClientData.RoleName; item.BuyerData.ZoneID = client.ClientData.ZoneID; item.BuyerData.strUserID = client.strUserID; item.BuyerData.ServerId = client.ServerId; if (Price >= AuctionCfg.MaxPrice && AuctionCfg.MaxPrice > 0) { if (!this.GoldAuctionMgr.DisposeAward(item)) { Info = 8; LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]一口价 RoleId={0}, Price={1},itemKey={2} fail", newBuyer, Price, cmdParams[1]), null, true); } else { this.GoldAuctionMgr.DelGoldAuction(item, "金团拍卖购买su"); upFlag = true; } } else if (!this.GoldAuctionMgr.UpdatePrice(item)) { Info = 8; LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]更新价格 RoleId={0}, Price={1},itemKey={2} fail", newBuyer, Price, cmdParams[1]), null, true); } else { upFlag = true; } if (upFlag) { this.GoldAuctionMgr.ReturnOldAuctionMoney(oldBuyerData, item.StrGoods); } else { this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource); GameManager.logDBCmdMgr.AddMessageLog(-1, "钻石", "金团购买失败扣除钻石", client.ClientData.RoleName, client.ClientData.RoleName, "减少", Price, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, ""); } } } } } catch (Exception ex) { if (null != item) { this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource); } Info = 100; LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }
public void SendItem(int roleID, AuctionRoleData roleData, GoldAuctionItem AuctionItem, AuctionConfig AuctionCfg) { lock (this.AuctionMutex) { try { if (roleID <= 0) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]SendItem roleid=0,ProductionTime={0},AuctionSource={1}", AuctionItem.ProductionTime, AuctionItem.AuctionSource), null, true); } else { List <GoodsData> goodsData = new List <GoodsData>(); GoodsData goods = GlobalNew.ParseGoodsData(AuctionItem.StrGoods); if (null == goods) { LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]SendItem null == goods,ProductionTime={0},AuctionSource={1}", AuctionItem.ProductionTime, AuctionItem.AuctionSource), null, true); } else { goodsData.Add(goods); string ItemName = this.GetItemName(AuctionItem.StrGoods); if (null == roleData) { roleData = new AuctionRoleData(); GameClient client = GameManager.ClientMgr.FindClient(roleID); if (client != null) { roleData.m_RoleID = roleID; roleData.strUserID = client.strUserID; roleData.m_RoleName = client.ClientData.RoleName; roleData.ZoneID = client.ClientData.ZoneID; roleData.ServerId = client.ServerId; } } string strTitle; string strIntro; if (roleID == AuctionItem.BuyerData.m_RoleID) { strTitle = "购买成功"; strIntro = "在金团拍卖购买成功"; } else { strTitle = AuctionCfg.FailTitle; strIntro = string.Format(AuctionCfg.FailIntro, ItemName); } if (!Global.UseMailGivePlayerAward3(roleID, goodsData, strTitle, strIntro, 0, 0, 0)) { GameManager.logDBCmdMgr.AddMessageLog(-1, ItemName, "邮件发放金团结算失败", roleData.m_RoleName, roleData.m_RoleName, "增加", goods.GCount, roleData.ZoneID, roleData.strUserID, -1, roleData.ServerId, AuctionItem.StrGoods); LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]SendItem 邮件发放金团结算失败 roleid={0}, item = {1}", roleID, AuctionItem.StrGoods), null, true); } else { GameManager.logDBCmdMgr.AddDBLogInfo(-1, ItemName, "邮件发放金团结算", "系统", roleData.m_RoleName, "增加", goods.GCount, roleData.ZoneID, roleData.strUserID, -1, roleData.ServerId, null); } } } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]SendItem send email roleid={0}, item = {1}", roleID, AuctionItem.StrGoods, ex.ToString()), null, true); } } }
public void GetGoldAuctionS2C(int Auctiontype, int ordeType, int sortNum, int startNum, int maxNum, string Seach, int Color, ref GoldAuctionS2C clientData) { try { lock (this.AuctionMutex) { string memKey = string.Format("{0}|{1}|{2}|{3}|{4}", new object[] { Auctiontype, ordeType, sortNum, Seach, Color }); int allNum = 0; List <AuctionItemS2C> dList = new List <AuctionItemS2C>(); AuctionS2CCache Cache; if (!this.S2CCache.TryGetValue(memKey, out Cache)) { Cache = new AuctionS2CCache(); foreach (GoldAuctionItem item in this.AuctionItemList) { if (item.AuctionType == Auctiontype) { allNum++; AuctionItemS2C temp; if (CopyData.Copy2AuctionItemS2C(item, out temp, Seach, Color)) { dList.Add(temp); } } } dList.Sort(new GlodAuctionIComparer(ordeType, sortNum > 0)); Cache.MaxNum = allNum; Cache.dList.AddRange(dList); this.S2CCache.Add(memKey, Cache); } else { allNum = Cache.MaxNum; foreach (AuctionItemS2C item2 in Cache.dList) { string[] itemKey = item2.AuctionItemKey.Split(new char[] { '|' }); GoldAuctionItem AuctionItem = this.getGoldAuctionItem(itemKey[0].Replace(',', ':'), Convert.ToInt32(itemKey[1])); AuctionItemS2C temp; if (CopyData.Copy2AuctionItemS2C(item2, out temp, AuctionItem)) { dList.Add(temp); } } } int len = maxNum; int starIndex = (startNum - 1) * maxNum; clientData.CurrentPage = startNum; if (starIndex < 1 || starIndex >= dList.Count) { clientData.CurrentPage = 1; len = Math.Min(maxNum, dList.Count); } else if (starIndex + maxNum > dList.Count) { len = dList.Count - starIndex; } clientData.TotalCount = allNum; clientData.ItemList.AddRange(dList.GetRange(starIndex, len)); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } }