|
- 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
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.04.01
- /// 描 述:新闻管理
- /// </summary>
- public class NewsController : MvcControllerBase
- {
- private NewsIBLL newsIBLL = new NewsBLL();
- WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL();
-
- #region 视图功能
- /// <summary>
- /// 管理页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 表单页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
- /// <summary>
- /// 获取分页数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="categoryId">类型</param>
- /// <param name="keyword">关键词</param>
- /// <returns></returns>
- public ActionResult GetPageList(string pagination, string keyword)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = newsIBLL.GetPageList(paginationobj, keyword);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records,
- };
- return JsonResult(jsonData);
- }
- /// <summary>
- /// 获取实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- public ActionResult GetEntity(string keyValue)
- {
- var data = newsIBLL.GetEntity(keyValue);
- data.F_NewsContent = WebHelper.HtmlDecode(data.F_NewsContent);
- return JsonResult(data);
- }
- #endregion
-
- #region 提交数据
- /// <summary>
- /// 保存表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="entity">实体</param>
- /// <returns></returns>
- [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.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:8007/api/v1/contents/" + siteId + "/" + channelId, SendNew.ToJson(), ApiId);
-
- #endregion
- #region 修改审核状态
- JavaScriptSerializer Jss = new JavaScriptSerializer();
- Dictionary<string, object> DicText = (Dictionary<string, object>)Jss.DeserializeObject(responses);
- string Nid = DicText["id"].ToString();
- AuditList AList = new AuditList();
- if (Nid != null)
- {
- AList.siteId = siteId;
- List<contents> listCon = new List<contents>();
- //这里应该循环,如果多个
- 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:8007/api/v1/contents/actions/check", AList.ToJson(), ApiId);
- }
- #endregion
- return Success("发布成功!");
- }
- else
- {
- return Success("保存成功!");
- }
- }
- /// <summary>
- /// 删除表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- newsIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- #endregion
-
- }
- }
|