public JsonResult getChannelByID(string channelID, int TypeId) { string[] channelIDs = channelID.Split('"'); channelID = channelIDs[0]; Channel msg = channelBLL.Get("ChannelID", channelID); string shtml = LoaddrpData(channelID, TypeId); msg.Shtml = shtml; JsonResult json = new JsonResult(msg); return(json); }
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()); //添加/修改成功 }