示例#1
0
 public ActionResult Edit(UserInfo userInfo)
 {
     if (userInfo.UserID == 0)
     {
         return Insert(userInfo);
     }
     else
     {
         return Update(userInfo);
     }
 }
示例#2
0
文件: UserDA.cs 项目: jerryxi/GXP
 public int InsertUser(Database db, DbTransaction tran, UserInfo userInfo)
 {
     throw new NotImplementedException();
 }
示例#3
0
文件: UserDA.cs 项目: jerryxi/GXP
 public int InsertUser(UserInfo userInfo)
 {
     throw new NotImplementedException();
 }
示例#4
0
文件: UserDA.cs 项目: jerryxi/GXP
 public int UpdateUser(UserInfo userInfo)
 {
     throw new NotImplementedException();
 }
示例#5
0
        /// <summary>
        /// 重写基类在Action之前执行的方法
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            #region -----校验用户是否登录进入网站的-----
            base.OnActionExecuting(filterContext);
            CurrentUserInfo = Session["UserInfo"] as UserInfo;

            //检验用户是否已经登录,如果登录则不执行,否则则执行下面的跳转代码
            if (CurrentUserInfo == null)
            {
                Response.Redirect("/Home/Logon");
            }
            else
            {
                //留个接口------
                if (CurrentUserInfo.UserName == "admin")
                {
                    return;
                }
            }
            #endregion

            /*
            #region -------检验用户是否有访问此地址的权利----
            //先将当前的请求,到权限表里面去找对应的数据
            //拿到当前请求的URL地址
            string requestUrl = filterContext.HttpContext.Request.Path;
            //拿到当前请求的类型
            string requestType = filterContext.HttpContext.Request.RequestType.ToLower().Equals("get") ? "HttpGet" : "HttpPost";
            //然后和权限表进行对比,如果取出来则通过请求,否则不通过
            //取出当前权限的数据
            var currentAction = null;//_actioninfoService.LoadEntities(c => c.RequestUrl.Equals(requestUrl, StringComparison.InvariantCultureIgnoreCase) && c.RequestHttpType.Equals(requestType)).FirstOrDefault();
            //如果没有权限对应当前请求的话,直接干掉
            if (currentAction == null)
            {
                EndRequest();
            }
            //想去用户权限表里面查询有没有数据
            //分析第一条线路 UserInfo->R_UserInfo_ActionInfo->ActionInfo
            //拿到当前的用户信息
            var userCurrent = null;//_userInfoService.LoadEntities(u => u.ID == CurrentUserInfo.ID).FirstOrDefault();
            var temp = (from r in userCurrent.R_UserInfo_ActionInfo
                        where r.ActionInfoID == currentAction.ID
                        select r).FirstOrDefault();
            if (temp != null)
            {
                if (temp.HasPermation)
                {
                    return;
                }
                else
                {
                    EndRequest();
                }
            }

            //分析第二条线路 UserInfo->ActionGroup->ActionInfo
            var groups = from n in userCurrent.ActionGroup //拿到当前用户所有的组
                         select n;
            //根据组信息遍历出权限信息
            bool isPass = (from g in groups
                           from a in g.ActionInfo
                           select a.ID).Contains(currentAction.ID);
            if (isPass)   //11,23,34不包含4
            {
                return;
            }

            //分析第三条线路 分为两个
            //1)UserInfo->R_UserInfo_Role->Role->ActionInfo

            //先拿到用户对应的所有的角色
            var UserRoles = from r in userCurrent.R_UserInfo_Role
                            select r.Role;
            //拿到角色对应的所有权限
            var Rolesaction = (from r in UserRoles
                               from a in r.ActionInfo
                               select a.ID);
            if (Rolesaction.Contains(currentAction.ID))
            {
                return;
            }

            //2)UserInfo->R_UserInfo_Role->Role->ActionGroup->ActionInfo
            //拿到组信息
            var RoleGroupActions = from r in UserRoles
                                   from g in r.ActionGroup
                                   select g;
            //拿到所有的组信息
            var groupActions = from r in RoleGroupActions
                               from g in r.ActionInfo
                               select g.ID;
            if (groupActions.Contains(currentAction.ID))
            {
                return;
            }
            #endregion
            */
        }
