|
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.LR_Desktop;
- using System.Web.Mvc;
- using System.Collections.Generic;
- using System.Collections;
- using System;
- using System.Linq;
-
- namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
- /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- /// 创 建:超级管理员
- /// 日 期:2021-04-23 16:58
- /// 描 述:消息提醒
- /// </summary>
- public class MessageRindController : MvcControllerBase
- {
- private MessageRindIBLL messageRindIBLL = new MessageRindBLL();
- private PsychologyReplyInfoIBLL psychologyReplyInfoIBLL = new PsychologyReplyInfoBLL();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 未读消息页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult UnreadIndex()
- {
- ViewBag.Name = (LoginUserInfo.Get()).realName;
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = messageRindIBLL.GetPageList(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
-
- /// <summary>
- /// 获取未读的消息的数量
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetCountForUnread()
- {
- var count = messageRindIBLL.GetCountForUnread();
-
- return Success(count);
- }
- /// <summary>
- /// 获取未读的消息
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetListForUnread()
- {
- var data = messageRindIBLL.GetListForUnread();
- //心理咨询数据
- var PsychologyReplyData = psychologyReplyInfoIBLL.GetListForUnread().OrderBy(x => x.IsReply).OrderBy(x => x.CreateTime);
- List<Hashtable> list = new List<Hashtable>();
- foreach (var item in PsychologyReplyData)
- {
- var url = "/LR_Desktop/PsychologyReplyInfo/Index";
- var title = "心理咨询";
- //跳转地址
- if (item.Description == "学生")
- {
- url = "/EducationalAdministration/PsychologyInfo/Index";
- }
- else
- {
- if (item.State == 2)
- {
- title = "心理回复-辅导员";
- }
- if (item.State == 3)
- {
- title = "心理回复-分院";
- url = "/LR_Desktop/PsychologyReplyInfo/Index3";
- }
- else if (item.State == 4)
- {
- title = "心理回复-学工";
- url = "/LR_Desktop/PsychologyReplyInfo/Index4";
- }
- else if (item.State == 5)
- {
- title = "心理回复-总站";
- url = "/LR_Desktop/PsychologyReplyInfo/IndexFive";
- }
- else if (item.State == 6)
- {
- title = "心理回复-老师";
- url = "/LR_Desktop/PsychologyReplyInfo/IndexSix";
- }
- if (item.IsReply == 0)
- url = "/LR_Desktop/PsychologyReplyInfo/IndexReply";
- else
- title = "心理咨询";
- }
- Hashtable ht = new Hashtable();
- ht["MessageId"] = item.Id;
- ht["SenderName"] = "";
- ht["TheTitle"] = title;
- ht["TheContent"] = item.Concent;
- ht["ConnectionUrl"] = url + "?type=" + item.State + "&keyvalue=";
- ht["InstanceId"] = item.Id;
- ht["isReply"] = item.IsReply;
- list.Add(ht);
- }
- //获取未处理的维修任务
- foreach (var entity in data)
- {
- Hashtable ht = new Hashtable();
- ht["MessageId"] = entity.MessageId;
- ht["SenderName"] = entity.SenderName;
- ht["TheTitle"] = entity.TheTitle;
- ht["TheContent"] = entity.TheContent;
- ht["ConnectionUrl"] = entity.ConnectionUrl;
- ht["InstanceId"] = entity.InstanceId;
- ht["isReply"] = 1;
- list.Add(ht);
- }
- return ToJsonResult(list);
- }
-
- /// <summary>
- /// 获取表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormData(string keyValue)
- {
- var MessageRemindData = messageRindIBLL.GetMessageRemindEntity(keyValue);
- var jsonData = new
- {
- MessageRemind = MessageRemindData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- messageRindIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="strEntity">实体</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- MessageRemindEntity entity = strEntity.ToObject<MessageRemindEntity>();
- messageRindIBLL.SaveEntity(keyValue, entity);
- if (string.IsNullOrEmpty(keyValue))
- {
- }
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 更改状态为已读
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="strEntity">实体</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult SaveReadSigns(string keyValue, string title)
- {
- if (!string.IsNullOrEmpty(keyValue))
- {
- if (title.Contains("心理咨询"))
- {
- psychologyReplyInfoIBLL.UpdateEntity(keyValue);
- }
- //else if (title.Contains("维修通知"))
- //{
-
- //}
- else
- {
- messageRindIBLL.SaveReadSigns(keyValue);
- }
- }
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 更改状态为已读
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult SaveReadSignsByUserId()
- {
- var loginUserInfo = LoginUserInfo.Get();
- if (!string.IsNullOrEmpty(loginUserInfo.userId))
- {
- messageRindIBLL.SaveReadSignsByUserId(loginUserInfo.userId);
- }
- return Success("保存成功!");
- }
-
- #endregion
-
- }
- }
|