|
|
@@ -1,450 +0,0 @@
|
|
|
-#include "stdafx.h"
|
|
|
-#include "SpBase.h"
|
|
|
-#include "Event.h"
|
|
|
-
|
|
|
-#ifndef _WIN32
|
|
|
-#include <time.h>
|
|
|
-#endif // !_WIN32
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-#include "InteractiveLog_server_g.h"
|
|
|
-#include "../mod_customeraware/Event.h"
|
|
|
-using namespace InteractiveLog;
|
|
|
-
|
|
|
-#include "bizlog.h"
|
|
|
-
|
|
|
-class CInterativeLogEntity;
|
|
|
-
|
|
|
-class ServerSession : public LogService_ServerSessionBase
|
|
|
-{
|
|
|
-public:
|
|
|
- ServerSession(CInterativeLogEntity *pEntity) : m_pEntity(pEntity) {}
|
|
|
-
|
|
|
- virtual void Handle_LogFunction(SpOnewayCallContext<LogService_LogFunction_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogCustomerID(SpOnewayCallContext<LogService_LogCustomerID_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogAgreement(SpOnewayCallContext<LogService_LogAgreement_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogReceipt(SpOnewayCallContext<LogService_LogReceipt_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogOperation(SpOnewayCallContext<LogService_LogOperation_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogResponse(SpOnewayCallContext<LogService_LogResponse_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogAgent(SpOnewayCallContext<LogService_LogAgent_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogBegin(SpOnewayCallContext<LogService_LogBegin_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogEnd(SpOnewayCallContext<LogService_LogEnd_Info>::Pointer ctx);
|
|
|
- virtual void Handle_LogCallID(SpOnewayCallContext<LogService_LogCallID_Info>::Pointer ctx);
|
|
|
-private:
|
|
|
- CInterativeLogEntity *m_pEntity;
|
|
|
-};
|
|
|
-
|
|
|
-// 0x
|
|
|
-
|
|
|
-class CInterativeLogEntity : public CEntityBase, public ILogListener, public ISysVarListener
|
|
|
-{
|
|
|
-public:
|
|
|
- CInterativeLogEntity() : m_log(NULL) {}
|
|
|
- virtual ~CInterativeLogEntity() {}
|
|
|
- virtual const char *GetEntityName() const { return "InteractiveLog"; }
|
|
|
- virtual bool IsService()const{return true;}
|
|
|
-
|
|
|
- virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
- {
|
|
|
- ErrorCodeEnum Error;
|
|
|
- CSimpleStringA strPath;
|
|
|
- m_nDesktopType = 0;
|
|
|
- m_strSessionCount = "0";
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- Error = GetFunction()->GetPath("InterLog", strPath);
|
|
|
- if (Error != Error_Succeed) {
|
|
|
- LOG_TRACE("getpath InterLog failed!");
|
|
|
- }
|
|
|
- m_log = bizlog_create((LPCSTR)strPath);
|
|
|
- if (!m_log)
|
|
|
- {
|
|
|
- Error = Error_Param;
|
|
|
- LOG_TRACE("create bizlog object failed!");
|
|
|
- }
|
|
|
-#else
|
|
|
- Error = Error_Succeed;
|
|
|
-#endif
|
|
|
-
|
|
|
- {
|
|
|
- CSmartPointer<IEntityFunction> Func = GetFunction();
|
|
|
- CSimpleStringA strValue;
|
|
|
- if (Func->RegistSysVarEvent(SYSVAR_DESKTOPTYPE, this) != Error_Succeed)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("register sysvar %s failed!", SYSVAR_DESKTOPTYPE);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Func->GetSysVar(SYSVAR_DESKTOPTYPE, strValue);
|
|
|
- if (strValue[0] ==DESKTOPTYPE_BUS) //切换到业务屏,打开LOG
|
|
|
- {
|
|
|
- m_nDesktopType = 0;
|
|
|
- }
|
|
|
- else if (strValue[0] == DESKTOPTYPE_INFO) //切换到信息屏,屏蔽LOG
|
|
|
- {
|
|
|
- m_nDesktopType = 1;
|
|
|
- }
|
|
|
- else if (strValue[0] == DESKTOPTYPE_USER) //切换到用户桌面,屏蔽LOG
|
|
|
- {
|
|
|
- m_nDesktopType = 2;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("unknown desktop type!");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*{
|
|
|
- CSmartPointer<IEntityFunction> Func = GetFunction();
|
|
|
- CSimpleStringA strValue;
|
|
|
- if (Func->RegistSysVarEvent("SessionCount", this) != Error_Succeed)
|
|
|
- {
|
|
|
- LOG_TRACE("register sysvar %SessionCount failed!");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Func->GetSysVar("SessionCount", m_strSessionCount);
|
|
|
- Dbg("SessionCount = %s",m_strSessionCount);
|
|
|
- }
|
|
|
- }
|
|
|
-*/
|
|
|
- GetFunction()->SubscribeLog(m_SubIDStopRecord, this, Log_Event, Severity_Middle, Error_IgnoreAll, EVENT_MOD_CUSTOMERAWARE_END, NULL, false);
|
|
|
- pTransactionContext->SendAnswer(Error);
|
|
|
- }
|
|
|
-
|
|
|
- virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
|
|
|
- const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
|
|
|
- const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext& pLinkInfo)
|
|
|
- {
|
|
|
- if (dwUserCode == EVENT_MOD_CUSTOMERAWARE_END)
|
|
|
- {
|
|
|
- ErrorCodeEnum errCode;
|
|
|
- errCode = GetFunction()->SetSysVar("CustomerID","N");
|
|
|
- if (errCode != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("set CustomerID failed (%d).",errCode);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("set customerid to N");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
- {
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- if (m_log)
|
|
|
- {
|
|
|
- bizlog_destroy(m_log);
|
|
|
- m_log = NULL;
|
|
|
- }
|
|
|
-#endif
|
|
|
- GetFunction()->UnsubscribeLog(m_SubIDStopRecord);
|
|
|
- pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
- }
|
|
|
-
|
|
|
- virtual void OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName)
|
|
|
- {
|
|
|
- if (_stricmp(pszKey, SYSVAR_DESKTOPTYPE) == 0)
|
|
|
- {
|
|
|
- Dbg("desktop type from : %c to %c", pszOldValue[0], pszValue[0]);
|
|
|
- if ((pszOldValue[0]==DESKTOPTYPE_BUS)) //如果从业务屏切换到其他屏,自动关闭当前interlog
|
|
|
- {
|
|
|
- LogEnd();
|
|
|
- }
|
|
|
-
|
|
|
- if (pszValue[0] == DESKTOPTYPE_BUS) //切换到业务屏,打开LOG
|
|
|
- {
|
|
|
- m_nDesktopType = 0;
|
|
|
- }
|
|
|
- else if (pszValue[0] == DESKTOPTYPE_INFO) //切换到信息屏,屏蔽LOG
|
|
|
- {
|
|
|
- m_nDesktopType = 1;
|
|
|
- }
|
|
|
- else if (pszValue[0] == DESKTOPTYPE_USER) //切换到用户桌面,屏蔽LOG
|
|
|
- {
|
|
|
- m_nDesktopType = 2;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("unknown desktop type!");
|
|
|
- }
|
|
|
- }
|
|
|
- //else if (_stricmp(pszKey, "SessionCount") == 0)
|
|
|
- //{
|
|
|
- // GetFunction()->GetSysVar("SessionCount", m_strSessionCount);
|
|
|
- // Dbg("SessionCount = %s",m_strSessionCount);
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
- virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * /*pszParam*/)
|
|
|
- {
|
|
|
- LOG_FUNCTION();
|
|
|
- return new ServerSession(this);
|
|
|
- }
|
|
|
-
|
|
|
- void LogFunction(SpOnewayCallContext<LogService_LogFunction_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- //Prepare();
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogFunction,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA name = CSimpleStringW2A(ctx->Info.nam);
|
|
|
- CSimpleStringA display = CSimpleStringW2A(ctx->Info.display);
|
|
|
- CSimpleStringA product = CSimpleStringW2A(ctx->Info.product);
|
|
|
- CSimpleStringA service_code = CSimpleStringW2A(ctx->Info.service_code);
|
|
|
- bizlog_function(m_log, name, display, product, service_code, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogCustomerID(SpOnewayCallContext<LogService_LogCustomerID_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogCustomerID,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
- CSimpleStringA customer_id = CSimpleStringW2A(ctx->Info.customer_id);
|
|
|
- ErrorCodeEnum errCode;
|
|
|
- errCode = GetFunction()->SetSysVar("CustomerID",customer_id);
|
|
|
- Dbg("set CustomerID to %s",customer_id.GetData());
|
|
|
- if (errCode != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("set CustomerID failed (%d).",errCode);
|
|
|
- }
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA verify_method = CSimpleStringW2A(ctx->Info.verify_method);
|
|
|
- bizlog_customer_id(m_log, customer_id, verify_method, ctx->Info.level, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogAgreement(SpOnewayCallContext<LogService_LogAgreement_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogAgreement,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA content = CSimpleStringW2A(ctx->Info.content);
|
|
|
- bizlog_agreement(m_log, content, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogReceipt(SpOnewayCallContext<LogService_LogReceipt_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogReceipt,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA content = CSimpleStringW2A(ctx->Info.content);
|
|
|
- bizlog_receipt(m_log, content, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogOperation(SpOnewayCallContext<LogService_LogOperation_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogOperation,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA code = CSimpleStringW2A(ctx->Info.code);
|
|
|
- CSimpleStringA content = CSimpleStringW2A(ctx->Info.content);
|
|
|
- bizlog_operation(m_log, code, content, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogResponse(SpOnewayCallContext<LogService_LogResponse_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogResponse,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA code = CSimpleStringW2A(ctx->Info.code);
|
|
|
- CSimpleStringA content = CSimpleStringW2A(ctx->Info.content);
|
|
|
- bizlog_response(m_log, code, content, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogAgent(SpOnewayCallContext<LogService_LogAgent_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogAgent,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA code = CSimpleStringW2A(ctx->Info.code);
|
|
|
- CSimpleStringA content = CSimpleStringW2A(ctx->Info.content);
|
|
|
- bizlog_agent(m_log, code, content, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogBegin(SpOnewayCallContext<LogService_LogBegin_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogBegin,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
- Dbg("log Begin get sessionid and sessioncnt");
|
|
|
- CSimpleStringA session_id = CSimpleStringW2A(ctx->Info.session_id);
|
|
|
- //文件名定为YYYYMMDD_XXX_SessionID。xxx为业务浏览器记录的运行时SessionID变化次数
|
|
|
-
|
|
|
- char strtimebuffer[256] = {0};
|
|
|
-
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- SYSTEMTIME nowTime; // 系统时间结构体
|
|
|
- GetLocalTime(&nowTime);
|
|
|
- sprintf_s(strtimebuffer, "%4d%02d%02d", nowTime.wYear, nowTime.wMonth, nowTime.wDay);
|
|
|
-#else
|
|
|
- struct tm* t;
|
|
|
- time_t tt;
|
|
|
- time(&tt);
|
|
|
- t = localtime(&tt);
|
|
|
- snprintf(strtimebuffer, 256, "%4d%02d%02d", t->tm_year+1900, t->tm_mon+1, t->tm_mday);
|
|
|
-#endif
|
|
|
-
|
|
|
- CSimpleStringA strTime = strtimebuffer;
|
|
|
- m_strSessionCount = CSimpleStringA::Format("%d",ctx->Info.session_count);
|
|
|
- //Dbg("SessionCount = %s",m_strSessionCount.GetData());
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA filename = strTime + "_" + m_strSessionCount + "_" + session_id;
|
|
|
- bizlog_session_begin(m_log, session_id, filename);
|
|
|
- Dbg("Begin new log -- %s", filename.GetData());
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogEnd(SpOnewayCallContext<LogService_LogEnd_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogEnd,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
- //Prepare();
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- bizlog_session_end(m_log);
|
|
|
- Dbg("End log");
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogEnd()
|
|
|
- {
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- bizlog_session_end(m_log);
|
|
|
- Dbg("Desktop type change to !B,Auto End log");
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void LogCallID(SpOnewayCallContext<LogService_LogCallID_Info>::Pointer ctx)
|
|
|
- {
|
|
|
- if (m_nDesktopType != 0) //如果不是业务状态
|
|
|
- {
|
|
|
- Dbg("LogCallID,desktop type is not B,ignore");
|
|
|
- return;
|
|
|
- }
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- CSimpleStringA callid = CSimpleStringW2A(ctx->Info.call_id);
|
|
|
- CSimpleStringA agentid = CSimpleStringW2A(ctx->Info.workNumber);
|
|
|
- CSimpleStringA skillCode = CSimpleStringW2A(ctx->Info.skillCode);
|
|
|
- bizlog_call_id(m_log, callid, skillCode, agentid, ctx->Info.action_id);
|
|
|
-#endif
|
|
|
- }
|
|
|
-
|
|
|
- void Prepare()
|
|
|
- {
|
|
|
- //if (m_log)
|
|
|
- //{
|
|
|
- // if (!bizlog_has_session(m_log))
|
|
|
- // {
|
|
|
- // m_uid = CUUID::Create(m_uid);
|
|
|
- // bizlog_session_begin(m_log, m_uid.ToString());
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
-
|
|
|
-private:
|
|
|
- CUUID m_SubIDStopRecord;
|
|
|
- bizlog_t *m_log;
|
|
|
- int m_nDesktopType; //0:业务屏,1:信息屏,2:用户桌面
|
|
|
- CSimpleStringA m_strSessionCount;
|
|
|
-};
|
|
|
-
|
|
|
-void ServerSession::Handle_LogFunction(SpOnewayCallContext<LogService_LogFunction_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogFunction(ctx);
|
|
|
-}
|
|
|
-void ServerSession::Handle_LogCustomerID(SpOnewayCallContext<LogService_LogCustomerID_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogCustomerID(ctx);
|
|
|
-}
|
|
|
-void ServerSession::Handle_LogAgreement(SpOnewayCallContext<LogService_LogAgreement_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogAgreement(ctx);
|
|
|
-}
|
|
|
-void ServerSession::Handle_LogReceipt(SpOnewayCallContext<LogService_LogReceipt_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogReceipt(ctx);
|
|
|
-}
|
|
|
-void ServerSession::Handle_LogOperation(SpOnewayCallContext<LogService_LogOperation_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogOperation(ctx);
|
|
|
-}
|
|
|
-void ServerSession::Handle_LogResponse(SpOnewayCallContext<LogService_LogResponse_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogResponse(ctx);
|
|
|
-}
|
|
|
-void ServerSession::Handle_LogAgent(SpOnewayCallContext<LogService_LogAgent_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogAgent(ctx);
|
|
|
-}
|
|
|
-
|
|
|
-void ServerSession::Handle_LogBegin(SpOnewayCallContext<LogService_LogBegin_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogBegin(ctx);
|
|
|
-}
|
|
|
-
|
|
|
-void ServerSession::Handle_LogEnd(SpOnewayCallContext<LogService_LogEnd_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogEnd(ctx);
|
|
|
-}
|
|
|
-
|
|
|
-void ServerSession::Handle_LogCallID(SpOnewayCallContext<LogService_LogCallID_Info>::Pointer ctx)
|
|
|
-{
|
|
|
- DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
- m_pEntity->LogCallID(ctx);
|
|
|
-}
|
|
|
-
|
|
|
-SP_BEGIN_ENTITY_MAP()
|
|
|
- SP_ENTITY(CInterativeLogEntity)
|
|
|
-SP_END_ENTITY_MAP()
|
|
|
-
|