Exemple #1
0
        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());
            //------------------------------------------------------------------------------------------------
        }
Exemple #2
0
        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());
            //------------------------------------------------------------------------------------------------
        }