Esempio n. 1
0
        /// <summary>
        /// 记录编辑操作日志
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="newObj">更新后的对象</param>
        /// <param name="oldObj">更新前的对象</param>
        /// <param name="user">更新前的对象</param>
        public static void Edit <T>(T newObj, T oldObj, tblUser_Sys user) where T : new()
        {
            StringBuilder sb   = new StringBuilder();
            Type          type = typeof(T);

            sb.AppendFormat("{0},更新数据:", type.Name);
            sb.Append("{");
            // 获得此模型的公共属性
            var plist = new List <PropertyInfo>(type.GetProperties());

            foreach (PropertyInfo p in plist)
            {
                if (ExcludePropertyList.Contains(p.Name))
                {
                    continue;
                }
                var oldVal = p.GetValue(oldObj, null);
                var newVal = p.GetValue(newObj, null);

                if (p.PropertyType == typeof(DateTime))
                {
                    sb.AppendFormat("{0}:{1:yyyy-MM-dd}=>{2:yyyy-MM-dd},", p.Name, Convert.ToDateTime(oldVal), Convert.ToDateTime(newVal));
                }
                else
                {
                    sb.AppendFormat("{0}:{1}=>{2},", p.Name, oldVal, newVal);
                }
            }
            sb.Append("}");


            SaveOperateLog(user.LoginName, user.UserName, sb.ToString(), "更新数据");
        }
Esempio n. 2
0
        /// <summary>
        /// 根据登录名与查看权限获取筛选
        /// </summary>
        /// <param name="loginName">登录名</param>
        /// <param name="authority">查看权限</param>
        /// <returns></returns>
        public string AuthWhere(string loginName, string authority)
        {
            StringBuilder where = new StringBuilder("1=1");
            tblUser_Sys user = CommonHelper.GetUserByLoginName(loginName);

            if (authority == "查看本人")
            {
                where.Append(" and (Seller= '" + user.UserName + "')");
            }
            else if (authority == "查看下级")
            {
                List <string> SellerXia = CommonHelper.ListUnderling(loginName);
                string        CdtSeller = " (";
                CdtSeller += String.Join("", SellerXia.Select(p => "'" + p + "',").ToList());
                CdtSeller += "'" + user.UserName + "')";
                where.Append(" and (Seller in " + CdtSeller + ")");
            }
            else if (authority == "查看本部门")
            {
                string    Sql = " select UserName from tblUser_Sys where dept_New in (select dept_New from tblUser_Sys where loginName='" + loginName + "')";
                DataTable DT  = DBContext.PTMMHZ.GetDataTable(Sql);
                for (int i = 0; i < DT.Rows.Count; i++)
                {
                    string UserName = Convert.ToString(DT.Rows[i]["UserName"]);
                    where.Append(" and (Seller= '" + UserName + "')");
                }
            }
            return(where.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// 记录添加操作日志
        /// </summary>
        public static void Create <T>(T obj, tblUser_Sys user) where T : new()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0},添加数据:", typeof(T).Name);
            sb.Append(GetPropertyInfo(obj));
            SaveOperateLog(user.LoginName, user.UserName, sb.ToString(), "添加数据");
        }
