您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->NETCMSv1.5(Build0509)完整源码版>>NetCMS.Content/NewsJS.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:NETCMSv1.5(Build0509)完整源码版
当前文件:文件类型 NetCMSv15/NetCMS.Content/NewsJS.cs打开代码结构图
普通视图
		            
1//====================================================== 2//== (c)2008 aspxcms inc by NeTCMS v1.0 == 3//== Forum:bbs.aspxcms.com == 4//== Website:www.aspxcms.com == 5//====================================================== 6using System; 7using System.Data; 8using System.IO; 9using System.Collections.Generic; 10using System.Text; 11using NetCMS.Model; 12using NetCMS.DALFactory; 13 14namespace NetCMS.Content 15{ 16 public class NewsJS 17 { 18 private INewsJS dal; 19 public NewsJS() 20 { 21 dal = DataAccess.CreateNewsJS(); 22 } 23 public IList<NewsJSInfo> GetPage(int PageIndex, int PageSize, out int RecordCount, out int PageCount, int JsType) 24 { 25 return dal.GetPage(PageIndex, PageSize, out RecordCount, out PageCount, JsType); 26 } 27 public void Delete(string id) 28 { 29 dal.Delete(id); 30 } 31 public DataTable GetJSFilePage(int PageIndex, int PageSize, out int RecordCount, out int PageCount, int id) 32 { 33 return dal.GetJSFilePage(PageIndex, PageSize, out RecordCount, out PageCount, id); 34 } 35 public DataTable GetJSFiles(string jsid) 36 { 37 return dal.GetJSFiles(jsid); 38 } 39 public void RemoveNews(int id) 40 { 41 dal.RemoveNews(id); 42 } 43 public NewsJSInfo GetSingle(int id) 44 { 45 return dal.GetSingle(id); 46 } 47 public void Update(NewsJSInfo info) 48 { 49 dal.Update(info); 50 EstablishJsFile(info); 51 } 52 /// <summary> 53 /// 重新生成JS文件 54 /// </summary> 55 /// <param name="id"></param> 56 public void RebuildFile(int id) 57 { 58 NewsJSInfo info = GetSingle(id); 59 EstablishJsFile(info); 60 } 61 public void Add(NewsJSInfo info) 62 { 63 info.JsID = dal.Add(info); 64 EstablishJsFile(info); 65 } 66 private void EstablishJsFile(NewsJSInfo info) 67 { 68 string JsContent = ""; 69 string TmpContent = GetJsTmpContent(info.JsTempletID); 70 if (TmpContent.Trim() != "") 71 { 72 if (info.jsType == 0) 73 { 74 系统JS 系统JS 81 } 82 else 83 { 84 自由JS 自由JS 99 } 100 } 101 JsContent = JsContent.Replace("\r\n", " "); 102 string JsPath = info.jssavepath; 103 if (JsPath.Substring(JsPath.Length - 1, 1) != "\\") 104 JsPath += "\\"; 105 JsPath = NetCMS.Common.ServerInfo.GetRootPath() + "\\" + JsPath; 106 if (!Directory.Exists(JsPath)) 107 Directory.CreateDirectory(JsPath); 108 string FileName = JsPath + info.jsfilename + ".js"; 109 using (StreamWriter sw = new StreamWriter(FileName, false)) 110 { 111 string FileContent = "document.write('"; 112 FileContent += JsContent.Replace("'","\'"); 113 FileContent += "');"; 114 sw.Write(FileContent); 115 } 116 } 117 private string GetJsTmpContent(string jstmpid) 118 { 119 return dal.GetJsTmpContent(jstmpid); 120 } 121 } 122} 123
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:NETCMSv1.5(Build0509)完整源码版