示例#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());
        }
示例#2
0
        /// <summary>
        /// 获取当前用户的小组信息
        /// </summary>
        /// <param name="cityId"></param>
        /// <param name="companyId"></param>
        /// <param name="userName"></param>
        /// <param name="_db"></param>
        /// <returns></returns>
        public static PriviDepartmentUser GetDepartmentUserByUserName(int cityId, int companyId, string userName, DataBase _db = null)
        {
            DataBase db = new DataBase(_db);

            try
            {
                string sql = "{0} FxtCompanyID=:companyId and CityId=:cityId and UserName=:userName and exists  (select * from {1} as tb2 with(nolock) where tb2.DepartmentID=_tb.DepartmentID and DValid=1)";
                sql = string.Format(sql, NHibernateUtility.GetMSSQL_SQL_NOLOCK(NHibernateUtility.TableName_PriviDepartmentUser), NHibernateUtility.TableName_PriviDepartment);
                List <NHParameter> parameters = new List <NHParameter>();
                parameters.Add(new NHParameter("companyId", companyId, NHibernateUtil.Int32));
                parameters.Add(new NHParameter("cityId", cityId, NHibernateUtil.Int32));
                parameters.Add(new NHParameter("userName", userName, NHibernateUtil.String));
                PriviDepartmentUser pdu = db.DB.GetCustomSQLQueryEntity <PriviDepartmentUser>(sql, parameters);
                //PriviDepartmentUser pdu = db.DB.GetCustom<PriviDepartmentUser>(
                //     (Expression<Func<PriviDepartmentUser, bool>>)(tbl => tbl.CityID == cityId && tbl.FxtCompanyID == companyId && tbl.UserName == userName)
                //    );
                db.Close();
                return(pdu);
            }
            catch (Exception ex)
            {
                db.Close();
                throw ex;
            }
        }
示例#3
0
        public ActionResult AddHouseDetails(HouseDetails house, long allotId, int fxtcompanyId, int cityId, UserCenter_LoginUserInfo loginUser)
        {
            DatAllotFlow allot = DatAllotFlowManager.GetDatAllotFlowById(allotId);

            if (allot == null)
            {
                return(WebUserHelp.GetAction404Page());//无此页面
            }
            //登陆用户所在小组
            PriviDepartmentUser loginDepartment = PriviDepartmentUserManager.GetDepartmentUserByUserName(loginUser.NowCityId, loginUser.FxtCompanyId, loginUser.UserName);
            //当前信息的发起用户所在小组
            PriviDepartmentUser infoStartDepartment = PriviDepartmentUserManager.GetDepartmentUserByUserName(loginUser.NowCityId, allot.FxtCompanyId, allot.UserName);
            //当前信息的用户所在小组
            PriviDepartmentUser infoDepartment = PriviDepartmentUserManager.GetDepartmentUserByUserName(loginUser.NowCityId, allot.FxtCompanyId, allot.SurveyUserName);

            #region 验证查看权限
            //获取当前用户对任务列表页拥有的权限(验证查看权限)
            List <int> nowFunctionCodes = WebUserHelp.GetNowPageFunctionCodes(loginUser.UserName, loginUser.FxtCompanyId, WebCommon.Url_AllotFlowInfo_AllotFlowManager);
            //是否用于查看权限
            if (!WebUserHelp.CheckNowPageViewFunctionCode(nowFunctionCodes.ToArray(), loginUser.UserName, allot.UserName, allot.SurveyUserName,
                                                          loginDepartment == null ? 0 : loginDepartment.DepartmentID, infoStartDepartment == null ? 0 : infoStartDepartment.DepartmentID,
                                                          infoDepartment == null ? 0 : infoDepartment.DepartmentID))
            {
                return(WebUserHelp.GetActionNotRightPage());//无权限
            }
            #endregion

            //户型结构
            ViewBag.StructureCode = SYSCodeManager.StructureCodeManager();
            //通风采光
            ViewBag.VDCode = SYSCodeManager.VDCodeManager();
            //噪音情况
            ViewBag.Noise = SYSCodeManager.NoiseManager();
            //用途
            ViewBag.PurposeCode = SYSCodeManager.HousePurposeCodeManager();

            #region 验证修改权限
            //获取当前用户对当前页拥有的权限
            List <int> nowFunctionCodes2 = WebUserHelp.GetNowPageFunctionCodes(loginUser.UserName, loginUser.FxtCompanyId, WebCommon.Url_AllotFlowInfo_AllotDetailed);
            if (WebUserHelp.CheckNowPageUpdateFunctionCode(nowFunctionCodes2.ToArray(), loginUser.UserName, allot.SurveyUserName,
                                                           loginDepartment == null ? 0 : loginDepartment.DepartmentID, infoDepartment == null ? 0 : infoDepartment.DepartmentID, allot.SurveyUserName) &&
                (allot.StateCode != SYSCodeManager.STATECODE_10))
            {
                ViewBag.IsUpdateRight = 1;//有权限
            }
            #endregion
            if (house.Id > 0)
            {
                return(View(_unitOfWork.HouseDetailsRepository.GetById(house.Id)));
            }
            else
            {
                return(View(house));
            }
        }
