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.
254 lines
9.4 KiB
C#
254 lines
9.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using DSWeb.Areas.SysMng.DAL.SysUser;
|
|
using DSWeb.Areas.SysMng.Models.SysUser;
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
using DSWeb.TruckMng.Helper;
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.SoftMng.Common;
|
|
using DSWeb.SoftMng.BLL;
|
|
using DSWeb.SoftMng.Filter;
|
|
using System.Web.Script.Serialization;
|
|
using DSWeb.Areas.Dispatch.Models;
|
|
using System.Runtime.Caching;
|
|
|
|
|
|
namespace DSWeb.Areas.SysMng.Controllers
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[JsonRequestBehavior]
|
|
public class SysUserController : Controller
|
|
{
|
|
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult Edit()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult OP()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ContentResult GetUserTreeRefList(string PARENTID)
|
|
{
|
|
var dataList = SysUserDAL.GetUserTreeRefList(PARENTID);
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = SysUserDAL.GetDataList(condition, sort);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetUserTeamList(string sort, string condition)
|
|
{
|
|
var dataList = SysUserDAL.GetUserTeamList(condition, sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
/*
|
|
public ContentResult GetDataList_USER(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = USERMANAGEDAL.GetDataList_USER(condition, sort);
|
|
|
|
var list = dataList.Skip(start).Take(limit);
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}*/
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
{
|
|
SysUserMC head = new SysUserMC();
|
|
//var umi = new USERMANAGEINFO();
|
|
//List<HcUtility.Core.Fieldmb> fieldlist = umi.GetFieldList();
|
|
if (handle == "add")
|
|
{
|
|
//head = new SysUserMC();
|
|
}
|
|
if (handle == "edit" || handle == "view")
|
|
{
|
|
|
|
head = SysUserDAL.GetData(condition);//, fieldlist
|
|
|
|
var result = SysUserDAL.GetUserIsUse(head.GID, head.CODENAME, head.SHOWNAME);
|
|
head.isedit = result.Success;
|
|
}
|
|
|
|
if (head == null)
|
|
{
|
|
head = new SysUserMC();
|
|
head.isedit = true;
|
|
}
|
|
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult Save(string opstatus, string data,string body)//
|
|
{
|
|
var head = JsonConvert.Deserialize<SysUserMC>(data);
|
|
var bodyList = JsonConvert.Deserialize<List<UserTeam>>(body);
|
|
//注册数量判断
|
|
var state = head.isUseSystem;
|
|
if (state=="on")
|
|
{
|
|
user_userattributeBLL ubll = new user_userattributeBLL();
|
|
var count = ubll.GetRecordCount(
|
|
"ATTRIBUTEID='2E5E6066-1C5D-4B04-BF8C-56637C20FC8C' AND VALUE='true' AND USERID IN (select gid from [user])");
|
|
sys_secCompanyBLL cbll = new sys_secCompanyBLL();
|
|
var model = cbll.GetModelList("").FirstOrDefault();
|
|
if (model != null)
|
|
{
|
|
var smodel = new JavaScriptSerializer().Deserialize<CecrietStr>(DSWeb.SoftMng.Common.Common.string_Decrypt(model.CompanySecretKey, "Dw9pVb9r"));
|
|
if ((opstatus == "add" && count >= smodel.Times)|| (opstatus == "edit" && count > smodel.Times))
|
|
{
|
|
//this.chk_isusesystem.Checked = false;
|
|
//Response.Write("<script>alert('系统允许使用人数已超过限制!');</script>");
|
|
//return;
|
|
head.isUseSystem = "false";
|
|
var jsonRespose2 = new JsonResponse
|
|
{
|
|
Success = false,
|
|
Message = "系统允许使用人数已超过限制!",
|
|
Data = head//, fieldlist
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (opstatus == "add"|| head.GID==""|| head.GID=="*")
|
|
{
|
|
head.DbOperationType = DbOperationType.DbotIns; //保存时的动作(如新增、修改等)
|
|
head.ModelUIStatus = "I";
|
|
head.GID = System.Guid.NewGuid().ToString();
|
|
|
|
head.CREATEUSER = Session["USERID"].ToString();
|
|
head.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
head.MODIFIEDUSER = Session["USERID"].ToString();
|
|
head.MODIFIEDTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
}
|
|
else if (opstatus == "edit")
|
|
{
|
|
head.DbOperationType = DbOperationType.DbotUpd;
|
|
head.ModelUIStatus = "E";
|
|
head.MODIFIEDUSER = Session["USERID"].ToString();
|
|
head.MODIFIEDTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
}
|
|
else
|
|
{
|
|
head.DbOperationType = DbOperationType.DbotDel;
|
|
}
|
|
|
|
var userbaseinfo = new USER_BASEINFOMC(head);
|
|
var usercompany = new USER_COMPANYMC(head);
|
|
|
|
head.ISDELETED ="0";
|
|
head.ISDISABLE = head.isDisable == "on" ? "1" : "0";
|
|
|
|
if (!BasicDataRefDAL.HaveExist(head.TableName, "CODENAME", head.CODENAME, "GID", head.GID)&& !BasicDataRefDAL.HaveExist(head.TableName, "SHOWNAME", head.SHOWNAME, "GID", head.GID))
|
|
{
|
|
var modb = new ModelObjectRepository();
|
|
DBResult result = modb.Save(head
|
|
);
|
|
if (result.Success) {
|
|
result = modb.Save(userbaseinfo);
|
|
}
|
|
if (result.Success)
|
|
{
|
|
result = modb.Save(usercompany);
|
|
}
|
|
if (result.Success)
|
|
{
|
|
var attrlist = SysUserDAL.GetAttr(head.GID);
|
|
user_userattributeMC.setAttribute(attrlist, head);
|
|
|
|
result = modb.SaveComm("USERID", head.GID,
|
|
ModelObjectConvert<user_userattributeMC>.ToModelObjectList(attrlist)
|
|
, null);
|
|
}
|
|
|
|
if (result.Success) {
|
|
SysUserDAL.SaveUserTeam(head,bodyList);
|
|
}
|
|
|
|
BasicDataRefDAL.SaveLog(head, Session["USERID"].ToString(), "用户管理", "保存");
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = SysUserDAL.GetData("CODENAME = '" + head.CODENAME + "'")//, fieldlist
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else
|
|
{
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = false,
|
|
Message = "姓名或代码已存在,不允许重复!",
|
|
Data = null
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}
|
|
|
|
public ContentResult Delete(string data, string USERID)
|
|
{
|
|
var head = JsonConvert.Deserialize<SysUserMC>(data);
|
|
//验证是否有
|
|
|
|
var result = SysUserDAL.GetUserIsUse(head.GID, head.CODENAME, head.SHOWNAME);
|
|
if (result.Success)
|
|
{
|
|
var modb = new ModelObjectDB();
|
|
result = modb.Delete(head, "delete from [user] where GID='" + head.GID + "'"); //真删除
|
|
}
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
public ContentResult DeleteUserTeam(string data)
|
|
{
|
|
var head = JsonConvert.Deserialize<UserTeam>(data);
|
|
var result = SysUserDAL.DeleteUserTeam(head);
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|