You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

160 lines
5.7 KiB

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