// // GET: /Home/ public ActionResult Index() { MyCreek.Platform.UsersRole buserRole = new MyCreek.Platform.UsersRole(); MyCreek.Platform.Role brole = new MyCreek.Platform.Role(); var roles = buserRole.GetByUserID(MyCreek.Platform.Users.CurrentUserID); ViewBag.RoleLength = roles.Count; ViewBag.DefaultRoleID = string.Empty; ViewBag.RolesOptions = string.Empty; if (roles.Count > 0) { var mainRole = roles.Find(p => p.IsDefault); ViewBag.defaultRoleID = mainRole != null?mainRole.RoleID.ToString() : roles.First().RoleID.ToString(); List <MyCreek.Data.Model.Role> roleList = new List <MyCreek.Data.Model.Role>(); foreach (var role in roles) { var role1 = brole.Get(role.RoleID); if (role1 == null) { continue; } roleList.Add(role1); } ViewBag.RolesOptions = brole.GetRoleOptions("", "", roleList); } var user = MyCreek.Platform.Users.CurrentUser; ViewBag.UserName = user == null ? "" : user.Name; ViewBag.DateTime = MyCreek.Utility.DateTimeNew.Now.ToDateWeekString(); return(View()); }
protected void Page_Load(object sender, EventArgs e) { string loginMsg = string.Empty; if (!Common.Tools.CheckLogin(out loginMsg)) { Response.Redirect("Login.aspx"); return; } #region 得到用户角色相关的信息 MyCreek.Platform.UsersRole buserRole = new MyCreek.Platform.UsersRole(); MyCreek.Platform.Role brole = new MyCreek.Platform.Role(); var roles = buserRole.GetByUserID(MyCreek.Platform.Users.CurrentUserID); RoleLength = roles.Count; DefaultRoleID = string.Empty; string rolesOptions = string.Empty; if (roles.Count > 0) { var mainRole = roles.Find(p => p.IsDefault); DefaultRoleID = mainRole != null?mainRole.RoleID.ToString() : roles.First().RoleID.ToString(); List <MyCreek.Data.Model.Role> roleList = new List <MyCreek.Data.Model.Role>(); foreach (var role in roles) { var role1 = brole.Get(role.RoleID); if (role1 == null) { continue; } roleList.Add(role1); } rolesOptions = brole.GetRoleOptions("", "", roleList); } #endregion this.UserName.Text = CurrentUserName; this.CurrentTime.Text = MyCreek.Utility.DateTimeNew.Now.ToDateWeekString(); this.RoleOptions.Text = rolesOptions; }