Esempio n. 1
0
        public ActionResult EditUser(string userName)
        {
            ViewBag.DeparUrl = WebCommon.Url_DepartmentInfo_DepartmentManager;
            //获取用户信息
            PriviDepartmentUser      pdu           = null;
            IList <SYSRoleUser>      roleUserList  = new List <SYSRoleUser>();
            List <UserCenter_Apps>   appList       = new List <UserCenter_Apps>();
            UserCenter_LoginUserInfo loginUserInfo = WebUserHelp.GetNowLoginUser(out appList);
            int    cityId                = WebUserHelp.GetNowCityId();
            int    companyId             = loginUserInfo.FxtCompanyId;
            string loginusername         = loginUserInfo.UserName;
            string loginsignname         = loginUserInfo.SignName;
            UserCenter_UserInfo userInfo = UserInfoManager.GetUserInfoByUserName(cityId, companyId, userName, loginsignname, loginsignname, appList, out pdu, out roleUserList);

            if (userInfo != null)
            {
                //输出给页面变量
                ViewBag.CompanyName = userInfo.CompanyName;
                ViewBag.UserName    = userInfo.UserName;
                ViewBag.TrueName    = userInfo.TrueName;
                ViewBag.Mebile      = userInfo.Mobile;
                if (pdu != null)
                {
                    ViewBag.DepartmentId = pdu.DepartmentID;
                }
                ViewBag.RoleUserList = roleUserList;
            }
            //获取小组+角色基础信息
            IList <SYSRole>         roleList = SYSRoleManager.GetSYSRoleByCompanyId(cityId, companyId);
            IList <PriviDepartment> pdList   = PriviDepartmentManager.GetDepartmentByCompanyId(cityId, companyId);

            ViewBag.DepartmentList = pdList;
            ViewBag.RoleList       = roleList;
            return(View());
        }
