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

📄 logdboper.cpp

📁 视频播放控制器程序
💻 CPP
字号:
// LogDbOper.cpp: implementation of the CLogDbOper class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "LogDbOper.h"
#include "MySqlOperator.h"
#include "MySqlRecordset.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLogDbOper::CLogDbOper()
{

}

CLogDbOper::~CLogDbOper()
{

}

void CLogDbOper::SetSqlOperator( CMySqlOperator *pSqlOper )
{
	m_pMySqlOper = pSqlOper;
}

CMySqlRecordset* CLogDbOper::SelectAllOperators()
{
	CString strSql = "select * from tbl_operator";
	CMySqlRecordset *pNewRecordSet = NULL;
	HANDLE hMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, MUTEX_SQLOPERATOR );
	if ( hMutex ) WaitForSingleObject( hMutex, 1000 );
	if ( m_pMySqlOper && m_pMySqlOper->IsConnected() )
	{
		pNewRecordSet = m_pMySqlOper->ExecuteQuery( strSql );
	}
	if ( hMutex ) ReleaseMutex(hMutex);
	return pNewRecordSet;
}

CMySqlRecordset* CLogDbOper::SelectLogs( COleDateTime STime, COleDateTime ETime, LPCTSTR szDevID, int nOprtorID )
{
	CString strSTime = STime.Format("%Y-%m-%d %H:%M:%S");
	CString strETime = ETime.Format("%Y-%m-%d %H:%M:%S");
	CString strSql = "select * from tbl_oplog,tbl_operator,tbl_opcode,tbl_dev \
		where oplog_devid = dev_id and opcode_id = oplog_code and oplog_operatorid=operator_id and oplog_time >= '" + strSTime + "' and oplog_time <= '" + strETime + "' ";
	CString strDevID = szDevID;
	if ( strDevID != STR_ALL_DEV )
	{
		strSql = strSql + "and oplog_devid= '" + strDevID + "' ";
	}
	if ( nOprtorID != 0 )
	{
		CString strOprtorID;
		strOprtorID.Format( "%d", nOprtorID );
		strSql = strSql + "and oplog_operatorid=" + strOprtorID;
	}
	strSql = strSql + " ORDER BY oplog_time DESC";
	CMySqlRecordset *pNewRecordSet = NULL;
	HANDLE hMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, MUTEX_SQLOPERATOR );
	if ( hMutex ) WaitForSingleObject( hMutex, 1000 );
	if ( m_pMySqlOper && m_pMySqlOper->IsConnected() )
	{
		pNewRecordSet = m_pMySqlOper->ExecuteQuery( strSql );
	}
	if ( hMutex ) ReleaseMutex(hMutex);
	return pNewRecordSet;
}

BOOL CLogDbOper::DeleteLog( int nLogID )
{
	CString strSql;
	strSql.Format( "%d", nLogID );
	strSql = "delete from tbl_oplog where oplog_id=" + strSql;
	HANDLE hMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, MUTEX_SQLOPERATOR );
	if ( hMutex ) WaitForSingleObject( hMutex, 1000 );
	BOOL rt = FALSE;
	if ( m_pMySqlOper && m_pMySqlOper->IsConnected() )
	{
		rt = m_pMySqlOper->Execute( strSql );
	}
	if ( hMutex ) ReleaseMutex(hMutex);
	return rt;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -