Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uid">用户ID</param>
        /// <param name="rid">权限ID</param>
        /// <returns></returns>
        public IEnumerable <MenuViewModel> Load(int uid, int rid)
        {
            var menus = new List <MenuViewModel>();

            var bll = new jmp_limit();
            var dt  = bll.GetUserLimit(uid, rid);
            var lst = bll.DataTableToList(dt);
            //得到顶级菜单
            var level1 = lst.Where(x => x.l_topid == 0).ToList();

            foreach (var l in level1)
            {
                //获取子菜单集合
                var level2   = lst.Where(x => x.l_topid == l.l_id).ToList();
                var children = level2.Select(x => new MenuViewModel
                {
                    Id    = x.l_id.ToString(),
                    Title = x.l_name,
                    Href  = x.l_url,
                    Icon  = x.l_icon
                }).ToList();
                var menu = new MenuViewModel
                {
                    Id       = l.l_id.ToString(),
                    Title    = l.l_name,
                    Href     = l.l_url,
                    Icon     = l.l_icon,
                    Children = children
                };

                menus.Add(menu);
            }
            return(menus);
        }
Example #2
0
        private object DoLogin(string userName, string userPwd)
        {
            object result;
            var    bllLimit = new jmp_limit();
            var    bll      = new CoBusinessPersonnel();
            var    model    = bll.GetModel(userName);
            //加密用户登录密码
            var jmPwd = DESEncrypt.Encrypt(userPwd).ToLower();

            if (model != null)
            {
                if (model.State == 1)
                {
                    result = new { msg = "您的账号已经冻结无法登录!", success = "2" };
                    return(result);
                }
                if (model.LoginName == userName && model.Password.ToLower() == jmPwd)
                {
                    UserInfo.UserId     = model.Id;
                    UserInfo.UserName   = model.DisplayName;
                    UserInfo.UserNo     = model.LoginName;
                    UserInfo.UserRoleId = model.RoleId;
                    var dtLimit = bllLimit.GetBusinessLimitSession(model.Id, model.RoleId);
                    if (dtLimit.Rows.Count > 0)
                    {
                        Session["dtSession"] = dtLimit;
                        model.LoginCount    += 1;
                        model.LogintTime     = DateTime.Now;
                        bll.Update(model);
                        var log = string.Format("用户({0})于{1}登录系统。", UserInfo.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        Logger.OperateLog("登录日志", log);
                        result = new { msg = "登录成功!", success = "1" };
                    }
                    else
                    {
                        result = new { msg = "权限不足!", success = "2" };
                    }
                }
                else
                {
                    result = new { msg = "用户名或密码错误!", success = "2" };
                }
            }
            else
            {
                result = new { msg = "用户名或密码错误!", success = "2" };
            }

            return(result);
        }
Example #3
0
        private object DoLogin(string userName, string userPwd)
        {
            object result;
            var    bllLimit = new jmp_limit();
            var    bll      = new CoAgent();
            var    model    = bll.GetModel(userName);
            //加密用户登录密码
            var jmPwd = DESEncrypt.Encrypt(userPwd).ToLower();

            if (model != null)
            {
                if (model.AuditState != 1 && model.State != 0)
                {
                    result = new { msg = "您的账号未审核或者已冻结请联系运营人员!", success = "2" };
                    return(result);
                }
                if (model.LoginName == userName && model.Password.ToLower() == jmPwd)
                {
                    UserInfo.UserId     = model.Id;
                    UserInfo.UserName   = model.DisplayName;
                    UserInfo.UserNo     = model.LoginName;
                    UserInfo.UserRoleId = model.RoleId;
                    var dtLimit = bllLimit.GetAgentLimitSession(model.Id, model.RoleId);
                    if (dtLimit.Rows.Count > 0)
                    {
                        Session["dtSession"] = dtLimit;
                        model.LoginCount    += 1;
                        bll.Update(model);
                        Logger.OperateLog("登录代理商平台", "用户('" + UserInfo.UserName + "')于{'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'}登录代理商平台");
                        // var log = string.Format("用户({0})于{1}登录后台系统。", UserInfo.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        // AddLocLog.AddLog(int.Parse(UserInfo.UserId), 2, RequestHelper.GetClientIp(), "用户" + UserInfo.UserName + "登录。", log);
                        result = new { msg = "登录成功!", success = "1" };
                    }
                    else
                    {
                        result = new { msg = "权限不足!", success = "2" };
                    }
                }
                else
                {
                    result = new { msg = "用户名或密码错误!", success = "2" };
                }
            }
            else
            {
                result = new { msg = "用户名或密码错误!", success = "2" };
            }

            return(result);
        }
Example #4
0
        private object DoLogin(string userName, string userPwd)
        {
            object result;
            var    bllLimit = new jmp_limit();
            var    bll      = new jmp_locuser();
            var    model    = bll.GetModel(userName);
            //加密用户登录密码
            var jmPwd = DESEncrypt.Encrypt(userPwd).ToLower();

            if (model != null)
            {
                if (model.u_loginname == userName && model.u_pwd.ToLower() == jmPwd)
                {
                    UserInfo.UserId      = model.u_id;
                    UserInfo.UserName    = model.u_realname;
                    UserInfo.UserNo      = model.u_loginname;
                    UserInfo.UserRoleId  = model.u_role_id;
                    UserInfo.UserDept    = model.u_department;
                    UserInfo.UserPostion = model.u_position;
                    var dtLimit = bllLimit.GetUserLimitSession(model.u_id, model.u_role_id);
                    if (dtLimit.Rows.Count > 0)
                    {
                        Session["dtSession"] = dtLimit;
                        model.u_count       += 1;
                        bll.Update(model);
                        var log = string.Format("用户({0})于{1}登录后台系统。", UserInfo.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        AddLocLog.AddLog(UserInfo.UserId, 2, RequestHelper.GetClientIp(), "用户" + UserInfo.UserName + "登录。", log);
                        result = new { mag = "登录成功!", status = "1" };
                    }
                    else
                    {
                        result = new { mag = "权限不足!", status = "4" };
                    }
                }
                else
                {
                    result = new { mag = "用户名或密码错误!", status = "2" }
                };
            }
            else
            {
                result = new { mag = "用户名或密码错误!", status = "2" }
            };
            return(result);
        }
Example #5
0
        private string GetSonMenu(int uId, int rId, int topId)
        {
            string    son_menu = string.Empty;
            jmp_limit bll      = new jmp_limit();
            DataTable dt       = bll.GetUserLimit(uId, rId, topId);
            string    temp     = "<li id=\"{0}\" {1}><a id=\"{2}\" href=\"javascript:\" onclick=\"TabObj(this,'{4}','{3}')\"><span>{4}</span></a></li>";
            string    action   = Request["action"];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr    = dt.Rows[i];
                string  lid   = !string.IsNullOrEmpty(dr["l_id"].ToString()) ? "menu_" + dr["l_id"].ToString() : "menu_" + i + 1;
                string  aid   = !string.IsNullOrEmpty(dr["l_id"].ToString()) ? "menu_" + dr["l_id"].ToString() + "_a" : "menu_" + i + 1 + "_a";
                string  css   = i == 0 ? "class=\"selected\"" : "";
                string  url   = !string.IsNullOrEmpty(dr["l_url"].ToString()) ? dr["l_url"].ToString() : "";
                string  title = !string.IsNullOrEmpty(dr["l_name"].ToString()) ? dr["l_name"].ToString() : "";
                son_menu += string.Format(temp, lid, css, aid, url, title);
            }
            return(son_menu);
        }
Example #6
0
        private string GetTopMenu(int uId, int rId, ref string son_menu)
        {
            //顶级菜单
            string topMenu = string.Empty;

            son_menu = "<ul><li id=\"menu_0\" class=\"\"><a href=\"javascript:\" onclick=\"TabObj(this, '交易走势图', '/REPORT/Index');\" ><span>交易走势图</span></a></li></ul>";
            jmp_limit bll  = new jmp_limit();
            DataTable dt   = bll.GetUserLimit(uId, rId, 0);
            string    temp = "<li class=\"header-body-nav-li{0}\"><a href=\"javascript:\" {1}>{2}</a></li>";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr    = dt.Rows[i];
                string  licss = i == 0 ? " selected" : "";
                string  acss  = !string.IsNullOrEmpty(dr["l_icon"].ToString()) ? "class=\"icon " + dr["l_icon"].ToString() + "\"" : "";
                string  lname = !string.IsNullOrEmpty(dr["l_name"].ToString()) ? dr["l_name"].ToString() : "";
                topMenu += string.Format(temp, licss, acss, lname);
                int tid = int.Parse(dr["l_id"].ToString());
                son_menu += "<ul style=\"display:none\">" + GetSonMenu(uId, rId, tid) + "</ul>";
            }
            return(topMenu);
        }
