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.
DS7/DSWeb/Areas/MvcShipping/Controllers/MsUserAuthorityController.cs

273 lines
10 KiB
C#

2 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.DAL.MsUerAuthority;
using DSWeb.MvcShipping.Models.MsUserAuthority;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.TruckMng.Helper.Repository;
using System.Web;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsUserAuthorityController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ContentResult GetUserAuthorityList(int start, int limit, string sort,string userid)
{
var dataList = MsUerAuthorityDAL.GetUserAuthorityList(userid,sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetUserTreeRefList(string PARENTID)
{
var dataList = MsUerAuthorityDAL.GetUserTreeRefList(PARENTID);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetUserTreeExpRefList(string PARENTID, string condition = "")
{
var dataList = MsUerAuthorityDAL.GetUserTreeRefList(PARENTID,true, condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save(string body)
{
var bodyList = JsonConvert.Deserialize<List<UserAuthority>>(body);
var modb = new ModelObjectRepository();
DBResult result = MsUerAuthorityDAL.SaveDetail(bodyList, Convert.ToString(Session["USERID"]));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetUserAuthorityCompanyList(int start, int limit, string sort, string userid, string authorityid)
{
var dataList = MsUerAuthorityDAL.GetUserAuthorityCompanyList(userid,authorityid,sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult SaveAuthorityCompany(string body, string rtype)
{
var bodyList = JsonConvert.Deserialize<List<UserAuthorityCompany>>(body);
var modb = new ModelObjectRepository();
DBResult result = MsUerAuthorityDAL.SaveAuthorityCompanyDetail(bodyList, Convert.ToString(Session["USERID"]), rtype);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
/// <summary>
/// 人员权限设置 右侧 选择人员列表
/// </summary>
/// <param name="start"></param>
/// <param name="limit"></param>
/// <param name="sort"></param>
/// <param name="userid"></param>
/// <param name="authorityid"></param>
/// <returns></returns>
public ContentResult GetUserAuthorityOpList(int start, int limit, string sort, string userid, string authorityid)
{
var dataList = MsUerAuthorityDAL.GetUserAuthorityOpList(userid, authorityid, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetUserAuthorityVISIBLETreeList(string PARENTID, string USERID, string AUTHORITYID)
{
var CURRUSERID = "";
var CURRAUTHORITYID = "";
if (string.IsNullOrEmpty(USERID))
{
if (PARENTID == "0")
{
var json1 = JsonConvert.Serialize(new { Success = true, Message = "" });
return new ContentResult() { Content = json1 };
};
try
{
CURRUSERID = HttpRuntime.Cache.Get(Convert.ToString(Session["USERID"]) + "_UserAuthorityVISIBLE_CURRUSERID").ToString();
CURRAUTHORITYID = HttpRuntime.Cache.Get(Convert.ToString(Session["USERID"]) + "_UserAuthorityVISIBLE_CURRAUTHORITYID").ToString();
}
catch
{
var json0 = JsonConvert.Serialize(new { Success = false, Message = "" });
return new ContentResult() { Content = json0 };
}
}
else
{
CURRUSERID = USERID;
CURRAUTHORITYID = AUTHORITYID;
HttpRuntime.Cache.Insert(Convert.ToString(Session["USERID"]) + "_UserAuthorityVISIBLE_CURRUSERID", USERID);
HttpRuntime.Cache.Insert(Convert.ToString(Session["USERID"]) + "_UserAuthorityVISIBLE_CURRAUTHORITYID", AUTHORITYID);
}
var dataList = MsUerAuthorityDAL.GetUserAuthorityVISIBLE_Tree(PARENTID, CURRUSERID, CURRAUTHORITYID);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetUserAuthorityOPERATETreeList(string PARENTID, string USERID, string AUTHORITYID) {
//var result = new JsonResponse();
var CURRUSERID = "";
var CURRAUTHORITYID = "";
if (string.IsNullOrEmpty(USERID))
{
if (PARENTID == "0")
{
var json1 = JsonConvert.Serialize(new { Success = true, Message = "" });
return new ContentResult() { Content = json1 };
};
try
{
CURRUSERID = HttpRuntime.Cache.Get(Convert.ToString(Session["USERID"]) + "_UserAuthorityOPERATE_CURRUSERID").ToString();
CURRAUTHORITYID = HttpRuntime.Cache.Get(Convert.ToString(Session["USERID"]) + "_UserAuthorityOPERATE_CURRAUTHORITYID").ToString();
}
catch
{
var json0 = JsonConvert.Serialize(new { Success = false, Message = "" });
return new ContentResult() { Content = json0 };
}
}
else
{
CURRUSERID = USERID;
CURRAUTHORITYID = AUTHORITYID;
HttpRuntime.Cache.Insert(Convert.ToString(Session["USERID"]) + "_UserAuthorityOPERATE_CURRUSERID", USERID);
HttpRuntime.Cache.Insert(Convert.ToString(Session["USERID"]) + "_UserAuthorityOPERATE_CURRAUTHORITYID", AUTHORITYID);
}
var dataList = MsUerAuthorityDAL.GetUserAuthorityOPERATE_Tree(PARENTID, CURRUSERID, CURRAUTHORITYID);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult SaveAuthorityOpDetail(string body, string rtype)
{
var bodyList = JsonConvert.Deserialize<List<UserAuthorityOp>>(body);
var modb = new ModelObjectRepository();
DBResult result = MsUerAuthorityDAL.SaveAuthorityOpDetail(bodyList, Convert.ToString(Session["USERID"]), rtype);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveAuthorityOpAll(string body, string rtype)
{
var bodyList = JsonConvert.Deserialize<List<UserAuthorityOp>>(body);
var AUTHORITYID = "";
var op = "";
if (bodyList.Count!=0) {
AUTHORITYID = bodyList[0].AUTHORITYID;
op = bodyList[0].USERID;
}
var modb = new ModelObjectRepository();
DBResult result = MsUerAuthorityDAL.SaveAuthorityOpDetailAll(AUTHORITYID, op,Convert.ToString(Session["USERID"]), rtype);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
public ContentResult SaveAuthorityOpVsDetail_Tree(string body, string rtype)
{
var bodyList = JsonConvert.Deserialize<List<UserAuthorityOp>>(body);
UserAuthorityOp.SetOpVsValue(bodyList, rtype);
var modb = new ModelObjectRepository();
DBResult result = MsUerAuthorityDAL.SaveAuthorityOpDetail(bodyList, Convert.ToString(Session["USERID"]), rtype);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveAuthorityOpVsAll_Tree(string USERID, string AUTHORITYID, string rtype)
{
var bodyList = MsUerAuthorityDAL.GetUserAuthority_All(USERID, AUTHORITYID);
var modb = new ModelObjectRepository();
DBResult result = MsUerAuthorityDAL.SaveAuthorityOpDetailAll(AUTHORITYID, USERID, Convert.ToString(Session["USERID"]), rtype);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
}