Esempio n. 4
0
        public ActionResult Edit(tblUser_Sys collection)
        {
            ReturnMessage RM = new ReturnMessage(false);

            if (ModelState.IsValid)
            {
                try
                {
                    var query =
                        BusinessContext.tblUser_Sys.GetList(
                            Query.And(Query <tblUser_Sys> .EQ(t => t.LoginName, collection.LoginName),
                                      Query <tblUser_Sys> .NE(t => t.Rid, collection.Rid)));
                    if (query.Count > 0)
                    {
                        RM.Message = "登录名已被占用";
                    }
                    else
                    {
                        tblUser_Sys old =
                            BusinessContext.tblUser_Sys.Get(Query <tblUser_Sys> .EQ(t => t.Rid, collection.Rid));

                        RM.IsSuccess = BusinessContext.tblUser_Sys.Update(collection);
                        if (RM.IsSuccess)
                        {
                            OperateLogHelper.Edit <tblUser_Sys>(collection, old);
                            var list =
                                BusinessContext.tblUser_Roles.GetList(Query <tblUser_Roles> .EQ(t => t.LoginName,
                                                                                                collection.LoginName)).Where(p => p.Role_Id == collection.DefaultRoleId).ToList();
                            if (list != null && list.Count > 0)
                            {
                                tblUser_Roles role = list[0];
                                role.IsDefault = true;
                                role.Role_Id   = collection.DefaultRoleId;

                                tblUser_Roles old_Roles = BusinessContext.tblUser_Roles.Get(Query <tblUser_Roles> .EQ(t => t.Rid, role.Rid));
                                BusinessContext.tblUser_Roles.Update(role);
                                OperateLogHelper.Edit <tblUser_Roles>(role, old_Roles);
                            }
                            else
                            {
                                tblUser_Roles role = new tblUser_Roles();
                                role.IsDefault = true;
                                role.LoginName = collection.LoginName;
                                role.Role_Id   = collection.DefaultRoleId;
                                BusinessContext.tblUser_Roles.Add(role);
                                OperateLogHelper.Create <tblUser_Roles>(role);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    RM.Message = ex.Message;
                }
            }
            return(Json(RM));
        }
Esempio n. 5
0
        public ActionResult Details(int id = 0)
        {
            tblUser_Sys tbluser_sys = BusinessContext.tblUser_Sys.Get(Query <tblUser_Sys> .EQ(t => t.Rid, id));

            if (tbluser_sys == null)
            {
                return(HttpNotFound());
            }
            return(View(tbluser_sys));
        }
Esempio n. 6
0
        public ActionResult Details(int id = 0)
        {
            tblUser_Sys tbluser_sys = BusinessContext.tblUser_Sys.GetModel(id);

            if (tbluser_sys == null)
            {
                return(HttpNotFound());
            }
            return(View(tbluser_sys));
        }
Esempio n. 7
0
        public static void Edit <T>(List <T> oldList, List <T> newList, tblUser_Sys user) where T : new()
        {
            List <sysOperateLog> list = new List <sysOperateLog>();

            for (int i = 0; i < oldList.Count; i++)
            {
                list.Add(EditList <T>(newList[i], oldList[i], user));
            }
            SaveOperateLog(list[0]);
        }
Esempio n. 8
0
        public ActionResult Edit(tblUser_Sys collection)
        {
            ReturnMessage RM = new ReturnMessage(false);

            if (ModelState.IsValid)
            {
                try
                {
                    var query = BusinessContext.tblUser_Sys.GetModelList(String.Format("LoginName='{0}' and TblRcdId<>{1}", collection.LoginName, collection.TblRcdId));
                    if (query.Count > 0)
                    {
                        RM.Message = "登录名已被占用";
                    }
                    else
                    {
                        tblUser_Sys old = BusinessContext.tblUser_Sys.GetModel(collection.TblRcdId);

                        RM.IsSuccess = BusinessContext.tblUser_Sys.Update(collection);
                        if (RM.IsSuccess)
                        {
                            OperateLogHelper.Edit <tblUser_Sys>(collection, old);
                            var list = BusinessContext.tblUser_Roles.GetModelList("LoginName='" + collection.LoginName + "'").Where(p => p.Role_Id == collection.DefaultRoleId).ToList();
                            if (list != null && list.Count > 0)
                            {
                                tblUser_Roles role = list[0];
                                role.IsDefault = true;
                                role.Role_Id   = collection.DefaultRoleId;

                                tblUser_Roles old_Roles = BusinessContext.tblUser_Roles.GetModel(role.TblRcdId);
                                BusinessContext.tblUser_Roles.Update(role);
                                OperateLogHelper.Edit <tblUser_Roles>(role, old_Roles);
                            }
                            else
                            {
                                tblUser_Roles role = new tblUser_Roles();
                                role.IsDefault = true;
                                role.LoginName = collection.LoginName;
                                role.Role_Id   = collection.DefaultRoleId;
                                BusinessContext.tblUser_Roles.Add(role);
                                OperateLogHelper.Create <tblUser_Roles>(role);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    RM.Message = ex.Message;
                }
            }
            return(Json(RM));
        }
Esempio n. 9
0
        public ActionResult Create(tblUser_Sys collection, string IsContinue = "0")
        {
            ReturnMessage RM = new ReturnMessage(false);

            try
            {
                if (collection.UserPwd == "" || string.IsNullOrEmpty(collection.UserPwd))
                {
                    ///默认密码MD5加密
                    collection.UserPwd = Md5.Encode("123456");
                }
                ///根据登录名称查询是否已经存在,
                var query = BusinessContext.tblUser_Sys.GetModelByLoginName(collection.LoginName);
                if (query != null)
                {
                    RM.Message = "登录名已被占用";
                }
                else
                {
                    ///添加用户,并返回数据库ID,保存操作日志
                    int tblRcdid = BusinessContext.tblUser_Sys.Add(collection);
                    RM.IsSuccess = tblRcdid > 0;
                    if (RM.IsSuccess)
                    {
                        collection.TblRcdId = tblRcdid;
                        tblUser_Roles tblUser_Roles = new Model.tblUser_Roles();
                        tblUser_Roles.Role_Id   = collection.DefaultRoleId;
                        tblUser_Roles.LoginName = collection.LoginName;
                        tblUser_Roles.IsDefault = true;
                        BusinessContext.tblUser_Roles.Add(tblUser_Roles);
                        OperateLogHelper.Create <tblUser_Roles>(tblUser_Roles);
                        OperateLogHelper.Create <tblUser_Sys>(collection);
                        ///IsContinue 为1时保存并继续
                        if (IsContinue == "1")
                        {
                            RM.IsContinue = true;
                        }
                        else
                        {
                            RM.IsContinue = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                RM.Message = ex.Message;
            }

            return(Json(RM));
        }
Esempio n. 10
0
        /// <summary>
        /// 记录批量删除操作日志
        /// </summary>
        public static void Create <T>(List <T> objList, tblUser_Sys user) where T : new()
        {
            if (objList.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (T obj in objList)
                {
                    sb.AppendFormat("{0},添加数据:", typeof(T).Name);
                    sb.Append(GetPropertyInfo(obj));
                }

                SaveOperateLog(user.LoginName, user.UserName, sb.ToString(), "添加数据");
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 根据登录名获取用户信息
        /// </summary>
        /// <param name="loginName">登录名</param>
        /// <returns></returns>
        public static tblUser_Sys GetUserByLoginName(string loginName)
        {
            tblUser_Sys user = CacheManager.Get("tblUser_Sys-" + loginName) as tblUser_Sys;

            if (user == null)
            {
                string             SQL      = "select * from tblUser_Sys where LoginName='" + loginName + "'";
                DataTable          DT       = DBContext.DataDecision.GetDataTable(SQL);
                List <tblUser_Sys> UserList = DT.ToList <tblUser_Sys>();
                if (UserList != null && UserList.Count > 0)
                {
                    user = UserList[0];
                }
                CacheManager.Insert("tblUser_Sys-" + loginName, user);
            }
            return(user ?? new tblUser_Sys());
        }
Esempio n. 12
0
        public ActionResult Edit(UserPassWord upw)
        {
            ReturnMessage RM = new ReturnMessage(false);

            try
            {
                tblUser_Sys tbluse = BusinessContext.tblUser_Sys.GetModelList("Loginname='" + upw.LoginName + "'").FirstOrDefault();

                if (upw.OldPassWord != tbluse.UserPwd)
                {
                    RM.IsSuccess = false;
                    RM.Message   = "旧密码输入错误,请重新输入!";
                    return(Json(RM));
                }
                if (upw.NewPassWord != upw.SureNewPassWord)
                {
                    RM.IsSuccess = false;
                    RM.Message   = "新密码不一致,请重新输入!";
                    return(Json(RM));
                }

                List <string> lsSql = new List <string>();

                StringBuilder strSql = new StringBuilder("update tblUser_Sys set UserPwd='" + upw.NewPassWord + "' where loginname='" + upw.LoginName + "'");
                lsSql.Add(strSql.ToString());

                if (DBContext.DataDecision.ExecTrans(lsSql.ToArray()))
                {
                    RM.IsSuccess = true;
                    RM.Message   = "密码设置成功!";
                }
                else
                {
                    RM.IsSuccess = true;
                    RM.Message   = "密码设置失败!";
                }

                return(Json(RM));
            }
            catch
            {
                return(Json(RM));
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 获取订单下拉
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="authority"></param>
        /// <returns></returns>
        public List <string> GetAdDesignList(string loginName, string authority)
        {
            List <string> list = new List <string>();

            CommonServiceFactory factory = new CommonServiceFactory();
            ICommonService       service = factory.GetInstance();

            StringBuilder where = new StringBuilder(" 1=1 ");
            tblUser_Sys user = CommonHelper.GetUserByLoginName(loginName);

            if (authority == "查看本人")
            {
                where.Append(" and (Seller= '" + user.UserName + "')");
            }
            else if (authority == "查看下级")
            {
                List <string> SellerXia = CommonHelper.ListUnderling(user.LoginName);
                string        CdtSeller = " (";
                CdtSeller += String.Join("", SellerXia.Select(p => "'" + p + "',").ToList());
                CdtSeller += "'" + user.UserName + "')";
                where.Append(" and (Seller in " + CdtSeller + ")");
            }
            else if (authority == "查看本部门")
            {
                string        Sql       = " select UserName from tblUser_Sys where dept_New in (select dept_New from tblUser_Sys where loginName='" + user.LoginName + "')";
                DataTable     DT        = DBContext.PTMMHZ.GetDataTable(Sql);
                List <string> SellerXia = new List <string>();
                for (int i = 0; i < DT.Rows.Count; i++)
                {
                    string UserName = Convert.ToString(DT.Rows[i]["UserName"]);
                    SellerXia.Add(UserName);
                }
                where.Append(" and (Seller in " + DBContext.PTMMHZ.AssemblyInCondition(SellerXia) + ")");
            }
            where.AppendFormat(@"and (adorderid in (select distinct  adorderid from tblAdOrderMedialist where InsureEndDate>='{0}') 
                                or adorderid in (select distinct  adorderid from tblAdFixingList where InsureEndDate>='{0}')
                                or adorderid in (select distinct  adorderid from tblOutdoorAdOrderMedia where EndDate>='{0}')
                                or adorderid in (select distinct  adorderid from tblBicycleMadialist where EndDate>='{0}'))", DateTime.Now);
            list = CommonHelper.ListDistinctField("tblAdOrder", "AdOrderId", where.ToString(), " adorderid desc");

            return(list);
        }
Esempio n. 14
0
        public ActionResult ChangePassword(string newPassword)
        {
            ReturnMessage RM = new ReturnMessage(false);

            if (string.IsNullOrWhiteSpace(newPassword))
            {
                RM.Message = "新密码不能为空";
            }
            else
            {
                tblUser_Sys user = CurrentHelper.CurrentUser.User;
                if (user == null || user.TblRcdId <= 0)
                {
                    RM.Message = "数据异常,请重新登录";
                }
                else
                {
                    tblUser_Sys model = new tblUser_Sys();

                    model.UserPwd       = Md5.Encode(newPassword);
                    model.TblRcdId      = user.TblRcdId;
                    model.LoginName     = user.LoginName;
                    model.UserName      = user.UserName;
                    model.Remark        = user.Remark;
                    model.RoleFlag      = user.RoleFlag;
                    model.dept          = user.dept;
                    model.dept_New      = user.dept_New;
                    model.DefaultRoleId = user.DefaultRoleId;
                    model.EnglishName   = user.EnglishName;
                    model.PassWord      = Md5.Encode(newPassword);
                    model.UserMark      = user.UserMark;

                    BusinessContext.tblUser_Sys.Update(model);
                    OperateLogHelper.Edit <tblUser_Sys>(model, user);
                    RM.IsSuccess = true;
                }
            }

            return(Json(RM));
        }
Esempio n. 15
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id)
        {
            tblUser_Sys dpt = BusinessContext.tblUser_Sys.Get(Query <tblUser_Sys> .EQ(t => t.Rid, id));

            if (dpt == null)
            {
                return(HttpNotFound());
            }


            if (dpt.DefaultRoleId == 0)
            {
                var q = Query.And(Query <tblUser_Roles> .EQ(t => t.LoginName, dpt.LoginName),
                                  Query <tblUser_Roles> .EQ(t => t.IsDefault, true));
                var query = BusinessContext.tblUser_Roles.GetList(q).OrderBy(p => p.Rid).Select(p => p.Role_Id).ToList();
                if (query != null && query.Count > 0)
                {
                    dpt.DefaultRoleId = query[0];
                }
            }
            List <SelectListItem> deptList = BusinessContext.tblDepart.GetList().Select(p => new SelectListItem {
                Text = p.dept, Value = p.dept, Selected = dpt.dept_New == p.dept
            }).ToList();

            deptList.Insert(0, new SelectListItem {
                Text = "-请选择-", Value = ""
            });
            ViewData["deptList"] = deptList;
            List <SelectListItem> RoleList = BusinessContext.sys_role.GetList().Select(p => new SelectListItem {
                Text = p.role_name, Value = p.Rid.ToString(), Selected = dpt.DefaultRoleId == p.Rid
            }).ToList();

            RoleList.Insert(0, new SelectListItem {
                Text = "-请选择-", Value = ""
            });
            ViewData["RoleList"] = RoleList;

            return(View(dpt));
        }
Esempio n. 16
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id)
        {
            tblUser_Sys dpt = BusinessContext.tblUser_Sys.GetModel(id);

            if (dpt == null)
            {
                return(HttpNotFound());
            }


            if (dpt.DefaultRoleId == 0)
            {
                var query = BusinessContext.tblUser_Roles.GetModelList("LoginName='" + dpt.LoginName + "' and IsDefault=1").OrderBy(p => p.TblRcdId).Select(p => p.Role_Id).ToList();
                if (query != null && query.Count > 0)
                {
                    dpt.DefaultRoleId = query[0];
                }
            }
            List <SelectListItem> deptList = BusinessContext.tblDepart.GetModelList("1=1").Select(p => new SelectListItem {
                Text = p.dept, Value = p.dept, Selected = dpt.dept_New == p.dept
            }).ToList();

            deptList.Insert(0, new SelectListItem {
                Text = "-请选择-", Value = ""
            });
            ViewData["deptList"] = deptList;
            List <SelectListItem> RoleList = BusinessContext.sys_role.GetModelList("1=1").Select(p => new SelectListItem {
                Text = p.role_name, Value = p.TblRcdId.ToString(), Selected = dpt.DefaultRoleId == p.TblRcdId
            }).ToList();

            RoleList.Insert(0, new SelectListItem {
                Text = "-请选择-", Value = ""
            });
            ViewData["RoleList"] = RoleList;

            return(View(dpt));
        }
Esempio n. 17
0
 internal static void Edit <T1>(tblUser_Sys collection, tblUser_Roles old)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
        public ActionResult Login()
        {
            try
            {
                if (Request.Cookies[CurrentHelper.LOGIN_INFO_COOKIE] != null)
                {
                    string loginName = CurrentHelper.CurrentUser.User.LoginName;
                    string pwd       = Request.Cookies[CurrentHelper.LOGIN_INFO_COOKIE].Values[CurrentHelper.LOGIN_PWD_COOKIE];
                    if (!string.IsNullOrEmpty(loginName))
                    {
                        tblUser_Sys user =
                            BusinessContext.tblUser_Sys.Get(Query <tblUser_Sys> .EQ(t => t.LoginName, loginName));
                        //根据cookie当中的记录,如果验证通过则直接登陆成功
                        if (user != null && pwd == user.UserPwd)
                        {
                            #region 初始化用户对象
                            UserModel m_CurrentUser = new UserModel();
                            m_CurrentUser.User  = user;
                            m_CurrentUser.Roles = new List <sys_role>();
                            List <tblUser_Roles> roleList =
                                BusinessContext.tblUser_Roles.GetList(Query <tblUser_Roles> .EQ(t => t.LoginName,
                                                                                                loginName));
                            List <int> roleIds = roleList.Select(p => p.Role_Id).ToList();
                            if (roleIds != null && roleIds.Count > 0)
                            {
                                //strWhere = string.Format("rid in {0}", DBContext.AssemblyInCondition(roleIds));
                                m_CurrentUser.Roles =
                                    BusinessContext.sys_role.GetList(Query <sys_role> .In(t => t.Rid, roleIds));
                            }
                            System.Web.HttpContext.Current.Session["User"] = m_CurrentUser;
                            #endregion

                            if (this.Request.RawUrl != this.Request.Url.AbsolutePath && !this.Request.RawUrl.ToLower().Contains("/home/login"))
                            {
                                FormsAuthentication.SetAuthCookie(user.LoginName, false);
                                return(Redirect(this.Request.RawUrl));
                            }
                            else
                            {
                                if (!string.IsNullOrWhiteSpace(FormsAuthentication.GetRedirectUrl(user.LoginName, false)))
                                {
                                    FormsAuthentication.RedirectFromLoginPage(user.LoginName, true);
                                }
                                else
                                {
                                    return(Redirect(FormsAuthentication.DefaultUrl));
                                }
                            }
                        }
                    }
                }
                else if (!string.IsNullOrWhiteSpace(Request["LoginName"]) && !string.IsNullOrWhiteSpace(Request["UserPwd"]))
                {
                    string      loginName = Request["LoginName"];
                    string      pwd       = Request["UserPwd"];
                    tblUser_Sys user      = BusinessContext.tblUser_Sys.Get(Query <tblUser_Sys> .EQ(t => t.LoginName, loginName));

                    if (user != null && pwd == user.UserPwd)
                    {
                        #region 初始化用户对象
                        UserModel m_CurrentUser = new UserModel();
                        m_CurrentUser.User  = user;
                        m_CurrentUser.Roles = new List <sys_role>();
                        //string strWhere = "LoginName='" + loginName + "'";
                        List <tblUser_Roles> roleList =
                            BusinessContext.tblUser_Roles.GetList(Query <tblUser_Roles> .EQ(t => t.LoginName,
                                                                                            loginName));
                        List <int> roleIds = roleList.Select(p => p.Role_Id).ToList();
                        if (roleIds != null && roleIds.Count > 0)
                        {
                            //strWhere = string.Format("rid in {0}", DBContext.AssemblyInCondition(roleIds));
                            m_CurrentUser.Roles =
                                BusinessContext.sys_role.GetList(Query <sys_role> .In(t => t.Rid, roleIds));
                        }

                        System.Web.HttpContext.Current.Session["User"] = m_CurrentUser;
                        #endregion

                        if (this.Request.RawUrl != this.Request.Url.AbsolutePath && !this.Request.RawUrl.ToLower().Contains("/home/login"))
                        {
                            FormsAuthentication.SetAuthCookie(user.LoginName, false);
                            return(Redirect(this.Request.RawUrl));
                        }
                        else
                        {
                            FormsAuthentication.RedirectFromLoginPage(user.LoginName, true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.Error("登录异常", ex);
                return(LogOut());
            }

            return(View());
        }
Esempio n. 19
0
        public ActionResult Login(FormCollection form)
        {
            string loginName   = form["LoginName"].ToString();
            string passWord    = form["PassWord"].ToString();
            string verifyCode  = form["verifyCode"] == null ? "" : form["verifyCode"];
            string sverifyCode = Session["verifyCode"] == null ? "" : Session["verifyCode"].ToString();
            int    type        = UseTools.GetSecurityType();

            if (verifyCode != sverifyCode && type != 0)
            {
                ReturnMessage RM = new ReturnMessage(false);
                RM.Message            = "验证码错误,请重新发送验证码!";
                Session["verifyCode"] = null;
                return(Json(RM, JsonRequestBehavior.AllowGet));
            }
            else
            {
                try
                {
                    Session["verifyCode"] = null;
                    tblUser_Sys user             = BusinessContext.tblUser_Sys.Get(Query <tblUser_Sys> .EQ(t => t.LoginName, loginName));
                    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
                    rsa.FromXmlString((string)Session["private_key"]);
                    byte[] result = rsa.Decrypt(passWord.ToHexBytes(), false);
                    passWord = Encoding.UTF8.GetString(result);
                    if (user != null && string.Compare(user.UserPwd, passWord, true) == 0)
                    {
                        HttpCookie userlogininfo = new HttpCookie(CurrentHelper.LOGIN_INFO_COOKIE);
                        userlogininfo.HttpOnly = true;
                        userlogininfo.Expires  = DateTime.Now.AddHours(2);//Cookie存活2小时
                        userlogininfo.Values.Add(CurrentHelper.LOGIN_NAME_COOKIE, user.LoginName);
                        userlogininfo.Values.Add(CurrentHelper.LOGIN_PWD_COOKIE, user.UserPwd);
                        Response.AppendCookie(userlogininfo);
                        #region 初始化用户对象
                        UserModel m_CurrentUser = new UserModel();
                        m_CurrentUser.User  = user;
                        m_CurrentUser.Roles = new List <sys_role>();
                        //string strWhere = "LoginName='" + loginName + "'";
                        List <tblUser_Roles> roleList =
                            BusinessContext.tblUser_Roles.GetList(Query <tblUser_Roles> .EQ(t => t.LoginName, loginName));
                        List <int> roleIds = roleList.Select(p => p.Role_Id).ToList();
                        if (roleIds != null && roleIds.Count > 0)
                        {
                            //strWhere = string.Format("rid in {0}", DBContext.AssemblyInCondition(roleIds));
                            m_CurrentUser.Roles =
                                BusinessContext.sys_role.GetList(Query <sys_role> .In(t => t.Rid, roleIds));
                        }
                        System.Web.HttpContext.Current.Session["User"] = m_CurrentUser;
                        #endregion
                        ReturnMessage RM = new ReturnMessage(true);
                        return(Json(RM, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        if (user != null && user.Rid > 0)
                        {
                            user.FailTimes++;
                            BusinessContext.tblUser_Sys.Update(user);
                        }
                        ReturnMessage RM = new ReturnMessage(false);
                        RM.Message = "登录名或密码错误!";
                        return(Json(RM, JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception ex)
                {
                    LogManager.Error("登录异常", ex);
                    ReturnMessage RM = new ReturnMessage(false);
                    RM.Message = "异常,请重试!";
                    return(Json(RM, JsonRequestBehavior.AllowGet));
                }
            }
        }