You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
330 lines
12 KiB
C#
330 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Estsh.Web.Util;
|
|
using Estsh.Web.Service;
|
|
using System.Collections;
|
|
using Estsh.Web.Models;
|
|
|
|
/***************************************************************************************************
|
|
*
|
|
* 作者:王勇
|
|
*
|
|
* *************************************************************************************************/
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 菜单模块控制类
|
|
/// </summary>
|
|
public class NoticeController : Controller
|
|
{
|
|
private NoticeService service = new NoticeService();
|
|
|
|
//
|
|
// GET: /Notice/
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载首页功能菜单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult getHomeNoticeById(string NoticeId)
|
|
{
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
Hashtable result = new Hashtable();
|
|
result = service.getHomeNoticeList(user,NoticeId);
|
|
//String json = Estsh.Web.Util.JSON.Encode(result);
|
|
return Json(result);
|
|
}
|
|
/// <summary>
|
|
/// 加载Main页功能主菜单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult getMainNoticeById(string NoticeId)
|
|
{
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
Hashtable result = new Hashtable();
|
|
result = service.getMainNoticeList(user, NoticeId);
|
|
//String json = Estsh.Web.Util.JSON.Encode(result);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载Main页功能子菜单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult getChildNoticeById(string NoticeId)
|
|
{
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
string path = Request.ApplicationPath; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); }
|
|
Hashtable result = new Hashtable();
|
|
result = service.getChildNoticeList(user, NoticeId,path);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载非Tab的Main页功能子菜单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult getNoNTabChildNoticeById(string NoticeId)
|
|
{
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
string path = Request.ApplicationPath; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); }
|
|
Hashtable result = new Hashtable();
|
|
result = service.getNoNTabChildNoticeList(user, NoticeId, path);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载功能树
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult getNoticeTree()
|
|
{
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
string path = Request.ApplicationPath; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); }
|
|
List<TreeNode> treeNodes = new List<TreeNode>();
|
|
treeNodes = service.getNoticeList(user, path);
|
|
Hashtable result = new Hashtable();
|
|
result.Add("treeNodes", treeNodes);
|
|
String json = Estsh.Web.Util.JSON.Encode(result);
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取菜单管理列表数据
|
|
/// </summary>
|
|
/// <param name="NoticeName">菜单名称</param>
|
|
/// <param name="pager">分页</param>
|
|
/// <param name="direction">排序方式</param>
|
|
/// <param name="sort">排序列</param>
|
|
/// <returns></returns>
|
|
public ActionResult getNoticeListByPage(string SUBJECT,string CONTENT_TYPE,string txtStartTime,string txtEndTime,String NoticeName, Pager pager, String direction, String sort)
|
|
{
|
|
string str = " 1=1 ";
|
|
|
|
if (string.IsNullOrEmpty(CONTENT_TYPE))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (!(string.IsNullOrEmpty(SUBJECT)) && SUBJECT != "null")
|
|
{
|
|
str += " and SUBJECT like '%" + SUBJECT + "%'";
|
|
}
|
|
|
|
if (!(string.IsNullOrEmpty(CONTENT_TYPE)) && CONTENT_TYPE != "null")
|
|
{
|
|
str += " and CONTENT_TYPE=" + CONTENT_TYPE + "";
|
|
}
|
|
|
|
if (!(string.IsNullOrEmpty(txtStartTime)) && txtStartTime != "null" && !(string.IsNullOrEmpty(txtEndTime)) && txtEndTime != "null")
|
|
{
|
|
str += " and PPUBLISH_TIME BEGIN '" + txtStartTime + "' AND '" + txtEndTime + "' end";
|
|
}
|
|
|
|
Hashtable result = new Hashtable();
|
|
result.Add("pager.pageNo",pager.pageNo);
|
|
Hashtable dataHt = this.service.getNoticeListByPage(NoticeName, pager, direction, sort, str);
|
|
result.Add("rows", dataHt["dataList"]);
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
result.Add("sort",sort);
|
|
result.Add("direction", direction);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取父节点菜单下拉列表数据
|
|
/// </summary>
|
|
/// <rehuoturns></returns>
|
|
public ActionResult getSelectNotice()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
ArrayList NoticeList = this.service.getSelectNotice();
|
|
result.Add("list", NoticeList);
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存菜单数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult saveNotice()
|
|
{
|
|
String editType = Request["editType"].ToString();
|
|
|
|
String SUBJECT = Request["SUBJECT"].ToString();
|
|
String EXPIRE_DATE = Request["EXPIRE_DATE"].ToString();
|
|
String CONTENT_TYPE = Request["CONTENT_TYPE"].ToString();
|
|
String BODY = Request["BODY"].ToString();
|
|
|
|
Hashtable htParams = new Hashtable();
|
|
htParams.Add("@SUBJECT", SUBJECT);
|
|
htParams.Add("@EXPIRE_DATE", EXPIRE_DATE);
|
|
htParams.Add("@CONTENT_TYPE", CONTENT_TYPE);
|
|
htParams.Add("@BODY", BODY);
|
|
|
|
UserInfo loginUser = (UserInfo)Session["loginedUser"];
|
|
|
|
String message = "";
|
|
String flag = "";
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
{
|
|
try
|
|
{
|
|
htParams.Add("@update_userid", loginUser.empId);
|
|
//htParams.Add("@Notice_id", Notice_id);
|
|
this.service.updateNotice(htParams);
|
|
message = "修改成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "修改失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
htParams.Add("@create_userid", loginUser.empId);
|
|
this.service.saveNotice(htParams);
|
|
message = "添加成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "添加失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
|
|
Hashtable result = new Hashtable();
|
|
result.Add("message", message);
|
|
result.Add("flag", flag);
|
|
return Json(result) ;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 查看菜单详情
|
|
/// </summary>
|
|
/// <param name="ruid"></param>
|
|
/// <returns></returns>
|
|
public ActionResult getNoticeDetail(String Notice_id)
|
|
{
|
|
ArrayList NoticeInfo = this.service.getNoticeDetail(Notice_id);
|
|
Hashtable htNoticeInfo = (Hashtable)NoticeInfo[0];
|
|
ViewData.Add("Notice_id", htNoticeInfo["Notice_id"]);
|
|
ViewData.Add("name", htNoticeInfo["name"]);
|
|
ViewData.Add("description", htNoticeInfo["description"]);
|
|
ViewData.Add("url", htNoticeInfo["url"]);
|
|
ViewData.Add("parent_id", htNoticeInfo["parent_id"]);
|
|
ViewData.Add("icon_url", htNoticeInfo["icon_url"]);
|
|
ViewData.Add("icon_open_url", htNoticeInfo["icon_open_url"]);
|
|
ViewData.Add("icon_close_url", htNoticeInfo["icon_close_url"]);
|
|
ViewData.Add("icon_skin", htNoticeInfo["icon_skin"]);
|
|
ViewData.Add("enabled", htNoticeInfo["enabled"]);
|
|
ViewData.Add("sort_num", htNoticeInfo["sort_num"]);
|
|
|
|
return View("~/Views/NoticeManage/viewNotice.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑菜单
|
|
/// </summary>
|
|
/// <param name="ruid"></param>
|
|
/// <returns></returns>
|
|
public ActionResult editNotice(String CONTENT_NO)
|
|
{
|
|
ArrayList NoticeInfo = this.service.getNoticeDetail(CONTENT_NO);
|
|
Hashtable htNoticeInfo = (Hashtable)NoticeInfo[0];
|
|
ViewData.Add("SUBJECT", htNoticeInfo["SUBJECT"]);
|
|
ViewData.Add("EXPIRE_DATE", htNoticeInfo["EXPIRE_DATE"]);
|
|
ViewData.Add("CONTENT_TYPE", htNoticeInfo["CONTENT_TYPE"]);
|
|
ViewData.Add("BODY", htNoticeInfo["BODY"]);
|
|
return View("~/Views/Sweb/Notice/editNotice.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑菜单
|
|
/// </summary>
|
|
/// <param name="ruid"></param>
|
|
/// <returns></returns>
|
|
public ActionResult viewSeeNotice(String CONTENT_NO)
|
|
{
|
|
ArrayList NoticeInfo = this.service.getNoticeDetail(CONTENT_NO);
|
|
Hashtable htNoticeInfo = (Hashtable)NoticeInfo[0];
|
|
ViewData.Add("SUBJECT", htNoticeInfo["SUBJECT"]);
|
|
ViewData.Add("EXPIRE_DATE", htNoticeInfo["EXPIRE_DATE"]);
|
|
ViewData.Add("CONTENT_TYPE", htNoticeInfo["CONTENT_TYPE"]);
|
|
ViewData.Add("BODY", htNoticeInfo["BODY"]);
|
|
return View("~/Views/Sweb/SeeNotice/viewSeeNotice.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除菜单
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public ActionResult deleteNotice(String ids)
|
|
{
|
|
int delCount = 0;
|
|
try
|
|
{
|
|
delCount = this.service.deleteNotice(ids);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
delCount = -1;
|
|
}
|
|
Hashtable result = new Hashtable();
|
|
result.Add("status", delCount);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取小尺寸工具栏
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult getMinToolbar()
|
|
{
|
|
ArrayList result = new ArrayList();
|
|
try
|
|
{
|
|
String path = Request.ApplicationPath;
|
|
if (path.EndsWith("/"))
|
|
{
|
|
path = path.Substring(0, path.Length - 1);
|
|
}
|
|
|
|
string url = Request.UrlReferrer.AbsolutePath;
|
|
url = url.Substring(url.LastIndexOf(path) + path.Length);
|
|
if (Request.UrlReferrer.AbsoluteUri.Split('?').Length > 1)
|
|
{
|
|
url = url + "?" + Request.UrlReferrer.AbsoluteUri.Split('?')[1];
|
|
}
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
string opType = Request["opType"];
|
|
if (user != null)
|
|
{
|
|
result.Add(CommonService.getMinToolbar(user, url, opType));
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result.Add(e.Message);
|
|
}
|
|
|
|
return Json(result);
|
|
}
|
|
}
|
|
}
|