예제 #1
0
        public void processCmd(GameServerClient client, byte[] cmdParams, int count)
        {
            string cmdData = null;
            int    nID     = (int)TCPGameServerCmds.CMD_DB_ADD_BAITANLOG;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID));
                client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0");
                return;
            }

            string[] fields = cmdData.Split(':');
            if (fields.Length != 12)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}",
                                                                  (TCPGameServerCmds)nID, fields.Length, cmdData));

                client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0");
                return;
            }

            int    roleID         = Convert.ToInt32(fields[0]);
            int    otherroleid    = Convert.ToInt32(fields[1]);
            string otherrname     = fields[2];
            int    goodsid        = Convert.ToInt32(fields[3]);
            int    goodsnum       = Convert.ToInt32(fields[4]);
            int    forgelevel     = Convert.ToInt32(fields[5]);
            int    totalprice     = Convert.ToInt32(fields[6]);
            int    leftyuanbao    = Convert.ToInt32(fields[7]);
            int    YinLiang       = Convert.ToInt32(fields[8]);
            int    LeftYinLiang   = Convert.ToInt32(fields[9]);
            int    tax            = Convert.ToInt32(fields[10]);
            int    excellenceinfo = Convert.ToInt32(fields[11]);

            BaiTanLogItemData data = new BaiTanLogItemData();

            data.rid            = roleID;
            data.OtherRoleID    = otherroleid;
            data.OtherRName     = otherrname;
            data.GoodsID        = goodsid;
            data.GoodsNum       = goodsnum;
            data.ForgeLevel     = forgelevel;
            data.TotalPrice     = totalprice;
            data.LeftYuanBao    = leftyuanbao;
            data.YinLiang       = YinLiang;
            data.LeftYinLiang   = LeftYinLiang;
            data.BuyTime        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            data.Tax            = tax;
            data.Excellenceinfo = excellenceinfo;

            BaiTanManager.getInstance().onAddBaiTanLog(data);

            client.sendCmd <string>((int)TCPGameServerCmds.CMD_DB_ADD_BAITANLOG, string.Format("{0}", 0));
        }
예제 #2
0
        /// <summary>
        /// 摆摊日志触发处理
        /// </summary>
        /// <param name="bhId"></param>
        /// <param name="roleName"></param>
        /// <param name="shijianType"></param>
        /// <param name="param1"></param>
        /// <param name="param2"></param>
        /// <param name="param3"></param>
        public void onAddBaiTanLog(BaiTanLogItemData data)
        {
            List <BaiTanLogItemData> _dataList  = null;
            List <BaiTanLogItemData> _dataList2 = null;

            lock (dataCache)
            {
                if (!dataCache.TryGetValue(data.rid, out _dataList))
                {
                    _dataList = new List <BaiTanLogItemData>();
                    dataCache.Add(data.rid, _dataList);
                }
                if (!dataCache.TryGetValue(data.OtherRoleID, out _dataList2))
                {
                    _dataList2 = new List <BaiTanLogItemData>();
                    dataCache.Add(data.OtherRoleID, _dataList2);
                }
            }

            lock (_dataList)
            {
                //将最新的数据插入到最前面
                _dataList.Insert(0, data);

                //超过规定容量,删除最后一个
                if (_dataList.Count > MaxCacheNum)
                {
                    _dataList.RemoveAt(_dataList.Count - 1);
                }
            }

            lock (_dataList2)
            {
                //将最新的数据插入到最前面
                _dataList2.Insert(0, data);

                //超过规定容量,删除最后一个
                if (_dataList2.Count > MaxCacheNum)
                {
                    _dataList2.RemoveAt(_dataList2.Count - 1);
                }
            }

            BaiTanLogDBController.getInstance().insert(data);
        }
예제 #3
0
        public void onAddBaiTanLog(BaiTanLogItemData data)
        {
            List <BaiTanLogItemData> _dataList  = null;
            List <BaiTanLogItemData> _dataList2 = null;

            lock (this.dataCache)
            {
                if (!this.dataCache.TryGetValue(data.rid, out _dataList))
                {
                    _dataList = new List <BaiTanLogItemData>();
                    this.dataCache.Add(data.rid, _dataList);
                }
                if (!this.dataCache.TryGetValue(data.OtherRoleID, out _dataList2))
                {
                    _dataList2 = new List <BaiTanLogItemData>();
                    this.dataCache.Add(data.OtherRoleID, _dataList2);
                }
            }
            lock (_dataList)
            {
                _dataList.Insert(0, data);
                if (_dataList.Count > BaiTanManager.MaxCacheNum)
                {
                    _dataList.RemoveAt(_dataList.Count - 1);
                }
            }
            lock (_dataList2)
            {
                _dataList2.Insert(0, data);
                if (_dataList2.Count > BaiTanManager.MaxCacheNum)
                {
                    _dataList2.RemoveAt(_dataList2.Count - 1);
                }
            }
            BaiTanLogDBController.getInstance().insert(data);
        }