Example #7
0
        public ActionResult UserLoginbyadm(string qs)
        {
            object result  = "";
            string ms      = JMP.TOOL.DESEncrypt.Decrypt(qs);
            string u_name  = ms.Split(';')[0].ToString();
            string u_pwd   = ms.Split(';')[1].ToString();
            string admname = ms.Split(';')[2].ToString();
            string admtime = ms.Split(';')[3].ToString();

            if (Convert.ToDateTime(admtime).AddMinutes(5) < System.DateTime.Now)
            {
                result = new { msg = "登录超时,后台密码失效,请从新刷新后台用户列表!", success = "2" };
            }
            else
            {
                var bllLimit = new jmp_limit();
                var bll      = new CoBusinessPersonnel();
                var model    = bll.GetModel(u_name);
                //加密用户登录密码

                if (model != null)
                {
                    if (model.State == 1)
                    {
                        result = new { mag = "您的账号已经冻结无法登录!", status = "2" };
                    }
                    else if (model.LoginName == u_name && model.Password.ToLower() == u_pwd.ToLower())
                    {
                        UserInfo.UserId     = model.Id;
                        UserInfo.UserName   = model.DisplayName;
                        UserInfo.UserNo     = model.LoginName;
                        UserInfo.UserRoleId = model.RoleId;
                        var dtLimit = bllLimit.GetBusinessLimitSession(model.Id, model.RoleId);
                        if (dtLimit.Rows.Count > 0)
                        {
                            Session["dtSession"] = dtLimit;
                            model.LoginCount    += 1;
                            model.LogintTime     = DateTime.Now;
                            bll.Update(model);
                            var log = string.Format("管理员({0})用{1}在{2}登录系统。", admname, UserInfo.UserName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            Logger.OperateLog("登录日志", log);
                            result = new { msg = "登录成功!", success = "1" };
                        }
                        else
                        {
                            result = new { msg = "权限不足!", success = "2" };
                        }
                    }
                    else
                    {
                        result = new { msg = "用户名或密码错误!", success = "2" };
                    }
                }
                else
                {
                    result = new { msg = "用户名或密码错误!", success = "2" };
                }
            }
            ViewBag.message = result;
            return(View());
        }