?? datamanager.cpp
字號:
// DataManager.cpp: implementation of the CDataManager class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "monitorclientapp.h"
#include "DataManager.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
CDataLog::CDataLog() : m_strLogFileName("C:\\MonitorLog_Client.INI")
{
}
BOOL CDataLog::SaveLogToFile()
{
if( m_lstLog.GetCount() <= 0 )
return TRUE;
POSITION posLast = m_lstLog.GetTailPosition();
ST_NET_LOGINFO oLogInfo = m_lstLog.GetAt( posLast );
CString strSect;
CString strKey1,strKey2,strKey3,strKey4,strKey5;
CString strVal1,strVal2,strVal3,strVal4,strVal5;
strSect = "LastLog";
strKey1 = "IP";
strKey2 = "Time";
strKey3 = "LogInfo";
strKey4 = "Type";
strKey5 = "AlarmIn";
strVal1.Format( "%s", oLogInfo.cIP );
strVal2.Format( "%s", oLogInfo.cTime );
strVal3.Format( "%s", oLogInfo.cInfo );
strVal4.Format( "%d", oLogInfo.nType );
strVal5.Format( "%d", oLogInfo.nAlarmIn );
WritePrivateProfileString( strSect, strKey1, strVal1, m_strLogFileName );
WritePrivateProfileString( strSect, strKey2, strVal2, m_strLogFileName );
WritePrivateProfileString( strSect, strKey3, strVal3, m_strLogFileName );
WritePrivateProfileString( strSect, strKey4, strVal4, m_strLogFileName );
WritePrivateProfileString( strSect, strKey5, strVal5, m_strLogFileName );
return TRUE;
}
ST_NET_LOGINFO CDataLog::ReadLogFromFile( CString strIP )
{
ST_NET_LOGINFO oLogInfo;
CString strSect, strKey, strVal;
//......
return oLogInfo;
}
ST_NET_LOGINFO CDataLog::ReadLastLogFromFile()
{
ST_NET_LOGINFO oLogInfo;
CString strSect;
CString strKey1,strKey2,strKey3,strKey4,strKey5;
CString strVal1,strVal2,strVal3,strVal4,strVal5;
char cBuf[256];
strSect = "LastLog";
strKey1 = "IP";
strKey2 = "Time";
strKey3 = "LogInfo";
strKey4 = "Type";
strKey5 = "AlarmIn";
GetPrivateProfileString ( strSect, strKey1, "192.168.254.138", oLogInfo.cIP, 16, m_strLogFileName );
GetPrivateProfileString ( strSect, strKey2, "2008-09-22 0:0:0",oLogInfo.cTime, 20, m_strLogFileName );
GetPrivateProfileString ( strSect, strKey3, " ", oLogInfo.cInfo, 255, m_strLogFileName );
GetPrivateProfileString ( strSect, strKey4, "0", cBuf, 255, m_strLogFileName );
oLogInfo.nType = atoi( cBuf );
GetPrivateProfileString ( strSect, strKey5, "0", cBuf, 255, m_strLogFileName );
oLogInfo.nAlarmIn = atoi( cBuf );
return oLogInfo;
}
BOOL CDataLog::AddLog(ST_NET_LOGINFO oLogInfo)
{
m_lstLog.AddTail( oLogInfo );
return TRUE;
}
ST_NET_LOGINFO CDataLog::GetLastLog()
{
ST_NET_LOGINFO oInfo;
if( m_lstLog.GetCount() > 0 )
oInfo = m_lstLog.GetTail();
return oInfo;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -