Ejemplo n.º 1
0
 public ActionResult AddMessage()
 {
     //接收人列表绑定
     List<Operator> operatorList = new OperatorRule().GetModelList("");
     ViewBag.operatorList = operatorList;
     //AddMessageNew操作提示消息
     if (TempData["tipMsg"] == null)
     {
         TempData["tipMsg"] = "";
     }
     string msgID = Request.QueryString["msgID"];
     if (string.IsNullOrEmpty(msgID))
     {
         ViewBag.Msg = new OperatorMsg();
     }
     else
     {
         ViewBag.Msg = new OperatorMsgRule().GetModel(msgID);
     }
     return View();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Authenticates a user against a database, web service, etc.
 /// </summary>
 /// <param name="username">Username</param>
 /// <param name="password">Password</param>
 /// <returns>User</returns>
 public static List<Ticket> AuthenticateUser(string username, string password)
 {
     List<Ticket> currentTicketList = new List<Ticket>();
     OperatorRule operatorRule = new OperatorRule();
     List<dynamic> userList = operatorRule.Login(username, password);
     if (userList == null || userList.Count == 0)
     {
         return null;
     }
     else
     {
         foreach (dynamic t in userList)
         {
             if (currentTicketList.Count<Ticket>(ct => ct.GroupName == t.GROUPNAME) > 0)
             {
                 continue;//同一用户多账号相同角色去重复
             }
             Ticket myTicket = new Ticket();
             myTicket.DeptID = t.DEPTID;
             myTicket.DeptName = t.DEPTNAME;
             myTicket.EmployeeID = t.EMPID;
             myTicket.EmployeeName = t.EMPNAME;
             myTicket.GroupID = t.GROUPID;
             myTicket.GroupName = t.GROUPNAME;
             myTicket.UserID = t.ID;
             myTicket.UserName = t.OPERNAME;
             myTicket.IsAdmin = (t.ISADMIN == "1") ? true : false;
             //myTicket.VoteList = new GroupVoteRule().GetOperVotes(t.GROUPID, t.ID);//获取权限列表
             myTicket.VoteDic = new Dictionary<string, int>();
             foreach (OperatorVote item in new GroupVoteRule().GetOperVotes(t.GROUPID, t.ID))
             {
                 myTicket.VoteDic.Add(item.PoupID, item.VoteType);
             }
             //myTicket.CurrentOperator = operatorRule.GetModel(t.ID);
             currentTicketList.Add(myTicket);
         }
         //Cache["currentUserList"] = currentTicketList;
         return currentTicketList;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        public ActionResult GoLogin(string userName, string pwd, string validateCode)
        {
            AjaxResult result = new AjaxResult();
            OperatorRule operatorRule = new OperatorRule();
            #if DEBUG
            validateCode = Session["ValidateCode"].ToString();
            #endif
            if (validateCode != Session["ValidateCode"].ToString())
            {
                result.Success = false;
                result.Message = "验证码输入错误。";
            }
            else
            {
                Logon logon = new Logon() { Password = pwd, Username = userName };
                if (UserManager.ValidateUser(logon, Response))
                {
                    List<Ticket> currentTicketList = new List<Ticket>();
                    if (HttpContext.Cache["UserList"] != null)
                    {
                        currentTicketList = HttpContext.Cache["UserList"] as List<Ticket>;
                    }
                    if (currentTicketList.Count == 1)
                    {
                        //MyTicket.CurrentTicket = currentTicketList[0]; //唯一角色的用户直接进入系统
                        result.Success = true;
                        result.Url = "/Home/Index";
                        //记录登录日志
                        LoginLog log = new LoginLog();
                        log.OperatorID = MyTicket.CurrentTicket.UserID;
                        log.CreateTime = DateTime.Now;
                        log.Type = 1;
                        log.ID = WebHelper.GetNewGuidUpper();
                        new LoginLogRule().Add(log);
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        return Json(currentTicketList, JsonRequestBehavior.AllowGet);
                    }
                }
                else
                {
                    result.Success = false;
                    result.Message = "用户名或者密码错误。";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                List<dynamic> userList = operatorRule.Login(userName, pwd);
                if (userList == null || userList.Count == 0)
                {
                    result.Success = false;
                    result.Message = "用户名或者密码错误。";

                }
                else
                {
                    List<Ticket> currentTicketList = new List<Ticket>();
                    foreach (dynamic t in userList)
                    {
                        if (currentTicketList.Count<Ticket>(ct => ct.GroupName == t.GROUPNAME) > 0)
                        {
                            continue;//同一用户多账号相同角色去重复
                        }
                        Ticket myTicket = new Ticket();
                        myTicket.DeptID = t.DEPTID;
                        myTicket.DeptName = t.DEPTNAME;
                        myTicket.EmployeeID = t.EMPID;
                        myTicket.EmployeeName = t.EMPNAME;
                        myTicket.GroupID = t.GROUPID;
                        myTicket.GroupName = t.GROUPNAME;
                        myTicket.UserID = t.ID;
                        myTicket.UserName = t.OPERNAME;
                        myTicket.IsAdmin = (t.ISADMIN == "1") ? true : false;
                        //myTicket.VoteList = new GroupVoteRule().GetOperVotes(t.GROUPID, t.ID);//获取权限列表
                        myTicket.VoteDic = new Dictionary<string, int>();
                        foreach (OperatorVote item in new GroupVoteRule().GetOperVotes(t.GROUPID, t.ID))
                        {
                            myTicket.VoteDic.Add(item.PoupID, item.VoteType);
                        }
                        //myTicket.CurrentOperator = operatorRule.GetModel(t.ID);
                        currentTicketList.Add(myTicket);
                    }
                    if (currentTicketList.Count == 1)
                    {
                        //MyTicket.CurrentTicket = currentTicketList[0];//唯一角色的用户直接进入系统
                        result.Success = true;
                        result.Url = "/Home/Index";
                        //记录登录日志
                        LoginLog log = new LoginLog();
                        log.OperatorID = MyTicket.CurrentTicket.UserID;
                        log.CreateTime = DateTime.Now;
                        log.Type = 1;
                        log.ID = WebHelper.GetNewGuidUpper();
                        new LoginLogRule().Add(log);
                    }
                    else
                    {
                        Session["currentUserList"] = currentTicketList;//记录角色列表,等待用户选择
                        return Json(currentTicketList, JsonRequestBehavior.AllowGet);
                    }
                }
            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 4
0
 public JsonResult OperatorDisable(string IDs)
 {
     AjaxResult result = new AjaxResult();
     try
     {
         OperatorRule rule = new OperatorRule();
         result.Success = rule.OperatorDisable(IDs.TrimEnd(',').Split(','));
         result.Message = result.Success ? "系统用户状态更新成功。" : "系统用户状态更新失败!";
     }
     catch (Exception ex)
     {
         result.Success = false;
         result.Message = "系统用户状态更新失败:" + ex.Message;
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 5
0
 public JsonResult GetOperatorByName(string q)
 {
     if (string.IsNullOrEmpty(q))
     {
         return Json(new { }, JsonRequestBehavior.AllowGet);
     }
     List<Operator> OperList = new OperatorRule().GetOperatorByName(q);
     var showlist = from oper in OperList
                    select new
                    {
                        id = oper.ID,
                        text = oper.Name
                    };
     return Json(showlist, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 密码修改
 /// </summary>
 /// <param name="old"></param>
 /// <param name="newPwd"></param>
 /// <returns></returns>
 public ActionResult ChangePwd(string old, string newPwd)
 {
     if (MyTicket.CurrentTicket == null)
     {
         return new HomeController().Login();
     }
     OperatorRule rule = new OperatorRule();
     bool result = rule.ChangePwd(MyTicket.CurrentTicket.UserID, old, newPwd);
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 7
0
 public ActionResult AddOperator(Operator opr, string EMPNAME)
 {
     AjaxResult result = new AjaxResult();
     opr.PY = Pinyin.GetPinyin(opr.Name);
     opr.ID = Guid.NewGuid().ToString("N");
     opr.CreateDate = DateTime.Now;
     opr.Status = 1;
     opr.Pwd = Ajax.Common.DEncrypt.DESEncrypt.Encrypt(opr.Pwd);
     OperatorRule rule = new OperatorRule();
     try
     {
         rule.Add(opr);
         result.Success = true;
         result.Message = "添加成功。";
     }
     catch (Exception ex)
     {
         result.Success = false;
         result.Message = "添加失败:" + ex.Message;
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Ejemplo n.º 8
0
 public ActionResult SearchOperator(EasyUIGridParamModel param, Operator oper, Employee emp)
 {
     int itemCount = 0;
     List<dynamic> operList = new OperatorRule().SearchOperator(param, oper, emp, out itemCount);
     var showList = from opers in operList
                    select new
                    {
                        ID = opers.ID,
                        EMPID = opers.EMPID,
                        STATUS = opers.STATUSNAME,
                        NAME = opers.NAME,
                        EMPNAME = opers.EMPNAME,
                        ISADMIN = opers.ISADMIN,
                        CREATEDATE = opers.CREATEDATE,
                        GROUPNAME = opers.GROUPNAME,
                    };
     return Json(new { total = itemCount, rows = showList }, JsonRequestBehavior.AllowGet);
 }