예제 #1
0
        private static void NotifyBusinessCppCode(NotifyItem item)
        {
            var           entity = item.LocalEntity;
            StringBuilder code   = new StringBuilder();

            code.Append($@"#include ""stdafx.h""
#include ""{item.Name}Business.h""
namespace GBS
{{
    namespace Futures
    {{
        namespace TradeManagement
        {{
            /** 
            * @brief 构造
            */
		    {item.Name}Business::{item.Name}Business()
			:m_call_arg(nullptr)
            {{
            }}

            /** 
            * @brief 析构
            */
            {item.Name}Business::~{item.Name}Business()
            {{
            }}

            /** 
            * @brief 初始化
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::initialization(PNetCommand cmd_arg)
            {{
                m_call_arg = cmd_arg;");
            if (entity != null)
            {
                code.Append(@"
                cmd_arg >> m_field;
                save_to_redis(&m_field);");
            }
            code.Append($@"
                return NET_COMMAND_STATE_SUCCEED;
            }}

            /** 
            * @brief 数据校验
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::verify()
            {{
                return NET_COMMAND_STATE_SUCCEED;
            }}

            /** 
            * @brief 准备执行
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::prepare()
            {{
                return NET_COMMAND_STATE_SUCCEED;
            }}

            /** 
            * @brief 执行动作(默认实现原样发到交易端)
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::doit()
            {{
                PNetCommand es_cmd_arg = new NetCommand();");
            if (entity != null)
            {
                code.Append(@"
                es_cmd_arg << m_field;");
            }
            code.Append(@"
                memcpy(es_cmd_arg, m_call_arg, NETCOMMAND_HEAD_LEN);
                server_message_send(es_cmd_arg);
                return NET_COMMAND_STATE_SUCCEED;
            }
        }
    }
}");
            FileCoder.WriteFile($@"c:\work\SharpCode\GbsNotify\{item.Name}Business.cpp", code.ToString());
        }
예제 #2
0
        private static void NotifyBusinessHCode(NotifyItem item)
        {
            var entity = item.LocalEntity;
            var code   = new StringBuilder();

            code.Append($@"#ifndef _{item.Name.ToUpper()}_BUSINESS_H
#define _{item.Name.ToUpper()}_BUSINESS_H
#pragma once
#include <stdafx.h>
#include <GbsBusiness/entity_redis.h>");

            if (entity != null)
            {
                code.Append($@"
#include <{entity.Parent.Name}/{entity.Name}.h>
using namespace {entity.Parent.NameSpace.Replace(".", "::")};");
            }

            code.Append($@"
namespace GBS
{{
	namespace Futures
	{{
		namespace TradeManagement
		{{
            /** 
            * @brief {item.Caption}逻辑处理类
            * @return 无
            */
			class {item.Name}Business
			{{"            );
            if (entity != null)
            {
                code.Append($@"
                //解析后的参数
				{entity.Name} m_field;"                );
            }
            code.Append($@"
                //原始调用参数
				PNetCommand m_call_arg;
			public:
                /** 
                * @brief 构造
                */
				{item.Name}Business();
                /** 
                * @brief 析构
                */
				~{item.Name}Business();
                /** 
                * @brief 初始化
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE initialization(PNetCommand cmd_arg);
                /** 
                * @brief 数据校验
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE verify();
                /** 
                * @brief 准备执行
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE prepare();
                /** 
                * @brief 执行动作
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE doit();
			}};
		}}
	}}
}}
#endif");
            FileCoder.WriteFile($@"c:\work\SharpCode\GbsNotify\{item.Name}Business.h", code.ToString());
        }