using Learun.Application.OA; using Learun.Application.TwoDevelopment.LR_Desktop; using Learun.Util; using Newtonsoft.Json; 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 { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创建人:陈彬彬 /// 日 期:2017.04.01 /// 描 述:新闻管理 /// public class NewsController : MvcControllerBase { private NewsIBLL newsIBLL = new NewsBLL(); WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL(); #region 视图功能 /// /// 管理页面 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 表单页面 /// /// [HttpGet] public ActionResult Form() { return View(); } #endregion #region 获取数据 /// /// 获取分页数据 /// /// 分页参数 /// 类型 /// 关键词 /// public ActionResult GetPageList(string pagination, string keyword) { Pagination paginationobj = pagination.ToObject(); var data = newsIBLL.GetPageList(paginationobj, keyword); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return JsonResult(jsonData); } /// /// 获取实体数据 /// /// 主键 /// public ActionResult GetEntity(string keyValue) { var data = newsIBLL.GetEntity(keyValue); data.F_NewsContent = WebHelper.HtmlDecode(data.F_NewsContent); return JsonResult(data); } #endregion #region 提交数据 /// /// 保存表单数据 /// /// 主键 /// 实体 /// [HttpPost, ValidateAntiForgeryToken, AjaxOnly, ValidateInput(false)] public ActionResult SaveForm(string keyValue, NewsEntity entity) { entity.F_NewsContent = WebHelper.HtmlEncode(entity.F_NewsContent); newsIBLL.SaveEntity(keyValue, entity); #region 发送到网站 if (entity.F_IsSendCMS == 1) { //获取配置文件 string siteId = ConfigurationManager.AppSettings["SiteId"]; string channelId = ConfigurationManager.AppSettings["ChannelId"]; string ApiKey = ConfigurationManager.AppSettings["ApiKey"]; string Ports = ConfigurationManager.AppSettings["Ports"]; #region 下发到CMS 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://" + Ports + "/api/v1/contents/" + siteId + "/" + channelId, SendNew.ToJson(), ApiId); #endregion #region 修改审核状态 string Nid = JsonConvert.DeserializeObject(responses).value.id; AuditList AList = new AuditList(); if (Nid != null) { AList.siteId = Convert.ToInt32(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://" + Ports + "/api/v1/contents/check", AList.ToJson(), ApiId); //Util.HttpMethods.HttpPosts("http://"+Ports+"/api/v1/contents/actions/check", AList.ToJson(), ApiId); } #endregion return Success("发布成功!"); } else { return Success("保存成功!"); } #endregion } /// /// 删除表单数据 /// /// 主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm(string keyValue) { newsIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } #endregion } public class Root { public RootValue value { get; set; } } public class RootValue { public string id { get; set; } } }