⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datamanager.cpp

📁 监控软件的客户端: 1.采用select模型; 2.采用多线程进行网络的接收和发送; 3.网络断线自动断开;
💻 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 + -