Пример #1
0
        public static bool EquipFluorescentGem(DBManager dbMgr, FluorescentGemSaveDBData data)
        {
            bool result;

            if (null == data)
            {
                result = false;
            }
            else
            {
                bool ret = false;
                using (MyDbConnection3 conn = new MyDbConnection3(false))
                {
                    string equipTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    string cmdText   = string.Format("INSERT INTO t_fluorescent_gem_equip(roleid, goodsid, position, type, equiptime, bind) VALUES({0}, {1}, {2}, {3}, '{4}', {5})", new object[]
                    {
                        data._RoleID,
                        data._GoodsID,
                        data._Position,
                        data._GemType,
                        equipTime,
                        data._Bind
                    });
                    ret = conn.ExecuteNonQueryBool(cmdText, 0);
                }
                result = ret;
            }
            return(result);
        }
        public TCPProcessCmdResults ProcessEquipGemCmd(DBManager dbMgr, GameServerClient client, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            bool bRet = false;
            FluorescentGemSaveDBData gemData = null;

            try
            {
                gemData = DataHelper.BytesToObject <FluorescentGemSaveDBData>(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                client.sendCmd <bool>(nID, bRet);
                return(TCPProcessCmdResults.RESULT_OK);
            }
            try
            {
                DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref gemData._RoleID);
                if (null == dbRoleInfo)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, gemData._RoleID), null, true);
                    client.sendCmd <bool>(nID, bRet);
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                bRet = FluorescentGemDBOperate.EquipFluorescentGem(dbMgr, gemData);
                if (bRet)
                {
                    lock (dbRoleInfo)
                    {
                        GoodsData goodsData = new GoodsData();
                        goodsData.GoodsID  = gemData._GoodsID;
                        goodsData.GCount   = 1;
                        goodsData.Binding  = gemData._Bind;
                        goodsData.Site     = 7001;
                        goodsData.BagIndex = this.GenerateBagIndex(gemData._Position, gemData._GemType);
                        dbRoleInfo.FluorescentGemData.GemEquipList.Add(goodsData);
                    }
                }
                client.sendCmd <bool>(nID, bRet);
                return(TCPProcessCmdResults.RESULT_OK);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            client.sendCmd <bool>(nID, bRet);
            return(TCPProcessCmdResults.RESULT_OK);
        }
Пример #3
0
        public static bool UnEquipFluorescentGem(DBManager dbMgr, FluorescentGemSaveDBData data)
        {
            bool result;

            if (null == data)
            {
                result = false;
            }
            else
            {
                bool ret = false;
                using (MyDbConnection3 conn = new MyDbConnection3(false))
                {
                    string cmdText = string.Format("DELETE FROM t_fluorescent_gem_equip WHERE roleid={0} and position={1} and type={2}", data._RoleID, data._Position, data._GemType);
                    ret = conn.ExecuteNonQueryBool(cmdText, 0);
                }
                result = ret;
            }
            return(result);
        }