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

📄 revokecertlist.cpp

📁 cisoca_for_mysql 编码
💻 CPP
字号:
/* ====================================================================
 * The Ciso Software License, Version 1.0
 *
 * Copyright (c) 2003-2004 The Chinese Infomation security organization.  
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Ciso(Chinese Infomation Security Organization) Software 
 *        (http://www.infosecurity.org.cn/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 */
#include "stdafx.h"
#include "RevokeCertList.h"

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

#include "RevokeCert.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CRevokeCertList, CObject,0)

CRevokeCertList::CRevokeCertList()
{
	szErrStr[0] = '\0';
}

CRevokeCertList::~CRevokeCertList()
{
	ClearContent();
}
int CRevokeCertList::GetCount()
{
	return m_list.GetCount();
}

int CRevokeCertList::AutoAssemble(MYSQL *pMySQL,
								  CString SNColName, 
								  CString TimeColName)
{
	ClearContent();
	BOOL ret = FALSE;
	CString strSql;
	int RowCount = 0;
	MYSQL_RES *pResUsers = NULL;
	MYSQL_ROW rowUser;

	// 如果没有建立连接,重新建立连接

	if(pMySQL == NULL)
	{
		sprintf(szErrStr,"%s","m_pMySQL == NULL");
		return 0;
	}
	strSql = "select "+SNColName+" , "+TimeColName+" from UserInfo  where CERT_STATE='0'";
	
	// 执行SQL语句得到一个记录集把其指针赋值给Recordset
	
	if(mysql_query(pMySQL,(LPCTSTR)strSql) != 0)
	{
		sprintf(szErrStr,"%s","mysql_query fail");
		return 0;
	}
	
	pResUsers = mysql_store_result(pMySQL);
	while (rowUser = mysql_fetch_row(pResUsers))//遍历所有记录
	{ 		
		// 逐条记录加入列表视图
		
		CString strSN=rowUser[0];
		CString strTime=rowUser[1];
		m_list.AddHead((CObject*)new CRevokeCert(strSN,strTime));
	}
	mysql_free_result(pResUsers);
	return 1;
}

int CRevokeCertList::ClearContent()
{
	szErrStr[0] = '\0';
	if(!m_list.IsEmpty())
	{
		for(int i = 0 ; i < m_list.GetCount(); i++)
		{
			POSITION pos = m_list.FindIndex(i);
			if(pos == NULL)break;
			CRevokeCert *prev = (CRevokeCert*)m_list.GetAt(pos);
			if(prev != NULL)delete prev;
		}
	}
	if(!m_list.IsEmpty())m_list.RemoveAll();
	return 1;
}

void CRevokeCertList::GetErrString(char *pErrStr)
{
	if(pErrStr == NULL)return ;
	// strcpy没有越界检查
	strcpy(pErrStr,szErrStr);
	return;
}

long CRevokeCertList::GetSerialNumber(int position)
{
	sprintf(szErrStr,"第%d个记录不存在!",position);
	if( position > m_list.GetCount() || m_list.IsEmpty()) return -1;
	POSITION pos = m_list.FindIndex(position);
	if(pos == NULL)return -1;
	CRevokeCert *prev = (CRevokeCert*)m_list.GetAt(pos);
	if(prev != NULL) return prev->GetSNWithLong();
	else			 return -1;
}

char * CRevokeCertList::GetTimeStr(int position)
{
	sprintf(szErrStr,"取第%d个记录中时间失败!",position);
	if( position > m_list.GetCount() || m_list.IsEmpty()) return NULL;
	POSITION pos = m_list.FindIndex(position);
	if(pos == NULL)return NULL;
	CRevokeCert *prev = (CRevokeCert*)m_list.GetAt(pos);
	if(prev != NULL) return prev->GetTimeStr();
	else			 return NULL;
}

char * CRevokeCertList::GetSerialStr(int position)
{
	sprintf(szErrStr,"第%d个记录不存在!",position);
	if( position > m_list.GetCount() || m_list.IsEmpty()) return NULL;
	POSITION pos = m_list.FindIndex(position);
	if(pos == NULL)return NULL;
	CRevokeCert *prev = (CRevokeCert*)m_list.GetAt(pos);
	if(prev != NULL) return prev->GetSNStr();
	else			 return NULL;
}

time_t CRevokeCertList::GetTime_t(int position)
{
	sprintf(szErrStr,"取第%d个记录中时间失败!",position);
	if( position > m_list.GetCount() || m_list.IsEmpty()) return -1L;
	POSITION pos = m_list.FindIndex(position);
	if(pos == NULL)return -1L;
	CRevokeCert *prev = (CRevokeCert*)m_list.GetAt(pos);
	if(prev != NULL) return prev->GetTime();
	else			 return -1L;
}

⌨️ 快捷键说明

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