Example #1
0
        /// <summary>
        /// 当商城在线购买
        /// 出售者在线
        /// </summary>
        /// <param name="whoBuy"></param>
        /// <param name="item"></param>
        public void OnMarketBuy(int whoBuy, int whoSale, GoodsData saleGoods)
        {
            if (saleGoods == null)
            {
                return;
            }

            int pay = Math.Max(saleGoods.SaleYuanBao, 0);
            Dictionary <int, int> tmpPriceDict = GoodsPriceDict;
            int price = (tmpPriceDict != null && tmpPriceDict.ContainsKey(saleGoods.GoodsID))
                ? (tmpPriceDict[saleGoods.GoodsID] * saleGoods.GCount) : 0;

            DateTime         now   = TimeUtil.NowDateTime();
            TradeBlackObject buyer = LoadTradeBlackObject(whoBuy);

            if (buyer != null)
            {
                lock (buyer)
                {
                    TradeBlackHourItem item = GetBlackHourItem(buyer, now);
                    item.MarketTimes++;
                    item.MarketInPrice  += price;
                    item.MarketOutPrice += pay;
                    if (!item.TradeRoles.Contains(whoSale))
                    {
                        item.TradeRoles.Add(whoSale);
                        item.TradeDistinctRoleCount++;
                    }
                    TradeBlackHourItem itemCopy = item.SimpleClone();
                    SaveTradeBlackObject(itemCopy);
                }
            }

            TradeBlackObject saler = LoadTradeBlackObject(whoSale);

            if (saler != null)
            {
                lock (saler)
                {
                    TradeBlackHourItem item = GetBlackHourItem(saler, now);
                    item.MarketTimes++;
                    item.MarketOutPrice += price;
                    item.MarketInPrice  += pay;
                    if (!item.TradeRoles.Contains(whoBuy))
                    {
                        item.TradeRoles.Add(whoBuy);
                        item.TradeDistinctRoleCount++;
                    }
                    TradeBlackHourItem itemCopy = item.SimpleClone();
                    SaveTradeBlackObject(itemCopy);
                }
            }

            CheckBanTrade(whoBuy);
            CheckBanTrade(whoSale);
        }
        public bool IsBanTrade(int roleId)
        {
            bool             bBan = false;
            TradeBlackObject obj  = this.LoadTradeBlackObject(roleId, true);

            if (obj != null)
            {
                bBan = (obj.BanTradeToTicks > 0L && obj.BanTradeToTicks > TimeUtil.NowDateTime().Ticks);
            }
            return(bBan);
        }
 public void Update()
 {
     if ((TimeUtil.NowDateTime() - this.lastCheckUnBanTime).TotalSeconds > 60.0)
     {
         this.lastCheckUnBanTime = TimeUtil.NowDateTime();
         List <int> roleIds = null;
         lock (this.TradeBlackObjs)
         {
             roleIds = this.TradeBlackObjs.Keys.ToList <int>();
         }
         if (roleIds != null)
         {
             roleIds.ForEach(delegate(int _r)
             {
                 this.CheckUnBanTrade(_r);
             });
         }
     }
     if ((TimeUtil.NowDateTime() - this.lastFreeUnusedTime).TotalHours > 1.0)
     {
         this.lastFreeUnusedTime = TimeUtil.NowDateTime();
         List <int> roleIds = null;
         lock (this.TradeBlackObjs)
         {
             roleIds = this.TradeBlackObjs.Keys.ToList <int>();
         }
         List <int> list;
         if (roleIds == null)
         {
             list = null;
         }
         else
         {
             list = roleIds.FindAll(delegate(int _r)
             {
                 TradeBlackObject obj = this.LoadTradeBlackObject(_r, true);
                 return(obj != null && obj.BanTradeToTicks <= 0L && (TimeUtil.NowDateTime() - obj.LastFlushTime).TotalHours > 12.0);
             });
         }
         List <int> removeIds = list;
         if (removeIds != null)
         {
             lock (this.TradeBlackObjs)
             {
                 foreach (int id in removeIds)
                 {
                     this.TradeBlackObjs.Remove(id);
                 }
             }
         }
     }
 }
        private TradeBlackHourItem GetBlackHourItem(TradeBlackObject obj, DateTime date)
        {
            TradeBlackHourItem item = obj.HourItems[date.Hour];

            if (item == null || item.Day != date.ToString("yyyy-MM-dd"))
            {
                item                     = new TradeBlackHourItem();
                item.RoleId              = obj.RoleId;
                item.Day                 = date.ToString("yyyy-MM-dd");
                item.Hour                = date.Hour;
                item.TradeRoles          = new HashSet <int>();
                obj.HourItems[date.Hour] = item;
            }
            return(item);
        }
        private void CheckUnBanTrade(int roleId)
        {
            TradeBlackObject obj = this.LoadTradeBlackObject(roleId, true);

            if (obj != null)
            {
                lock (obj)
                {
                    if (obj.BanTradeToTicks > 0L && obj.BanTradeToTicks < TimeUtil.NowDateTime().Ticks)
                    {
                        this.SetBanTradeToTicks(roleId, 0L);
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// 定时检测解封交易
        /// </summary>
        public void Update()
        {
            // 60s检测一次解封
            if ((TimeUtil.NowDateTime() - lastCheckUnBanTime).TotalSeconds > 60)
            {
                lastCheckUnBanTime = TimeUtil.NowDateTime();
                List <int> roleIds = null;
                lock (TradeBlackObjs)
                {
                    roleIds = TradeBlackObjs.Keys.ToList();
                }

                if (roleIds != null)
                {
                    roleIds.ForEach(_r => CheckUnBanTrade(_r));
                }
            }

            // 每小时检测1次可以释放的黑名单对象
            if ((TimeUtil.NowDateTime() - lastFreeUnusedTime).TotalHours > 1)
            {
                lastFreeUnusedTime = TimeUtil.NowDateTime();
                List <int> roleIds = null;
                lock (TradeBlackObjs)
                {
                    roleIds = TradeBlackObjs.Keys.ToList();
                }

                // 从内存中卸载未被封禁的,12个小时未被访问的黑名单对象
                List <int> removeIds = roleIds != null?roleIds.FindAll(_r =>
                {
                    TradeBlackObject obj = LoadTradeBlackObject(_r);
                    return(obj != null && obj.BanTradeToTicks <= 0 && (TimeUtil.NowDateTime() - obj.LastFlushTime).TotalHours > 12);
                }) : null;

                if (removeIds != null)
                {
                    lock (TradeBlackObjs)
                    {
                        foreach (var id in removeIds)
                        {
                            TradeBlackObjs.Remove(id);
                        }
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        /// 检查解封交易
        /// </summary>
        /// <param name="roleId"></param>
        private void CheckUnBanTrade(int roleId)
        {
            TradeBlackObject obj = LoadTradeBlackObject(roleId);

            if (obj == null)
            {
                return;
            }

            lock (obj)
            {
                if (obj.BanTradeToTicks > 0 && obj.BanTradeToTicks < TimeUtil.NowDateTime().Ticks)
                {
                    // 解封
                    SetBanTradeToTicks(roleId, 0);
                }
            }
        }
 public void UpdateObjectExtData(GameClient client)
 {
     if (client != null)
     {
         TradeBlackObject obj = this.LoadTradeBlackObject(client.ClientData.RoleID, false);
         if (obj != null)
         {
             lock (obj)
             {
                 obj.ChangeLife = client.ClientData.ChangeLifeCount;
                 obj.Level      = client.ClientData.Level;
                 obj.VipLevel   = client.ClientData.VipLevel;
                 obj.ZoneId     = client.ClientData.ZoneID;
                 obj.RoleName   = client.ClientData.RoleName;
             }
         }
     }
 }
Example #9
0
        public void SetBanTradeToTicks(int roleid, long toTicks)
        {
            toTicks = Math.Max(0, toTicks);
            //设置角色的属性 update db
            GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_DB_UPDATEROLEPROPS,
                                          string.Format("{0}:{1}:{2}", roleid, (int)RolePropIndexs.BanTrade, toTicks),
                                          null, GameManager.LocalServerId);

            TradeBlackObject obj = LoadTradeBlackObject(roleid);

            if (obj != null)
            {
                lock (obj)
                {
                    obj.BanTradeToTicks = toTicks;
                }
            }

            long banTradeSec = 0;

            if (toTicks > TimeUtil.NowDateTime().Ticks)
            {
                banTradeSec = (long)(new DateTime(toTicks) - TimeUtil.NowDateTime()).TotalSeconds;
                banTradeSec = Math.Max(0, banTradeSec);
            }

            if (banTradeSec > 0)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("roleid={0} 被封禁交易,秒数={1}", roleid, banTradeSec));
            }

            GameClient client = GameManager.ClientMgr.FindClient(roleid);

            if (client != null)
            {
                client.ClientData.BanTradeToTicks = toTicks;

                if (banTradeSec > 0)
                {
                    string tip = string.Format(Global.GetLang("您目前已被禁止交易以及使用交易行,剩余时间【{0}】秒"), banTradeSec);
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, tip, GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox);
                }
            }
        }
        public void SetBanTradeToTicks(int roleid, long toTicks)
        {
            toTicks = Math.Max(0L, toTicks);
            GameManager.DBCmdMgr.AddDBCmd(10119, string.Format("{0}:{1}:{2}", roleid, 3, toTicks), null, 0);
            TradeBlackObject obj = this.LoadTradeBlackObject(roleid, true);

            if (obj != null)
            {
                lock (obj)
                {
                    obj.BanTradeToTicks = toTicks;
                }
            }
            long banTradeSec = 0L;

            if (toTicks > TimeUtil.NowDateTime().Ticks)
            {
                banTradeSec = (long)(new DateTime(toTicks) - TimeUtil.NowDateTime()).TotalSeconds;
                banTradeSec = Math.Max(0L, banTradeSec);
            }
            if (banTradeSec > 0L)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("roleid={0} 被封禁交易,秒数={1}", roleid, banTradeSec), null, true);
            }
            GameClient client = GameManager.ClientMgr.FindClient(roleid);

            if (client != null)
            {
                client.ClientData.BanTradeToTicks = toTicks;
                if (banTradeSec > 0L)
                {
                    string tip = string.Format(GLang.GetLang(35, new object[0]), banTradeSec);
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, tip, GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                }
            }
        }
Example #11
0
        private TradeBlackObject LoadTradeBlackObject(int roleid, bool loadDbIfNotExist = true)
        {
            DateTime         now = TimeUtil.NowDateTime();
            TradeBlackObject obj = null;
            int offsetDay        = Global.GetOffsetDay(TimeUtil.NowDateTime());

            lock (TradeBlackObjs)
            {
                if (TradeBlackObjs.TryGetValue(roleid, out obj))
                {
                    obj.LastFlushTime = now;
                }
            }

            if (obj == null && loadDbIfNotExist)
            {
                string reqCmd = string.Format("{0}:{1}:{2}", roleid, now.ToString("yyyy-MM-dd"), now.Hour);
                List <TradeBlackHourItem> items = Global.sendToDB <List <TradeBlackHourItem>, string>(
                    (int)TCPGameServerCmds.CMD_DB_LOAD_TRADE_BLACK_HOUR_ITEM, reqCmd, GameManager.LocalServerId);

                obj               = new TradeBlackObject();
                obj.RoleId        = roleid;
                obj.LastFlushTime = now;
                obj.HourItems     = new TradeBlackHourItem[24];

                GameClient client = GameManager.ClientMgr.FindClient(roleid);
                if (client != null)
                {
                    obj.VipLevel        = client.ClientData.VipLevel;
                    obj.ChangeLife      = client.ClientData.ChangeLifeCount;
                    obj.Level           = client.ClientData.Level;
                    obj.BanTradeToTicks = client.ClientData.BanTradeToTicks;
                    obj.ZoneId          = client.ClientData.ZoneID;
                    obj.RoleName        = client.ClientData.RoleName;
                }
                else
                {
                    SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleid);
                    if (clientData != null)
                    {
                        obj.VipLevel        = Global.CalcVipLevelByZuanShi(Global.GetUserInputAllYuanBao(clientData.RoleID, clientData.RoleName, GameManager.LocalServerId));
                        obj.ChangeLife      = clientData.ChangeLifeCount;
                        obj.Level           = clientData.Level;
                        obj.BanTradeToTicks = clientData.BanTradeToTicks;
                        obj.ZoneId          = clientData.ZoneID;
                        obj.RoleName        = clientData.RoleName;
                    }
                }

                if (items != null)
                {
                    foreach (var item in items)
                    {
                        int idx = item.Hour % 24; // 哈哈,hour,必然在0 --- 24 范围内吧
                        obj.HourItems[idx] = item;
                        item.TradeRoles    = item.TradeRoles ?? new HashSet <int>();
                    }
                }

                // 防止多个线程同时都从数据库加载同一个人的信息
                lock (TradeBlackObjs)
                {
                    if (!TradeBlackObjs.ContainsKey(roleid))
                    {
                        TradeBlackObjs[roleid] = obj;
                    }
                    else
                    {
                        obj = TradeBlackObjs[roleid];
                    }
                }
            }

            return(obj);
        }
Example #12
0
        /// <summary>
        /// 当完成交易
        /// </summary>
        /// <param name="ed"></param>
        public void OnExchange(int roleid1, int roleid2, List <GoodsData> gdList1, List <GoodsData> gdList2, int zuanshi1, int zuanshi2)
        {
            long price1 = zuanshi1 > 0 ? zuanshi1 : 0; // roleid1 的支出
            long price2 = zuanshi2 > 0 ? zuanshi2 : 0; // roleid2 的支出

            Func <List <GoodsData>, Dictionary <int, int>, long> _GetGoodsPrice = (gdList, priceDict) =>
            {
                long totalPrice = 0;
                if (gdList != null && priceDict != null)
                {
                    gdList.ForEach(_g => totalPrice += priceDict.ContainsKey(_g.GoodsID) ? priceDict[_g.GoodsID] * _g.GCount : 0);
                }
                return(totalPrice);
            };

            price1 += _GetGoodsPrice(gdList1, this.GoodsPriceDict);
            price2 += _GetGoodsPrice(gdList2, this.GoodsPriceDict);

            DateTime         now  = TimeUtil.NowDateTime();
            TradeBlackObject obj1 = LoadTradeBlackObject(roleid1);

            if (obj1 != null)
            {
                lock (obj1)
                {
                    TradeBlackHourItem item = GetBlackHourItem(obj1, now);
                    item.TradeTimes++;
                    item.TradeOutPrice += price1;
                    item.TradeInPrice  += price2;
                    if (!item.TradeRoles.Contains(roleid2))
                    {
                        item.TradeRoles.Add(roleid2);
                        item.TradeDistinctRoleCount++;
                    }

                    TradeBlackHourItem itemCopy = item.SimpleClone();
                    SaveTradeBlackObject(itemCopy);
                }
            }

            TradeBlackObject obj2 = LoadTradeBlackObject(roleid2);

            if (obj2 != null)
            {
                lock (obj2)
                {
                    TradeBlackHourItem item = GetBlackHourItem(obj2, now);
                    item.TradeTimes++;
                    item.TradeInPrice  += price1;
                    item.TradeOutPrice += price2;
                    if (!item.TradeRoles.Contains(roleid1))
                    {
                        item.TradeRoles.Add(roleid1);
                        item.TradeDistinctRoleCount++;
                    }
                    TradeBlackHourItem itemCopy = item.SimpleClone();
                    SaveTradeBlackObject(itemCopy);
                }
            }

            CheckBanTrade(roleid1);
            CheckBanTrade(roleid2);
        }
Example #13
0
        /// <summary>
        /// 检查封禁交易
        /// </summary>
        /// <param name="roleId"></param>
        private void CheckBanTrade(int roleId)
        {
            TradeBlackObject obj = LoadTradeBlackObject(roleId);

            if (obj == null)
            {
                return;
            }

            int kick_out_minutes = -1;

            lock (obj)
            {
                if (obj.BanTradeToTicks <= 0)
                {
                    List <TradeConfigItem> items = this.TradeCfgItems;
                    TradeConfigItem        item  = items != null?items.Find(_i => {
                        return(_i.MinVip <= obj.VipLevel && _i.MaxVip >= obj.VipLevel &&
                               _i.UnionMinLevel <= Global.GetUnionLevel(obj.ChangeLife, obj.Level) &&
                               _i.UnionMaxLevel >= Global.GetUnionLevel(obj.ChangeLife, obj.Level));
                    }) : null;

                    if (item != null)
                    {
                        long totalInPrice = 0, totalOutPrice = 0, totalTimes = 0;
                        foreach (var hourItem in obj.HourItems)
                        {
                            if (hourItem == null)
                            {
                                continue;
                            }

                            totalInPrice  += hourItem.MarketInPrice + hourItem.TradeInPrice;
                            totalOutPrice += hourItem.MarketOutPrice + hourItem.TradeOutPrice;
                            totalTimes    += hourItem.MarketTimes + hourItem.TradeTimes;
                        }

                        if (totalInPrice >= item.MaxPrice || totalOutPrice >= item.MaxPrice || totalTimes >= item.MaxTimes)
                        {
                            int _banTradeSec = Math.Max(this.BanTradeSec, 0);
                            if (_banTradeSec > 0)
                            {
                                long toTicks = TimeUtil.NowDateTime().AddSeconds(_banTradeSec).Ticks;
                                SetBanTradeToTicks(roleId, toTicks);
                            }

                            if (this.BanTradeLog == 1)
                            {
                                LogManager.WriteLog(LogTypes.Analysis, string.Format("tradeblack player={0} inprice={1} outprice={2} times={3} bansec={4}", roleId, totalInPrice, totalOutPrice, totalTimes, _banTradeSec));
                            }

                            kick_out_minutes = Math.Max(this.BanTradeLogin, 0) / 60;
                            if (kick_out_minutes > 0)
                            {
                                BanManager.BanRoleName(Global.FormatRoleName3(obj.ZoneId, obj.RoleName), kick_out_minutes, (int)BanManager.BanReason.TradeException);
                            }
                        }
                    }
                }
            }

            if (kick_out_minutes > 0)
            {
                GameClient client = GameManager.ClientMgr.FindClient(roleId);
                if (client != null)
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                             StringUtil.substitute(Global.GetLang("系统检测到您交易异常,您的帐号将被禁止登录{0}分钟!"), kick_out_minutes), GameInfoTypeIndexes.Error, ShowGameInfoTypes.HintAndBox);

                    Global.ForceCloseClient(client, "交易封禁");

                    /*
                     * string gmCmdData = string.Format("-kick {0}", obj.RoleName);
                     * //转发GM消息到DBServer
                     * GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_SPR_CHAT,
                     *  string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}:{8}", obj.RoleId, "", 0, "", 0, gmCmdData, 0, 0, GameManager.ServerLineID),
                     *  null, GameManager.LocalServerId);
                     */
                }
            }
        }
        private TradeBlackObject LoadTradeBlackObject(int roleid, bool loadDbIfNotExist = true)
        {
            DateTime         now = TimeUtil.NowDateTime();
            TradeBlackObject obj = null;
            int offsetDay        = Global.GetOffsetDay(TimeUtil.NowDateTime());

            lock (this.TradeBlackObjs)
            {
                if (this.TradeBlackObjs.TryGetValue(roleid, out obj))
                {
                    obj.LastFlushTime = now;
                }
            }
            if (obj == null && loadDbIfNotExist)
            {
                string reqCmd = string.Format("{0}:{1}:{2}", roleid, now.ToString("yyyy-MM-dd"), now.Hour);
                List <TradeBlackHourItem> items = Global.sendToDB <List <TradeBlackHourItem>, string>(14007, reqCmd, 0);
                obj               = new TradeBlackObject();
                obj.RoleId        = roleid;
                obj.LastFlushTime = now;
                obj.HourItems     = new TradeBlackHourItem[24];
                GameClient client = GameManager.ClientMgr.FindClient(roleid);
                if (client != null)
                {
                    obj.VipLevel        = client.ClientData.VipLevel;
                    obj.ChangeLife      = client.ClientData.ChangeLifeCount;
                    obj.Level           = client.ClientData.Level;
                    obj.BanTradeToTicks = client.ClientData.BanTradeToTicks;
                    obj.ZoneId          = client.ClientData.ZoneID;
                    obj.RoleName        = client.ClientData.RoleName;
                }
                else
                {
                    SafeClientData clientData = Global.GetSafeClientDataFromLocalOrDB(roleid);
                    if (clientData != null)
                    {
                        obj.VipLevel        = Global.CalcVipLevelByZuanShi(Global.GetUserInputAllYuanBao(clientData.RoleID, clientData.RoleName, 0));
                        obj.ChangeLife      = clientData.ChangeLifeCount;
                        obj.Level           = clientData.Level;
                        obj.BanTradeToTicks = clientData.BanTradeToTicks;
                        obj.ZoneId          = clientData.ZoneID;
                        obj.RoleName        = clientData.RoleName;
                    }
                }
                if (items != null)
                {
                    foreach (TradeBlackHourItem item in items)
                    {
                        int idx = item.Hour % 24;
                        obj.HourItems[idx] = item;
                        item.TradeRoles    = (item.TradeRoles ?? new HashSet <int>());
                    }
                }
                lock (this.TradeBlackObjs)
                {
                    if (!this.TradeBlackObjs.ContainsKey(roleid))
                    {
                        this.TradeBlackObjs[roleid] = obj;
                    }
                    else
                    {
                        obj = this.TradeBlackObjs[roleid];
                    }
                }
            }
            return(obj);
        }
        public void OnExchange(int roleid1, int roleid2, List <GoodsData> gdList1, List <GoodsData> gdList2, int zuanshi1, int zuanshi2)
        {
            long price  = (long)((zuanshi1 > 0) ? zuanshi1 : 0);
            long price2 = (long)((zuanshi2 > 0) ? zuanshi2 : 0);
            Func <List <GoodsData>, Dictionary <int, int>, long> _GetGoodsPrice = delegate(List <GoodsData> gdList, Dictionary <int, int> priceDict)
            {
                long totalPrice = 0L;
                if (gdList != null && priceDict != null)
                {
                    gdList.ForEach(delegate(GoodsData _g)
                    {
                        totalPrice += (long)(priceDict.ContainsKey(_g.GoodsID) ? (priceDict[_g.GoodsID] * _g.GCount) : 0);
                    });
                }
                return(totalPrice);
            };

            price  += _GetGoodsPrice(gdList1, this.GoodsPriceDict);
            price2 += _GetGoodsPrice(gdList2, this.GoodsPriceDict);
            DateTime         now = TimeUtil.NowDateTime();
            TradeBlackObject obj = this.LoadTradeBlackObject(roleid1, true);

            if (obj != null)
            {
                lock (obj)
                {
                    TradeBlackHourItem item = this.GetBlackHourItem(obj, now);
                    item.TradeTimes++;
                    item.TradeOutPrice += price;
                    item.TradeInPrice  += price2;
                    if (!item.TradeRoles.Contains(roleid2))
                    {
                        item.TradeRoles.Add(roleid2);
                        item.TradeDistinctRoleCount++;
                    }
                    TradeBlackHourItem itemCopy = item.SimpleClone();
                    this.SaveTradeBlackObject(itemCopy);
                }
            }
            TradeBlackObject obj2 = this.LoadTradeBlackObject(roleid2, true);

            if (obj2 != null)
            {
                lock (obj2)
                {
                    TradeBlackHourItem item = this.GetBlackHourItem(obj2, now);
                    item.TradeTimes++;
                    item.TradeInPrice  += price;
                    item.TradeOutPrice += price2;
                    if (!item.TradeRoles.Contains(roleid1))
                    {
                        item.TradeRoles.Add(roleid1);
                        item.TradeDistinctRoleCount++;
                    }
                    TradeBlackHourItem itemCopy = item.SimpleClone();
                    this.SaveTradeBlackObject(itemCopy);
                }
            }
            this.CheckBanTrade(roleid1);
            this.CheckBanTrade(roleid2);
        }
        private void CheckBanTrade(int roleId)
        {
            TradeBlackObject obj = this.LoadTradeBlackObject(roleId, true);

            if (obj != null)
            {
                int kick_out_minutes = -1;
                lock (obj)
                {
                    if (obj.BanTradeToTicks <= 0L)
                    {
                        List <TradeConfigItem> items = this.TradeCfgItems;
                        TradeConfigItem        tradeConfigItem;
                        if (items == null)
                        {
                            tradeConfigItem = null;
                        }
                        else
                        {
                            tradeConfigItem = items.Find((TradeConfigItem _i) => _i.MinVip <= obj.VipLevel && _i.MaxVip >= obj.VipLevel && _i.UnionMinLevel <= Global.GetUnionLevel(obj.ChangeLife, obj.Level, false) && _i.UnionMaxLevel >= Global.GetUnionLevel(obj.ChangeLife, obj.Level, false));
                        }
                        TradeConfigItem item = tradeConfigItem;
                        if (item != null)
                        {
                            long totalInPrice  = 0L;
                            long totalOutPrice = 0L;
                            long totalTimes    = 0L;
                            foreach (TradeBlackHourItem hourItem in obj.HourItems)
                            {
                                if (hourItem != null)
                                {
                                    totalInPrice  += hourItem.MarketInPrice + hourItem.TradeInPrice;
                                    totalOutPrice += hourItem.MarketOutPrice + hourItem.TradeOutPrice;
                                    totalTimes    += (long)(hourItem.MarketTimes + hourItem.TradeTimes);
                                }
                            }
                            if (totalInPrice >= (long)item.MaxPrice || totalOutPrice >= (long)item.MaxPrice || totalTimes >= (long)item.MaxTimes)
                            {
                                int _banTradeSec = Math.Max(this.BanTradeSec, 0);
                                if (_banTradeSec > 0)
                                {
                                    long toTicks = TimeUtil.NowDateTime().AddSeconds((double)_banTradeSec).Ticks;
                                    this.SetBanTradeToTicks(roleId, toTicks);
                                }
                                if (this.BanTradeLog == 1)
                                {
                                    LogManager.WriteLog(LogTypes.Analysis, string.Format("tradeblack player={0} inprice={1} outprice={2} times={3} bansec={4}", new object[]
                                    {
                                        roleId,
                                        totalInPrice,
                                        totalOutPrice,
                                        totalTimes,
                                        _banTradeSec
                                    }), null, true);
                                }
                                kick_out_minutes = Math.Max(this.BanTradeLogin, 0) / 60;
                                if (kick_out_minutes > 0)
                                {
                                    BanManager.BanRoleName(Global.FormatRoleName3(obj.ZoneId, obj.RoleName), kick_out_minutes, 3);
                                }
                            }
                        }
                    }
                }
                if (kick_out_minutes > 0)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(roleId);
                    if (client != null)
                    {
                        GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(36, new object[0]), new object[]
                        {
                            kick_out_minutes
                        }), GameInfoTypeIndexes.Error, ShowGameInfoTypes.HintAndBox, 0);
                        Global.ForceCloseClient(client, "交易封禁", true);
                    }
                }
            }
        }