Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

172 righe
5.9 KiB

  1. using Learun.Application.OA;
  2. using Learun.Application.TwoDevelopment.LR_Desktop;
  3. using Learun.Util;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Configuration;
  8. using System.Net;
  9. using System.Web;
  10. using System.Web.Mvc;
  11. using System.Web.Script.Serialization;
  12. namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
  13. {
  14. /// <summary>
  15. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  16. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  17. /// 创建人:陈彬彬
  18. /// 日 期:2017.04.01
  19. /// 描 述:新闻管理
  20. /// </summary>
  21. public class NewsController : MvcControllerBase
  22. {
  23. private NewsIBLL newsIBLL = new NewsBLL();
  24. WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL();
  25. #region 视图功能
  26. /// <summary>
  27. /// 管理页面
  28. /// </summary>
  29. /// <returns></returns>
  30. [HttpGet]
  31. public ActionResult Index()
  32. {
  33. return View();
  34. }
  35. /// <summary>
  36. /// 表单页面
  37. /// </summary>
  38. /// <returns></returns>
  39. [HttpGet]
  40. public ActionResult Form()
  41. {
  42. return View();
  43. }
  44. #endregion
  45. #region 获取数据
  46. /// <summary>
  47. /// 获取分页数据
  48. /// </summary>
  49. /// <param name="pagination">分页参数</param>
  50. /// <param name="categoryId">类型</param>
  51. /// <param name="keyword">关键词</param>
  52. /// <returns></returns>
  53. public ActionResult GetPageList(string pagination, string keyword)
  54. {
  55. Pagination paginationobj = pagination.ToObject<Pagination>();
  56. var data = newsIBLL.GetPageList(paginationobj, keyword);
  57. var jsonData = new
  58. {
  59. rows = data,
  60. total = paginationobj.total,
  61. page = paginationobj.page,
  62. records = paginationobj.records,
  63. };
  64. return JsonResult(jsonData);
  65. }
  66. /// <summary>
  67. /// 获取实体数据
  68. /// </summary>
  69. /// <param name="keyValue">主键</param>
  70. /// <returns></returns>
  71. public ActionResult GetEntity(string keyValue)
  72. {
  73. var data = newsIBLL.GetEntity(keyValue);
  74. data.F_NewsContent = WebHelper.HtmlDecode(data.F_NewsContent);
  75. return JsonResult(data);
  76. }
  77. #endregion
  78. #region 提交数据
  79. /// <summary>
  80. /// 保存表单数据
  81. /// </summary>
  82. /// <param name="keyValue">主键</param>
  83. /// <param name="entity">实体</param>
  84. /// <returns></returns>
  85. [HttpPost, ValidateAntiForgeryToken, AjaxOnly, ValidateInput(false)]
  86. public ActionResult SaveForm(string keyValue, NewsEntity entity)
  87. {
  88. entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent);
  89. newsIBLL.SaveEntity(keyValue, entity);
  90. #region 发送到网站
  91. if (entity.F_IsSendCMS == 1)
  92. {
  93. //获取配置文件
  94. string siteId = ConfigurationManager.AppSettings["SiteId"];
  95. string channelId = ConfigurationManager.AppSettings["ChannelId"];
  96. string ApiKey = ConfigurationManager.AppSettings["ApiKey"];
  97. string Ports = ConfigurationManager.AppSettings["Ports"];
  98. #region 下发到CMS
  99. SemdNewList SendNew = new SemdNewList
  100. {
  101. Title = entity.F_FullHead,
  102. SubTitle = entity.F_BriefHead,
  103. Content = entity.F_NewsContent,
  104. Author = entity.F_AuthorName,
  105. Source = entity.F_SourceName,
  106. AddDate = DateTime.Now,
  107. Tags = entity.F_TagWord,
  108. AddUserName = entity.F_CreateUserName,
  109. };
  110. WebHeaderCollection ApiId = new WebHeaderCollection
  111. {
  112. { "X-SS-API-KEY", ApiKey }
  113. };
  114. string responses = Util.HttpMethods.HttpPosts("http://" + Ports + "/api/v1/contents/" + siteId + "/" + channelId, SendNew.ToJson(), ApiId);
  115. #endregion
  116. #region 修改审核状态
  117. string Nid = JsonConvert.DeserializeObject<Root>(responses).value.id;
  118. AuditList AList = new AuditList();
  119. if (Nid != null)
  120. {
  121. AList.siteId = Convert.ToInt32(siteId);
  122. List<contents> listCon = new List<contents>();
  123. //这里应该循环,如果多个
  124. contents con = new contents();
  125. con.channelId = Convert.ToInt32(channelId);
  126. con.id = Convert.ToInt32(Nid);
  127. listCon.Add(con);
  128. AList.contents = listCon;
  129. //AList.reasons = "终审通过";
  130. Util.HttpMethods.HttpPosts("http://" + Ports + "/api/v1/contents/check", AList.ToJson(), ApiId);
  131. //Util.HttpMethods.HttpPosts("http://"+Ports+"/api/v1/contents/actions/check", AList.ToJson(), ApiId);
  132. }
  133. #endregion
  134. return Success("发布成功!");
  135. }
  136. else
  137. {
  138. return Success("保存成功!");
  139. }
  140. #endregion
  141. }
  142. /// <summary>
  143. /// 删除表单数据
  144. /// </summary>
  145. /// <param name="keyValue">主键</param>
  146. /// <returns></returns>
  147. [HttpPost]
  148. [AjaxOnly]
  149. public ActionResult DeleteForm(string keyValue)
  150. {
  151. newsIBLL.DeleteEntity(keyValue);
  152. return Success("删除成功!");
  153. }
  154. #endregion
  155. }
  156. public class Root
  157. {
  158. public RootValue value { get; set; }
  159. }
  160. public class RootValue
  161. {
  162. public string id { get; set; }
  163. }
  164. }