//[SettingsAllowAnonymous(false)] //[CustomProviderData("Limit;int")] //public int Limit //{ // get { return (int)this.GetPropertyValue("Limit"); } // set { this.SetPropertyValue("Limit", value); } //} public static CustomProfile GetUserProfile(string username) { CustomProfile customProfile = Create(username) as CustomProfile; if (customProfile.DeptId != Guid.Empty) { var Uow = DependencyResolver.Current.GetService <IFairiesMemberManageUow>(); Depts dept = Uow.Depts.GetById(g => g.DeptId == customProfile.DeptId); if (dept != null) { customProfile.DeptCode = dept.DeptCode; customProfile.DeptName = dept.DeptName; } } return(customProfile); }
public static CustomProfile GetUserProfile(string username) { CustomProfile customProfile = Create(username) as CustomProfile; ynhnTransportManage contex = new ynhnTransportManage(); if (customProfile.DeptId != Guid.Empty) { Dept dept = contex.Depts.FirstOrDefault <Dept>(d => d.DeptId == customProfile.DeptId); if (dept != null) { customProfile.DeptCode = dept.DeptCode; customProfile.DeptName = dept.DeptName; } } return(customProfile); }
private ActionResult DisplayRolesOfUser(Guid id) { MembershipUser user = MembershipService.GetUser(id); if (user == null) { ModelState.AddModelError("", "未能找到用户信息"); return(View()); } DXInfo.Profile.CustomProfile profile = DXInfo.Profile.CustomProfile.GetUserProfile(user.UserName); if (profile == null) { ModelState.AddModelError("", "未能找到配置信息"); return(View()); } Dept dept = MembershipService.GetDept(profile.DeptId); if (dept == null) { ModelState.AddModelError("", "未能找到部门信息"); return(View()); } AddUserToRolesModel model = new AddUserToRolesModel(); model.UserId = Guid.Parse(user.ProviderUserKey.ToString()); model.UserName = user.UserName; model.FullName = profile.FullName; model.DeptName = profile.DeptName; DXInfo.Models.ynhnTransportManage contex = new DXInfo.Models.ynhnTransportManage(); string sql = string.Format(@"select a.RoleId,a.RoleName,a.Description,case when b.UserId is null then CONVERT(bit,0) else CONVERT(bit,1) end as IsInRole from aspnet_Roles a left join (select * from aspnet_UsersInRoles where UserId='{0}') b on a.RoleId=b.RoleId", id.ToString()); var roles = contex.Database.SqlQuery <RolesInfoModel>(sql).ToList(); model.Roles = roles.AsEnumerable <RolesInfoModel>(); return(View("AddUserToRole", model)); }