示例#6
0
文件: UserDA.cs 项目: jerryxi/GXP
 /// <summary>
 /// 设置SQL参数表
 /// </summary>
 /// <param name="User">User对象</param>
 /// <returns>User参数数组</returns>
 private SqlParameter[] Set_User_Parameters(UserInfo userInfo)
 {
     SqlParameter[] paramArray = new SqlParameter[] {new SqlParameter("@UserID",userInfo.UserID),
                                                         new SqlParameter("@UserCode",userInfo.UserCode),
                                                         new SqlParameter("@UserName",userInfo.UserName),
                                                         new SqlParameter("@LoginPwd",string.IsNullOrEmpty(userInfo.LoginPwd)?"":userInfo.LoginPwd),
                                                         new SqlParameter("@Sex",string.IsNullOrEmpty(userInfo.Sex)?"":userInfo.Sex),
                                                         new SqlParameter("@Age",userInfo.Age),
                                                         new SqlParameter("@Department",string.IsNullOrEmpty(userInfo.Department)?"":userInfo.Department),
                                                         new SqlParameter("@JobNum",string.IsNullOrEmpty(userInfo.JobNum)?"":userInfo.JobNum),
                                                         new SqlParameter("@Email",string.IsNullOrEmpty(userInfo.Email)?"":userInfo.Email),
                                                         new SqlParameter("@MobilePhone",string.IsNullOrEmpty(userInfo.MobilePhone)?"":userInfo.MobilePhone),
                                                         new SqlParameter("@IsActive",string.IsNullOrEmpty(userInfo.IsActive)?"":userInfo.IsActive),
                                                         new SqlParameter("@UserGroup",string.IsNullOrEmpty(userInfo.UserGroup)?"":userInfo.UserGroup),
                                                         new SqlParameter("@CreatedBy",string.IsNullOrEmpty(userInfo.CreatedBy)?"":userInfo.CreatedBy),
                                                         new SqlParameter("@UpdatedBy",string.IsNullOrEmpty(userInfo.UpdatedBy)?"":userInfo.UpdatedBy)
                                                     };
     return paramArray;
 }
示例#7
0
 public ActionResult Update(UserInfo userInfo)
 {
     try
     {
         userInfo.UpdatedBy = CurrentUserInfo.UserName;
         userInfo.UpdatedDate = DateTime.Now;
         IUserService userService = UnityHelper.UnityResolve<IUserService>();
         var data = userService.UpdateUser(userInfo);
         LogHelper.LogOperation(CurrentUserInfo.UserCode, string.Format("更新用户{0},{1}", LogHelper.ChangeEntityToLog(userInfo), data));
         if (data > 0)
         {
             return Content("OK");
         }
         else
         {
             return Content("Failed");
         }
     }
     catch (BusinessException bex)
     {
         return Content(bex.Message);
     }
     catch (Exception ex)
     {
         LogHelper.LogError(ex, "");
         return Content(ex.Message);
     }
 }
示例#8
0
文件: UserDA.cs 项目: jerryxi/GXP
 /// <summary>
 /// 初始化UserInfo
 /// </summary>
 private UserInfo InitUserInfoByDataReader(UserInfo userInfo, IDataReader reader)
 {
     userInfo = new UserInfo(reader["UserID"].ToString() != "" ? Int32.Parse(reader["UserID"].ToString()) : 0,
     reader["UserCode"].ToString(),
     reader["UserName"].ToString(),
     reader["LoginPwd"].ToString(),
     reader["Sex"].ToString(),
     reader["Age"].ToString() != "" ? Int32.Parse(reader["Age"].ToString()) : 0,
     reader["Department"].ToString(),
     reader["JobNum"].ToString(),
     reader["Email"].ToString(),
     reader["MobilePhone"].ToString(),
     reader["IsActive"].ToString(),
     reader["UserGroup"].ToString(),
     reader["CreatedBy"].ToString(),
     reader["CreatedDate"].ToString() != "" ? DateTime.Parse(reader["CreatedDate"].ToString()) : new DateTime(),
     reader["UpdatedBy"].ToString(),
     reader["UpdatedDate"].ToString() != "" ? DateTime.Parse(reader["UpdatedDate"].ToString()) : new DateTime());
     return userInfo;
 }
示例#9
0
文件: UserDA.cs 项目: jerryxi/GXP
 /// <summary>
 /// 更新一条User记录
 /// </summary>
 /// <param name="db">DataBase对象</param>
 /// <param name="tran">一个有效的DbTransaction</param>
 /// <param name="user">User对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行更新对数据库影响的行数</returns>
 public int UpdateUser(Database db, DbTransaction tran, UserInfo userInfo)
 {
     int result = 0;
     SqlParameter[] paras = Set_User_Parameters(userInfo);
     if (paras != null)
     {
         result += DBHelper.ExecuteNonQuery(db, tran, CommandType.Text, SQL_UPDATE_USER, paras);
     }
     return result;
 }
示例#10
0
文件: UserDA.cs 项目: jerryxi/GXP
 /// <summary>
 /// 新增一条User记录
 /// </summary>
 /// <param name="user">User对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行新增对数据库影响的行数</returns>
 public int InsertUser(UserInfo userInfo)
 {
     int result = 0;
     SqlParameter[] paras = Set_User_Parameters(userInfo);
     if (paras != null)
     {
         result = DBHelper.ExecuteNonQuery(CommandType.Text, SQL_INSERT_USER, paras);
     }
     return result;
 }
示例#11
0
 /// <summary>
 /// 更新一条User记录
 /// </summary>
 /// <param name="user">User对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行更新对数据库影响的行数</returns>
 public int UpdateUser(UserInfo userInfo)
 {
     return userDA.UpdateUser(userInfo);
 }
示例#12
0
 /// <summary>
 /// 新增一条User记录
 /// </summary>
 /// <param name="user">User对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行新增对数据库影响的行数</returns>
 public int InsertUser(UserInfo userInfo)
 {
     return userDA.InsertUser(userInfo);
 }