已阅读5页,还剩59页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
using System;using System.Data;using FuYang.Web.Class.Business;namespace FuYang.Web.InfoPub.Business/ / ClassPublishTree 的摘要说明。/ public class ClassPublishTreeprivate FunkeLab.MyTreeView TreeView1;private string targetFrame=;private string linkUrl=;public ClassPublishTree(FunkeLab.MyTreeView MyTreeView)/ TODO: 在此处添加构造函数逻辑/TreeView1=MyTreeView;FunkeLab.MyTreeView.ImagesFolder=FuYang.Config.ModuleConfig.GetSettings().ImagePath;/ / 显示树节点,Item.Remark=templateName,Item.OtherInfo=templateId/ / public void ShowNode(FunkeLab.MyTreeViewItem Item,DataTable dataTable)if (dataTable.Rows.Count=0)TreeView1.Items.Clear();FunkeLab.MyTreeViewItem item=new FunkeLab.MyTreeViewItem(栏目列表,);item.Id=-1;TreeView1.Items.Add(item);return;FunkeLab.MyTreeViewItem childItem=null;FunkeLab.MyTreeViewItemCollection itemCollection=null;if(Item=null)TreeView1.Items.Clear();itemCollection=TreeView1.Items;elseif(Item.Items.Count!=1) | (Item.Items0.Id!=-1)return;Item.Items.Clear();itemCollection=Item.Items;foreach(DataRow dataRow in dataTable.Rows)FunkeLab.MyTreeViewItem item=new FunkeLab.MyTreeViewItem(dataRowname.ToString(),);item.Id=int.Parse(dataRowid.ToString();item.Name=dataRowname.ToString();item.Describe=dataRowdescribe.ToString();item.Remark=dataRowtemplateName.ToString();item.OtherInfo=(dataRowtemplateId.ToString()=?-1:dataRowtemplateId.ToString()+;+(dataRowdocTemplateId.ToString()=?-1:dataRowdocTemplateId.ToString()+;+(dataRowclassDeptId.ToString()=?-1:dataRowclassDeptId.ToString()+;item.Abbreviate=(dataRowitemNumber.ToString()=?0:dataRowitemNumber.ToString();item.Enabled=(dataRowenabled.ToString()=True?true:false);item.Value=dataRowclassType.ToString();/item.Image=(item.Enabled?FunkeLab.MyTreeView.ImagesFolder + Node_Enable.gif:FunkeLab.MyTreeView.ImagesFolder +Node_Disable.gif);if(new Classes().GetChildClassesCountById(int.Parse(dataRowid.ToString()0)childItem=new FunkeLab.MyTreeViewItem(,);childItem.Id=-1;item.Items.Add(childItem);elseitem.Selector=FunkeLab.MyTreeViewItem.SelectionMode.CheckBox;itemCollection.Add(item);/ / 通过站点ID得到该站点所有栏目/ public bool GetClassBySiteId(int siteId)TreeView1.Items.Clear();DataTable dataTable=new Classes().GetClassesBySiteId(siteId);ShowNode(null,dataTable);return true;/ / 判断当前节点是否叶节点. 是:返回1:不是:0;无选中节点:-1/ public int isLeafNode()if(System.Web.HttpContext.Current.SessionClassId=null)return -1;int id=int.Parse(System.Web.HttpContext.Current.SessionClassId.ToString();if(TreeView1.GetNodeById(id).Items.Count0)return 0;return 1;/ / 设置targetFrame. Item请传为null/ public void SetTargetFrame(string newTargetFrame,string newLinkUrl,FunkeLab.MyTreeViewItem Item)targetFrame=newTargetFrame;linkUrl=newLinkUrl;FunkeLab.MyTreeViewItemCollection itemCollection;if (Item=null)itemCollection=TreeView1.Items;elseitemCollection=Item.Items;for(int i=0;i 0)SetTargetFrame(newTargetFrame,linkUrl,itemCollectioni);using System;using System.Net;using System.IO;using System.Text;using System.Net.Sockets;using System.Diagnostics;using System.Runtime.Remoting;using System.Runtime.Remoting.Messaging;/* * FTP Client library in C# * Author: Jaimon Mathew * mailto: * /archives/archive9.html * * Addapted for use by Dan Glass 07/03/03 */namespace FTPClientpublic class FtpClientpublic class FtpException : Exceptionpublic FtpException(string message) : base(message)public FtpException(string message, Exception innerException) : base(message,innerException)private static int BUFFER_SIZE = 512;private static Encoding ASCII = Encoding.ASCII;private bool verboseDebugging = false;/ defaultsprivate string server = localhost;private string remotePath = .;private string username = anonymous;private string password = ;private string message = null;private string result = null;private int port = 21;private int bytes = 0;private int resultCode = 0;private bool loggedin = false;private bool binMode = false;private Byte buffer = new ByteBUFFER_SIZE;private Socket clientSocket = null;private int timeoutSeconds = 10;/ / Default contructor/ public FtpClient()/ / / / / / public FtpClient(string server, string username, string password)this.server = server;this.username = username;this.password = password;/ / / / / / / / public FtpClient(string server, string username, string password, int timeoutSeconds, int port)this.server = server;this.username = username;this.password = password;this.timeoutSeconds = timeoutSeconds;this.port = port;/ / Display all communications to the debug log/ public bool VerboseDebugginggetreturn this.verboseDebugging;setthis.verboseDebugging = value;/ / Remote server port. Typically TCP 21/ public int Portgetreturn this.port;setthis.port = value;/ / Timeout waiting for a response from server, in seconds./ public int Timeoutgetreturn this.timeoutSeconds;setthis.timeoutSeconds = value;/ / Gets and Sets the name of the FTP server./ / public string Servergetreturn this.server;setthis.server = value;/ / Gets and Sets the port number./ / public int RemotePortgetreturn this.port;setthis.port = value;/ / GetS and Sets the remote directory./ public string RemotePathgetreturn this.remotePath;setthis.remotePath = value;/ / Gets and Sets the username./ public string Usernamegetreturn this.username;setthis.username = value;/ / Gets and Set the password./ public string Passwordgetreturn this.password;setthis.password = value;/ / If the value of mode is true, set binary mode for downloads, else, Ascii mode./ public bool BinaryModegetreturn this.binMode;setif ( this.binMode = value ) return;if ( value )sendCommand(TYPE I);elsesendCommand(TYPE A);if ( this.resultCode != 200 ) throw new FtpException(result.Substring(4);/ / Login to the remote server./ public void Login()if ( this.loggedin ) this.Close();Debug.WriteLine(Opening connection to + this.server, FtpClient );IPAddress addr = null;IPEndPoint ep = null;trythis.clientSocket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );addr = Dns.Resolve(this.server).AddressList0;ep = new IPEndPoint( addr, this.port );this.clientSocket.Connect(ep);catch(Exception ex)/ doubtfullif ( this.clientSocket != null & this.clientSocket.Connected ) this.clientSocket.Close();throw new FtpException(Couldnt connect to remote server,ex);this.readResponse();if(this.resultCode != 220)this.Close();throw new FtpException(this.result.Substring(4);this.sendCommand( USER + username );if( !(this.resultCode = 331 | this.resultCode = 230) )this.cleanup();throw new FtpException(this.result.Substring(4);if( this.resultCode != 230 )this.sendCommand( PASS + password );if( !(this.resultCode = 230 | this.resultCode = 202) )this.cleanup();throw new FtpException(this.result.Substring(4);this.loggedin = true;Debug.WriteLine( Connected to + this.server, FtpClient );this.ChangeDir(this.remotePath);/ / Close the FTP connection./ public void Close()Debug.WriteLine(Closing connection to + this.server, FtpClient );if( this.clientSocket != null )this.sendCommand(QUIT);this.cleanup();/ / Return a string array containing the remote directorys file list./ / public string GetFileList()return this.GetFileList(*.*);xmlWr.WriteAttributeString(Author,Author1);xmlWr.WriteAttributeString(DocTime,DocTime1);xmlWr.WriteAttributeString(DeptName,DeptName);xmlWr.WriteAttributeString(ImgUrl,ImgUrl);xmlWr.WriteAttributeString(Link,UrlExt+/news/+classDir1+/+docname);/if(DocType=doc)/xmlWr.WriteString(strReplace(docs.Table.RowskContent.ToString();/xmlWr.WriteEndElement();else if(DocType=doc)if(docnum=1)string DocTime1=null;if(DisplayShortDate)DocTime1=docs.Table.Rows0DocTime.ToString();DocTime1=DocTime1.Substring(0,DocTime1.IndexOf( );elseDocTime1=docs.Table.Rows0DocTime.ToString();string docid=docs.Table.Rows0DocId.ToString();string HeadTitle1=docs.Table.Rows0HeadTitle.ToString();string Subhead1=docs.Table.Rows0Subhead.ToString();string Author1=docs.Table.Rows0Author.ToString();string DeptName=docs.Table.Rows0DeptName.ToString();string docname=docs.Table.Rows0publishFileName.ToString();string classDir1=docs.Table.Rows0ShortName.ToString();xmlWr.WriteStartElement(doc);xmlWr.WriteAttributeString(HeadTitle,HeadTitle1);xmlWr.WriteAttributeString(Subhead,Subhead1);xmlWr.WriteAttributeString(Author,Author1);xmlWr.WriteAttributeString(DocTime,DocTime1);xmlWr.WriteAttributeString(DeptName,DeptName);xmlWr.WriteAttributeString(Link,UrlExt+/news/+classDir1+/+docname);xmlWr.WriteString(docs.Table.Rows0Content.ToString();xmlWr.WriteEndElement();else if(docnum1)string DocTime1=null;DataRow dr_brief=(docs.Table.Rows0Content.ToString().Lengthdocs.Table.Rows1Content.ToString().Length)?docs.Table.Rows1:docs.Table.Rows0;DataRow dr_detail=(docs.Table.Rows0Content.ToString().Lengthdocs.Table.Rows1Content.ToString().Length)?docs.Table.Rows0:docs.Table.Rows1;if(DisplayShortDate)DocTime1=dr_detailDocTime.ToString();DocTime1=DocTime1.Substring(0,DocTime1.IndexOf( );elseDocTime1=dr_detailDocTime.ToString();string DeptName=dr_detailDeptName.ToString();string docname=dr_detailpublishFileName.ToString();string classDir1=dr_detailShortName.ToString();xmlWr.WriteStartElement(doc);xmlWr.WriteAttributeString(HeadTitle,dr_detailHeadTitle.ToString();xmlWr.WriteAttributeString(Subhead,dr_detailSubhead.ToString();xmlWr.WriteAttributeString(Author,dr_detailAuthor.ToString();xmlWr.WriteAttributeString(DocTime,DocTime1);xmlWr.WriteAttributeString(DeptName,DeptName);xmlWr.WriteAttributeString(Link,UrlExt+/news/+classDir1+/+docname);xmlWr.WriteString(dr_briefContent.ToString();xmlWr.WriteEndElement();xmlWr.WriteEndElement();xmlWr.WriteEndElement();xmlWr.WriteEndDocument();xmlWr.Flush();/xmlWr.Close();mStream.Seek(0,SeekOrigin.Begin);StreamReader streamRr=new StreamReader(mStream,Encoding.GetEncoding(GB2312);xDoc.Load(streamRr);/载入内存流方式XslTransform xslTransform=new XslTransform();xslTransform.Load(Path+siteTemplateFile);MemoryStream stream1=new MemoryStream();xslTransform.Transform(xDoc,null,stream1); /输出到内存流,作为ftp上传参数stream1.Seek(0,SeekOrigin.Begin);/string indexFileName=index.html;if(IsRemote)IndexPublishToRemote(stream1,Homepage);elseIndexPublishToLocal(stream1,localPath+RemoteDir,Homepage);catch(Exception e)msg.Title=siteName+主页面;msg.State=0;msg.Status=失败;msg.Memo=站点主页(+e.Message.ToString()+);this.PubMsgList.Add(msg);private void IndexPublishToLocal(MemoryStream memoryStream,string pubDir,string filename)StreamReader streamReader=new StreamReader(memoryStream,Encoding.GetEncoding(gb2312);string buffer=; string received=; received+=streamReader.ReadLine();/读流中一行 while(received!=null) buffer+=received; buffer+=rn; received=streamReader.ReadLine(); buffer=StrReplace(buffer);if(!Directory.Exists(pubDir)Directory.CreateDirectory(pubDir);System.IO.StreamWriter sw = new StreamWriter(pubDir+filename, false, System.Text.Encoding.GetEncoding(gb2312);/sw.Write(EncodingStr);sw.Write(buffer);sw.Flush();sw.Close();private void IndexPublishToRemote(MemoryStream memoryStream,string filename)StreamReader streamReader=new StreamReader(memoryStream,Encoding.GetEncoding(gb2312);string buffer=; string received=; received+=streamReader.ReadLine();/读流中一行 while(received!=null) buffer+=received; buffer+=rn; received=streamReader.ReadLine(); buffer=StrReplace(buffer);System.IO.StreamWriter sw = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath(+publishTempPath).ToString()+filename,false, Encoding.GetEncoding(gb2312);/sw.Write(EncodingStr);sw.Write(buffer);sw.Flush();sw.Close();ftpc.ChangeDir(/);public void updateClassPage(int uclassid)DataRow classDr=classInstance.GetClassById(uclassid);int ClassType=int.Parse(classDrClassType.ToString();if(ClassType=4)return; /如果是单页面发布型的栏目则无须更新PubMessage msg=new PubMessage();int pagesize=10; /每页显示记录数string classid=classDrClassId.ToString();string classDirName=classDrShortName.ToString();string classname=classDrname.ToString();pagesize=int.Parse(classDritemNumber.ToString();msg.Title=classname;msg.Id=classid;string templatefile=classDrtemplate.ToString();string navStr=;string returnNavStr=;tryDataView pclasses=GetAllClassesBySubID(int.Parse(classid);int num=pclasses.Table.Rows.Count;if(num0)for(int j=0;jnum;j+)/string dir=pclasses.Table.RowsjClassId.ToString();string dir=pclasses.Table.RowsjShortName.ToString();string cname=pclasses.Table.Rowsjname.ToString();navStr=->+cname+navStr;returnNavStr=->+cname+returnNavStr;navStr=navStr.Substring(5,navStr.Length-5);navStr=首页->+navStr;returnNavStr=returnNavStr.Substring(5,returnNa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司年会策划方案
- 人力资源部绩效管理体系优化方案
- 公务用车档案管理员岗位培训计划
- HR管理实-用指南招聘与留才的秘诀
- 企业管理-水利水电资金申请报告模板
- 仓储安全规范面试中必问知识点
- 健康工程师培训计划
- 中国烟草总公司内蒙古自治区公司笔试试题2025
- 元数据项目经理元数据检索方案
- 供应链风险管理方案及应急预案
- 安装护栏安全协议书范本
- 恋爱合同协议书 性关系
- 教育、科技、人才一体化发展
- (合同范本)游戏工作室合股合同7篇
- 2025年黑龙江省交通投资集团招聘笔试参考题库含答案解析
- DB32-T 4569-2023 发泡陶瓷保温板 保温系统应用技术规程
- 医院2025年人才工作总结和2025年工作计划
- 初中生心理健康家长会
- 支气管扩张护理课件
- 电脑租合同模板
- JG-T 562-2018 预制混凝土楼梯
评论
0/150
提交评论