From de1684e161dc8485e980a9d78b4a3076ef8a335f Mon Sep 17 00:00:00 2001 From: ndbs Date: Fri, 24 Dec 2021 15:17:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=8F=91=E9=80=9A=E7=9F=A5=E5=85=AC?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LR_OAModule/Views/Notice/FormFlow.cshtml | 6 +- .../LR_OAModule/Views/Notice/FormFlow.js | 5 + .../Areas/LR_OAModule/Views/Notice/Index.js | 5 + .../XmlConfig/system.config | 9 + .../Learun.Application.OA.csproj | 4 + .../Learun.Application.OA/News/NewsEntity.cs | 172 ++++++++++++++++++ .../Learun.Application.OA/News/NewsService.cs | 58 +++++- .../Learun.Util/Web/HttpMethods.cs | 27 +++ 8 files changed, 282 insertions(+), 4 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.cshtml index f80c7809c..2a0d89168 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.cshtml @@ -4,10 +4,14 @@ }
-
+
公告标题*
+
+
下发CMS*
+
+
公告类别*
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.js index 8cb2bc2fd..6c6b9199c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/FormFlow.js @@ -26,6 +26,11 @@ var bootstrap = function ($, learun) { }, bind: function () { var loginInfo = top.learun.clientdata.get(['userinfo']); + $('#IsSend').lrselect({ + data: [{ text: "是", value: "1" }, { text: "否", value: "0" }], + text: "text", + value: "value" + }); //公告类别 $('#F_CategoryId').lrselect({ url: top.$.rootUrl + '/LR_OAModule/Notice/GetNoticeCategoryByDepartment?userId=' + loginInfo.userId, diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Index.js index fbb4547d1..8f1430fc0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/Notice/Index.js @@ -23,6 +23,11 @@ var bootstrap = function ($, learun) { $('#lr_refresh').on('click', function () { location.reload(); }); + $('#IsSend').lrselect({ + data: [{ text: "是", value: "1" }, { text: "是", value: "否" }], + text: "text", + value: "value" + }); // 新增 $('#lr_add').on('click', function () { learun.layerForm({ 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 13b68a4ce..ea87cb9b4 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,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Learun.Application.OA.csproj b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Learun.Application.OA.csproj index 164545276..728c69d8d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Learun.Application.OA.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Learun.Application.OA.csproj @@ -45,6 +45,9 @@ False ..\..\..\packages\Dapper.1.50.2\lib\net45\Dapper.dll + + ..\..\..\packages\Nancy.1.4.1\lib\net40\Nancy.dll + ..\..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll @@ -95,6 +98,7 @@ + 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 ce821e2fa..c22cf9573 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; } + + /// + /// 是否下发到网站 + /// + [Column("ISSEND")] + public string IsSend { get; set; } #endregion #region 扩展操作 @@ -241,6 +248,171 @@ 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.Application.Module/Learun.Application.OA/News/NewsService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs index 0749d2131..cd2fbe287 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/News/NewsService.cs @@ -2,8 +2,13 @@ using Learun.Util; using System; using System.Collections.Generic; +using System.Net; using System.Text; +using Nancy.Json; using Spire.Pdf.General.Render.Decode.Jpeg2000.Icc; +using static Learun.Application.OA.NewsEntity; +using Nancy.Helpers; +using System.Configuration; namespace Learun.Application.OA { @@ -16,6 +21,7 @@ namespace Learun.Application.OA /// public class NewsService : RepositoryFactory { + #region 获取数据 /// /// 新闻列表 @@ -178,14 +184,60 @@ namespace Learun.Application.OA try { - var newEntity = this.BaseRepository() - .FindEntity(a => a.F_ProgressId == parameterProcessId); + var newEntity = this.BaseRepository().FindEntity(a => a.F_ProgressId == parameterProcessId); if (null != newEntity) { if (status == 2) { - newEntity.F_Status = "2"; + if (newEntity.IsSend == "1") //判断是否下发 + { + #region 获取配置文件 + + string siteId = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["SiteId"]); + string channelId = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["ChannelId"]); + string ApiKey = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["ApiKey"]); + string ports = HttpUtility.UrlEncode(ConfigurationManager.AppSettings["Ports"]); + + #endregion + SemdNewList SendNew = new SemdNewList + { + Title = newEntity.F_FullHead, + SubTitle = newEntity.F_BriefHead, + Content = newEntity.F_NewsContent, + Author = newEntity.F_AuthorName, + Source = newEntity.F_SourceName, + AddDate = DateTime.Now, + Tags = newEntity.F_TagWord, + AddUserName = newEntity.F_CreateUserName, + }; + WebHeaderCollection ApiId = new WebHeaderCollection + { + { "X-SS-API-KEY", ApiKey } + }; + + string responses = Util.HttpMethods.HttpPosts("http://localhost:" + ports + "/api/v1/contents/" + siteId + "/" + channelId, SendNew.ToJson(), ApiId); + + #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:" + ports + "/api/v1/contents/actions/check", AList.ToJson(), ApiId); + } + #endregion + } } else { 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..6e1f9085d 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; + } } }