PageRenderTime 14ms CodeModel.GetById 6ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/TGame/TServerMS/Database/DBMessageHandlerProgress.cpp

http://awoe.googlecode.com/
C++ | 117 lines | 81 code | 25 blank | 11 comment | 7 complexity | e9bca4414ada82ebb85e355e7df8e9a5 MD5 | raw file
  1//
  2//	Generated by lua
  3//	2009-2011	(C) Simplay Inc. Reserved
  4//
  5//
  6#include "stdafx.h"
  7#include "DBMessageHandlerProgress.h"
  8#include "Message/DBMessageProgress.h"
  9
 10
 11
 12//
 13//	Dabase Message Handler for LoadProgresss//
 14
 15DBMessageHandlerLoadProgresss::DBMessageHandlerLoadProgresss( void )
 16{
 17}
 18
 19DBMessageHandlerLoadProgresss::~DBMessageHandlerLoadProgresss( void )
 20{
 21}
 22
 23bool DBMessageHandlerLoadProgresss::handleMsg( IMsg * message )
 24{
 25	MsgLoadProgresss* msg = dynamic_cast< MsgLoadProgresss * >( message );
 26	Assert( msg && message );
 27
 28	SQL_QUERY( "call load_progresss(%d)", msg->pid );
 29
 30	if ( sqlResult >= 0 )
 31	{
 32		while ( m_DBMysql.GetRow() )
 33		{
 34				DBProgress 	o;
 35				m_DBMysql.GetField(o.cid, 0 );
 36				m_DBMysql.GetField(o.did, 1 );
 37				m_DBMysql.GetField(o.sid, 2 );
 38				m_DBMysql.GetField(o.data, 3 );
 39				msg->progresss.push_back(o);
 40		}
 41		msg->m_errcode = Msg::ecSuccess;
 42	}
 43	else
 44	{
 45		LOG_ERROR("Failed to handle db msg: MsgLoadProgresss , DBMessageHandlerLoadProgresss!");
 46		msg->m_errcode = Msg::ecFailed;
 47		return false;
 48	}
 49
 50	return true;
 51}
 52
 53//
 54//	Dabase Message Handler for UpdateProgress//
 55
 56DBMessageHandlerUpdateProgress::DBMessageHandlerUpdateProgress( void )
 57{
 58}
 59
 60DBMessageHandlerUpdateProgress::~DBMessageHandlerUpdateProgress( void )
 61{
 62}
 63
 64bool DBMessageHandlerUpdateProgress::handleMsg( IMsg * message )
 65{
 66	MsgUpdateProgress* msg = dynamic_cast< MsgUpdateProgress * >( message );
 67	Assert( msg && message );
 68
 69	SQL_QUERY( "call update_progress(%d, %d, %d, %d, %d)", msg->pid, msg->progress.cid, msg->progress.did, msg->progress.sid, msg->progress.data );
 70
 71	if ( sqlResult >= 0 )
 72	{
 73		msg->m_errcode = Msg::ecSuccess;
 74	}
 75	else
 76	{
 77		LOG_ERROR("Failed to handle db msg: MsgUpdateProgress , DBMessageHandlerUpdateProgress!");
 78		msg->m_errcode = Msg::ecFailed;
 79		return false;
 80	}
 81
 82	return true;
 83}
 84
 85//
 86//	Dabase Message Handler for RemoveProgress//
 87
 88DBMessageHandlerRemoveProgress::DBMessageHandlerRemoveProgress( void )
 89{
 90}
 91
 92DBMessageHandlerRemoveProgress::~DBMessageHandlerRemoveProgress( void )
 93{
 94}
 95
 96bool DBMessageHandlerRemoveProgress::handleMsg( IMsg * message )
 97{
 98	MsgRemoveProgress* msg = dynamic_cast< MsgRemoveProgress * >( message );
 99	Assert( msg && message );
100
101	SQL_QUERY( "call remove_progress(%d, %d, %d, %d)", msg->pid, msg->cid, msg->did, msg->sid );
102
103	if ( sqlResult >= 0 )
104	{
105		msg->m_errcode = Msg::ecSuccess;
106	}
107	else
108	{
109		LOG_ERROR("Failed to handle db msg: MsgRemoveProgress , DBMessageHandlerRemoveProgress!");
110		msg->m_errcode = Msg::ecFailed;
111		return false;
112	}
113
114	return true;
115}
116
117