Esempio n. 2
0
        //public static List<UserInfoJoinRoleJoinDepartment> GetUserInfoJoinRoleJoinDepartmentBySurveyRight(int cityId, int companyId,string nowUserName, string keyword,
        //     int[] functionCodes, int pageIndex, int pageSize, string loginusername, string loginsignname, out int count, bool isGetCount = true, DataBase _db = null)
        //{
        //    count = 0;
        //    List<UserInfoJoinRoleJoinDepartment> list = new List<UserInfoJoinRoleJoinDepartment>();
        //    DataBase db = new DataBase(_db);
        //    StringBuilder sb = new StringBuilder();
        //    List<NHParameter> parameters = new List<NHParameter>();
        //    parameters.Add(new NHParameter("companyId", companyId, NHibernateUtil.Int32));
        //    parameters.Add(new NHParameter("cityId", cityId, NHibernateUtil.Int32));
        //    sb.Append(string.Format("{0} CityID=:cityId and FxtCompanyId=:companyId ", NHibernateUtility.GetMSSQL_SQL_NOLOCK(NHibernateUtility.TableName_SYSRoleUser, "distinct", "UserName")));
        //    //根据操作权限
        //    if (functionCodes != null && functionCodes.Contains(SYSCodeManager.FunOperCode_3))//查看公司全部(管理员+分配人+审核人)
        //    {
        //    }
        //    else if (functionCodes != null && functionCodes.Contains(SYSCodeManager.FunOperCode_2))//查看小组内(组长)
        //    {
        //        sb.Append(string.Format("and (UserName=:userName or  UserName in (select UserName from {0} with(nolock) where DepartmentID in (select DepartmentID from {0} with(nolock) where  CityID=:cityId and FxtCompanyID=:companyId and UserName=:userName  and DepartmentID in (select DepartmentID from {1} with(nolock) where DValid=1))))", NHibernateUtility.TableName_PriviDepartmentUser, NHibernateUtility.TableName_PriviDepartment));
        //        parameters.Add(new NHParameter("userName", nowUserName, NHibernateUtil.String));
        //    }
        //    else//查看自己(查勘员)
        //    {
        //        sb.Append(" and UserName=:userName ");
        //        parameters.Add(new NHParameter("userName", nowUserName, NHibernateUtil.String));
        //    }
        //    if (!string.IsNullOrEmpty(keyword))
        //    {
        //        sb.Append(" and UserName like :keyword ");
        //        parameters.Add(new NHParameter("keyword", "%" + keyword + "%", NHibernateUtil.String));
        //    }
        //    UtilityPager pageInfo = new UtilityPager(pageSize: pageSize, pageIndex: pageIndex, isGetCount: isGetCount);
        //    IList ilist = db.DB.GetCustomSQLQueryObjectList(pageInfo, sb.ToString(), parameters);
        //    count = pageInfo.Count;
        //    if (ilist == null || ilist.Count < 1)
        //    {
        //        db.Close();
        //        return new List<UserInfoJoinRoleJoinDepartment>();
        //    }
        //    List<string> userNameList = new List<string>();
        //    foreach (var l in ilist)
        //    {
        //        userNameList.Add(Convert.ToString(l));
        //    }
        //    int count2 = 0;
        //    List<View_UserJoinRoleJoinDepartmen> roleList = ViewUserJoinRoleJoinDepartmenManager.GetUserJoinRoleJoinDepartmenByUserNames(companyId, cityId, userNameList.ToArray(), _db: db);
        //    List<UserCenter_UserInfo> userList = UserCenterUserInfoApi.GetUserListByCompanyId(companyId, userNameList.ToArray(), null, null, pageIndex, pageSize, out count2, loginusername, loginsignname);
        //    List<UserInfoJoinRoleJoinDepartment> list = UserInfoJoinRoleJoinDepartment.GetList(roleList2, departmentList, userList, roleList);
        //}

        /// <summary>
        /// 获取单个用户信息
        /// </summary>
        /// <param name="cityId">当前城市</param>
        /// <param name="companyId">所属机构ID</param>
        /// <param name="userName">用户名</param>
        /// <param name="loginusername">当前登录的username(用于api验证)</param>
        /// <param name="loginsignname">当前登录的signname(用于api验证)</param>
        /// <param name="loginAppList">当前登录的用户拥有的api信息集合(用于验证api)</param>
        /// <param name="pdu"></param>
        /// <param name="roleUserList"></param>
        /// <param name="_db"></param>
        /// <returns></returns>
        public static UserCenter_UserInfo GetUserInfoByUserName(int cityId, int companyId, string userName, string loginusername, string loginsignname, List <UserCenter_Apps> loginAppList, out PriviDepartmentUser pdu, out IList <SYSRoleUser> roleUserList, DataBase _db = null)
        {
            pdu          = null;
            roleUserList = new List <SYSRoleUser>();
            int count = 0;
            UserCenter_UserInfo userInfo = null;

            if (string.IsNullOrEmpty(userName))
            {
                return(null);
            }
            List <UserCenter_UserInfo> userInfoList = UserCenterUserInfoApi.GetUserListByCompanyId(companyId, new string[] { userName }, "", null, 1, 1, out count, loginusername, loginsignname, loginAppList);

            if (userInfoList == null || userInfoList.Count < 1)
            {
                return(null);
            }
            userInfo = userInfoList[0];
            DataBase db = new DataBase(_db);

            try
            {
                pdu          = PriviDepartmentUserManager.GetDepartmentUserByUserName(cityId, companyId, userName, db);
                roleUserList = SYSRoleUserManager.GetSYSRoleUserByUserName(cityId, companyId, userName, db);
                db.Close();
                return(userInfo);
            }
            catch (Exception ex)
            {
                db.Close();
                throw ex;
            }
        }
        /// <summary>
        /// 只按角色查询时,用此方法转换
        /// </summary>
        /// <param name="roleBaseList">主数据</param>
        /// <param name="departmentList"></param>
        /// <param name="userList"></param>
        /// <param name="roleList"></param>
        /// <returns></returns>
        public static List <UserInfoJoinRoleJoinDepartment> GetList(List <View_UserJoinRoleJoinDepartmen> roleBaseList, IList <View_UserJoinDepartment> departmentList, List <UserCenter_UserInfo> userList, List <View_UserJoinRoleJoinDepartmen> roleList)
        {
            List <UserInfoJoinRoleJoinDepartment> list = new List <UserInfoJoinRoleJoinDepartment>();

            if (roleBaseList != null)
            {
                foreach (View_UserJoinRoleJoinDepartmen roleBaseInfo in roleBaseList)
                {
                    int?   departmentId          = null;
                    string departmentName        = null;
                    string roleNames             = null;
                    string trueName              = null;
                    string companyName           = null;
                    int    userValid             = 0;
                    string mobile                = "";
                    UserCenter_UserInfo userInfo = userList.Where(obj => obj.UserName == roleBaseInfo.UserName).FirstOrDefault();
                    if (userInfo != null)
                    {
                        trueName    = userInfo.TrueName;
                        companyName = userInfo.CompanyName;
                        userValid   = userInfo.UserValid;
                        mobile      = userInfo.Mobile;
                    }
                    View_UserJoinDepartment departmentInfo = departmentList.Where(obj => obj.UserName == roleBaseInfo.UserName).FirstOrDefault();
                    if (departmentInfo != null)
                    {
                        departmentId   = departmentInfo.DepartmentID;
                        departmentName = departmentInfo.DepartmentName;
                    }
                    List <View_UserJoinRoleJoinDepartmen> nowRoleList = roleList.Where(obj => obj.UserName == roleBaseInfo.UserName).ToList();
                    if (nowRoleList != null)
                    {
                        StringBuilder sb = new StringBuilder("");
                        foreach (View_UserJoinRoleJoinDepartmen roleInfo in nowRoleList)
                        {
                            sb.Append(roleInfo.RoleName).Append(",");
                        }
                        roleNames = sb.ToString().TrimEnd(',');
                    }
                    UserInfoJoinRoleJoinDepartment obj2 = new UserInfoJoinRoleJoinDepartment(roleBaseInfo.UserName, trueName, mobile, companyName, userValid, roleNames, departmentId, departmentName);
                    list.Add(obj2);
                }
            }
            return(list);
        }