- 浏览: 913668 次
文章分类
最新评论
-
wmaizai163:
有源码文件么 可调试的那种 发我邮箱可以么 3906902 ...
java文件传输 -
shenselongge:
排版能否改改
Mina2.0框架源码剖析(一) -
grandry:
谢谢!这是一个困扰我多时的问题
delphi的tclientdataset的中文过滤使用注意事项 -
LongXiTianXia:
我不知道哪里下载那个组件
基于朴素贝叶斯分类器的文本分类算法(下) -
LongXiTianXia:
可以说一下分词组件怎么使用吗?
基于朴素贝叶斯分类器的文本分类算法(下)
一个RSS阅读器类
classCFeedItem
{//RSS条目
public:
CFeedItem();
virtual~CFeedItem();
public:
CStringm_strAuthor;//作者
CStringm_strCategory;//类别
CStringm_strDescription;//描述信息
CStringm_strLink;//链接地址
CStringm_strPubDate;//发布日期
CStringm_strSubject;//主题
CStringm_strTitle;//标题
CStringm_strReadStatus;//是否已读
};
classCFeedSource
{//RSS源
public:
CFeedSource();
virtual~CFeedSource();
public:
CStringm_strCopyright;//版权
CStringm_strDescription;//描述信息
CStringm_strGenerator;//生产者
CStringm_strLanguage;//语言
CStringm_strLastBuildDate;//上次构建日期
CStringm_strLink;//链接地址
CStringm_strTitle;//标题
CStringm_strTtl;
CStringm_strWebMaster;//管理员
CStringm_strImageDescription;//图片描述信息
CStringm_strImageHeight;//图片高度
CStringm_strImageWidth;//图片宽度
CStringm_strImageLink;//图片链接地址
CStringm_strImageTitle;//图片标题
CStringm_strImageUrl;//图片Url
CStringm_strVersion;//图片版本
};
classCFeed
{//RSS种子
public:
CFeed();
CFeed(CStringstrXMLFile);
virtual~CFeed();
public:
staticvoidRefreshAll();
staticvoidMarkItemRead(CStringstrLink);
staticvoidDeleteFeedSource(CStringstrLink);
staticvoidDeleteListArray(CStringArray&strLinkArray);
staticvoidGetFeedSourceList(CStringArray&strTitleArray,CStringArray&strLinkArray);
voidLoadLocal(CString&strLink);
voidBuildFromFile(CStringstrXMLFile);
CFeedSourcem_source;//FeedSource
CArray<CFeedItem,CFeedItem>m_item;//FeedItem
BOOLm_bAdded;
voidSave(BOOLbSaveSource=TRUE);
private:
staticCStringEscapeQuote(CStringstrValue);
staticCStringGetModuleFileDir();
staticCStringGetFieldValue(FieldsPtrfields,longnIndex);
staticCStringGetComError(_com_error&e);
staticBOOLExecuteSQL(_ConnectionPtr&pCnn,CString&strSQL,CString&strMsg);
voidGetVersion(MSXML2::IXMLDOMNode*pNode);
voidIterateChildNodes(MSXML2::IXMLDOMNode*pNode);
voidBuildImage(MSXML2::IXMLDOMNode*pNode);
voidBuildItem(MSXML2::IXMLDOMNode*pNode);
MSXML2::IXMLDOMDocument2*m_pDoc;//XMLDOMDocument
intm_nDepth;
};
{//RSS条目
public:
CFeedItem();
virtual~CFeedItem();
public:
CStringm_strAuthor;//作者
CStringm_strCategory;//类别
CStringm_strDescription;//描述信息
CStringm_strLink;//链接地址
CStringm_strPubDate;//发布日期
CStringm_strSubject;//主题
CStringm_strTitle;//标题
CStringm_strReadStatus;//是否已读
};
classCFeedSource
{//RSS源
public:
CFeedSource();
virtual~CFeedSource();
public:
CStringm_strCopyright;//版权
CStringm_strDescription;//描述信息
CStringm_strGenerator;//生产者
CStringm_strLanguage;//语言
CStringm_strLastBuildDate;//上次构建日期
CStringm_strLink;//链接地址
CStringm_strTitle;//标题
CStringm_strTtl;
CStringm_strWebMaster;//管理员
CStringm_strImageDescription;//图片描述信息
CStringm_strImageHeight;//图片高度
CStringm_strImageWidth;//图片宽度
CStringm_strImageLink;//图片链接地址
CStringm_strImageTitle;//图片标题
CStringm_strImageUrl;//图片Url
CStringm_strVersion;//图片版本
};
classCFeed
{//RSS种子
public:
CFeed();
CFeed(CStringstrXMLFile);
virtual~CFeed();
public:
staticvoidRefreshAll();
staticvoidMarkItemRead(CStringstrLink);
staticvoidDeleteFeedSource(CStringstrLink);
staticvoidDeleteListArray(CStringArray&strLinkArray);
staticvoidGetFeedSourceList(CStringArray&strTitleArray,CStringArray&strLinkArray);
voidLoadLocal(CString&strLink);
voidBuildFromFile(CStringstrXMLFile);
CFeedSourcem_source;//FeedSource
CArray<CFeedItem,CFeedItem>m_item;//FeedItem
BOOLm_bAdded;
voidSave(BOOLbSaveSource=TRUE);
private:
staticCStringEscapeQuote(CStringstrValue);
staticCStringGetModuleFileDir();
staticCStringGetFieldValue(FieldsPtrfields,longnIndex);
staticCStringGetComError(_com_error&e);
staticBOOLExecuteSQL(_ConnectionPtr&pCnn,CString&strSQL,CString&strMsg);
voidGetVersion(MSXML2::IXMLDOMNode*pNode);
voidIterateChildNodes(MSXML2::IXMLDOMNode*pNode);
voidBuildImage(MSXML2::IXMLDOMNode*pNode);
voidBuildItem(MSXML2::IXMLDOMNode*pNode);
MSXML2::IXMLDOMDocument2*m_pDoc;//XMLDOMDocument
intm_nDepth;
};
//FeedSource.cpp:implementationoftheCFeedSourceclass.
//
/**///////////////////////////////////////////////////////////////////////
#include"stdafx.h"
#include"AgileReader.h"
#include"FeedSource.h"
#ifdef_DEBUG
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#definenewDEBUG_NEW
#endif
/**///////////////////////////////////////////////////////////////////////
//Construction/Destruction
/**///////////////////////////////////////////////////////////////////////
CFeedItem::CFeedItem()
{
}
CFeedItem::~CFeedItem()
{
}
CFeedSource::CFeedSource()
{
}
CFeedSource::~CFeedSource()
{
}
CFeed::CFeed()
{
m_pDoc=NULL;
m_nDepth=0;
m_bAdded=FALSE;
}
CFeed::CFeed(CStringstrXMLFile)
{
m_pDoc=NULL;
m_nDepth=0;
m_bAdded=FALSE;
BuildFromFile(strXMLFile);
}
CFeed::~CFeed()
{
}
/**//////////////////////////////////////////////////////////////////////////////
//BuildXMLFeedInformationfromanXMLFile
//
//strXMLFile:ParsedinXMLFileName
//ThisfunctionwillbuildFeedObjectfromscratchbyparsingXMLFeedInformation
//Resultisstoredinm_sourceandm_itemobjects
//
voidCFeed::BuildFromFile(CStringstrXMLFile)
{
CStringstrTmpFile=GetModuleFileDir()+_T("//AgileReader.xml");
//Step0.DownloadXMLFile
if(URLDownloadToFile(NULL,strXMLFile,strTmpFile,0,NULL)!=S_OK)
{//下载XML文件
AfxMessageBox(_T("Failedtodownload")+strXMLFile);
return;
}
//Step1.OpenXMLDocument,ifopenfails,thenreturn
if(m_pDoc!=NULL)
{
m_pDoc->Release();
m_pDoc=NULL;
}
if(SUCCEEDED(CoCreateInstance(MSXML2::CLSID_DOMDocument,
NULL,
CLSCTX_INPROC_SERVER,
MSXML2::IID_IXMLDOMDocument,
reinterpret_cast<void**>(&m_pDoc))))
m_pDoc->put_async(VARIANT_FALSE);
if(m_pDoc->load(_bstr_t(strTmpFile))==VARIANT_FALSE)
{//加载XML文档
//FailedtoloadXMLDocument,reporterrormessage
AfxMessageBox(_T("FailedtoloadXMLDocument"));
return;
}
//Step2.Getversionpropertyifitisavailable
//Step3.Iteratetochannelnode,getthefollowingchilditems
//title
//link
//description
//language
//copyright
//webMaster
//lastBuildDate
//ttl
//generator
//Thengotoimagenode,getthefollowingitems
//title
//url
//link
//width
//height
//description
//Step4.gotoitemnode,getthefollowingitems
//title
//description
//link
//author
//category
//pubDate
//subject
MSXML2::IXMLDOMNode*pNode=NULL;
if(SUCCEEDED(m_pDoc->QueryInterface(MSXML2::IID_IXMLDOMNode,
reinterpret_cast<void**>(&pNode))))
{
IterateChildNodes(pNode);
pNode->Release();
pNode=NULL;
}
//Wearenotusingsmartpointer,sowehavetoreleaseitoutself
if(m_pDoc)
{
m_pDoc->Release();
m_pDoc=NULL;
}
}
/**//////////////////////////////////////////////////////////////////////////////
//GetFeedVersionInformation
//
voidCFeed::GetVersion(MSXML2::IXMLDOMNode*pNode)
{
}
/**//////////////////////////////////////////////////////////////////////////////
//IterateChildNode
//
voidCFeed::IterateChildNodes(MSXML2::IXMLDOMNode*pNode)
{//迭代访问所有子节点
BSTRbstrNodeName;
if(pNode)
{
m_nDepth++;
CStringstrOutput;
pNode->get_nodeName(&bstrNodeName);
//
//Findoutthenodetype(asastring).
//
BSTRbstrNodeType;
pNode->get_nodeTypeString(&bstrNodeType);
CStringstrType;
strType=CString(bstrNodeType);
SysFreeString(bstrNodeType);
MSXML2::DOMNodeTypeeEnum;
pNode->get_nodeType(&eEnum);
CStringstrValue;
BSTRbstrValue;
switch(eEnum)
{
caseMSXML2::NODE_TEXT:
{
//TextstringintheXMLdocument
BSTRbstrValue;
pNode->get_text(&bstrValue);
strOutput=CString(bstrValue);
SysFreeString(bstrValue);
break;
}
caseMSXML2::NODE_COMMENT:
{
//CommentintheXMLdocument
VARIANTvValue;
pNode->get_nodeValue(&vValue);
VariantClear(&vValue);
break;
}
caseMSXML2::NODE_PROCESSING_INSTRUCTION:
{
//Processinginstruction
strOutput=CString(bstrNodeName);
break;
}
caseMSXML2::NODE_ELEMENT:
{
//Element
strOutput=CString(bstrNodeName);
if(strOutput==_T("rss"))
{
GetVersion(pNode);
}
elseif(strOutput==_T("copyright"))
{
pNode->get_text(&bstrValue);
m_source.m_strCopyright=CString(bstrValue);
}
elseif(strOutput==_T("title")&&m_nDepth==4)
{
pNode->get_text(&bstrValue);
m_source.m_strTitle=CString(bstrValue);
}
elseif(strOutput==_T("link")&&m_nDepth==4)
{
pNode->get_text(&bstrValue);
m_source.m_strLink=CString(bstrValue);
}
elseif(strOutput==_T("description")&&m_nDepth==4)
{
pNode->get_text(&bstrValue);
m_source.m_strDescription=CString(bstrValue);
}
elseif(strOutput==_T("language"))
{
pNode->get_text(&bstrValue);
m_source.m_strLanguage=CString(bstrValue);
}
elseif(strOutput==_T("webMaster"))
{
pNode->get_text(&bstrValue);
m_source.m_strWebMaster=CString(bstrValue);
}
elseif(strOutput==_T("lastBuildDate"))
{
pNode->get_text(&bstrValue);
m_source.m_strLastBuildDate=CString(bstrValue);
}
elseif(strOutput==_T("ttl"))
{
pNode->get_text(&bstrValue);
m_source.m_strTtl=CString(bstrValue);
}
elseif(strOutput==_T("generator"))
{
pNode->get_text(&bstrValue);
m_source.m_strGenerator=CString(bstrValue);
}
elseif(strOutput==_T("image"))
{
BuildImage(pNode);
}
elseif(strOutput==_T("item"))
{
BuildItem(pNode);
}
break;
}
caseMSXML2::NODE_DOCUMENT:
{
//Document
strOutput=CString(bstrNodeName)+_T("-")+CString(strType);
break;
}
caseMSXML2::NODE_DOCUMENT_TYPE:
{
//DocumentType
strOutput=CString(bstrNodeName)+_T("-")+CString(strType);
break;
}
caseMSXML2::NODE_DOCUMENT_FRAGMENT:
{
//DocumentFragment
strOutput=CString(bstrNodeName)+_T("-")+CString(strType);
break;
}
caseMSXML2::NODE_NOTATION:
{
//Notation
strOutput=CString(bstrNodeName)+_T("-")+CString(strType);
break;
}
caseMSXML2::NODE_ENTITY:
{
//Entity
strOutput=CString(bstrNodeName)+_T("-")+CString(strType);
break;
}
caseMSXML2::NODE_ENTITY_REFERENCE:
{
//EntityReference
strOutput=CString(bstrNodeName)+_T("-")+CString(strType);
}
caseMSXML2::NODE_CDATA_SECTION:
{
//CDatasection
strOutput=CString(bstrNodeName)+_T("-")+CString(strType);
}
}
SysFreeString(bstrNodeName);
}
//
//Anychildnodesofthisnodeneeddisplayingtoo.
//
MSXML2::IXMLDOMNode*pNext=NULL;
MSXML2::IXMLDOMNode*pChild;
pNode->get_firstChild(&pChild);
while(pChild)
{//递归遍历子节点
IterateChildNodes(pChild);
pChild->get_nextSibling(&pNext);
pChild->Release();
pChild=pNext;
}
m_nDepth--;//递归深度减
}
/**//////////////////////////////////////////////////////////////////////////////
//BuildImageSection
//
voidCFeed::BuildImage(MSXML2::IXMLDOMNode*pNode)
{
MSXML2::IXMLDOMNode*pNext=NULL;
MSXML2::IXMLDOMNode*pChild;
CStringstrOutput;
BSTRbstrNodeName;
BSTRbstrValue;
pNode->get_firstChild(&pChild);
while(pChild)
{
pChild->get_nodeName(&bstrNodeName);
strOutput=CString(bstrNodeName);
if(strOutput==_T("title"))
{
pChild->get_text(&bstrValue);
m_source.m_strImageTitle=CString(bstrValue);
}
elseif(strOutput==_T("url"))
{
pChild->get_text(&bstrValue);
m_source.m_strImageUrl=CString(bstrValue);
}
elseif(strOutput==_T("link"))
{
pChild->get_text(&bstrValue);
m_source.m_strImageLink=CString(bstrValue);
}
elseif(strOutput==_T("width"))
{
pChild->get_text(&bstrValue);
m_source.m_strImageWidth=CString(bstrValue);
}
elseif(strOutput==_T("height"))
{
pChild->get_text(&bstrValue);
m_source.m_strImageHeight=CString(bstrValue);
}
elseif(strOutput==_T("description"))
{
pChild->get_text(&bstrValue);
m_source.m_strImageDescription=CString(bstrValue);
}
pChild->get_nextSibling(&pNext);
pChild->Release();
pChild=pNext;
}
}
/**//////////////////////////////////////////////////////////////////////////////
//BuildItemSection
//
voidCFeed::BuildItem(MSXML2::IXMLDOMNode*pNode)
{
MSXML2::IXMLDOMNode*pNext=NULL;
MSXML2::IXMLDOMNode*pChild;
CStringstrOutput;
BSTRbstrNodeName;
CFeedItemitem;
BSTRbstrValue;
pNode->get_firstChild(&pChild);
while(pChild)
{
pChild->get_nodeName(&bstrNodeName);
strOutput=CString(bstrNodeName);
if(strOutput==_T("title"))
{
pChild->get_text(&bstrValue);
item.m_strTitle=CString(bstrValue);
}
elseif(strOutput==_T("description"))
{
pChild->get_text(&bstrValue);
item.m_strDescription=CString(bstrValue);
}
elseif(strOutput==_T("link"))
{
pChild->get_text(&bstrValue);
item.m_strLink=CString(bstrValue);
}
elseif(strOutput==_T("author"))
{
pChild->get_text(&bstrValue);
item.m_strAuthor=CString(bstrValue);
}
elseif(strOutput==_T("category"))
{
pChild->get_text(&bstrValue);
item.m_strCategory=CString(bstrValue);
}
elseif(strOutput==_T("pubDate"))
{
pChild->get_text(&bstrValue);
item.m_strPubDate=CString(bstrValue);
}
elseif(strOutput==_T("subject"))
{
pChild->get_text(&bstrValue);
item.m_strSubject=CString(bstrValue);
}
pChild->get_nextSibling(&pNext);
pChild->Release();
pChild=pNext;
}
m_item.Add(item);
}
/**//////////////////////////////////////////////////////////////////////////////
//SaveFeedInformationintoDatabase
//
voidCFeed::Save(BOOLbSaveSource/**//*=TRUE*/)
{//保持RSS种子信息倒数据库种
_ConnectionPtrpCnn=NULL;
CStringstrSQL;
CStringstrMsg;
intnIndex;
//Step1.Createobject
pCnn.CreateInstance(__uuidof(Connection));
if(pCnn==NULL)
{
AfxMessageBox(_T("Cannotcreateconnectionobject,pleaseinstallMDAC!"));
return;
}
//Step2.Openconnection
try
{
CStringstrCnn;
strCnn.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s//AgileReader.mdb;JetOLEDB:DatabasePassword=philips;"),GetModuleFileDir());
pCnn->Open(_bstr_t(strCnn),"","",adConnectUnspecified);
}
catch(_com_error&e)
{
AfxMessageBox(_T("Cannotopenconnection:/n")+GetComError(e));
pCnn.Release();
return;
}
//Step3.ExecuteInsertStatementonFeedSource
//Indoubleclickcase,wedon'twanttosavethis
if(bSaveSource)
{
strSQL.Format(_T("insertintoFeedSource(FeedLink,description,title,version,copyright,generator,feedlanguage,lastbuilddate,ttl,webmaster,imagedescription,imageheight,imagewidth,imagelink,imagetitle,imageurl)values('%s','%s','%s','%s','%s','%s','%s','%s',%d,'%s','%s','%s','%s','%s','%s','%s')"),
EscapeQuote(m_source.m_strLink),
EscapeQuote(m_source.m_strDescription),
EscapeQuote(m_source.m_strTitle),
_T("2.0"),
EscapeQuote(m_source.m_strCopyright),
EscapeQuote(m_source.m_strGenerator),
EscapeQuote(m_source.m_strLanguage),
EscapeQuote(m_source.m_strLastBuildDate),
EscapeQuote(m_source.m_strTtl),
EscapeQuote(m_source.m_strWebMaster),
EscapeQuote(m_source.m_strImageDescription),
EscapeQuote(m_source.m_strImageHeight),
EscapeQuote(m_source.m_strImageWidth),
EscapeQuote(m_source.m_strImageLink),
EscapeQuote(m_source.m_strImageTitle),
EscapeQuote(m_source.m_strImageUrl));
if(!ExecuteSQL(pCnn,strSQL,strMsg))
{
//AfxMessageBox(strMsg+strSQL);
}
else
{
m_bAdded=TRUE;
}
}
//Step4.ExecuteInsertStatementonFeedItem
for(nIndex=0;nIndex<m_item.GetSize();nIndex++)
{
strSQL.Format(_T("insertintoFeedItem(FeedLink,title,link,description,pubdate,author,category,subject)values('%s','%s','%s','%s','%s','%s','%s','%s')"),
EscapeQuote(m_source.m_strLink),
EscapeQuote(m_item[nIndex].m_strTitle),
EscapeQuote(m_item[nIndex].m_strLink),
EscapeQuote(m_item[nIndex].m_strDescription),
EscapeQuote(m_item[nIndex].m_strPubDate),
EscapeQuote(m_item[nIndex].m_strAuthor),
EscapeQuote(m_item[nIndex].m_strCategory),
EscapeQuote(m_item[nIndex].m_strSubject)
);
if(!ExecuteSQL(pCnn,strSQL,strMsg))
{
//AfxMessageBox(strMsg+strSQL);
}
}
pCnn.Release();
}
/**//////////////////////////////////////////////////////////////////////////////
//ExecuteSQLStatementandreturnerrormessageifany
//
BOOLCFeed::ExecuteSQL(_ConnectionPtr&pCnn,CString&strSQL,CString&strMsg)
{
try
{
pCnn->Execute(_bstr_t(strSQL),NULL,adCmdText);
}
catch(_com_error&e)
{
strMsg=GetComError(e);
returnFALSE;
}
returnTRUE;
}
/**//////////////////////////////////////////////////////////////////////////////
//RetrieveComErrorInformation
//
CStringCFeed::GetComError(_com_error&e)
{
CStringstrMsg;
_bstr_tbstrSource(e.Source());
_bstr_tbstrDescription(e.Description());
strMsg.Format(_T("Code=%08lx/nCodemeaning=%s/nSource=%s/nDescription=%s"),
e.Error(),
e.ErrorMessage(),
(LPCSTR)bstrSource,
(LPCSTR)bstrDescription);
returnstrMsg;
}
/**//////////////////////////////////////////////////////////////////////////////
//LoadFeedInformationfromdatabase
//
voidCFeed::LoadLocal(CString&strLink)
{//从数据库中读取RSS种子信息
_ConnectionPtrpCnn=NULL;
CStringstrSQL;
CStringstrMsg;
_RecordsetPtrrs=NULL;
//Step1.Createobject
pCnn.CreateInstance(__uuidof(Connection));
if(pCnn==NULL)
{
AfxMessageBox(_T("Cannotcreateconnectionobject,pleaseinstallMDAC!"));
return;
}
//Step2.Openconnection
try
{
CStringstrCnn;
strCnn.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s//AgileReader.mdb;JetOLEDB:DatabasePassword=philips;"),GetModuleFileDir());
pCnn->Open(_bstr_t(strCnn),"","",adConnectUnspecified);
}
catch(_com_error&e)
{
AfxMessageBox(_T("Cannotopenconnection:/n")+GetComError(e));
pCnn.Release();
return;
}
//Step3.ReadFeedSourceandpopulateitintom_sourceobject
strSQL.Format(_T("select*fromFeedSourcewhereFeedLink='%s'"),strLink);
try
{
rs=pCnn->Execute(_bstr_t(strSQL),NULL,adCmdText);
if(rs!=NULL&&rs->adoEOF!=TRUE)
{
m_source.m_strLink=strLink;
m_source.m_strDescription=GetFieldValue(rs->Fields,1);
m_source.m_strTitle=GetFieldValue(rs->Fields,2);
m_source.m_strVersion=GetFieldValue(rs->Fields,3);
m_source.m_strCopyright=GetFieldValue(rs->Fields,4);
m_source.m_strGenerator=GetFieldValue(rs->Fields,5);
m_source.m_strLanguage=GetFieldValue(rs->Fields,6);
m_source.m_strLastBuildDate=GetFieldValue(rs->Fields,7);
m_source.m_strTtl=GetFieldValue(rs->Fields,8);
m_source.m_strWebMaster=GetFieldValue(rs->Fields,9);
m_source.m_strImageDescription=GetFieldValue(rs->Fields,10);
m_source.m_strImageHeight=GetFieldValue(rs->Fields,11);
m_source.m_strImageWidth=GetFieldValue(rs->Fields,12);
m_source.m_strImageLink=GetFieldValue(rs->Fields,13);
m_source.m_strImageTitle=GetFieldValue(rs->Fields,14);
m_source.m_strImageUrl=GetFieldValue(rs->Fields,15);
}
}
catch(_com_error&e)
{
AfxMessageBox(GetComError(e));
}
rs.Release();
rs=NULL;
//Step4.ReadFeedItemandpopulateitintom_itemobject
strSQL.Format(_T("select*fromFeedItemwhereFeedLink='%s'orderbypubDatedesc,titleasc"),strLink);
try
{
rs=pCnn->Execute(_bstr_t(strSQL),NULL,adCmdText);
while(rs!=NULL&&rs->adoEOF!=TRUE)
{
if(rs->adoEOF)
{
break;
}
CFeedItemitem;
item.m_strTitle=GetFieldValue(rs->Fields,1);
item.m_strLink=GetFieldValue(rs->Fields,2);
item.m_strDescription=GetFieldValue(rs->Fields,3);
item.m_strPubDate=GetFieldValue(rs->Fields,4);
item.m_strAuthor=GetFieldValue(rs->Fields,5);
item.m_strCategory=GetFieldValue(rs->Fields,6);
item.m_strSubject=GetFieldValue(rs->Fields,7);
item.m_strReadStatus=GetFieldValue(rs->Fields,8);
m_item.Add(item);
rs->MoveNext();
if(rs->adoEOF)
{
break;
}
}
}
catch(_com_error&e)
{
AfxMessageBox(GetComError(e));
}
rs.Release();
rs=NULL;
pCnn.Release();
pCnn=NULL;
}
/**//////////////////////////////////////////////////////////////////////////////
//GetFieldValue
//
CStringCFeed::GetFieldValue(FieldsPtrfields,longnIndex)
{
_variant_tvt=fields->GetItem(nIndex)->Value;
if(vt.vt==VT_NULL||vt.vt==VT_EMPTY)
{
return_T("");
}
returnCString((char*)_bstr_t(vt));
}
voidCFeed::GetFeedSourceList(CStringArray&strTitleArray,CStringArray&strLinkArray)
{
_ConnectionPtrpCnn=NULL;
CStringstrSQL;
CStringstrMsg;
_RecordsetPtrrs=NULL;
//Step1.Createobject
pCnn.CreateInstance(__uuidof(Connection));
if(pCnn==NULL)
{
AfxMessageBox(_T("Cannotcreateconnectionobject,pleaseinstallMDAC!"));
return;
}
//Step2.Openconnection
try
{
CStringstrCnn;
strCnn.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s//AgileReader.mdb;JetOLEDB:DatabasePassword=philips;"),GetModuleFileDir());
pCnn->Open(_bstr_t(strCnn),"","",adConnectUnspecified);
}
catch(_com_error&e)
{
AfxMessageBox(_T("Cannotopenconnection:/n")+GetComError(e));
pCnn.Release();
return;
}
//Step3.ReadFeedSourceandpopulateitintom_sourceobject
strSQL=_T("selectdistincttitle,FeedLinkfromFeedSourceorderbytitle");
try
{
rs=pCnn->Execute(_bstr_t(strSQL),NULL,adCmdText);
while(rs!=NULL&&rs->adoEOF!=TRUE&&rs->BOF!=TRUE)
{
if(rs->adoEOF)
{
break;
}
strTitleArray.Add(GetFieldValue(rs->Fields,0));
strLinkArray.Add(GetFieldValue(rs->Fields,1));
rs->MoveNext();
}
}
catch(_com_error&e)
{
AfxMessageBox(GetComError(e));
}
rs.Release();
rs=NULL;
pCnn.Release();
}
/**//////////////////////////////////////////////////////////////////////////////
//GetModuleFilePath
//
CStringCFeed::GetModuleFileDir()
{//获取模块文件路径
DWORDdwLength,dwSize;
TCHARszFileName[MAX_PATH];
CStringstrFileName;
intnPos;
dwSize=sizeof(szFileName)/sizeof(szFileName[0]);
dwLength=::GetModuleFileName(AfxGetInstanceHandle(),szFileName,dwSize);
if(dwLength<=0)
{
return_T("");
}
strFileName=szFileName;
nPos=strFileName.ReverseFind('//');
returnstrFileName.Left(nPos);
}
/**//////////////////////////////////////////////////////////////////////////////
//EscapeSingleQuote
//
CStringCFeed::EscapeQuote(CStringstrValue)
{
strValue.Replace(_T("'"),_T("''"));
returnstrValue;
}
/**//////////////////////////////////////////////////////////////////////////////
//DeletelistfromDatabase
//
voidCFeed::DeleteListArray(CStringArray&strLinkArray)
{
_ConnectionPtrpCnn=NULL;
CStringstrSQL;
CStringstrMsg;
intnIndex;
//Step1.Createobject
pCnn.CreateInstance(__uuidof(Connection));
if(pCnn==NULL)
{
AfxMessageBox(_T("Cannotcreateconnectionobject,pleaseinstallMDAC!"));
return;
}
//Step2.Openconnection
try
{
CStringstrCnn;
strCnn.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s//AgileReader.mdb;JetOLEDB:DatabasePassword=philips;"),GetModuleFileDir());
pCnn->Open(_bstr_t(strCnn),"","",adConnectUnspecified);
}
catch(_com_error&e)
{
AfxMessageBox(_T("Cannotopenconnection:/n")+GetComError(e));
pCnn.Release();
return;
}
//Step3.DeleteLinkfromFeedListtable
for(nIndex=0;nIndex<strLinkArray.GetSize();nIndex++)
{
strSQL.Format(_T("deletefromFeedItemwherelink='%s'"),EscapeQuote(strLinkArray[nIndex]));
ExecuteSQL(pCnn,strSQL,strMsg);
}
//Step4.Done!
pCnn.Release();
}
/**//////////////////////////////////////////////////////////////////////////////
//DeleteFeedSource
//
voidCFeed::DeleteFeedSource(CStringstrLink)
{
_ConnectionPtrpCnn=NULL;
CStringstrSQL;
CStringstrMsg;
//Step1.Createobject
pCnn.CreateInstance(__uuidof(Connection));
if(pCnn==NULL)
{
AfxMessageBox(_T("Cannotcreateconnectionobject,pleaseinstallMDAC!"));
return;
}
//Step2.Openconnection
try
{
CStringstrCnn;
strCnn.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s//AgileReader.mdb;JetOLEDB:DatabasePassword=philips;"),GetModuleFileDir());
pCnn->Open(_bstr_t(strCnn),"","",adConnectUnspecified);
}
catch(_com_error&e)
{
AfxMessageBox(_T("Cannotopenconnection:/n")+GetComError(e));
pCnn.Release();
return;
}
//Step3.DeleteLinkfromFeedListtable
strSQL.Format(_T("deletefromFeedSourcewhereFeedLink='%s'"),EscapeQuote(strLink));
ExecuteSQL(pCnn,strSQL,strMsg);
//Step4.Done!
pCnn.Release();
}
/**//////////////////////////////////////////////////////////////////////////////
//Markanitemasread
//
voidCFeed::MarkItemRead(CStringstrLink)
{//标记Rss条目为已读状态
_ConnectionPtrpCnn=NULL;
CStringstrSQL;
CStringstrMsg;
//Step1.Createobject
pCnn.CreateInstance(__uuidof(Connection));
if(pCnn==NULL)
{
AfxMessageBox(_T("Cannotcreateconnectionobject,pleaseinstallMDAC!"));
return;
}
//Step2.Openconnection
try
{
CStringstrCnn;
strCnn.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s//AgileReader.mdb;JetOLEDB:DatabasePassword=philips;"),GetModuleFileDir());
pCnn->Open(_bstr_t(strCnn),"","",adConnectUnspecified);
}
catch(_com_error&e)
{
AfxMessageBox(_T("Cannotopenconnection:/n")+GetComError(e));
pCnn.Release();
return;
}
//Step3.DeleteLinkfromFeedListtable
strSQL.Format(_T("updateFeedItemsetreadstatus=1wherelink='%s'"),EscapeQuote(strLink));
ExecuteSQL(pCnn,strSQL,strMsg);
//Step4.Done!
pCnn.Release();
}
/**//////////////////////////////////////////////////////////////////////////////
//RefreshAllSubScriptions
//
voidCFeed::RefreshAll()
{//刷新订阅信息
_ConnectionPtrpCnn=NULL;
CStringstrSQL;
CStringstrMsg;
CStringArraystrLinkArray;
_RecordsetPtrrs=NULL;
//Step1.Createobject
pCnn.CreateInstance(__uuidof(Connection));
if(pCnn==NULL)
{
AfxMessageBox(_T("Cannotcreateconnectionobject,pleaseinstallMDAC!"));
return;
}
//Step2.Openconnection
try
{
CStringstrCnn;
strCnn.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s//AgileReader.mdb;JetOLEDB:DatabasePassword=philips;"),GetModuleFileDir());
pCnn->Open(_bstr_t(strCnn),"","",adConnectUnspecified);
}
catch(_com_error&e)
{
AfxMessageBox(_T("Cannotopenconnection:/n")+GetComError(e));
pCnn.Release();
return;
}
//Step3.Getallthesubscriptions
strSQL=_T("selectFeedLinkfromFeedSource");
try
{
rs=pCnn->Execute(_bstr_t(strSQL),NULL,adCmdText);
while(rs!=NULL&&rs->adoEOF!=TRUE)
{
if(rs->adoEOF)
{
break;
}
strLinkArray.Add(GetFieldValue(rs->Fields,0));
rs->MoveNext();
}
}
catch(_com_error&e)
{
AfxMessageBox(GetComError(e));
}
rs.Release();
rs=NULL;
//Step4.Refreaheachlink
for(intnIndex=0;nIndex<strLinkArray.GetSize();nIndex++)
{
CFeedfeed(strLinkArray.GetAt(nIndex));
feed.m_source.m_strLink=strLinkArray.GetAt(nIndex);
feed.Save();
}
//Step5.Done!
pCnn.Release();
}
相关推荐
如何基于iPhone 设计一个简单的RSS阅读器应用 How To Make A Simple RSS Reader iPhone App Tutorial
一个基于新浪RSS的android RSS阅读器源码 虽然不成熟 但是基本功能已经实现 可以学习学习
RSS阅读器,rss新闻在线阅读,XML,Ajax
新浪RSS 新闻阅读器源码啊 android
基于JAVA SWING的RSS阅读器,使用JDOM解析本地XML文件
周博通RSS阅读器.周博通RSS阅读器.周博通RSS阅读器.周博通RSS阅读器.周博通RSS阅读器.周博通RSS阅读器.周博通RSS阅读器.周博通RSS阅读器.
Plenary Pro v3.0 for Android 一个现代的RSS阅读器「RSS feed阅读器」
Rss阅读器编码Rss阅读器编码Rss阅读器编码Rss阅读器编码Rss阅读器编码Rss阅读器编码
C# RSS阅读器 能添加和阅读订阅RSS网址 并且提供订阅网址的访问 能把订阅的内容详细展示出来
求新RSS阅读器用于订阅RSS新闻。功能特点:用户可自己管理RSS频道,用户可设置新闻更新频率,新闻内容保留时间,阅读器可浏览网页,包含新闻播放功能。如果你想一边工作,一边听新闻,或者你不想整天盯着电脑看新闻...
MVC在线RSS阅读器(ASP.NET 4.0) 包含数据库文件 MicroSoft SqlServer 2008 + VisualStudio 2010
我们希望通过我们RSS阅读管理器这样一个软件,为用户提供关于RSS方面的尽可能多的帮助与支持,以帮助用户运用该软件通过RSS订阅的方式,更方便,更实用的获得信息,处理信息,储存信息,管理信息,传递信息。
周博通RSS阅读器,很好用的!
你可以自由的转载发布,但请保留原文地址及一下声明信息。 Rss 是一种描述和同步网站内容的格式,是目前使用最广泛的XML应用。RSS 搭建了信息迅速传播的一个...你可以使用他在五分钟内实现自己的 Rss 在线阅读器。
一个基于C#开发的RSS阅读器
RSS阅读器模块 jsp教程 适合毕业设计的实现和源码爱好者学习
RSS阅读器是基于java语言开发的一套完整源码实例,是一个完整的开发项目。
windows 简单的RSS阅读器.一个简单的RSS demo
一个简单的RSS阅读器,通过解析xml节点获取rss信息。
一个简单的网络阅读器,是用 。net的windows窗体希望大家喜欢,可以直接加载xml格式的RSS