123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- using PMS.BusinessModels.Account;
- using PMS.BusinessModels.Problem;
- using PMS.EntityModels.NoticeManager;
- using PMS.Interface;
- using PMS.Interface.MessageManage;
- using QWPlatform.SystemLibrary.Utils;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace PMS.WebUI.Controllers
- {
- public class NoticeController : BaseController
- {
- #region 接口实例
- IMessageManage notice = InterfaceFactory.CreateBusinessInstance<IMessageManage>();
- #endregion
- #region 查询
- //通知类型
- public ActionResult NoticeType()
- {
- return Content(notice.NoticeType(), "application/json");
- }
- //通知优先级
- public ActionResult NoticeOrder()
- {
- return Content(notice.NoticeOrder(), "application/json");
- }
- //通知对象
- public ActionResult NoticePerson()
- {
- int PersonProperty = GetCurrentUser().PersonProperty;
- return Content(notice.NoticePerson(PersonProperty), "application/json");
- }
- //根据ID获取通知信息
- public ActionResult GetNoticeByID(string id)
- {
- return Content(notice.GetNoticeByID(id), "application/json");
- }
- //根据公告ID获取通知对象
- public ActionResult GetNatureByID(string id)
- {
- return Content(notice.GetNatureByID(id), "application/json");
- }
- //获取渠道
- public ActionResult GetChannelByNature()
- {
- var user = GetCurrentUser();
- return Content(notice.GetChannelByNature(user), "application/json");
- }
- //获取进入首页的通知公告
- public ActionResult ShowNotice()
- {
- var user = GetCurrentUser();
- return Content(notice.ShowNotice(user), "application/json");
- }
- //获取登陆人ID
- public string GetFeedbackID()
- {
- var user = GetCurrentUser();
- return user.PersonID;
- }
- #endregion
- #region 通知首页
- //公告首页
- public ActionResult Index()
- {
- return View();
- }
- //公告信息绑定
- public ActionResult DataBind(int page, int rows, string query)
- {
- var user = GetCurrentUser();
- return Content(notice.DataBind(page, rows, query, user), "application/json");
- }
- //获取首页公告信息
- public ActionResult GetHome()
- {
- var userInfo = GetCurrentUser();
- var json = notice.GetHome(userInfo);
- return Content(json, "application/json");
- }
- //公告列表首页
- public ActionResult HomeGetList(int page, int rows)
- {
- var user = GetCurrentUser();
- return Content(notice.HomeGetList(page, rows, user), "application/json");
- }
- //通知列表首页
- public ActionResult HomeGetNotice(int page, int rows)
- {
- var user = GetCurrentUser();
- return Content(notice.HomeGetNotice(page, rows, user), "application/json");
- }
- #endregion
- #region 首页通知公告显示
- //判断是否显示通知
- public bool PanDuanIsShow()
- {
- var user = GetCurrentUser();
- var Count = notice.GetCount(user);
- return Count > 0;
- }
- public ActionResult Notice_Window()
- {
- return View();
- }
- //显示总部和渠道的最新公告通知
- public ActionResult GetMessageOnIndex()
- {
- var user = GetCurrentUser();
- return Content(notice.GetMessageOnIndex(user), "application/json");
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ActionResult SaveNoticeConfig(string NoticeId, bool IsOpen)
- {
- var user = GetCurrentUser();
- var r = notice.SaveNoticeConfig(user.PersonID, NoticeId, IsOpen);
- return Content(r ? "1" : "0", "application/json");
- }
- #endregion
- #region 添加
- //添加公告弹窗
- public ActionResult Add_Window()
- {
- return View();
- }
- //添加操作
- [HttpPost]
- public int Add_Notice(string text)
- {
- //反编码并转换为一个Model对象
- MessageManageModel model = Strings.JsonToModel<MessageManageModel>(HttpUtility.UrlDecode(text));
- model.PersonName = GetCurrentUser().Name;
- model.PersonId = GetCurrentUser().PersonID;
- var user = GetCurrentUser();
- string ID = Guid.NewGuid().ToString();
- if (TempData["PID"] != null)
- {
- model.FJID = TempData["PID"].ToString();
- }
- var r = notice.AddMessage(model, user,ID);
- //推送
- if (r && model.IsShow == 1)
- {
- App_Start.ClientManager.Add_NoticeToNotice();
- }
- return r ? 1 : 0;
- }
- #endregion
- #region 修改
- //添加公告弹窗
- public ActionResult Edit_Window(string id)
- {
- ViewBag.id = id;
- TempData["NID"] = id;
- return View();
- }
- //修改操作
- [HttpPost]
- public int Edit_Notice(string text)
- {
- //反编码并转换为一个Model对象
- MessageManageModel model = Strings.JsonToModel<MessageManageModel>(HttpUtility.UrlDecode(text));
- if (model.FJID == null)
- {
- var tempdata = TempData["PID"];
- if (tempdata != null)
- {
- model.FJID = tempdata.ToString();
- }
- }
- return notice.Edit_Notice(model) ? 1 : 0;
- }
- [HttpPost]
- public int DeleteFJ(string id)
- {
- return notice.DeleteFJ(id);
- }
- #endregion
- #region 删除
- public int Del_Notice(string id)
- {
- MessageManageModel model = new MessageManageModel();
- model.ID = id;
- return notice.DeleteMessage(model) ? 1 : 0;
- }
- #endregion
- #region 是否启用
- public int NoticeStatus(string id)
- {
- return notice.NoticeStatus(id);
- }
- #endregion
- #region APP首页推送
- public ActionResult APPIndex()
- {
- return View();
- }
- //APP公告获取
- public ActionResult APPDataBind(int page, int rows)
- {
- return Content(notice.APPDataBind(page, rows), "application/json");
- }
- //添加公告弹窗
- public ActionResult App_Window()
- {
- return View();
- }
- //添加操作
- [HttpPost]
- public string Add_AppPush(string text)
- {
- //反编码并转换为一个Model对象
- AppPush_Model model = Strings.JsonToModel<AppPush_Model>(HttpUtility.UrlDecode(text));
- model.TJRID = GetCurrentUser().PersonID;
- var user = GetCurrentUser();
- var id = notice.Add_AppPush(model);
- TempData["imgID"] = id;
- return id;
- }
- //图片上传
- [HttpPost]
- public int FileUpload(int type)
- {
- AppPush_Model model = new AppPush_Model();
- var files = this.Request.Files;
- if (this.Request.Files.Count > 0)
- {
- using (BinaryReader br = new BinaryReader(files[0].InputStream))
- {
- byte[] byteData = br.ReadBytes((int)files[0].InputStream.Length);
- var uploadFile = files[0];
- var fileName = uploadFile.FileName;
- var fileLen = uploadFile.ContentLength;
- var fileType = uploadFile.ContentType;
- string _tp = System.IO.Path.GetExtension(fileName);
- var r = UploadFile(byteData, fileName, fileType);
- if (r.code == 100)
- {
- if (type == 1)
- {
- model.TPID = r.data;
- model.ID = TempData["imgID"].ToString();
- model.TJRID = GetCurrentUser().PersonID;
- return notice.Edit_AppNotice(model);
- }
- if(type==2)
- {
- return notice.Edit_NoticeFJ(r.data, TempData["NID"].ToString());
- }
- if(type==3)
- {
- TempData["PID"]= r.data;
- return 1;
- }
- }
- }
- }
- return 0;
- }
- //清空Tempdata
- [HttpPost]
- public void ClearTempData()
- {
- TempData["PID"] = null;
- }
- //app公告是否启用
- public int AppNoticeStatus(string id)
- {
- return notice.AppNoticeStatus(id);
- }
- //app公告删除
- public int Del_AppNotice(string id)
- {
- return notice.Del_AppNotice(id);
- }
- //获取启用的app公告
- [HttpPost]
- public ActionResult GetWorkNotice()
- {
- return Content(notice.GetWorkNotice(),"application/json");
- }
- #endregion
- }
- }
|