/***************************************************************************
                   Insert Data Class Header ( InsertData.h )
                -----------------------------------------

	begin      : 2013/07/03
	copyright  : (C) 2013 Solbox Inc.
	author     : Development 1 Team
					- 2013/07/03 - 1st dadamin
	email      : dev1@solbox.com
	version    : 3.2.0

	CopyRight(C) 2005 Solbox Inc. All Rights reserved.
	Redistribution and use in source and binary forms, with or with out
	modification, are not permitted in outside of Solbox Inc.
***************************************************************************/
#ifndef __INSERT_DATA_H__
#define __INSERT_DATA_H__

#include "DataDefine.h"

class CDBManager;

class CInsertData
{
public:
	CInsertData();
	CInsertData(string &rc, string &userseq, string  &svcseq, string &svcname);
	virtual ~CInsertData();

	void MakeStatKey(string stattype, string val);
	void MakeInsertFailKey(string  failtype);

	void SetServiceInfo(string &rc, string &userseq, string  &svcseq, string &svcname);
	bool SetStat(string valuetype, string val);
	inline void SetFailType(string val) { m_failtype.push_back(val); }
	bool SetInsertFail(string statkey, string valuetype, string val);
	bool SetInsertFail(string statkey, map <string, string > &val);

	bool FindFailType(string stype);

	bool ExecuteInsert(string stype, CDBManager*  dbmanager);

	bool MakeXMLNode(Element* root);

	inline const char* GetRC()				{ return m_svc[XML_SVC_RC].c_str(); }
	inline const char* GetUserSEQ()			{ return m_svc[XML_SVC_USER_SEQ].c_str(); }
	inline const char* GetSvcSEQ()			{ return m_svc[XML_SVC_SEQ].c_str(); }
	inline const char* GetSvcName()			{ return m_svc[XML_SVC_NAME].c_str(); }
	inline const char* GetFailType(int i)	{ return m_failtype[i].c_str(); }
	inline const char* GetSuccess()			{ return m_joblog[0].c_str(); }
	inline const char* GetFail()			{ return m_joblog[1].c_str(); }
	
	inline int FailTypeSize()				{ return m_failtype.size(); }

	inline void ClearJobLog()			{ m_joblog[0].clear(); m_joblog[1].clear(); }

	inline void	ClearKey()		{ m_key.clear(); }
	void	Clear();

	void	PrintServiceInfo();
	void	PrintStat();
	void	PrintFailType();
	void	PrintStatAll();

	void	PrintInsertFail();
	void	PrintInsertFailAll();

private:
	string			m_key;
	map <string, string > m_svc;
	map<string, map <string, string > > m_stat;
	vector<string> m_failtype;

	map<string, map<string, map <string, string > > > m_insertfail;
	string	m_joblog[2];
};

#endif // __INSERT_DATA_H__
