// STKMsgAttachmentRowSet.cpp : implementation file // #include "stdafx.h" #include "mbamdb.h" #include "STKMsgAttachmentRowSet.h" #include "MBAMDBFun.h" // STKMsgAttachmentRowSet CSTKMsgAttachmentRowSet::CSTKMsgAttachmentRowSet() { m_pDBConnect = NULL; m_pMsgAttachments = NULL; } CSTKMsgAttachmentRowSet::~CSTKMsgAttachmentRowSet() { CleanDataSet( ); } void CSTKMsgAttachmentRowSet::operator = ( const CSTKMsgAttachmentRowSet &Item ) { m_strStartDate = Item.m_strStartDate; m_strEndDate = Item.m_strEndDate; m_pDBConnect = Item.m_pDBConnect; m_pMsgAttachments = Item.m_pMsgAttachments; } void CSTKMsgAttachmentRowSet::CleanDataSet( ) { if(m_pMsgAttachments) delete m_pMsgAttachments; m_pMsgAttachments = NULL; } bool CSTKMsgAttachmentRowSet::SetDBConnect( CMBAMDBConnect *pDBConnect ) { m_pDBConnect = pDBConnect; return true; } bool CSTKMsgAttachmentRowSet::ListAttachments( CString strUser,CString strUserName, CString strKey ,long &nCount ) { nCount = 0; if ( !m_pDBConnect || !m_pDBConnect->IsOpenDB() ) return false; CleanDataSet(); m_pDBConnect->AddRef(); m_pMsgAttachments = new CMsgAttachments( m_pDBConnect); CHighTime tmHigh; SYSTEMTIME tmSystem; // Set Filter if ( !m_strStartDate.IsEmpty() && tmHigh.ParseDateTime( m_strStartDate ) ) { tmHigh.GetAsSystemTime( tmSystem ); if ( tmSystem.wSecond < 0 ) tmSystem.wSecond = 0; m_pMsgAttachments->m_tmStartDate = COleDateTime( tmSystem.wYear, tmSystem.wMonth, tmSystem.wDay, tmSystem.wHour, tmSystem.wMinute, tmSystem.wSecond ); } if ( !m_strEndDate.IsEmpty() && tmHigh.ParseDateTime( m_strEndDate ) ) { tmHigh.GetAsSystemTime( tmSystem ); if ( tmSystem.wSecond < 0 ) tmSystem.wSecond = 0; m_pMsgAttachments->m_tmEndDate = COleDateTime( tmSystem.wYear, tmSystem.wMonth, tmSystem.wDay, tmSystem.wHour, tmSystem.wMinute, tmSystem.wSecond ); } int nMsgCount(0); nMsgCount = m_pMsgs->ListReceiveBoxMsg( strUser,strUserName,strContentKey, nAttach ); if ( nMsgCount <= 0 ) { delete m_pMsgs; m_pMsgs = NULL; return true; } m_nType = ROWTYPE_MSG; m_pMsgs->GetData( ); nCount = nMsgCount; return true; } bool CSTKMsgAttachmentRowSet::ListRecordCount( long &nCount ) { nCount = 0; if ( m_pMsgAttachments ) nCount = m_pMsgAttachments->ListRecordCount(); return true; } bool CSTKMsgAttachmentRowSet::Top( ) { if ( m_pMsgAttachments && !m_pMsgAttachments->MoveFirst() ) return false; return true; } bool CSTKMsgAttachmentRowSet::Prev() { if ( m_pMsgAttachments && !m_pMsgAttachments->MovePrev() ) return false; return true; } bool CSTKMsgAttachmentRowSet::Next( ) { if ( m_pMsgAttachments && !m_pMsgAttachments->MoveNext() ) return false; return true; } bool CSTKMsgAttachmentRowSet::MoveTo( long nPos ) { if ( m_pMsgAttachments && !m_pMsgAttachments->MoveTo(nPos) ) return false; return true; } bool CSTKMsgAttachmentRowSet::GetRow( CSTKMsgAttachmentRow *pSTKRow ) { if ( !pSTKRow ) return false; pSTKRow->m_pAConnect = m_pDBConnect; pSTKRow->m_pCursor = m_pMsgAttachments; return true; } bool CSTKMsgAttachmentRowSet::GetItemValueStr( CString strItemName, CString &strData ) { CString strValue = _T( "" ); CString strName = strItemName; if ( strName.IsEmpty() ) return false; if ( !m_pMsgAttachments ) return false; m_pMsgAttachments->GetData( ); if ( !((*m_pMsgAttachments).GetItemValue( strName, strValue )) ) return false; strData = strValue; return true; } bool CSTKMsgAttachmentRowSet::GetItemValue( CString strItemName, VARIANT &vData ) { vData.vt = VT_EMPTY; CString strName = strItemName; if ( strName.IsEmpty() ) return false; COleVariant oleData; if ( !m_pMsgAttachments ) return false; m_pMsgAttachments->GetData( ); if ( !((*m_pMsgAttachments).GetItemValue( strName, oleData )) ) return false; vData = oleData; return true; } bool CSTKMsgAttachmentRowSet::SetMsgFilterDate( CString strStartDate, CString strEndDate ) { m_strStartDate = strStartDate; m_strEndDate = strEndDate; return true; }