public static void CreateNewsHtml(String newsId, String fileName, bool checkExists) { if ((!checkExists) || (!System.IO.File.Exists(fileName))) { var news = new BLL.news.V_NewsInfo().GetModel(Int64.Parse(newsId)); if (news != null) { // 读取模板文件 string temp = HttpContext.Current.Server.MapPath("/home/news/template/news_template.html"); String newsStr = FileOperate.ReadFile(temp); newsStr = newsStr.Replace("titlexxx", news.NI_Tile); StringBuilder sb = new StringBuilder(); if (news.UI_RealName != "") { sb.Append("<span>发布者:").Append(news.UI_RealName).Append("</span>"); } var isCampusCol = IsCampusCol(news.NCh_Id); if (isCampusCol) { var newsChannel = new BLL.news.News_NewsChannel().GetModel(news.NCh_Id); //content += "<p>来源:<a href='" + newsChannel.NCh_RssUrl + "'>" + newsChannel.NCh_Name + "</a></p>"; sb.Append(" <span>来源:" + newsChannel.NCh_Name + "</span>"); } sb.Append(" "); sb.Append(news.CN_PubDate); //sb.Append(" ").Append("阅读次数:").Append(news.NI_ReadNum); newsStr = newsStr.Replace("desxxx", sb.ToString()); String content = HttpContext.Current.Server.HtmlDecode(news.NI_Content); //newsStr = newsStr.Replace("contentxxx", content); newsStr = newsStr.Replace("contentxxx", NewsHelper.SetHtmlImgWidth(content, "98%", "")); sb.Clear(); var newsAttach = new BLL.news.News_NewsInfo().GetModel(Int64.Parse(newsId)).NewsAttach; if (newsAttach != null && newsAttach.Count > 0) { sb.Append("<p class='attachTitle'>附件:</p>"); var itemCnt = 1; foreach (var item in newsAttach) { sb.Append("<p class='attachItem'>(").Append(itemCnt).Append(") <a href='") .Append("/home/news/Attach.aspx?id=").Append(DESEncrypt.Encrypt(item.NA_Id.ToString())) .Append("&address=").Append(HttpUtility.UrlEncode(item.NA_Address)) .Append("&name=").Append(HttpUtility.UrlEncode(item.NA_Name)) .Append("' target='_blank' >") .Append(item.NA_Name) .Append("</a>") .Append(OnlineViewHelper.GetOnlineViewWrapLink(item.NA_Address, item.NA_Name)) .Append("</p>"); itemCnt++; } } newsStr = newsStr.Replace("attachxxx", sb.ToString()); //写文件 FileOperate.WriteNewFile(fileName, newsStr); } } }
public static void CreateWebNewsHtml(String newsId, String fileName, bool checkExists) { if ((!checkExists) || (!System.IO.File.Exists(fileName))) { var news = new BLL.CCOM.News().GetModel(Int32.Parse(newsId)); if (news != null) { // 读取模板文件 string temp = HttpContext.Current.Server.MapPath("news_temp.html"); String newsStr = FileOperate.ReadFile(temp); newsStr = newsStr.Replace("titlexxx", news.News_title); StringBuilder sb = new StringBuilder(); int creator_id = news.News_creator_id; string realname = new BLL.CCOM.User_information().GetModel(creator_id).User_realname; if (realname != "请填写真实姓名") { sb.Append("<span>发布者:").Append(realname).Append("</span>"); } sb.Append(" "); sb.Append(news.News_date); //sb.Append(" ").Append("阅读次数:").Append(news.NI_ReadNum); newsStr = newsStr.Replace("desxxx", sb.ToString()); String content = HttpContext.Current.Server.HtmlDecode(news.News_content); newsStr = newsStr.Replace("contentxxx", content); sb.Clear(); //var newsAttach = new BLL.news.News_NewsInfo().GetModel(Int64.Parse(newsId)).NewsAttach; string strWhere = " News_id=" + newsId; var newsAttach = new BLL.CCOM.News_attach().GetModelList(strWhere); if (newsAttach != null && newsAttach.Count > 0) { sb.Append("<p class='attachTitle'>附件:</p>"); var itemCnt = 1; foreach (var item in newsAttach) { sb.Append("<p class='attachItem'>(").Append(itemCnt).Append(") <a href='") .Append("/home/news/Attach.aspx?id=").Append(DESEncrypt.Encrypt(item.News_attach_id.ToString())) .Append("&address=").Append(HttpUtility.UrlEncode(item.News_attach_address)) .Append("&name=").Append(HttpUtility.UrlEncode(item.News_attach_name)) .Append("' target='_blank' >") .Append(item.News_attach_name) .Append("</a>") .Append(OnlineViewHelper.GetOnlineViewWrapLink(item.News_attach_address, item.News_attach_name)) .Append("</p>"); itemCnt++; } } newsStr = newsStr.Replace("attachxxx", sb.ToString()); ////写文件 FileOperate.WriteNewFile(fileName, newsStr); } } }
public static void CreateWebPushHtml(String pushId, String fileName, bool checkExists) { if ((!checkExists) || (!System.IO.File.Exists(fileName))) { var push = new BLL.CCOM.Notice().GetModel(Int64.Parse(pushId)); if (push != null) { //根据通知类型,读取对应的模板文件 string temp = HttpContext.Current.Server.MapPath("/AdminMetro/CCOM/notice/Notice_temp.html"); //图文通知 if (push.Notice_type != null && (bool)push.Notice_type) { temp = HttpContext.Current.Server.MapPath("/AdminMetro/CCOM/notice/Notice_image_temp.html"); } String pushStr = FileOperate.ReadFile(temp); //替换推送者 string realname = new BLL.CCOM.User_information().GetModel(push.Notice_sender_id).User_realname; pushStr = pushStr.Replace("authorxxx", realname); //替换发布日期 pushStr = pushStr.Replace("pubdatexxx", push.Notice_date.ToString()); //替换通知内容 String content = HttpContext.Current.Server.HtmlDecode(push.Notice_content); pushStr = pushStr.Replace("contentxxx", content); //替换标题 pushStr = pushStr.Replace("titlexxx", push.Notice_title); //图文通知还需要替换附件 if (push.Notice_type != null && (bool)push.Notice_type) { //替换附件 StringBuilder sb = new StringBuilder(); var attachList = new BLL.CCOM.Notice_attach().GetModelList("Notice_id = " + pushId); if (attachList.Count > 0) { sb.Append("<p class='attachTitle'>附件:</p>"); var itemCnt = 1; foreach (var item in attachList) { sb.Append("<p class='attachItem'>(").Append(itemCnt).Append(") <a href='") .Append("/home/push/Attach.aspx?id=").Append(DESEncrypt.Encrypt(item.Notice_attach_id.ToString())) .Append("&address=").Append(HttpUtility.UrlEncode(item.Notice_attach_address)) .Append("&name=").Append(HttpUtility.UrlEncode(item.Notice_attach_name)) .Append("' target='_blank' >") .Append(item.Notice_attach_name) .Append("</a>") .Append(OnlineViewHelper.GetOnlineViewWrapLink(item.Notice_attach_address, item.Notice_attach_name)) .Append("</p>"); itemCnt++; } } pushStr = pushStr.Replace("attachxxx", sb.ToString()); } //写文件 FileOperate.WriteNewFile(fileName, pushStr); } } }