示例#4
0
        /// <summary>
        /// 设置用户信息(分配小组+角色)
        /// </summary>
        /// <param name="cityId"></param>
        /// <param name="companyId"></param>
        /// <param name="userName"></param>
        /// <param name="departmentId">小组ID</param>
        /// <param name="roleIds">多个角色ID组成的数组</param>
        /// <param name="message"></param>
        /// <param name="_db"></param>
        /// <returns></returns>
        public static bool SetUserInfo(int cityId, int companyId, string userName, string truename, int?departmentId, int[] roleIds, out string message, DataBase _db = null)
        {
            //DataTable aa = new DataTable();
            //aa.Rows.Add()
            //    aa.Rows.InsertAt()
            DataBase db = new DataBase(_db);

            try
            {
                bool result = true;
                message = "";
                using (ITransaction tx = db.DB.BeginTransaction())
                {
                    try
                    {
                        #region (更新小组信息)
                        if (Convert.ToInt32(departmentId) == 0)
                        {
                            if (!PriviDepartmentUserManager.DeleteByUserName(cityId, companyId, userName, db, tx))
                            {
                                message = "删除小组异常";
                                result  = false;
                                tx.Rollback();
                                goto end;
                            }
                            goto 更新角色信息;
                        }
                        bool pduUpdate          = true;//是否存在并更新
                        PriviDepartmentUser pdu = PriviDepartmentUserManager.GetDepartmentUserByUserName(cityId, companyId, userName, db);
                        if (pdu == null)
                        {
                            pduUpdate = false;
                            pdu       = new PriviDepartmentUser();
                        }
                        pdu.UserName     = userName;
                        pdu.DepartmentID = Convert.ToInt32(departmentId);
                        pdu.CreateDate   = DateTime.Now;
                        pdu.CityID       = cityId;
                        pdu.FxtCompanyID = companyId;
                        bool pduUpdateResult = true;
                        if (pduUpdate)//更新
                        {
                            pduUpdateResult = db.DB.Update(pdu, tx);
                        }
                        else
                        {
                            pduUpdateResult = db.DB.Create(pdu, tx);
                        }
                        if (!pduUpdateResult)//插入
                        {
                            message = "更新小组异常";
                            result  = false;
                            tx.Rollback();
                            goto end;
                        }
                        #endregion

更新角色信息:
                        #region (更新角色信息)
                        bool upRoleResult = SYSRoleUserManager.SetRoleUser(cityId, companyId, userName, truename, out message, roleIds, db, tx);
                        if (!upRoleResult)
                        {
                            result = false;
                            tx.Rollback();
                            goto end;
                        }
                        ////如果为删除所有
                        //if (roleIds == null || roleIds.Length < 1)
                        //{
                        //    if (!SYSRoleUserManager.DeleteByUserName(cityId, companyId, userName, db, tx))
                        //    {
                        //        message = "删除所有角色异常";
                        //        result = false;
                        //        tx.Rollback();
                        //        goto end;
                        //    }
                        //    goto resultend;
                        //}
                        //IList<SYSRoleUser> roleUserList = SYSRoleUserManager.GetSYSRoleUserByUserName(cityId, companyId, userName, db);
                        //IList<SYSRoleUser> addUserList = new List<SYSRoleUser>();//存储要新增的role
                        //List<int> delList = new List<int>();//存储要删除的role
                        ////获取要删除的role
                        //IList<SYSRoleUser> delUserList = roleUserList.Where(obj => !roleIds.Contains(obj.RoleID)).ToList();
                        //foreach (SYSRoleUser roleUser in delUserList)
                        //{
                        //    delList.Add(roleUser.RoleID);
                        //}
                        ////获取要新增的role
                        //foreach (int roleId in roleIds)
                        //{
                        //    int existsCount = roleUserList.Where(obj => obj.RoleID == roleId).Count();
                        //    int existsCount2 = addUserList.Where(obj => obj.RoleID == roleId).Count();
                        //    if (existsCount < 1 && existsCount2 < 1)
                        //    {
                        //        SYSRoleUser roleUser = new SYSRoleUser { CityID = cityId, FxtCompanyID = companyId, RoleID = roleId, UserName = userName };
                        //        addUserList.Add(roleUser);
                        //    }
                        //}
                        //if (!SYSRoleUserManager.DeleteByUserName(cityId, companyId, userName, delList.ToArray(), db, tx))
                        //{
                        //    message = "删除指定角色异常";
                        //    result = false;
                        //    tx.Rollback();
                        //    goto end;
                        //}
                        //if (!db.DB.Create<SYSRoleUser>(addUserList, tx))
                        //{
                        //    message = "新增角色异常";
                        //    result = false;
                        //    tx.Rollback();
                        //    goto end;
                        //}
                        #endregion
resultend:
                        tx.Commit();
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();
                        message = "系统异常";
                        log.Error(message, ex);
                        result = false;
                    }
                }
end:
                db.Close();
                return(result);
            }
            catch (Exception ex)
            {
                db.Close();
                throw ex;
            }
        }
示例#5
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;
            }
        }