浏览 4755 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-06-27
using System; using System.Net; using MCMSProxy.MCMSServer; namespace MCMSProxy { /// <summary> /// Summary description for Class1. /// </summary> public class Client { MCMSServer.MCMS MCMSServer=new MCMS(); bool _readOnly=false; public Client(string Url) { // // TODO: Add constructor logic here // SiteUrl=Url; MCMSServer.CookieContainer = new System.Net.CookieContainer(); } public Client(string Url,bool readOnly) { // // TODO: Add constructor logic here // _readOnly=readOnly; SiteUrl=Url; MCMSServer.CookieContainer = new System.Net.CookieContainer(); } /// <summary> /// 添加新的新闻 /// </summary> /// <param name="ChannelPath">频道相对于根的路径。例如:http://server/CmsRoot 写为“CmsRoot”</param> /// <param name="Name">新闻名称</param> /// <param name="DisplayName">显示名称</param> /// <param name="Template">模板相对于根的路径</param> /// <param name="thePlaceholders">内容集合</param> /// <param name="theCustomProperties">个性化属性集合</param> /// <returns>新生成的新闻的GUID</returns> public string AddNews(string ChannelPath,string Name,string DisplayName,string TemplatePath,System.Collections.DictionaryEntry[] thePlaceholders,System.Collections.DictionaryEntry[] theCustomProperties) { CheckCredentials(); MCMSProxy.MCMSServer.DictionaryEntry[] thePlaceholders2=null; if(thePlaceholders!=null) { thePlaceholders2= new MCMSProxy.MCMSServer.DictionaryEntry[thePlaceholders.Length]; for(int i=0;i<thePlaceholders.Length;i++) { thePlaceholders2[i]=new MCMSProxy.MCMSServer.DictionaryEntry(); thePlaceholders2[i].Key = thePlaceholders[i].Key; thePlaceholders2[i].Value = thePlaceholders[i].Value; } } MCMSProxy.MCMSServer.DictionaryEntry[] theCustomProperties2=null; if(theCustomProperties!=null) { theCustomProperties2= new MCMSProxy.MCMSServer.DictionaryEntry[theCustomProperties.Length]; for(int i=0;i<theCustomProperties2.Length;i++) { theCustomProperties2[i]=new MCMSProxy.MCMSServer.DictionaryEntry(); theCustomProperties2[i].Key = theCustomProperties[i].Key; theCustomProperties2[i].Value = theCustomProperties[i].Value; } } return MCMSServer.AddNews(ChannelPath,Name,DisplayName,TemplatePath,thePlaceholders2,theCustomProperties2); } /// <summary> /// 添加新的新闻,适用于只有一个placeholder且 placeholder名为"content"的新闻模板,例如:常用工具/新闻(自动生成标题) /// </summary> /// <param name="ChannelPath">频道相对于根的路径。例如:http://server/CmsRoot 写为“CmsRoot”</param> /// <param name="Name">新闻名称</param> /// <param name="DisplayName">显示名称</param> /// <param name="Template">模板相对于根的路径</param> /// <param name="Content">内容</param> /// <param name="theCustomProperties">个性化属性集合</param> /// <returns>新生成的新闻的GUID</returns> public string AddNews(string ChannelPath,string Name,string DisplayName,string TemplatePath,string Content,System.Collections.DictionaryEntry[] theCustomProperties) { System.Collections.DictionaryEntry[] thePlaceholders= new System.Collections.DictionaryEntry[1]; thePlaceholders[0]=new System.Collections.DictionaryEntry(); thePlaceholders[0].Key="Content"; thePlaceholders[0].Value =Content; return AddNews(ChannelPath,Name,DisplayName,TemplatePath,thePlaceholders,theCustomProperties); } /// <summary> /// 发布新闻 /// </summary> /// <param name="PostingGuid">被发布新闻的GUID</param> /// <param name="startDate">开始发布时间</param> /// <param name="ExpiryDate">过期时间</param> /// <returns>是否成功发布</returns> public bool PublishNews(string PostingGuid, DateTime startDate, DateTime ExpiryDate) { CheckCredentials(); return MCMSServer.PublishNews(PostingGuid,startDate,ExpiryDate); } /// <summary> /// /// </summary> /// <param name="_ChannelPath"></param> /// <param name="_SummaryChannel"></param> /// <param name="_Conditions"></param> /// <param name="_Filter"></param> /// <param name="_OrderBy"></param> /// <param name="_DeepLevel"></param> /// <param name="_SummarySubChannel"></param> /// <param name="_maxCount"></param> /// <param name="_postingcount"></param> /// <returns></returns> public System.Data.DataSet ListNews(string SummaryChannel,string Conditions,string Filter,string OrderBy,int DeepLevel,bool SummarySubChannel,int maxCount,int postingcount) { CheckCredentials(); return MCMSServer.ListNews(SummaryChannel, Conditions, Filter, OrderBy, DeepLevel, SummarySubChannel, maxCount, postingcount); } /// <summary> /// </summary> /// <param name="ChannelPath"></param> /// <param name="SummaryChannel"></param> /// <param name="Conditions"></param> /// <param name="postingcount"></param> /// <returns></returns> public System.Data.DataSet ListNews( string SummaryChannel,string Conditions,int MaxCount) { //CheckCredentials(); return MCMSServer.ListNews( SummaryChannel, Conditions, "", "",-1, false,MaxCount, -1); } public System.Xml.XmlNode getNews(string GUID) { CheckCredentials(); return MCMSServer.getNews(GUID); } public string FileToResource(byte[] iBuffer, string fileName) { CheckCredentials(); return MCMSServer.FileToResource(iBuffer,fileName); } private void CheckCredentials() { if(MCMSServer.Credentials==null) MCMSServer.Credentials=System.Net.CredentialCache.DefaultCredentials; } // public string GetLog() // { // try // { // return MCMSServer.Getlog(); // } // catch(Exception ex) // { // return "读取日志出错!"+ex.Message ; // } // } // <summary> // Wss site server Url or WebServer Url like "http://testserver/CmsWebService/MCMS.asmx?NRMODE=Update" // </summary> public string SiteUrl { set { string m_Site=value; if(m_Site.EndsWith("/")) m_Site=m_Site.Substring(0,m_Site.Length-1); if(_readOnly) { if(m_Site.ToLower().EndsWith("mcms.asmx")) MCMSServer.Url =m_Site; else MCMSServer.Url =m_Site+"/EipCmsTemplate/WebService/MCMS.asmx"; } else { if(m_Site.ToLower().EndsWith("mcms.asmx?nrmode=update")) MCMSServer.Url =m_Site; else MCMSServer.Url =m_Site+"/EipCmsTemplate/WebService/MCMS.asmx?NRMODE=Update"; } } } /// <summary> /// if use Proxy /// </summary> public System.Net.IWebProxy Proxy { set { MCMSServer.Proxy =value; } } /// <summary> /// Credentials /// </summary> public ICredentials Credentials { set { MCMSServer.Credentials= value; } } } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |