// MBAMBaseDBMgr.cpp : implementation file
|
//
|
|
#include "stdafx.h"
|
#include "mbamdb.h"
|
#include "MBAMBaseDBMgr.h"
|
#include "MBAMDBFun.h"
|
#include "MBAMDBDef.h"
|
|
// CMBAMBaseDBMgr
|
extern CCriticalSection m_csConnectDB;
|
|
CMBAMBaseDBMgr::CMBAMBaseDBMgr()
|
{
|
m_bIsCloseDB = TRUE;
|
m_pDBConnect = NULL;
|
m_arSaveToDBMsg.RemoveAll();
|
m_arSaveToDBCrowdMsg.RemoveAll();
|
m_arBatchSaveToDBSyncMsg.RemoveAll();
|
m_arAMOpenMsg.RemoveAll();
|
m_arBackupDBFile.RemoveAll();
|
}
|
|
CMBAMBaseDBMgr::~CMBAMBaseDBMgr()
|
{
|
m_arSaveToDBMsg.RemoveAll();
|
m_arSaveToDBCrowdMsg.RemoveAll();
|
m_arAMOpenMsg.RemoveAll();
|
}
|
|
|
// CMBAMBaseDBMgr member functions
|
void CMBAMBaseDBMgr::CleanDBConnect( )
|
{
|
//SaveAMMsgsOpenDate();
|
CSingleLock lock( &m_csConnectDB, true );
|
if( m_bIsCloseDB)
|
return;
|
m_bIsCloseDB = TRUE;
|
if ( m_pDBConnect )
|
{
|
m_pDBConnect->Release();
|
m_pDBConnect = NULL;
|
}
|
}
|
int CMBAMBaseDBMgr::Logined( CString strLoginName, CString strPassword, CString strServerID, BOOL &bFirstDB)
|
{
|
bFirstDB = FALSE;
|
CMBAMDBConnect *pDBConnect = NULL;
|
BOOL bIsNew = false;
|
|
strLoginName.MakeLower();
|
m_dwLocalVer = VER_STKCLIENTDB;
|
{
|
if ( m_pDBConnect )
|
{
|
if(m_pDBConnect->IsThisDB( strLoginName, strServerID ))
|
{
|
if( m_pDBConnect->IsOpenDB())
|
{
|
return 0;
|
}
|
}
|
if( m_pDBConnect->IsOpenDB())
|
{
|
CleanDBConnect( );
|
m_pDBConnect = NULL;
|
}
|
}
|
if( !m_pDBConnect)
|
{
|
pDBConnect = new CMBAMDBConnect;
|
try
|
{
|
int nRet = pDBConnect->OpenDB( strLoginName, strServerID, bFirstDB ) ;
|
if(nRet)
|
{
|
delete pDBConnect;
|
pDBConnect = NULL;
|
return nRet;
|
}
|
|
}
|
catch ( ... )
|
{
|
return STKERR_DB_OPENEXCEPTION;
|
}
|
m_pDBConnect = pDBConnect;
|
}
|
m_bIsCloseDB = FALSE;
|
if ( !VerifyDBVersion( m_dwLocalVer ) )
|
{
|
CleanDBConnect( );
|
return STKERR_DB_VERIFYDBVERFERROR;
|
}
|
}
|
SetUserInfo( strLoginName, strPassword );
|
SetDBVersion( m_dwLocalVer );
|
m_strServerID = strServerID;
|
m_strLoginName = strLoginName;
|
//SaveNeedSaveMsg();
|
LoadBackupDBFile();
|
return 0;
|
}
|
int CMBAMBaseDBMgr::CreateDBConnect( CString strLoginName,CString strDBFile)
|
{
|
CMBAMDBConnect *pDBConnect = NULL;
|
BOOL bIsNew = false;
|
|
strLoginName.MakeLower();
|
m_dwLocalVer = VER_STKCLIENTDB;
|
{
|
if ( m_pDBConnect )
|
{
|
if( m_pDBConnect->IsOpenDB())
|
{
|
CleanDBConnect( );
|
m_pDBConnect = NULL;
|
}
|
}
|
if( !m_pDBConnect)
|
{
|
pDBConnect = new CMBAMDBConnect;
|
try
|
{
|
int nRet = pDBConnect->OpenDB( strDBFile ) ;
|
if(nRet)
|
{
|
delete pDBConnect;
|
pDBConnect = NULL;
|
return nRet;
|
}
|
|
}
|
catch ( ... )
|
{
|
return STKERR_DB_OPENEXCEPTION;
|
}
|
m_pDBConnect = pDBConnect;
|
}
|
m_bIsCloseDB = FALSE;
|
}
|
m_strLoginName = strLoginName;
|
return 0;
|
}
|
BOOL CMBAMBaseDBMgr::VerifyDBVersion( DWORD dwVersion )
|
{
|
CString strValue = _T("");
|
DWORD dwDBVersion;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pDBConnect->GetPropertyData( CLASS_DBVERSION, _T( "DBVersion" ),strValue );
|
if ( strValue.IsEmpty() )
|
{
|
return true;
|
}
|
CEncrypt::Decrypt( strValue, PSW_KEY );
|
dwDBVersion = _tstoi( strValue );
|
if ( dwVersion > dwDBVersion )
|
{
|
if( !UpdateNewDBTableInfo(dwDBVersion))
|
{
|
return false;
|
}
|
return true;
|
}
|
return true;
|
}
|
|
CMBAMDBConnect* CMBAMBaseDBMgr::GetMBAMDBConnect( )
|
{
|
if(m_pDBConnect)
|
{
|
m_pDBConnect->AddRef();
|
return m_pDBConnect;
|
}
|
return NULL;
|
}
|
|
//==============================================
|
// ±£´æµÇ¼Óû§µÄ±¾µØÊý¾Ý¿â°æ±¾ÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::SetDBVersion( DWORD dwVersion )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strDWVersion;
|
strDWVersion.Format( _T("%d"), dwVersion );
|
CEncrypt::Encrypt( strDWVersion, PSW_KEY );
|
pDBConnect->SetPropertyData( CLASS_DBVERSION, _T( "DBVersion" ),strDWVersion );
|
return true;
|
}
|
|
//==============================================
|
// ±£´æµÇ¼Óû§µÄÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::SetUserInfo( CString strLogin, CString strPassword )
|
{
|
if ( strLogin.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strDWVersion;
|
CEncrypt::Encrypt( strPassword, PSW_KEY );
|
pDBConnect->SetPropertyData( CLASS_SYSTEM, _T( "LoginName" ),strPassword );
|
return true;
|
}
|
BOOL CMBAMBaseDBMgr::UpdateNewDBTableInfo(int nVer )
|
{
|
return TRUE;
|
}
|
//==============================================
|
// ÒÆ³ý×î½üÁªÏµÈË
|
//==============================================
|
BOOL CMBAMBaseDBMgr::RemoveLastContact( CString strID, int nType)
|
{
|
BOOL bRet;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->RemoveLastContact(strID, nType);
|
pDBConnect->Release();
|
return bRet;
|
}
|
//==============================================
|
// »ñÈ¡×î½üÁªÏµÈË
|
//==============================================
|
BOOL CMBAMBaseDBMgr::LoadLastContact(CArraySTKLastContact &arLastContact, int nLimitCount )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet = pDBConnect->LoadLastContact(arLastContact,nLimitCount );
|
pDBConnect->Release();
|
return true;
|
}
|
BOOL CMBAMBaseDBMgr::GetLastContactItem(CString strID, int nType,stSTKLastContact &itemLastContact )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet = pDBConnect->GetLastContactItem(strID,nType,itemLastContact );
|
pDBConnect->Release();
|
return bRet;
|
}
|
//==============================================
|
// »ñȡָ¶¨Óû§»òÕßȺµÄδ¶ÁÏûÏ¢ÊýÄ¿
|
//==============================================
|
int CMBAMBaseDBMgr::GetUnreadMsgCount( CString strID, int nType)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return 0;
|
int nUnreadCnt = pDBConnect->GetUnreadMsgCount(strID,nType );
|
pDBConnect->Release();
|
return nUnreadCnt;
|
}
|
//==============================================
|
// »ñȡδ¶ÁÏûÏ¢ÊýÄ¿
|
//==============================================
|
int CMBAMBaseDBMgr::GetUnreadMsgCount( )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return 0;
|
int nUnreadCnt = pDBConnect->GetUnreadMsgCount( );
|
pDBConnect->Release();
|
return nUnreadCnt;
|
}
|
//=======================================================
|
// µÃµ½ÏûÏ¢Ö¸¶¨µÄFolderÃû³Æ
|
//=======================================================
|
long CMBAMBaseDBMgr::GetMsgFolderID( long nParentFolderID, CString strFolderName )
|
{
|
if ( strFolderName.IsEmpty() )
|
return 0L;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return 0L;
|
CMsgFolders Folders( pDBConnect );
|
CMsgFolderItem folder;
|
long nFolderID;
|
|
if ( Folders.ListSpFolder( nParentFolderID, strFolderName ) > 0 )
|
{
|
Folders.GetData( );
|
return Folders.m_nID;
|
}
|
nFolderID = Folders.GetMaxFolderID( );
|
if ( nFolderID < FOLDERID_BASE )
|
nFolderID = FOLDERID_BASE;
|
nFolderID++;
|
folder.m_nID = nFolderID;
|
folder.m_strName = strFolderName;
|
folder.m_nParentID = nParentFolderID;
|
Folders.AddFloder( &folder );
|
return nFolderID;
|
}
|
long CMBAMBaseDBMgr::GetMsgFolderID( CString strFolderName )
|
{
|
if ( strFolderName.IsEmpty() )
|
return 0L;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return 0L;
|
long nParentFolderID = 0;
|
long nFolderID = 0;
|
CString strItem;
|
CMsgFolders Folders( pDBConnect );
|
while ( CMBAMDBFun::GetElementItem( strFolderName, strItem, _T( "\\" ) ) )
|
{
|
if ( !strItem.IsEmpty() )
|
{
|
nFolderID = GetMsgFolderID( nParentFolderID, strItem );
|
if ( nFolderID == 0 )
|
break;
|
nParentFolderID = nFolderID;
|
}
|
}
|
return nFolderID;
|
}
|
//==============================================
|
// µÃµ½FolderÃû³Æ
|
//==============================================
|
bool CMBAMBaseDBMgr::GetFolderName( long nFolderID, CString &strFolderName )
|
{
|
strFolderName =_T( "" );
|
|
if ( nFolderID <= 0 )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
CMsgFolders Folders( pDBConnect);
|
|
if ( Folders.ListSpFolder( nFolderID ) <= 0 )
|
return false;
|
Folders.GetData( );
|
strFolderName = Folders.m_strName;
|
return true;
|
}
|
//========================================
|
// ±£´æÏûÏ¢µ½±¾µØÊý¾Ý¿â
|
//========================================
|
BOOL CMBAMBaseDBMgr::SaveSendMulMsgToDB( CMsgItem *pMsg )
|
{
|
BOOL bReturn = false;
|
if ( !pMsg )
|
return false;
|
if ( pMsg->m_strID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
{
|
return false;
|
}
|
CMsgs Msgs( pDBConnect);
|
//pDBConnect->StartTransaction( );
|
bReturn = Msgs.DoSaveSendMulMsg( pMsg);
|
// pDBConnect->Commit( );
|
return bReturn;
|
}
|
//========================================
|
// ±£´æÏûÏ¢µ½±¾µØÊý¾Ý¿â
|
//========================================
|
BOOL CMBAMBaseDBMgr::SaveMsgToDB( CMsgItem *pMsg, long nComfirmFlag/* = 0*/ )
|
{
|
BOOL bReturn = false;
|
if ( !pMsg )
|
return false;
|
if ( pMsg->m_strID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
{
|
m_arSaveToDBMsg.Add(*pMsg);
|
return false;
|
}
|
CMsgs Msgs( pDBConnect);
|
bool bNeedConfirm = false;
|
bool bIsSendMsg = false;
|
|
if ( nComfirmFlag == 0 )
|
bNeedConfirm = false;
|
else
|
bNeedConfirm = true;
|
if(pMsg->m_strSender.CompareNoCase(m_strLoginName) == 0)
|
bIsSendMsg = true;;
|
//pDBConnect->StartTransaction( );
|
bReturn = Msgs.DoSaveMsg( pMsg, bIsSendMsg, bNeedConfirm );
|
// pDBConnect->Commit( );
|
return bReturn;
|
}
|
|
|
void CMBAMBaseDBMgr::AddBatchSaveSyncMsgToDB( CMsgItem *pMsg )
|
{
|
|
m_arBatchSaveToDBSyncMsg.Add(*pMsg);
|
}
|
|
void CMBAMBaseDBMgr::BatchSaveSyncMsgToDB( )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return;
|
CMsgItem itemMsg;
|
try
|
{
|
if(m_arBatchSaveToDBSyncMsg.GetCount() < 1)
|
return;
|
//CSTKDBFun::WriteDBErrToFile( _T("BatchSaveMsgToDB") );
|
pDBConnect->StartTransaction( );
|
for(int i =0; i < m_arBatchSaveToDBSyncMsg.GetCount(); i++)
|
{
|
itemMsg = m_arBatchSaveToDBSyncMsg.GetAt(i);
|
if ( !itemMsg.m_strID.IsEmpty() )
|
{
|
pDBConnect->AddRef();
|
CMsgs Msgs( pDBConnect);
|
bool bNeedConfirm = false;
|
bool bIsSendMsg = false;
|
if ( itemMsg.m_nNeedConfirm == 0 )
|
bNeedConfirm = false;
|
else
|
bNeedConfirm = true;
|
if(itemMsg.m_strSender.CompareNoCase(m_strLoginName) == 0)
|
bIsSendMsg = true;;
|
Msgs.DoSaveSyncMsg( &itemMsg, bIsSendMsg, bNeedConfirm );
|
}
|
}
|
pDBConnect->Commit( );
|
}
|
catch( ... )
|
{
|
pDBConnect->Abort();
|
m_arBatchSaveToDBSyncMsg.RemoveAll();
|
pDBConnect->Release();
|
return;
|
}
|
//CSTKDBFun::WriteDBErrToFile( _T("BatchSaveMsgToDB 2") );
|
m_arBatchSaveToDBSyncMsg.RemoveAll();
|
pDBConnect->Release();
|
return;
|
}
|
void CMBAMBaseDBMgr::SaveNeedSaveMsg()
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return;
|
CMsgItem itemMsg;
|
try
|
{
|
if(m_arSaveToDBMsg.GetCount() > 0)
|
{
|
for(int i =0; i < m_arSaveToDBMsg.GetCount(); i++)
|
{
|
itemMsg = m_arSaveToDBMsg.GetAt(i);
|
if ( !itemMsg.m_strID.IsEmpty() )
|
{
|
pDBConnect->AddRef();
|
CMsgs Msgs( pDBConnect);
|
bool bNeedConfirm = false;
|
bool bIsSendMsg = false;
|
if ( itemMsg.m_nNeedConfirm == 0 )
|
bNeedConfirm = false;
|
else
|
bNeedConfirm = true;
|
if(itemMsg.m_strSender.CompareNoCase(m_strLoginName) == 0)
|
bIsSendMsg = true;;
|
|
Msgs.DoSaveMsg( &itemMsg, bIsSendMsg, bNeedConfirm );
|
|
}
|
}
|
}
|
}
|
catch( ... )
|
{
|
pDBConnect->Release();
|
///pDBConnect->Commit( );
|
//m_arSaveToDBMsg.RemoveAll();
|
return ;
|
}
|
m_arSaveToDBMsg.RemoveAll();
|
try
|
{
|
CCrowdMsgItem itemCrowdMsg;
|
if(m_arSaveToDBCrowdMsg.GetCount() > 0)
|
{
|
pDBConnect->StartTransaction( );
|
for(int i =0; i < m_arSaveToDBCrowdMsg.GetCount(); i++)
|
{
|
itemCrowdMsg = m_arSaveToDBCrowdMsg.GetAt(i);
|
if ( !itemCrowdMsg.m_strID.IsEmpty() )
|
{
|
pDBConnect->AddRef();
|
CCrowdMsgs Msgs( pDBConnect);
|
|
Msgs.DoSaveCrowdMsg( &itemCrowdMsg );
|
|
}
|
}
|
pDBConnect->Commit( );
|
}
|
}
|
catch( ... )
|
{
|
pDBConnect->Abort();
|
pDBConnect->Release();
|
//pDBConnect->Commit( );
|
//m_arSaveToDBCrowdMsg.RemoveAll();
|
return ;
|
}
|
m_arSaveToDBCrowdMsg.RemoveAll();
|
pDBConnect->Release();
|
}
|
|
|
//=======================================================
|
// ÅÉ·¢ÐÅÏ¢
|
// ±¾µØÏûÏ¢
|
//=======================================================
|
void CMBAMBaseDBMgr::DispatchMsg( CMsgItem * pMsgItem )
|
{
|
|
pMsgItem->m_tmDate = COleDateTime::GetCurrentTime();
|
pMsgItem->m_nReadState = pMsgItem->m_nReadState | MSG_READSTATE_DOWNLOAD;
|
|
if ( !(pMsgItem->m_nMsgFlag & MSGFLAG_CLIENT_NOSAVE) )
|
{
|
if ( pMsgItem->m_strFolderName.IsEmpty() )
|
{
|
if ( pMsgItem->m_strSender.CompareNoCase( m_strLoginName ) == 0 )
|
pMsgItem->m_nMsgFolder = FOLDER_BOX_OUT;
|
else
|
pMsgItem->m_nMsgFolder = FOLDER_BOX_IN;
|
}
|
else
|
pMsgItem->m_nMsgFolder = GetMsgFolderID( pMsgItem->m_strFolderName );
|
|
SaveMsgToDB( pMsgItem, 0 );
|
}
|
}
|
|
//========================================
|
// ÅúÁ¿±£´æÏûÏ¢ÒѶÁÐÅÏ¢µ½±¾µØÊý¾Ý¿â
|
//========================================
|
void CMBAMBaseDBMgr::SaveAMMsgsOpenDate( )
|
{
|
CString strLog;
|
CArrayAMOpenMsg arAMOpenMsg;
|
arAMOpenMsg.RemoveAll();
|
{
|
CSingleLock lock( &m_csAMOpenMsg, true );
|
if(m_arAMOpenMsg.GetCount() > 0)
|
{
|
arAMOpenMsg.Copy(m_arAMOpenMsg);
|
m_arAMOpenMsg.RemoveAll();
|
}
|
else
|
return;
|
}
|
try
|
{
|
strLog.Format(_T("SaveAMMsgsOpenDate£¡"));
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return;
|
CMapStringToLong mapGroupSendMsg;
|
stAMOpenMsg itemMsg;
|
CMsgOwners msgOwners( pDBConnect );
|
CMsgs Msgs( pDBConnect );
|
CHighTime tmCur;
|
SYSTEMTIME tmSystem;
|
mapGroupSendMsg.RemoveAll();
|
pDBConnect->AddRef();
|
pDBConnect->StartTransaction( );
|
for(int i=0;i < arAMOpenMsg.GetCount();i++)
|
{
|
itemMsg = arAMOpenMsg.GetAt(i);
|
if ( Msgs.ListSpMsgID( itemMsg.strMsgID ) <= 0 )
|
break ;
|
Msgs.GetMsgData( );
|
if ( itemMsg.strOpenDate.IsEmpty() || !tmCur.ParseDateTime( itemMsg.strOpenDate ) )
|
tmCur = tmCur.GetPresentTime( true );
|
tmCur.GetAsSystemTime( tmSystem );
|
if ( tmSystem.wSecond < 0 )
|
tmSystem.wSecond = 0;
|
if( !Msgs.m_nIsGroupSend)
|
{
|
Msgs.m_nReadState = Msgs.m_nReadState | MSG_READSTATE_IOPEN | MSG_READSTATE_ALL;
|
Msgs.m_tmOpenDate = COleDateTime( tmSystem.wYear, tmSystem.wMonth, tmSystem.wDay,
|
tmSystem.wHour, tmSystem.wMinute, tmSystem.wSecond );
|
|
Msgs.UpdateRecord( pDBConnect->GetDBConnect() );
|
}
|
else
|
{
|
if ( msgOwners.ListSpMsgID( itemMsg.strMsgID, itemMsg.strUser ) != 0 )
|
{
|
msgOwners.GetData( );
|
msgOwners.m_tmOpenDate = COleDateTime( tmSystem.wYear, tmSystem.wMonth, tmSystem.wDay,
|
tmSystem.wHour, tmSystem.wMinute, tmSystem.wSecond );
|
|
msgOwners.UpdateRecord( pDBConnect->GetDBConnect() );
|
}
|
mapGroupSendMsg.SetAt( itemMsg.strMsgID, Msgs.m_nReadState );
|
}
|
}
|
pDBConnect->Commit( );
|
|
if(mapGroupSendMsg.GetCount() > 0)
|
{
|
CString strMsgID;
|
long nTempReadState;
|
long nReadState;
|
pDBConnect->StartTransaction( );
|
for(POSITION pos= mapGroupSendMsg.GetStartPosition();pos;pos)
|
{
|
mapGroupSendMsg.GetNextAssoc(pos, strMsgID, nReadState);
|
msgOwners.ListSpMsgID( strMsgID );
|
nTempReadState = MSG_READSTATE_IOPEN | MSG_READSTATE_DOWNLOAD | MSG_READSTATE_ALL;
|
do
|
{
|
msgOwners.GetData( );
|
if ( msgOwners.m_tmOpenDate.GetYear() <= 1990 )
|
{
|
nTempReadState = MSG_READSTATE_IOPEN | MSG_READSTATE_DOWNLOAD | MSG_READSTATE_LITTLE;
|
break;
|
}
|
|
}while (msgOwners.MoveNext());
|
if(nReadState != nTempReadState)
|
{
|
Msgs.ListSpMsgID( strMsgID );
|
Msgs.GetMsgData();
|
Msgs.m_nReadState = nTempReadState;
|
Msgs.UpdateRecord( pDBConnect->GetDBConnect() );
|
}
|
}
|
pDBConnect->Commit( );
|
}
|
}
|
catch( ... )
|
{
|
strLog.Format(_T("SaveAMMsgsOpenDateÒì³£"));
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
return;
|
}
|
strLog.Format(_T("SaveAMMsgsOpenDate½áÊø"));
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
}
|
//========================================
|
// ±£´æÏûÏ¢µ½±¾µØÊý¾Ý¿â
|
//========================================
|
BOOL CMBAMBaseDBMgr::SaveSendMsgToDB( CMsgItem *pMsg, long nComfirmFlag/* = 0*/ )
|
{
|
BOOL bReturn = false;
|
if ( !pMsg )
|
{
|
CString strLog;
|
strLog.Format(_T("SaveSendMsgToDB MsgÒì³££¡"));
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
return false;
|
}
|
if ( pMsg->m_strID.IsEmpty() )
|
{
|
CString strLog;
|
strLog.Format(_T("SaveSendMsgToDB ÏûÏ¢IDΪ¿Õ£¡"));
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
return false;
|
}
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
{
|
CString strLog;
|
strLog.Format(_T("SaveSendMsgToDB GetMBAMDBConnectʧ°Ü£¡"));
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
return false;
|
}
|
CMsgs Msgs( pDBConnect);
|
bool bNeedConfirm = false;
|
if ( nComfirmFlag == 0 )
|
bNeedConfirm = true;
|
else
|
bNeedConfirm = false;
|
// pDBConnect->StartTransaction( );
|
bReturn = Msgs.DoSaveMsg( pMsg, true, bNeedConfirm );
|
// pDBConnect->Commit( );
|
return bReturn;
|
}
|
//==============================================
|
// ¸üÐÂÏûÏ¢½ÓÊÕÕß
|
//==============================================
|
BOOL CMBAMBaseDBMgr::UpdateMsgOwnerOpened( CString strMsgID, CString strOwner, CString strOpenDate )
|
{
|
if ( strMsgID.IsEmpty() || strOwner.IsEmpty() )
|
return FALSE;
|
stAMOpenMsg itemMsg;
|
itemMsg.strMsgID = strMsgID;
|
itemMsg.strUser = strOwner;
|
itemMsg.strUser.MakeLower();
|
itemMsg.strOpenDate = strOpenDate;
|
{
|
CSingleLock lock( &m_csAMOpenMsg, true );
|
m_arAMOpenMsg.Add(itemMsg);
|
}
|
return TRUE;
|
}
|
|
bool CMBAMBaseDBMgr::SetMsgReaded( CString strMsgID )
|
{
|
if ( strMsgID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
CMsgs Msgs( pDBConnect);
|
if ( Msgs.ListSpMsgID( strMsgID ) <= 0 )
|
{
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return false;
|
}
|
|
Msgs.GetMsgData( );
|
if( Msgs.m_nReadState & MSG_READSTATE_IOPEN )
|
{
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return true;
|
}
|
|
// ÉèÖôò¿ªµÄ״̬
|
COleDateTime tmCur;
|
SYSTEMTIME tmSys;
|
tmCur = COleDateTime::GetCurrentTime();
|
tmCur.GetAsSystemTime( tmSys );
|
if ( tmSys.wSecond < 0 )
|
tmSys.wSecond = 0;
|
Msgs.m_tmOpenDate = COleDateTime( tmSys.wYear, tmSys.wMonth, tmSys.wDay,
|
tmSys.wHour, tmSys.wMinute, tmSys.wSecond );
|
|
Msgs.m_nReadState = Msgs.m_nReadState | MSG_READSTATE_IOPEN;
|
Msgs.UpdateRecord( pDBConnect->GetDBConnect() );
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
// ÉèÖÃÎÒ´ò¿ªÏûÏ¢µÄʱ¼ä
|
pDBConnect->AddRef();
|
CMsgOwners msgOwners(pDBConnect );
|
if ( msgOwners.ListSpMsgID( strMsgID, m_strLoginName ) != 0 )
|
{
|
msgOwners.GetData( );
|
if ( msgOwners.m_tmOpenDate.GetYear() <= 1990 )
|
{
|
tmCur = COleDateTime::GetCurrentTime();
|
tmCur.GetAsSystemTime( tmSys );
|
if ( tmSys.wSecond < 0 )
|
tmSys.wSecond = 0;
|
msgOwners.m_tmOpenDate = COleDateTime( tmSys.wYear, tmSys.wMonth, tmSys.wDay,
|
tmSys.wHour, tmSys.wMinute, tmSys.wSecond );
|
|
msgOwners.UpdateRecord( pDBConnect->GetDBConnect() );
|
}
|
}
|
return true;
|
}
|
|
BOOL CMBAMBaseDBMgr::SetCrowdMsgReaded(CString strMsgID )
|
{
|
if ( strMsgID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
CCrowdMsgs CrowdMsgs( pDBConnect );
|
|
if ( CrowdMsgs.ListSpMsgID( strMsgID ) <= 0 )
|
return false;
|
CrowdMsgs.GetMsgData( );
|
if( CrowdMsgs.m_nReadState & MSG_READSTATE_IOPEN )
|
return true;
|
CrowdMsgs.m_nReadState = CrowdMsgs.m_nReadState | MSG_READSTATE_IOPEN;
|
{
|
CrowdMsgs.UpdateRecord( pDBConnect->GetDBConnect() );
|
}
|
return true;
|
}
|
|
bool CMBAMBaseDBMgr::SetMsgIgnore( CString strMsgID )
|
{
|
if ( strMsgID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
|
CMsgs Msgs( pDBConnect );
|
|
if ( Msgs.ListSpMsgID( strMsgID ) <= 0 )
|
{
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return false;
|
}
|
Msgs.GetMsgData( );
|
Msgs.m_nReadState = MSG_READSTATE_IGNORE;
|
{
|
Msgs.UpdateRecord( pDBConnect->GetDBConnect() );
|
}
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return true;
|
|
}
|
bool CMBAMBaseDBMgr::SetCrowdMsgIgnore( CString strMsgID )
|
{
|
if ( strMsgID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
CCrowdMsgs Msgs( pDBConnect );
|
if ( Msgs.ListSpMsgID( strMsgID ) <= 0 )
|
{
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return false;
|
}
|
Msgs.GetMsgData( );
|
Msgs.m_nReadState = MSG_READSTATE_IGNORE;
|
{
|
Msgs.UpdateRecord( pDBConnect->GetDBConnect() );
|
}
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return true;
|
|
}
|
//=========================================================
|
// µÃµ½ÈËÔ±ÏêϸÐÅÏ¢
|
//=========================================================
|
BOOL CMBAMBaseDBMgr::LoadUserInfo( CString strLogin, CString &strXml, int &nVer)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass, strName;
|
CString strValue = _T("");
|
BOOL bRet;
|
|
strClass = _T("_UserInfo");
|
strName = strLogin;
|
|
bRet = pDBConnect->GetPropStringData(strClass,strName, nVer,strValue,strXml);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::SaveUserInfo( CString strLogin, CString strXml, int nVer)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass, strName;
|
CString strValue = _T("");
|
BOOL bRet;
|
|
strClass = _T("_UserInfo");
|
strName = strLogin;
|
|
bRet = pDBConnect->UpdatePropStringData(strClass,strName, nVer,strValue,strXml);
|
pDBConnect->Release();
|
return bRet;
|
}
|
|
BOOL CMBAMBaseDBMgr::LoadUserInfoVer( CString strLogin, int &nVer)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass, strName;
|
CString strValue = _T("");
|
BOOL bRet;
|
|
strClass = _T("_UserInfo");
|
strName = strLogin;
|
|
bRet = pDBConnect->GetPropVersion(strClass,strName, nVer);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::UpdateUserAttitude(CString strID, CString strUser, CString strAttitude)
|
{
|
BOOL bReturn = false;
|
if ( strID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
{
|
return false;
|
}
|
if( !pDBConnect->IsOpenDB())
|
{
|
pDBConnect->Release();
|
return FALSE;
|
}
|
CMsgItem itemMsg;
|
itemMsg.m_strID = strID;
|
itemMsg.UpdateUserAttitude(pDBConnect->GetDBConnect(), strAttitude);
|
CMsgOwnerItem itemMsgOwner;
|
itemMsgOwner.m_strOwner = strUser;
|
itemMsgOwner.m_strMsgID = strID;
|
itemMsgOwner.UpdateUserAttitude(pDBConnect->GetDBConnect(), strAttitude);
|
pDBConnect->Release();
|
return bReturn;
|
}
|
BOOL CMBAMBaseDBMgr::HasMsg( CString strMsgID )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
//CSTKDBFun::WriteDBErrToFile( _T("HasMsg ") );
|
int nCount = pDBConnect->CheckMsgExist(strMsgID);
|
pDBConnect->Release();
|
//CSTKDBFun::WriteDBErrToFile( _T("HasMsg 2") );
|
if(nCount > 0)
|
return TRUE;
|
return FALSE;
|
}
|
bool CMBAMBaseDBMgr::ListTalking3(CString strStartDate,CString strEndDate, CString strUser, CSTKMsgRowSet *pMsgRowSet ,long nLimitCount,long &nCount, BOOL bTimeAsc )
|
{
|
{
|
strUser.MakeLower();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListTalking3(strUser,nLimitCount, nCount, bTimeAsc);
|
pDBConnect->Release();
|
}
|
//pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListTalking2(CString strStartDate,CString strEndDate, CString strUser, CSTKMsgRowSet *pMsgRowSet ,long nLimitCount,long &nCount, BOOL bTimeAsc )
|
{
|
{
|
strUser.MakeLower();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListTalking2(strUser,nLimitCount, nCount, bTimeAsc);
|
pDBConnect->Release();
|
}
|
//pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListTalking(CString strStartDate,CString strEndDate, CString strUser, CSTKMsgRowSet *pMsgRowSet ,long &nCount,bool bOnlyAttachmentMsg,bool bGroupSend, BOOL bTimeAsc )
|
{
|
DWORD dwTickCount;
|
DWORD dwTickCount2;
|
DWORD dwInterset;
|
DWORD dwInterset2;
|
strUser.MakeLower();
|
//CSTKDBFun::WriteDBErrToFile(_T("CMBAMBaseDBMgr::ListTalking 1"));
|
{
|
dwTickCount = ::GetTickCount();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
dwTickCount2 = ::GetTickCount();
|
dwInterset = dwTickCount2 - dwTickCount;
|
//CSTKDBFun::WriteDBErrToFile(_T("CMBAMBaseDBMgr::ListTalking 2"));
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListTalking(strUser,nCount,bOnlyAttachmentMsg,bGroupSend,bTimeAsc);
|
dwTickCount2 = ::GetTickCount();
|
dwInterset2 = dwTickCount2 - dwTickCount;
|
pDBConnect->Release();
|
}
|
//pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
//strLog.Format(_T("CMBAMBaseDBMgr::ListTalking ²éѯʱ¼ä(%d-%d-%d-%d)"),dwInterset,dwInterset2);
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSearchingTalking(CString strStartDate,CString strEndDate, CString strUser, CString strKey,bool bOnlyAttachmentMsg, CSTKMsgRowSet *pMsgRowSet, long &nCount,bool bGroupSend , BOOL bTimeAsc )
|
{
|
{
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListSearchingTalking(strUser,strKey,bOnlyAttachmentMsg, nCount,bGroupSend, bTimeAsc);
|
pDBConnect->Release();
|
}
|
//pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListTalkingAllMsg(CString strStartDate,CString strEndDate, CString strUser, CSTKMsgRowSet *pMsgRowSet ,long &nCount, BOOL bTimeAsc )
|
{
|
DWORD dwTickCount;
|
DWORD dwTickCount2;
|
DWORD dwInterset;
|
DWORD dwInterset2;
|
strUser.MakeLower();
|
//CSTKDBFun::WriteDBErrToFile(_T("CMBAMBaseDBMgr::ListTalking 1"));
|
{
|
dwTickCount = ::GetTickCount();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
dwTickCount2 = ::GetTickCount();
|
dwInterset = dwTickCount2 - dwTickCount;
|
//CSTKDBFun::WriteDBErrToFile(_T("CMBAMBaseDBMgr::ListTalking 2"));
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListTalkingAllMsg(strUser,nCount,bTimeAsc);
|
dwTickCount2 = ::GetTickCount();
|
dwInterset2 = dwTickCount2 - dwTickCount;
|
pDBConnect->Release();
|
}
|
//pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
//strLog.Format(_T("CMBAMBaseDBMgr::ListTalking ²éѯʱ¼ä(%d-%d-%d-%d)"),dwInterset,dwInterset2);
|
//CSTKDBFun::WriteDBErrToFile(strLog);
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSearchingTalkingAllMsg(CString strStartDate,CString strEndDate, CString strUser, CString strKey, CSTKMsgRowSet *pMsgRowSet, long &nCount, BOOL bTimeAsc )
|
{
|
{
|
|
CSingleLock lock( &m_csConnectDB, true );
|
strUser.MakeLower();
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListSearchingTalkingAllMsg(strUser,strKey,nCount, bTimeAsc);
|
pDBConnect->Release();
|
}
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListCrowdMsg2(CString strStartDate,CString strEndDate, CString strCrowdID, CCrowdMsgRowSet *pMsgRowSet ,long nLimitCount, long &nCount, BOOL bTimeAsc )
|
{
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListCrowdMsg2(strCrowdID, nLimitCount, nCount, bTimeAsc);
|
pDBConnect->Release();
|
}
|
//pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListCrowdMsg(CString strStartDate,CString strEndDate, CString strCrowdID, CCrowdMsgRowSet *pMsgRowSet , long &nCount, BOOL bTimeAsc )
|
{
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListCrowdMsg(strCrowdID, nCount, bTimeAsc);
|
pDBConnect->Release();
|
}
|
//pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSearchCrowdMsg(CString strStartDate,CString strEndDate, CString strCrowdID, CString strKey, CCrowdMsgRowSet *pMsgRowSet , long &nCount, BOOL bTimeAsc )
|
{
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListSearchCrowdMsg(strCrowdID,strKey, nCount, bTimeAsc);
|
pDBConnect->Release();
|
}
|
// pMsgRowSet->ListRecordCount(nCount);
|
//pMsgRowSet->Top();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListReceiveBoxMsg(CString strStartDate,CString strEndDate, CString strSender,CString strSenderName,CString strContentKey, int nAttach, CSTKMsgRowSet *pMsgRowSet,long &nCount )
|
{
|
strSender.MakeLower();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListReceiveBoxMsg(strSender,strSenderName,strContentKey,nAttach,nCount);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSendBoxMsg(CString strStartDate,CString strEndDate, CString strReceiver,CString strReceiverName,CString strContentKey, int nAttach, CSTKMsgRowSet *pMsgRowSet,long &nCount )
|
{
|
strReceiver.MakeLower();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListSendBoxMsg(strReceiver,strReceiverName,strContentKey,nAttach,nCount);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListFavBoxMsg(CString strStartDate,CString strEndDate, CString strSender,CString strSenderName, CString strContentKey,int nFavFolder, CSTKMsgRowSet *pMsgRowSet,long &nCount )
|
{
|
strSender.MakeLower();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListFavBoxMsg(strSender,strSenderName,strContentKey,nFavFolder,nCount);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSysBoxMsg(CString strStartDate,CString strEndDate, CSTKMsgRowSet *pMsgRowSet,long &nCount )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListSysBoxMsg(nCount);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSyncBoxMsg(CString strSynchDate,CSTKMsgRowSet *pMsgRowSet,long &nCount )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->ListSyncBoxMsg(strSynchDate,nCount);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListMsgAttachment(CString strStartDate,CString strEndDate, CString strSender,CString strSenderName, CString strKey,CSTKMsgRowSet *pMsgRowSet,long &nCount )
|
{
|
strSender.MakeLower();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListAttachments(strSender,strSenderName,strKey,nCount);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSearchingTalkingMsg(CString strStartDate,CString strEndDate, CString strUser, CString strKey, CSTKMsgRowSet *pMsgRowSet, long &nCount, BOOL bTimeAsc )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
strUser.MakeLower();
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListSearchingTalkingMsg(strUser,strKey,nCount, bTimeAsc);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListSearchCrowdMsgBox(CString strStartDate,CString strEndDate, CString strCrowdID, CString strKey,CCrowdMsgRowSet *pMsgRowSet, long &nCount, BOOL bTimeAsc )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->SetMsgFilterDate(strStartDate, strEndDate);
|
pMsgRowSet->ListSearchCrowdMsgBox(strCrowdID,strKey, nCount, bTimeAsc);
|
pDBConnect->Release();
|
return true;
|
}
|
BOOL CMBAMBaseDBMgr::ClearReceiveBoxMsg(CString strStartDate,CString strEndDate, CString strSender,CString strSenderName,CString strContentKey, int nAttach)
|
{
|
BOOL bRet;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->ClearReceiveBoxMsg(strStartDate, strEndDate , strSender,strSenderName,strContentKey,nAttach);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::ClearSendBoxMsg(CString strStartDate,CString strEndDate,CString strReceiver,CString strReceiverName,CString strContentKey, int nAttach)
|
{
|
BOOL bRet;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->ClearSendBoxMsg(strStartDate, strEndDate,strReceiver,strReceiverName,strContentKey,nAttach );
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::ClearSysBoxMsg(CString strStartDate,CString strEndDate)
|
{
|
BOOL bRet;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->ClearSysBoxMsg(strStartDate, strEndDate );
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::ClearFavBoxMsg(CString strStartDate,CString strEndDate, CString strContentKey, int nFavFolder)
|
{
|
BOOL bRet;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->ClearFavBoxMsg(strStartDate, strEndDate,strContentKey, nFavFolder);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::ClearCrowdMsgBox(CString strStartDate,CString strEndDate, CString strCrowdID, CString strKey)
|
{
|
BOOL bRet;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->ClearCrowdMsgBox(strStartDate, strEndDate,strCrowdID, strKey);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::GetMsgFileInfo( CString strMsgID, CString strFileID, CString &strFileName,
|
CString &strFileSflag, __int64 &nFileSize )
|
{
|
BOOL bRet;
|
|
if(strFileID.IsEmpty())
|
return FALSE;
|
strFileSflag = _T("");
|
strFileName = _T("");
|
nFileSize = 0;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->GetMsgFileInfo(strMsgID,strFileID,strFileName, strFileSflag, nFileSize );
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::GetMsgFilesInfo( CString strMsgID,CStringArray &arAttachID)
|
{
|
BOOL bRet;
|
|
if(strMsgID.IsEmpty())
|
return FALSE;
|
//CString strFileSflag = _T("");
|
arAttachID.RemoveAll();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->GetMsgFilesInfo(strMsgID,arAttachID);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::GetMsgFilePath(CString strMsgID, CString strFileID, CString &strFilePath )
|
{
|
BOOL bRet;
|
|
if(strFileID.IsEmpty())
|
return FALSE;
|
strFilePath = _T("");
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
bRet = pDBConnect->GetMsgFilePath(strMsgID,strFileID,strFilePath );
|
pDBConnect->Release();
|
return bRet;
|
}
|
|
BOOL CMBAMBaseDBMgr::SetMsgFilePath(CString strMsgID, CString strFileID, CString strFilePath )
|
{
|
BOOL bRet;
|
|
if(strFileID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
|
bRet = pDBConnect->SetMsgFilePath(strMsgID,strFileID,strFilePath );
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::ListUnReadCrowdMsg( CObList &listMsg )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
//CSTKDBFun::WriteDBErrToFile(_T("CMBAMBaseDBMgr::ListUnReadCrowdMsg"));
|
int nMsgCount, nMsgIndex;
|
CCrowdMsgs msgs( pDBConnect );
|
CCrowdMsgItem *pMsg = NULL;
|
nMsgCount = msgs.ListUnreadMsg( );
|
for ( nMsgIndex = 0; nMsgIndex < nMsgCount; nMsgIndex++ )
|
{
|
pMsg = new CCrowdMsgItem;
|
listMsg.AddTail( (CObject*)pMsg );
|
pMsg->m_strID = msgs.m_strID;
|
pMsg->m_strCrowdID = msgs.m_strCrowdID;
|
pMsg->m_strCrowdName = msgs.m_strCrowdName;
|
pMsg->m_strSender = msgs.m_strSender;
|
pMsg->m_strSenderName = msgs.m_strSenderName;
|
pMsg->m_nReadState = msgs.m_nReadState;
|
|
if ( pMsg->m_strSenderName.IsEmpty() )
|
{
|
pMsg->m_strSenderName = pMsg->m_strSender;
|
}
|
pMsg->m_tmDate = msgs.m_tmDate;
|
pMsg->m_strContent = msgs.m_strContent;
|
pMsg->m_nMsgFlag = msgs.m_nMsgFlag;
|
msgs.MoveNext();
|
}
|
// CSTKDBFun::WriteDBErrToFile(_T("CMBAMBaseDBMgr::ListUnReadCrowdMsg 2"));
|
return true;
|
}
|
|
BOOL CMBAMBaseDBMgr::ListUnReadMsg( CObList &listMsg )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
pDBConnect->ListUnReadMsg(listMsg);
|
pDBConnect->Release();
|
return true;
|
}
|
|
BOOL CMBAMBaseDBMgr::LoadUserPictureVer( CString strLoginName, int &nVer )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
|
CString strClass, strName;
|
BOOL bRet;
|
strClass = _T("_UserPicture");
|
strName = strLoginName;
|
|
bRet = pDBConnect->GetPropVersion(strClass,strName, nVer);
|
pDBConnect->Release();
|
if( !bRet)
|
return FALSE;
|
return TRUE;
|
}
|
BOOL CMBAMBaseDBMgr::SaveUserPictureVer( CString strLoginName, int nVer )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return false;
|
CString strClass, strName;
|
CString strFileDir;
|
BOOL bRet;
|
int nTmpVer = 0;
|
|
strClass = _T("_UserPicture");
|
strName = strLoginName;
|
nTmpVer= nVer;
|
if(nTmpVer <= 0)
|
{
|
LoadUserPictureVer(strLoginName, nTmpVer) ;
|
nTmpVer++;
|
}
|
bRet = pDBConnect->SetPropVersion(strClass,strName, nTmpVer);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::SaveCrowdMsg( CCrowdMsgItem *pMsg)
|
{
|
BOOL bReturn = false;
|
if ( !pMsg )
|
return false;
|
if ( pMsg->m_strID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
{
|
m_arSaveToDBCrowdMsg.Add(*pMsg);
|
return false;
|
}
|
CCrowdMsgs Msgs( pDBConnect);
|
pDBConnect->StartTransaction( );
|
bReturn = Msgs.DoSaveCrowdMsg( pMsg );
|
pDBConnect->Commit( );
|
return bReturn;
|
}
|
//==============================================
|
// ÉèÖÃÏûÏ¢µÄ´ò¿ª³ö´í
|
//==============================================
|
bool CMBAMBaseDBMgr::SetMsgReadError( CString strMsgID )
|
{
|
if ( strMsgID.IsEmpty() )
|
return false;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
|
CMsgs Msgs( pDBConnect );
|
if ( Msgs.ListSpMsgID( strMsgID ) <= 0 )
|
{
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return false;
|
}
|
Msgs.GetMsgData( );
|
if( Msgs.m_nReadState & MSG_READSTATE_ERROR )
|
{
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return true;
|
}
|
// ÉèÖôò¿ªµÄ״̬
|
Msgs.m_nReadState = Msgs.m_nReadState | MSG_READSTATE_ERROR;
|
Msgs.UpdateRecord( pDBConnect->GetDBConnect() );
|
pDBConnect->RemoveUnreadMsg(strMsgID);
|
return true;
|
}
|
//==============================================
|
// ɾ³ýȺÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::DeletCrowdMsg( CString strMsgID,CString strGroupID)
|
{
|
if(strMsgID.IsEmpty() || strGroupID.IsEmpty() )
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->DeletCrowdMsg(strMsgID,strGroupID);
|
pDBConnect->Release();
|
return bRet;
|
}
|
//==============================================
|
// ɾ³ýȺ¹²ÏíÎļþÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::DeleteGroupFileInfo( CString strGroupID, CString strShareID )
|
{
|
if(strShareID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->DeleteGroupFileInfo(strGroupID,strShareID);
|
pDBConnect->Release();
|
return bRet;
|
}
|
//==============================================
|
// ×°ÔØÈº¹²ÏíÎļþÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::UpdateGroupFileInfo( CString strGroupID, CString strShareID, CString strFilePath, CString strFileName, __int64 nFileSize )
|
{
|
if(strShareID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->UpdateGroupFileInfo(strGroupID,strShareID, strFilePath,strFileName ,nFileSize );
|
pDBConnect->Release();
|
return bRet;
|
}
|
//==============================================
|
// Ìí¼ÓÊÕµ½Èº¹²ÏíÎļþÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::AddGroupFileInfo( CString strGroupID, CString strShareID, CString strFileName, __int64 nFileSize )
|
{
|
if(strShareID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->AddGroupFileInfo(strGroupID,strShareID, strFileName, nFileSize);
|
pDBConnect->Release();
|
return bRet;
|
}
|
//==============================================
|
// ×°ÔØÈº¹²ÏíÎļþÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::LoadGroupFilePath( CString strGroupID, CString strShareID, CString &strFilePath )
|
{
|
strFilePath = _T("");
|
if(strShareID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->LoadGroupFilePath(strGroupID,strShareID, strFilePath);
|
pDBConnect->Release();
|
if(strFilePath.IsEmpty())
|
return FALSE;
|
return bRet;
|
}
|
//==============================================
|
// ×°ÔØÈº¹²ÏíÎļþÐÅÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::LoadGroupFileInfo( CString strGroupID, CString strShareID, CString &strFileName, __int64 &nFileSize )
|
{
|
strFileName = _T("");
|
nFileSize = 0;
|
if(strShareID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->LoadGroupFileInfo(strGroupID,strShareID, strFileName,nFileSize );
|
pDBConnect->Release();
|
if(strFileName.IsEmpty())
|
return FALSE;
|
return bRet;
|
}
|
|
BOOL CMBAMBaseDBMgr::LoadGroupFileInfo2( CString strGroupID, CString strShareID, CString &strFileName, CString &strFilePath, __int64 &nFileSize )
|
{
|
strFileName = _T("");
|
nFileSize = 0;
|
if(strShareID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->LoadGroupFileInfo2(strGroupID,strShareID, strFileName,strFilePath,nFileSize );
|
pDBConnect->Release();
|
if(strFileName.IsEmpty())
|
return FALSE;
|
return bRet;
|
}
|
|
BOOL CMBAMBaseDBMgr::LoadMsgFromDB( CString strMsgID, CMsgItem *pMsg )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CMsgs msgs(pDBConnect);
|
int nCount= msgs.ListSpMsgID(strMsgID);
|
if(nCount > 0)
|
{
|
msgs.GetData();
|
*pMsg = msgs;
|
|
long nPropertyCount = 0;
|
long nNum = 0;
|
CString strAttribName;
|
CString strAttribValue;
|
CString strAttitudeset;
|
CString strRightButton;
|
CString strAttitudeOk;
|
|
if ( pMsg->m_nMsgFlag & MSGFLAG_RESERTBUTTON )
|
{
|
strAttitudeset = pMsg->m_strAttitudeset ;
|
|
//Row.GetProp( (_T("rightbutton")), strRightButton );
|
if ( !strAttitudeset.IsEmpty() )
|
pMsg->SetProp( _T("attitudeset"), strAttitudeset );
|
if ( !strRightButton.IsEmpty() )
|
{
|
strAttitudeOk.Format( _T("%d"), pMsg->IsAttitudeOk( strRightButton ) );
|
pMsg->SetProp( _T("attitudeok"), strAttitudeOk );
|
}
|
}
|
|
return TRUE;
|
}
|
return FALSE;
|
|
}
|
BOOL CMBAMBaseDBMgr::LoadMsgAttachmentFromDB( CString strMsgID, CString strFileID, CMsgAttachmentItem *pMsg )
|
{
|
|
if ( strMsgID.IsEmpty() || strFileID.IsEmpty() )
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CMsgAttachments msgAttachments(pDBConnect);
|
int nCount= msgAttachments.ListSpMsgID(strMsgID,strFileID);
|
if(nCount > 0)
|
{
|
msgAttachments.GetData();
|
*pMsg = msgAttachments;
|
return TRUE;
|
}
|
return FALSE;
|
|
}
|
//==============================================
|
// ɾ³ýÏûÏ¢
|
//==============================================
|
BOOL CMBAMBaseDBMgr::DeleteMsgFromDB( CString strMsgID)
|
{
|
if(strMsgID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->DeleteMsgFromDB(strMsgID);
|
pDBConnect->Release();
|
return bRet;
|
}
|
bool CMBAMBaseDBMgr::ListMsg(CString strDate,CString strSender,long nLimitCount,CArrayShortMsg &arUserMsg,BOOL bTimeAsc )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pDBConnect->ListMsg(strDate,strSender,nLimitCount,arUserMsg, bTimeAsc);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::ListMsg2(CString strDate,CString strExtType,long nLimitCount,CArrayShortMsg &arUserMsg,BOOL bTimeAsc )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pDBConnect->ListMsg2(strDate,strExtType,nLimitCount,arUserMsg, bTimeAsc);
|
pDBConnect->Release();
|
return true;
|
}
|
|
bool CMBAMBaseDBMgr::MoveMsg( CString strMsgID, long nNewFolderID )
|
{
|
if ( strMsgID.IsEmpty() || nNewFolderID <= 0 )
|
return false;
|
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CMsgs msgs( pDBConnect );
|
return msgs.MoveMsg(strMsgID, nNewFolderID);
|
}
|
bool CMBAMBaseDBMgr::ListFolder(long nParentFolderID, CSTKMsgRowSet *pMsgRowSet, long &nCount)
|
{
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pMsgRowSet->SetDBConnect(pDBConnect);
|
pMsgRowSet->ListFolder(nParentFolderID, nCount);
|
pDBConnect->Release();
|
}
|
pMsgRowSet->ListRecordCount(nCount);
|
pMsgRowSet->Top();
|
return true;
|
}
|
//==============================================
|
// ɾ³ýÊղؼÐ
|
//==============================================
|
BOOL CMBAMBaseDBMgr::DeleteFolder(long nFolderID,int nMoveMsg)
|
{
|
if(nFolderID < FOLDERID_BASE)
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
BOOL bRet;
|
bRet = pDBConnect->DeleteFolder( nFolderID,nMoveMsg);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::LoadCrowdMsgFromDB( CString strMsgID, CCrowdMsgItem *pMsg )
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CCrowdMsgs msgs(pDBConnect);
|
int nCount= msgs.ListSpMsgID(strMsgID);
|
if(nCount > 0)
|
{
|
msgs.GetData();
|
*pMsg = msgs;
|
return TRUE;
|
}
|
return FALSE;
|
|
}
|
bool CMBAMBaseDBMgr::GetSendPerson( CArrayAMObject &arAMObject)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pDBConnect->GetSendPerson(arAMObject);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::GetReceivePerson( CArrayAMObject &arAMObject)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pDBConnect->GetReceivePerson(arAMObject);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::GetSendAttachPerson(CArrayAMObject &arAMObject)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pDBConnect->GetSendAttachPerson(arAMObject);
|
pDBConnect->Release();
|
return true;
|
}
|
bool CMBAMBaseDBMgr::GetCrowds(CArrayAMObject &arAMObject)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
pDBConnect->GetCrowds(arAMObject);
|
pDBConnect->Release();
|
return true;
|
}
|
|
//=========================================================
|
// µÃµ½ÈËÔ±±¸×¢Ãû
|
//=========================================================
|
BOOL CMBAMBaseDBMgr::SaveUserRemarks( CString strLogin,CString strRemarks)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass;
|
BOOL bRet;
|
strClass = _T("_UserRemarks");
|
strLogin.MakeLower();
|
if(strRemarks.IsEmpty())
|
{
|
bRet = pDBConnect->RemovePropStringValue(strClass, strLogin);
|
}
|
else
|
bRet = pDBConnect->UpdatePropStringValue(strClass, strLogin,0,strRemarks);
|
pDBConnect->Release();
|
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::LoadUsersRemarks(CMapStringToString &mapUserRemarks)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass;
|
BOOL bRet;
|
mapUserRemarks.RemoveAll();
|
strClass = _T("_UserRemarks");
|
bRet = pDBConnect->LoadUsersPropValue(strClass,mapUserRemarks);
|
pDBConnect->Release();
|
return bRet;
|
}
|
|
BOOL CMBAMBaseDBMgr::LoadBackupDBFile()
|
{
|
m_arBackupDBFile.RemoveAll();
|
CString strTmpPath;
|
CString strTmpDir;
|
CString strTmpName;
|
ULONGLONG nSize = 0;
|
WIN32_FIND_DATA wfd;
|
ULONGLONG nMaxDword = MAXDWORD;
|
strTmpDir = CBaseCommFun::GetAMUserDataDir(m_strLoginName,m_strServerID );
|
strTmpPath.Format(_T("%s\\STKClient_*.db3"), strTmpDir );
|
HANDLE hFind = FindFirstFile(strTmpPath,&wfd);
|
if(hFind == INVALID_HANDLE_VALUE)
|
return FALSE;
|
do
|
{
|
if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
{
|
continue ;
|
}
|
else
|
{
|
strTmpName.Format(_T("%s"), wfd.cFileName);
|
if(strTmpName.GetLength() == 31)
|
{
|
strTmpPath.Format(_T("%s\\%s"), strTmpDir, strTmpName);
|
m_arBackupDBFile.Add(strTmpPath);
|
}
|
}
|
}
|
while(FindNextFile(hFind,&wfd));
|
FindClose(hFind);
|
return TRUE;
|
}
|
BOOL CMBAMBaseDBMgr::GetBackupDBFile(CStringArray &arBackupDB)
|
{
|
arBackupDB.RemoveAll();
|
arBackupDB.Copy(m_arBackupDBFile);
|
return TRUE;
|
}
|
|
CString CMBAMBaseDBMgr::GetOldestMsg()
|
{
|
CString strDate = _T("");
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return strDate;
|
strDate= pDBConnect->GetOldestMsg();
|
pDBConnect->Release();
|
return strDate;
|
}
|
CString CMBAMBaseDBMgr::GetUpToDateMsg()
|
{
|
CString strDate = _T("");
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return strDate;
|
strDate= pDBConnect->GetUpToDateMsg();
|
pDBConnect->Release();
|
return strDate;
|
}
|
BOOL CMBAMBaseDBMgr::GetMsgDataCount(long &nMsgCount,long &nRelatedCount)
|
{
|
BOOL bRet = FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return bRet;
|
bRet = pDBConnect->GetMsgDataCount(nMsgCount,nRelatedCount);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::CleanDateBeforeMsg(CString strDate)
|
{
|
BOOL bRet = FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return bRet;
|
bRet = pDBConnect->CleanDateBeforeMsg(strDate);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::CleanDateAfterMsg(CString strDate)
|
{
|
BOOL bRet = FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return bRet;
|
bRet = pDBConnect->CleanDateAfterMsg(strDate);
|
pDBConnect->Release();
|
return bRet;
|
}
|
|
BOOL CMBAMBaseDBMgr::CleanAMExtraData()
|
{
|
BOOL bRet = FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return bRet;
|
bRet = pDBConnect->CleanAMExtraData();
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::LoadGetUnreadMsgTime( CString &strLastTime )
|
{
|
strLastTime = _T("");
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
int nPropVer;
|
CString strPropExtValue;
|
CString strClass, strName;
|
BOOL bRet;
|
strClass = _T("_UnreadMsgTime");
|
strName = strClass;
|
bRet = pDBConnect->GetPropStringData(strClass,strName, nPropVer,strLastTime,strPropExtValue);
|
pDBConnect->Release();
|
if( !bRet)
|
return FALSE;
|
return TRUE;
|
}
|
BOOL CMBAMBaseDBMgr::SaveGetUnreadMsgTime( CString strLastTime)
|
{
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass, strName;
|
CString strFileDir;
|
BOOL bRet;
|
int nTmpVer = 0;
|
|
strClass = _T("_UnreadMsgTime");
|
strName = strClass;
|
bRet = pDBConnect->UpdatePropFileData(strClass,strName, nTmpVer,strLastTime,_T(""));
|
pDBConnect->Release();
|
return bRet;
|
}
|
|
//=========================================================
|
// µÃµ½ÈËÔ±ÏûÏ¢ÏÔʾȨÏÞ
|
//=========================================================
|
BOOL CMBAMBaseDBMgr::LoadContactMsgRight( CMapStringToInt &mapMsgRight,int nContactType)
|
{
|
mapMsgRight.RemoveAll();
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass;
|
BOOL bRet;
|
if(nContactType == AM_VIEWITEMTYPE_USER )
|
{
|
strClass = _T("_UserMsgRight");
|
}
|
else if(nContactType == AM_VIEWITEMTYPE_CROWD )
|
{
|
strClass = _T("_CrowdMsgRight");
|
}
|
else
|
{
|
pDBConnect->Release();
|
return FALSE;
|
}
|
bRet = pDBConnect->LoadContactMsgRight(strClass, mapMsgRight);
|
pDBConnect->Release();
|
return bRet;
|
}
|
BOOL CMBAMBaseDBMgr::SaveContactMsgRight( CString strID, int nMsgRight,int nContactType)
|
{
|
if(strID.IsEmpty())
|
return FALSE;
|
CSingleLock lock( &m_csConnectDB, true );
|
CMBAMDBConnect* pDBConnect = GetMBAMDBConnect();
|
if ( !pDBConnect )
|
return FALSE;
|
CString strClass, strName;
|
CString strValue = _T("");
|
BOOL bRet;
|
if(nContactType == AM_VIEWITEMTYPE_USER )
|
{
|
strClass = _T("_UserMsgRight");
|
}
|
else if(nContactType == AM_VIEWITEMTYPE_CROWD )
|
{
|
strClass = _T("_CrowdMsgRight");
|
}
|
else
|
{
|
pDBConnect->Release();
|
return FALSE;
|
}
|
strName = strID;
|
strValue.Format(_T("%d"), nMsgRight);
|
bRet = pDBConnect->UpdatePropStringData(strClass,strName, 0,strValue,_T(""));
|
pDBConnect->Release();
|
return bRet;
|
}
|