diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NewsController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NewsController.cs index 8bbc465b0..5338529bc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NewsController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NewsController.cs @@ -1,6 +1,13 @@ using Learun.Application.OA; +using Learun.Application.TwoDevelopment.LR_Desktop; using Learun.Util; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Net; +using System.Web; using System.Web.Mvc; +using System.Web.Script.Serialization; namespace Learun.Application.Web.Areas.LR_OAModule.Controllers { @@ -14,6 +21,7 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers public class NewsController : MvcControllerBase { private NewsIBLL newsIBLL = new NewsBLL(); + WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL(); #region 视图功能 /// @@ -82,7 +90,57 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers { entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent); newsIBLL.SaveEntity(keyValue, entity); - return Success("保存成功!"); + + #region 发送到网站 + if (entity.IsSend == "1") + { + //获取配置文件 + string siteId = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["SiteId"]); + string channelId = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["ChannelId"]); + string ApiKey = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["ApiKey"]); + SemdNewList SendNew = new SemdNewList + { + Title = entity.F_FullHead, + SubTitle = entity.F_BriefHead, + Content = entity.F_NewsContent, + Author = entity.F_AuthorName, + Source = entity.F_SourceName, + AddDate = DateTime.Now, + Tags = entity.F_TagWord, + AddUserName = entity.F_CreateUserName, + }; + WebHeaderCollection ApiId = new WebHeaderCollection + { + { "X-SS-API-KEY", ApiKey } + }; + string responses = Util.HttpMethods.HttpPosts("http://localhost:8005/api/v1/contents/" + siteId + "/" + channelId, SendNew.ToJson(), ApiId); + + #endregion + #region 修改审核状态 + JavaScriptSerializer Jss = new JavaScriptSerializer(); + Dictionary DicText = (Dictionary)Jss.DeserializeObject(responses); + string Nid = DicText["id"].ToString(); + AuditList AList = new AuditList(); + if (Nid != null) + { + AList.siteId = siteId; + List listCon = new List(); + //这里应该循环,如果多个 + contents con = new contents(); + con.channelId = Convert.ToInt32(channelId); + con.id = Convert.ToInt32(Nid); + listCon.Add(con); + AList.contents = listCon; + AList.reasons = "终审通过"; + Util.HttpMethods.HttpPosts("http://localhost:8005/api/v1/contents/actions/check", AList.ToJson(), ApiId); + } + #endregion + return Success("发布成功!"); + } + else + { + return Success("保存成功!"); + } } /// /// 删除表单数据 @@ -97,5 +155,6 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers return Success("删除成功!"); } #endregion + } } \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.cshtml index 58e677d48..acf4cb7e9 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.cshtml @@ -4,10 +4,14 @@ }
-
+
新闻标题*
+
+
是否下发到CMS
+
+
新闻栏目*
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.js index 9d15f5b68..a6e7d2b64 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Form.js @@ -17,6 +17,11 @@ var bootstrap = function ($, learun) { page.initData(); }, bind: function () { + $('#IsSend').lrselect({ + data: [{ text: "是", value: "1" }, { text: "否", value: "0" }], + text: "text", + value: "value" + }) //新闻栏目 $('#F_CategoryId').lrDataItemSelect({ code: 'NewsCategory', maxHeight: 230 }); //内容编辑器 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Index.js index dd4c5980a..e022b481a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/News/Index.js @@ -20,6 +20,11 @@ var bootstrap = function ($, learun) { var keyword = $('#txt_Keyword').val(); page.search({ keyword: keyword }); }); + $('#IsSend').lrselect({ + data: [{ text: "是", value: "1" }, { text: "是", value: "否" }], + text: "text", + value: "value" + }) // 刷新 $('#lr_refresh').on('click', function () { location.reload(); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config index 689551bb5..28fd8c9e0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config @@ -167,4 +167,9 @@ + + + + + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs index 50420fb2c..4c8f43f31 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsEntity.cs @@ -1,5 +1,6 @@ using Learun.Util; using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; namespace Learun.Application.OA @@ -206,6 +207,12 @@ namespace Learun.Application.OA ///
[NotMapped] public string RTime { get; set; } + + /// + /// 是否下发到网站 + /// + [NotMapped] + public string IsSend { get; set; } #endregion #region 扩展操作 @@ -240,6 +247,173 @@ namespace Learun.Application.OA } #endregion + } + + public class SemdNewList + { + /// + /// 添加人 + /// + [NotMapped] + public string AddUserName { get; set; } + /// + /// 修改人 + /// + [NotMapped] + public string LastEditUserName { get; set; } + /// + /// 投稿人 + /// + [NotMapped] + public string WritingUserName { get; set; } + /// + /// 修改时间 + /// + [NotMapped] + public DateTime? LastEditDate { get; set; } + /// + /// 排序 + /// + [NotMapped] + public int? Taxis { get; set; } + /// + /// 内容组 + /// + [NotMapped] + public string GroupNameCollection { get; set; } + /// + /// 标签 + /// + [NotMapped] + public string Tags { get; set; } + /// + /// 来源内容Id + /// + [NotMapped] + public int? SourceId { get; set; } + /// + /// 引用内容Id + /// + [NotMapped] + public int? ReferenceId { get; set; } + /// + /// 是否终审通过通过 + /// + [NotMapped] + public string IsChecked { get; set; } + /// + /// 未终审通过情况下,处于第几级审核状态 + /// + [NotMapped] + public int? CheckedLevel { get; set; } + /// + /// 总点击量 + /// + [NotMapped] + public int? Hits { get; set; } + /// + /// 日点击 + /// + [NotMapped] + public int? HitsByDay { get; set; } + /// + /// 月点击 + /// + [NotMapped] + public int? HitsByMonth { get; set; } + /// + /// 最后点击时间 + /// + [NotMapped] + public DateTime? LastHitsDate { get; set; } + /// + /// 标题 + /// + [NotMapped] + public string Title { get; set; } + [NotMapped] + /// + /// 是否置顶内容 + /// + public int? IsTop { get; set; } + /// + /// 是否置顶内容 + /// + [NotMapped] + public int? IsRecommend { get; set; } + /// + /// 是否热点内容 + /// + [NotMapped] + public int? IsHot { get; set; } + /// + /// 是否醒目内容 + /// + [NotMapped] + public int? IsColor { get; set; } + /// + /// 外部链接 + /// + [NotMapped] + public string LinkUrl { get; set; } + /// + /// 添加时间 + /// + [NotMapped] + public DateTime? AddDate { get; set; } + /// + /// 内容副标题 + /// + [NotMapped] + public string SubTitle { get; set; } + /// + /// 内容图片 + /// + [NotMapped] + public string ImageUrl { get; set; } + /// + /// 内容视频 + /// + [NotMapped] + public string VideoUrl { get; set; } + /// + /// 内容附件 + /// + [NotMapped] + public string FileUrl { get; set; } + /// + /// 内容正文 + /// + [NotMapped] + public string Content { get; set; } + /// + /// 内容摘要 + /// + [NotMapped] + public string Summary { get; set; } + /// + /// 作者 + /// + [NotMapped] + public string Author { get; set; } + /// + /// 来源 + /// + [NotMapped] + public string Source { get; set; } + } + + public class AuditList + { + public string siteId { get; set; } + public List contents { get; set; } + public string reasons { get; set; } + } + + public class contents + { + public int channelId { get; set; } + public int id { get; set; } } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs index 27ded0347..947f80a48 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Web/HttpMethods.cs @@ -148,5 +148,32 @@ namespace Learun.Util } return result; } + + public static string HttpPosts(string url, string json, WebHeaderCollection header) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json;charset=UTF-8"; + req.Headers.Add(header); + byte[] data = Encoding.UTF8.GetBytes(json);//把字符串转换为字节 + + req.ContentLength = data.Length; //请求长度 + + using (Stream reqStream = req.GetRequestStream()) //获取 + { + reqStream.Write(data, 0, data.Length);//向当前流中写入字节 + reqStream.Close(); //关闭当前流 + } + + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); //响应结果 + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } } }