public string MakeArticle(string newsId, string OperateType) { // string[] arrId; // arrId = newsId.Split(','); // foreach (var i in arrId) // { List <News> news = newsBLL.MakeArticle(newsId); for (var i = 0; i < news.Count; i++) { var channel = channelBLL.Get("ChannelId", news[i].ChannelId); //news.OrderDay = string.Format("{0:yyyyMMdd}", news.CreatedTime); //news.OrderTime = string.Format("{0:HHmmss}", news.CreatedTime); //news.OrderNum = 60; if (string.IsNullOrEmpty(news[i].Url)) { var createdTime = news[i].CreatedTime ?? DateTime.Now; news[i].Url = string.Format("/{0}/{1:yyyyMM}/{1:ddHHmmss}{2:fff}.html", channel.ChannelEnName, createdTime, DateTime.Now); newsBLL.UpdateNewsUrl(news[i].NewsId, news[i].Url); } HtmlServer.CreateSingleNews(news[i].NewsId, "add"); } return("000000"); }
public string AddEditTitleArticle(News news, string operateType, string blod) { if (string.IsNullOrEmpty(news.Title)) { return("000001"); //标题不能为空 } var channel = channelBLL.Get("ChannelId", news.ChannelId); if (news.ChannelId == "0" || channel == null) { return("000002"); //分类有误 } if (string.IsNullOrEmpty(blod)) { news.IsBold = (0).ToString(); } else { news.IsBold = (1).ToString(); } if (string.IsNullOrEmpty(news.CreatedTime.ToString())) { news.CreatedTime = DateTime.Now; } if (operateType == "add") { news.OrderDay = string.Format("{0:yyyyMMdd}", news.CreatedTime); news.OrderTime = string.Format("{0:HHmmss}", news.CreatedTime); if (string.IsNullOrEmpty(news.Url)) { news.SecondUrl = "http://"; } else { news.SecondUrl = news.Url; } news.SecondTitle = news.Title; } else { news.UpdatedTime = DateTime.Now; } int result = newsBLL.AddOrEdit(news, operateType); newsBLL.NewsStockRelation(result, news.StockCode); HtmlServer.CreateSingleNews(result, operateType); if (!string.IsNullOrEmpty(news.lmid)) { RelatedEmptyArticle(result, news.lmid, operateType); } return(result.ToString()); //添加/修改成功 }
public string MakeChannelIdArticle(string ChannelId) { List <News> news = newsBLL.GetChannelIdList(ChannelId); for (var i = 0; i < news.Count; i++) { var channel = channelBLL.Get("ChannelId", news[i].ChannelId); if (string.IsNullOrEmpty(news[i].Url)) { var createdTime = news[i].CreatedTime ?? DateTime.Now; news[i].Url = string.Format("/{0}/{1:yyyyMM}/{1:ddHHmmss}{2:fff}.html", channel.ChannelEnName, createdTime, DateTime.Now); newsBLL.UpdateNewsUrl(news[i].NewsId, news[i].Url); } HtmlServer.CreateSingleNews(news[i].NewsId, "add"); } return("000000"); }
public string AddEditArticle(News news, string operateType, string blod, int checkAbstract) { if (string.IsNullOrEmpty(news.Title)) { return("000001"); //标题不能为空 } var channel = channelBLL.Get("ChannelId", news.ChannelId); if (news.ChannelId == "0" || channel == null) { return("000002"); //分类有误 } //if (string.IsNullOrEmpty(news.Author)) //{ // return "000004"; //来源不能为空 //} if (string.IsNullOrEmpty(news.Content)) { return("000003"); //内容不能为空 } if (checkAbstract == 0) //自动获取摘要 { if (string.IsNullOrEmpty(news.NewsAbstract)) { if (!string.IsNullOrEmpty(news.Content)) { news.NewsAbstract = Regex.Replace(news.Content, @"<.+?>|&(.+?);|\n|-|—|chr(.+?)", "", RegexOptions.IgnoreCase); if (news.NewsAbstract.Length > 100) { news.NewsAbstract = news.NewsAbstract.Substring(0, 100); } } } } string absoluteUrl = "http://img.pinyifu.com"; news.Content = Regex.Replace(news.Content, "<(.*?)(src|href)=\"(?!http)(.*?)\"(.*?)>", "<$1$2=\"" + absoluteUrl + "$3\"$4>", RegexOptions.IgnoreCase | RegexOptions.Multiline); //return value.Replace(absoluteUrl + "/", absoluteUrl); //news.Content = news.Content; if (string.IsNullOrEmpty(blod)) { news.IsBold = (0).ToString(); } else { news.IsBold = (1).ToString(); } if (string.IsNullOrEmpty(news.CreatedTime.ToString())) { news.CreatedTime = DateTime.Now; } if (operateType == "add") { news.OrderDay = string.Format("{0:yyyyMMdd}", news.CreatedTime); news.OrderTime = string.Format("{0:HHmmss}", news.CreatedTime); news.Url = string.Format("/{0}/{1:yyyyMM}/{1:ddHHmmss}{2:fff}.html", channel.ChannelEnName, news.CreatedTime, DateTime.Now); news.SecondUrl = news.Url; news.SecondTitle = news.Title; } else { if (string.IsNullOrEmpty(news.Url)) { news.Url = news.SecondUrl; } news.UpdatedTime = DateTime.Now; } string strForeCast = ""; if (!string.IsNullOrEmpty(news.ForeCast)) { string[] str; str = news.ForeCast.Replace("\n", "@").Split('@'); for (int i = 0; i < str.Length; i++) { if (i == str.Length - 1) { strForeCast += str[i]; } else { strForeCast += str[i] + "|"; } } } news.ForeCast = strForeCast; int result = newsBLL.AddOrEdit(news, operateType); // Loger.Info(result.ToString() + "----------------"); HtmlServer.CreateSingleNews(result, operateType); if (!string.IsNullOrEmpty(news.lmid)) { RelatedEmptyArticle(result, news.lmid, operateType); } return(result.ToString()); //添加/修改成功 }