//架构性代码和协议生成 public static void GenStructs() { sb.Clear(); sb = GenCommon.GenHeader(sb, "DBTypes.h", vesion, "生成所有的数据表结构类,一张表对应一个类。"); sb.Append(@"#pragma once #include <string> namespace DBProduce { "); foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { sb.Append(@" struct "+ table.Key + @" {" ); foreach (DBField field in table.Value) { sb.Append(@" " + TypesChange.dbtocpp(field.type) + @" " + field.name + @";"); } sb.Append(@" }; "); } sb.Append(@"}"); OutPut.Out(GlobalData.SavePath + "\\DBTypes.h", sb.ToString()); }
private void Handler_BattleModelChanged(TypesChange typeChange) { this.Dispatcher.Invoke(() => { switch (typeChange) { case TypesChange.CountPlyers: Handler_ChangeCountPlyers(); break; } }); }
public static void GenDBGameProto() { StringBuilder sbb = new StringBuilder(); int protoId = 200; sb.Clear(); sb.Append(@" import ""DBStruct.proto""; message GD_LogicRegister { //#define DG_REGISTER 200 optional uint32 uiServerId = 1; } message DG_LogicRegister { //#define GD_REGISTER 201 optional int32 iRet = 1; }"); sbb.Append(@" //#define DG_REGISTER 200 //#define GD_REGISTER 201 "); protoId++; foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { protoId++; sb.Append(@" //通过id获取" + table.Key + @"中的对应数据 message GD_Get" + table.Key + @" { //#define GD_GET_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; optional " + TypesChange.dbtoProto(table.Value[0].type) + " " + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + @"id = 2; } "); sbb.Append(@" //#define GD_GET_" + table.Key.ToUpper() + @" "+ protoId + @" "); protoId++; sb.Append(@" message DG_Get" + table.Key + @" { //#define DG_GET_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; required int32 iRet = 2; optional PD." + table.Key + " st" + table.Key + @" =3; } "); sbb.Append(@" //#define DG_GET_" + table.Key.ToUpper() + @" "+ protoId + @" "); protoId++; sb.Append(@" //创建" + table.Key + @"中的对应数据 message GD_Create" + table.Key + @" { //#define GD_CREATE_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; optional PD." + table.Key + " st" + table.Key + @" =2; } "); sbb.Append(@" //#define GD_CREATE_" + table.Key.ToUpper() + @" "+ protoId + @" "); protoId++; sb.Append(@" message DG_Create" + table.Key + @" { //#define DG_CREATE_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; optional int32 iRet =2; optional PD." + table.Key + " st" + table.Key + @" =3; } "); sbb.Append(@" //#define DG_CREATE_" + table.Key.ToUpper() + @" "+ protoId + @" "); protoId++; sb.Append(@" //更新" + table.Key + @"中的对应数据 message GD_Update" + table.Key + @" { //#define GD_UPDATE_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; optional PD." + table.Key + " st" + table.Key + @" =2; } "); sbb.Append(@" //#define GD_UPDATE_" + table.Key.ToUpper() + @" "+ protoId + @" "); protoId++; sb.Append(@" message DG_Update" + table.Key + @" { //#define DG_UPDATE_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; optional int32 iRet = 2; } "); sbb.Append(@" //#define DG_UPDATE_" + table.Key.ToUpper() + @" "+ protoId + @" "); protoId++; sb.Append(@" //通过id删除" + table.Key + @"中的对应数据 message GD_Delete" + table.Key + @" { //#define GD_DELETE_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; optional " + TypesChange.dbtoProto(table.Value[0].type) + " " + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + @"id = 2; } "); sbb.Append(@" //#define GD_DELETE_" + table.Key.ToUpper() + @" "+ protoId + @" "); protoId++; sb.Append(@" message DG_Delete" + table.Key + @" { //#define DG_DELETE_" + table.Key.ToUpper() + @" "+ protoId + @" required uint32 uiaccid = 1; optional int32 iRet = 2; } "); sbb.Append(@" //#define DG_DELETE_" + table.Key.ToUpper() + @" "+ protoId + @" "); } sb.Append(@" //替换消息头的宏定义 " + sbb.ToString() + @" "); OutPut.Out(folder + "DGProtocol.proto", sb.ToString()); //------------------------------------------------------------------------------------------------ }
//业务性代码和协议生成 public static void GenDBGameTask() { sb.Clear(); sb = GenCommon.GenHeader(sb, "DGameTask.h", vesion, "用于实现游戏服务器与数据服务器的数据表操作消息处理"); sb.Append(@"#pragma once class DGameTask: public wdcyClient { private: public: DGameTask(wdcyTcpServerDispatcher *pDispatcher, evutil_socket_t fd) : wdcyClient(pDispatcher, fd) { registerMsgHandle(); } /* * @brief 客户端已经建立连接 */ void onConnected(); /* * @brief 客户端断开连接 */ void onDisconnected(); /* * @brief 连接验证 */ int verifyConn(const MessageHead* pMsg, const uint32_t iLength); /* * @brief 消息解析 */ void msgParse(const MessageHead* pMsg, const uint32_t iLength); /* * @brief 消息注册 */ void registerMsgHandle(); private: wdcyMsgRouter m_MsgRouter; public: //自定义事件" ); foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { sb.Append(@" //表" + table.Key + @"的增删改查操作 int onGet" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength); int onCreate" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength); int onUpdate" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength); int onDelete" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength); "); } sb.Append(@" }; "); OutPut.Out(folder + "DGameTask.h", sb.ToString()); //CPP文件--------------------------------------------------------------------------- sb.Clear(); sb = GenCommon.GenHeader(sb, "DGameTask.cpp", vesion, "用于实现游戏服务器与数据服务器的数据表操作消息处理"); sb.Append(@"#include ""All.h"" /* * @brief 客户端已经建立连接 */ void DGameTask::onConnected() { std::cout << ""有游戏服务器连接进来"" << std::endl; DGameTaskMgr::getInstance().addClient(this); } /* * @brief 客户端断开连接 */ void DGameTask::onDisconnected() { std::cout << ""有游戏服务器断开连接"" << std::endl; DGameTaskMgr::getInstance().removeClient(getSockId()); } /* * @brief 游戏服务器连接验证 */ int DGameTask::verifyConn(const MessageHead* pMsg, const uint32_t iLength) { std::cout << ""游戏服务器进行验证"" << std::endl; GD_LogicRegister stMsg; stMsg.ParseFromArray(pMsg->data, pMsg->length); std::cout << ""passwd:"" << stMsg.uiserverid() << std::endl; std::cout << ""--------------------------"" << std::endl; DG_LogicRegister sendMsg; sendMsg.set_iret(0); Net::send(this, sendMsg, DG_REGISTER); std::cout << ""verifyConn success"" << std::endl; return 0; } /* * @brief 消息解析 */ void DGameTask::msgParse(const MessageHead* pMsg, const uint32_t iLength) { bool bResult = m_MsgRouter.HandMsg(pMsg, pMsg->length); if (!bResult) { //GAME_LOG(LOG_ERROR, ""解析消息错误,:%d"", pMsg->msgId); } } "); sb.Append(@"/* * @brief 消息注册 */ void DGameTask::registerMsgHandle() { #define REGIST_MSG_HANDLE(msgid, func) \ m_MsgRouter.regMsgHandler(msgid, std::bind(&DGameTask::func, this, std::placeholders::_1, std::placeholders::_2)); " ); foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { sb.Append(@" //表" + table.Key + @"操作消息注册 REGIST_MSG_HANDLE(GD_GET_" + table.Key.ToUpper() + @", onGet" + table.Key + @"); REGIST_MSG_HANDLE(GD_CREATE_" + table.Key.ToUpper() + @", onCreate" + table.Key + @"); REGIST_MSG_HANDLE(GD_UPDATE_" + table.Key.ToUpper() + @", onUpdate" + table.Key + @"); REGIST_MSG_HANDLE(GD_DELETE_" + table.Key.ToUpper() + @", onDelete" + table.Key + @"); "); } sb.Append(@" }"); foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { sb.Append(@" int DGameTask::onGet" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength) {"); sb.Append(@" GD_Get" + table.Key + @" stMsg; stMsg.ParseFromArray(pMsg->data, pMsg->length); std::shared_ptr < DBProduce::" + table.Key + @" > p" + table.Key + @"(new DBProduce::" + table.Key + @"()); if (DBProduce::RedisReader::Get" + table.Key + @"(p" + table.Key + @", stMsg." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + table.Value[0].name + @"())) { DG_Get" + table.Key + @" sendMsg; PD::" + table.Key + @"* st" + table.Key + @" = sendMsg.mutable_st" + table.Key + @"(); sendMsg.set_iret(0); sendMsg.set_uiaccid(stMsg.uiaccid()); " ); for (int i = 0; i < table.Value.Count; i++) { sb.Append(@" st" + table.Key + @"->set_" + TypesChange.dbtoProtohead(table.Value[i].type) + table.Value[i].name + @"(p" + table.Key + @" ->" + table.Value[i].name + @"); "); } sb.Append(@" Net::send(this, sendMsg, DG_GET_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO, ""获取" + table.Key + @"成功""); } else { DG_Get" + table.Key + @" sendMsg; PD::" + table.Key + @"* st" + table.Key + @" = sendMsg.mutable_st" + table.Key + @"(); sendMsg.set_iret(-1); sendMsg.set_uiaccid(stMsg.uiaccid()); Net::send(this, sendMsg, DG_GET_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO,""获取" + table.Key + @"失败""); } return 0;" ); sb.Append(@" }"); sb.Append(@" int DGameTask::onCreate" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength) {"); sb.Append(@" GD_Create" + table.Key + @" stMsg; stMsg.ParseFromArray(pMsg->data, pMsg->length); std::shared_ptr < DBProduce::" + table.Key + @" > p" + table.Key + @"(new DBProduce::" + table.Key + @"()); if (!DBProduce::RedisReader::Get" + table.Key + @"(p" + table.Key + @", stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Value[0].name + @"())) { std::shared_ptr < DBProduce::DBMsg > dbMsg(new DBProduce::DBMsg()); dbMsg->id = stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Value[0].name + @"(); dbMsg->dbCMD = DBProduce::DBCMD::dbinsert; dbMsg->tablename = """ + table.Key + @"""; std::shared_ptr < std::map<std::string, std::string> > data(new std::map<std::string, std::string>()); "); for (int i = 1; i < table.Value.Count; i++) { if (TypesChange.dbtocpp(table.Value[i].type) != "std::string") { sb.Append(@" data->insert( std::pair<std::string, std::string>(""" + table.Value[i].name + @""", std::to_string(stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[i].type) + table.Value[i].name + @"())));"); } else { sb.Append(@" data->insert( std::pair<std::string, std::string>(""" + table.Value[i].name + @""", stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[i].type) + table.Value[i].name + @"()));"); } } sb.Append(@" dbMsg->data = data; DBProduce::WriteBackMgr::getInstance().WriteBack(dbMsg); DG_Create" + table.Key + @" sendMsg; sendMsg.set_iret(0); sendMsg.set_uiaccid(stMsg.uiaccid()); PD::" + table.Key + @"* st" + table.Key + @" = sendMsg.mutable_st" + table.Key + @"(); " ); for (int i = 0; i < table.Value.Count; i++) { sb.Append(@" st" + table.Key + @"->set_" + TypesChange.dbtoProtohead(table.Value[i].type) + table.Value[i].name + @"(stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[i].type) + table.Value[i].name + @"()); "); } sb.Append(@" "); sb.Append(@" Net::send(this, sendMsg, DG_CREATE_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO, ""创建" + table.Key + @"成功""); } else { DG_Create" + table.Key + @" sendMsg; sendMsg.set_iret(-1); sendMsg.set_uiaccid(stMsg.uiaccid()); Net::send(this, sendMsg, DG_CREATE_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO, ""创建_" + table.Key + @"失败""); } return 0; "); sb.Append(@" }"); sb.Append(@" int DGameTask::onUpdate" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength) {"); sb.Append(@" GD_Update" + table.Key + @" stMsg; stMsg.ParseFromArray(pMsg->data, pMsg->length); std::shared_ptr < DBProduce::" + table.Key + @" > p" + table.Key + @"(new DBProduce::" + table.Key + @"()); if (DBProduce::RedisReader::Get" + table.Key + @"(p" + table.Key + @", stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Value[0].name + @"())) { std::shared_ptr < DBProduce::DBMsg > dbMsg(new DBProduce::DBMsg()); dbMsg->id = stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Value[0].name + @"(); dbMsg->dbCMD = DBProduce::DBCMD::dbupdate; dbMsg->tablename = """ + table.Key + @"""; std::shared_ptr < std::map<std::string, std::string> > data(new std::map<std::string, std::string>()); "); for (int i = 1; i < table.Value.Count; i++) { if (TypesChange.dbtocpp(table.Value[i].type) != "std::string") { sb.Append(@" data->insert( std::pair<std::string, std::string>(""" + table.Value[i].name + @""", std::to_string(stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[i].type) + table.Value[i].name + @"())));"); } else { sb.Append(@" data->insert( std::pair<std::string, std::string>(""" + table.Value[i].name + @""", stMsg.st" + table.Key + @"()." + TypesChange.dbtoProtohead(table.Value[i].type) + table.Value[i].name + @"()));"); } } sb.Append(@" dbMsg->data = data; DBProduce::WriteBackMgr::getInstance().WriteBack(dbMsg); DG_Update" + table.Key + @" sendMsg; sendMsg.set_iret(0); sendMsg.set_uiaccid(stMsg.uiaccid()); Net::send(this, sendMsg, DG_UPDATE_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO, ""更新" + table.Key + @"成功""); } else { DG_Update" + table.Key + @" sendMsg; sendMsg.set_iret(-1); sendMsg.set_uiaccid(stMsg.uiaccid()); Net::send(this, sendMsg, DG_UPDATE_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO, ""更新" + table.Key + @"失败""); } return 0; "); sb.Append(@" }"); sb.Append(@" int DGameTask::onDelete" + table.Key + @"(const MessageHead* pMsg, const uint32_t iLength) {"); sb.Append(@" GD_Delete" + table.Key + @" stMsg; stMsg.ParseFromArray(pMsg->data, pMsg->length); std::shared_ptr < DBProduce::" + table.Key + @" > p" + table.Key + @"(new DBProduce::" + table.Key + @"()); if (DBProduce::RedisReader::Get" + table.Key + @"(p" + table.Key + @", stMsg." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + table.Value[0].name + @"())) { std::shared_ptr < DBProduce::DBMsg > dbMsg(new DBProduce::DBMsg()); dbMsg->id = stMsg." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + table.Value[0].name + @"(); dbMsg->dbCMD = DBProduce::DBCMD::dbdelete; dbMsg->tablename = """ + table.Key + @"""; std::shared_ptr < std::map<std::string, std::string> > data(new std::map<std::string, std::string>()); data->insert( std::pair<std::string, std::string>(""" + table.Value[0].name + @""", std::to_string(stMsg." + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + table.Value[0].name + @"()))); dbMsg->data = data; DBProduce::WriteBackMgr::getInstance().WriteBack(dbMsg); DG_Delete" + table.Key + @" sendMsg; sendMsg.set_iret(0); sendMsg.set_uiaccid(stMsg.uiaccid()); Net::send(this, sendMsg, DG_DELETE_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO, ""删除" + table.Key + @"成功""); } else { DG_Get" + table.Key + @" sendMsg; sendMsg.set_iret(-1); sendMsg.set_uiaccid(stMsg.uiaccid()); Net::send(this, sendMsg, DG_DELETE_" + table.Key.ToUpper() + @"); GAME_LOG(LOG_INFO, ""删除" + table.Key + @"失败""); } return 0; "); sb.Append(@" }"); } OutPut.Out(folder + "DGameTask.cpp", sb.ToString()); }
public static void GenRedisHandler() { sb.Clear(); sb = GenCommon.GenHeader(sb, "RedisHandler.h", vesion, "继承自DBHandler,以redis数据入库的方式来处理数据读出的数据。"); sb.Append(@"#pragma once namespace DBProduce { class RedisHandler: public DBHandler { private: DBProduce::RedisDBEngine* redisDBEngine; public: RedisHandler(DBProduce::RedisDBEngine* _redisDBEngine); virtual ~RedisHandler(); //清空redis中所有的数据,慎用 void flashAll();" ); foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { sb.Append(@" void read" + table.Key + @"(std::shared_ptr <DBProduce::" + table.Key + @"> _" + table.Key + @");"); } sb.Append(@" }; } "); OutPut.Out(folder + "RedisHandler.h", sb.ToString()); //CPP文件--------------------------------------------------------------------------- sb.Clear(); sb = GenCommon.GenHeader(sb, "RedisHandler.cpp", vesion, "继承自DBHandler,以redis数据入库的方式来处理数据读出的数据。"); sb.Append(@"#include ""All.h"" namespace DBProduce { RedisHandler::RedisHandler(DBProduce::RedisDBEngine* _redisDBEngine) { redisDBEngine = _redisDBEngine; } RedisHandler::~RedisHandler() { } void RedisHandler::flashAll() { std::string cmd = ""flushall""; redisDBEngine->excuteCommoned(cmd); }" ); foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { sb.Append(@" void RedisHandler::read" + table.Key + @"(std::shared_ptr <DBProduce::" + table.Key + @"> _" + table.Key + @") {" ); sb.Append(@" std::string cmd = ""hmset " + table.Key + @":"" + std::to_string((long long)_" + table.Key + @"->" + table.Value[0].name + @"); "); for (int i = 1; i < table.Value.Count; i++) { if (table.Value[i].type == "blob" || table.Value[i].type == "datetime") { sb.Append(@" if (_" + table.Key + @"->" + table.Value[i].name + @".empty()) { cmd.append( "" " + table.Value[i].name + @" \"""" + NetUtility::replace(_" + table.Key + @"->" + table.Value[i].name + @","" "",""$$"")+""\"" ""); } else { cmd.append("" " + table.Value[i].name + @" "" + NetUtility::replace(_" + table.Key + @"->" + table.Value[i].name + @","" "",""$$"")); } "); } else { if (TypesChange.dbtocpp(table.Value[i].type) == "std::string") { sb.Append(@" cmd.append("" " + table.Value[i].name + @" "" + NetUtility::replace(_" + table.Key + @"->" + table.Value[i].name + @","" "",""$$"")); "); } else { sb.Append(@" cmd.append("" " + table.Value[i].name + @" "" + NetUtility::replace(std::to_string(_" + table.Key + @"->" + table.Value[i].name + @"),"" "",""$$"") ); "); } } } sb.Append(@"; redisDBEngine->excuteCommoned(cmd); }" ); } sb.Append(@" } "); OutPut.Out(folder + "RedisHandler.cpp", sb.ToString()); }
public static void GenDBGameProto() { StringBuilder sbb = new StringBuilder(); int protoId = 200; sb.Clear(); string head = @"syntax = ""proto3""; import ""DB_Base.proto""; package PDB_Option; "; protoId++; foreach (KeyValuePair <String, List <DBField> > table in DownDatas.tables) { protoId++; sb.Append(@" //通过id获取" + table.Key + @"中的对应数据 message GD_Get" + table.Key + @" { //#define GD_GET_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; " + TypesChange.dbtoProto(table.Value[0].type) + " " + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + @"id = 2; } "); sbb.Append(@" GD_GET_" + table.Key.ToUpper() + @"=" + protoId + @";"); protoId++; sb.Append(@" message DG_Get" + table.Key + @" { //#define DG_GET_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; int32 iRet = 2; PDB_Base." + table.Key + " st" + table.Key + @" =3; } "); sbb.Append(@" DG_GET_" + table.Key.ToUpper() + @"=" + protoId + @";"); protoId++; sb.Append(@" //创建" + table.Key + @"中的对应数据 message GD_Create" + table.Key + @" { //#define GD_CREATE_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; PDB_Base." + table.Key + " st" + table.Key + @" =2; } "); sbb.Append(@" GD_CREATE_" + table.Key.ToUpper() + @"=" + protoId + @";"); protoId++; sb.Append(@" message DG_Create" + table.Key + @" { //#define DG_CREATE_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; int32 iRet =2; PDB_Base." + table.Key + " st" + table.Key + @" =3; } "); sbb.Append(@" DG_CREATE_" + table.Key.ToUpper() + @"=" + protoId + @";"); protoId++; sb.Append(@" //更新" + table.Key + @"中的对应数据 message GD_Update" + table.Key + @" { //#define GD_UPDATE_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; PDB_Base." + table.Key + " st" + table.Key + @" =2; } "); sbb.Append(@" GD_UPDATE_" + table.Key.ToUpper() + @"=" + protoId + @";"); protoId++; sb.Append(@" message DG_Update" + table.Key + @" { //#define DG_UPDATE_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; int32 iRet = 2; } "); sbb.Append(@" DG_UPDATE_" + table.Key.ToUpper() + @"=" + protoId + @";"); protoId++; sb.Append(@" //通过id删除" + table.Key + @"中的对应数据 message GD_Delete" + table.Key + @" { //#define GD_DELETE_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; " + TypesChange.dbtoProto(table.Value[0].type) + " " + TypesChange.dbtoProtohead(table.Value[0].type) + table.Key + @"id = 2; } "); sbb.Append(@" GD_DELETE_" + table.Key.ToUpper() + @"=" + protoId + @";"); protoId++; sb.Append(@" message DG_Delete" + table.Key + @" { //#define DG_DELETE_" + table.Key.ToUpper() + @" "+ protoId + @" uint32 uiaccid = 1; int32 iRet = 2; } "); sbb.Append(@" DG_DELETE_" + table.Key.ToUpper() + @"=" + protoId + @";"); } sb.Insert(0, @" //替换消息头的宏定义 enum EDB_CMD{ DB_CMD_NONE=0; " + sbb.ToString() + @" }"); sb.Insert(0, head); OutPut.Out(GlobalData.ProtoPath + "\\DB_Option.proto", sb.ToString()); //------------------------------------------------------------------------------------------------ }