// // 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()); }
public ActionResult AddRole(FormCollection collection) { string name = Request.Form["Name"]; string note = Request.Form["Note"]; string useMember = Request.Form["UseMember"]; MyCreek.Data.Model.Role role = new MyCreek.Data.Model.Role(); if (collection != null) { using (System.Transactions.TransactionScope trans = new System.Transactions.TransactionScope()) { role.ID = Guid.NewGuid(); role.Name = name.Trim(); if (!useMember.IsNullOrEmpty()) { role.UseMember = useMember; MyCreek.Platform.UsersRole busersRole = new MyCreek.Platform.UsersRole(); var users = new MyCreek.Platform.Organize().GetAllUsers(useMember); foreach (var user in users) { MyCreek.Data.Model.UsersRole ur = new MyCreek.Data.Model.UsersRole(); ur.IsDefault = true; ur.MemberID = user.ID; ur.RoleID = role.ID; busersRole.Add(ur); } } if (!note.IsNullOrEmpty()) { role.Note = note.Trim(); } new MyCreek.Platform.Role().Add(role); //添加一个根应用 MyCreek.Data.Model.RoleApp roleApp = new MyCreek.Data.Model.RoleApp(); roleApp.ID = Guid.NewGuid(); roleApp.ParentID = Guid.Empty; roleApp.RoleID = role.ID; roleApp.Sort = 1; roleApp.Title = "管理目录"; new MyCreek.Platform.RoleApp().Add(roleApp); trans.Complete(); ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();"; } } return(View(role)); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string name = Request.Form["Name"]; string note = Request.Form["Note"]; string useMember = Request.Form["UseMember"]; MyCreek.Data.Model.Role role = new MyCreek.Data.Model.Role(); using (System.Transactions.TransactionScope trans = new System.Transactions.TransactionScope()) { role.ID = Guid.NewGuid(); role.Name = name.Trim(); if (!useMember.IsNullOrEmpty()) { role.UseMember = useMember; MyCreek.Platform.UsersRole busersRole = new MyCreek.Platform.UsersRole(); var users = new MyCreek.Platform.Organize().GetAllUsers(useMember); foreach (var user in users) { MyCreek.Data.Model.UsersRole ur = new MyCreek.Data.Model.UsersRole(); ur.IsDefault = true; ur.MemberID = user.ID; ur.RoleID = role.ID; busersRole.Add(ur); } } if (!note.IsNullOrEmpty()) { role.Note = note.Trim(); } new MyCreek.Platform.Role().Add(role); //添加一个根应用 MyCreek.Data.Model.RoleApp roleApp = new MyCreek.Data.Model.RoleApp(); roleApp.ID = Guid.NewGuid(); roleApp.ParentID = Guid.Empty; roleApp.RoleID = role.ID; roleApp.Sort = 1; roleApp.Title = "管理目录"; new MyCreek.Platform.RoleApp().Add(roleApp); trans.Complete(); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true); } } }
protected void Page_Load(object sender, EventArgs e) { string userid = Request.QueryString["id"]; MyCreek.Platform.Role brole = new MyCreek.Platform.Role(); var roles = new MyCreek.Platform.UsersRole().GetByUserID(userid.ToGuid()); 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); } RoleOptions = new MyCreek.Platform.Role().GetRoleOptions(Request.QueryString["roleid"], "", roleList); }
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; }
public ActionResult Tree() { string userid = Request.QueryString["id"]; MyCreek.Platform.Role brole = new MyCreek.Platform.Role(); var roles = new MyCreek.Platform.UsersRole().GetByUserID(userid.ToGuid()); 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.RoleOptions = new MyCreek.Platform.Role().GetRoleOptions(Request.QueryString["roleid"], "", roleList); return(View()); }
protected void Page_Load(object sender, EventArgs e) { MyCreek.Platform.Organize borganize = new MyCreek.Platform.Organize(); MyCreek.Platform.Users busers = new MyCreek.Platform.Users(); MyCreek.Platform.UsersRelation buserRelation = new MyCreek.Platform.UsersRelation(); MyCreek.Data.Model.Users user = null; MyCreek.Data.Model.Organize organize = null; string id = Request.QueryString["id"]; string parentID = Request.QueryString["parentid"]; string parentString = string.Empty; this.Account.Attributes.Add("validate_url", "CheckAccount.ashx?id=" + id); Guid userID, organizeID; if (id.IsGuid(out userID)) { user = busers.Get(userID); if (user != null) { //所在组织字符串 System.Text.StringBuilder sb = new System.Text.StringBuilder(); var userRelations = buserRelation.GetAllByUserID(user.ID).OrderByDescending(p => p.IsMain); foreach (var userRelation in userRelations) { sb.Append("<div style='margin:3px 0;'>"); sb.Append(borganize.GetAllParentNames(userRelation.OrganizeID, true)); if (userRelation.IsMain == 0) { sb.Append("<span style='color:#999'> [兼职]</span>"); } sb.Append("</div>"); } this.ParentString.Text = sb.ToString(); var roles = new MyCreek.Platform.UsersRole().GetByUserIDFromCache(userID); MyCreek.Platform.Role brole = new MyCreek.Platform.Role(); System.Text.StringBuilder rolesb = new System.Text.StringBuilder(); foreach (var role in roles) { var role1 = brole.Get(role.RoleID); if (role1 == null) { continue; } rolesb.Append(role1.Name); rolesb.Append(","); } this.RoleString.Text = rolesb.ToString().TrimEnd(','); } } if (parentID.IsGuid(out organizeID)) { organize = borganize.Get(organizeID); } if (IsPostBack) { #region 保存 if (!Request.Form["Save"].IsNullOrEmpty() && user != null) { string name = Request.Form["Name"]; string account = Request.Form["Account"]; string status = Request.Form["Status"]; string note = Request.Form["Note"]; string oldXML = user.Serialize(); user.Name = name.Trim(); user.Account = account.Trim(); user.Status = status.ToInt(1); user.Note = note.IsNullOrEmpty() ? null : note.Trim(); busers.Update(user); MyCreek.Platform.Log.Add("修改了用户", "", MyCreek.Platform.Log.Types.组织机构, oldXML, user.Serialize()); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('保存成功!');parent.frames[0].reLoad('" + parentID + "');", true); } #endregion #region 除用户 if (!Request.Form["DeleteBut"].IsNullOrEmpty() && user != null && organize != null) { using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { var urs = buserRelation.GetAllByUserID(user.ID); busers.Delete(user.ID); buserRelation.DeleteByUserID(user.ID); new MyCreek.Platform.UsersInfo().Delete(user.ID); new MyCreek.Platform.UsersRole().DeleteByUserID(user.ID); //更新父级[ChildsLength]字段 foreach (var ur in urs) { borganize.UpdateChildsLength(ur.OrganizeID); } scope.Complete(); } string refreshID = parentID; string url = string.Empty; var users = borganize.GetAllUsers(refreshID.ToGuid()); if (users.Count > 0) { url = "User.aspx?id=" + users.Last().ID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&parentid=" + parentID; } else { refreshID = organize.ParentID == Guid.Empty ? organize.ID.ToString() : organize.ParentID.ToString(); url = "Body.aspx?id=" + parentID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&parentid=" + organize.ParentID; } MyCreek.Platform.Log.Add("删除了用户", user.Serialize(), MyCreek.Platform.Log.Types.组织机构); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('删除成功');parent.frames[0].reLoad('" + refreshID + "');window.location='" + url + "'", true); new MyCreek.Platform.AppLibrary().ClearUseMemberCache(); } #endregion #region 初始化密码 if (!Request.Form["InitPass"].IsNullOrEmpty() && user != null) { string initpass = busers.GetInitPassword(); busers.InitPassword(user.ID); MyCreek.Platform.Log.Add("初始化了用户密码", user.Serialize(), MyCreek.Platform.Log.Types.组织机构); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('密码已初始化为:" + initpass + "');", true); } #endregion #region 调动 if (!Request.Form["Move1"].IsNullOrEmpty() && user != null) { string moveto = Request.Form["movetostation"]; string movetostationjz = Request.Form["movetostationjz"]; Guid moveToID; if (moveto.IsGuid(out moveToID)) { using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { var us = buserRelation.GetAllByUserID(user.ID); if ("1" != movetostationjz) { buserRelation.DeleteByUserID(user.ID); } MyCreek.Data.Model.UsersRelation ur = new MyCreek.Data.Model.UsersRelation(); ur.UserID = user.ID; ur.OrganizeID = moveToID; ur.IsMain = "1" == movetostationjz ? 0 : 1; ur.Sort = buserRelation.GetMaxSort(moveToID); buserRelation.Add(ur); foreach (var u in us) { borganize.UpdateChildsLength(u.OrganizeID); } borganize.UpdateChildsLength(organizeID); borganize.UpdateChildsLength(moveToID); scope.Complete(); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('调动成功!');parent.frames[0].reLoad('" + parentID + "');parent.frames[0].reLoad('" + moveto + "')", true); } MyCreek.Platform.Log.Add(("1" == movetostationjz ? "兼职" : "全职") + "调动了人员的岗位", "将人员调往岗位(" + moveto + ")", MyCreek.Platform.Log.Types.组织机构); new MyCreek.Platform.AppLibrary().ClearUseMemberCache(); } } #endregion } if (user != null) { this.Name.Value = user.Name; this.Account.Value = user.Account; this.Note.Value = user.Note; } this.StatusRadios.Text = borganize.GetStatusRadio("Status", user != null ? user.Status.ToString() : "", "validate=\"radio\""); }
public ActionResult EditRole(FormCollection collection) { MyCreek.Platform.Role brole = new MyCreek.Platform.Role(); MyCreek.Data.Model.Role role = null; string roleID = Request.QueryString["roleid"]; Guid roleGID; string name = string.Empty; string useMember = string.Empty; string note = string.Empty; if (roleID.IsGuid(out roleGID)) { role = brole.Get(roleGID); } if (!Request.Form["Copy"].IsNullOrEmpty()) { string tpl = Request.Form["ToTpl"]; if (tpl.IsGuid()) { new MyCreek.Platform.RoleApp().CopyRoleApp(roleGID, tpl.ToGuid()); MyCreek.Platform.Log.Add("复制了模板应用", "源:" + roleID + "复制给:" + tpl, MyCreek.Platform.Log.Types.角色应用); ViewBag.Script = "alert('复制成功!');"; } } if (!Request.Form["Save"].IsNullOrEmpty() && role != null) { MyCreek.Platform.UsersRole busersRole = new MyCreek.Platform.UsersRole(); using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { name = Request.Form["Name"]; useMember = Request.Form["UseMember"]; note = Request.Form["Note"]; role.Name = name.Trim(); role.Note = note.IsNullOrEmpty() ? null : note.Trim(); role.UseMember = useMember.IsNullOrEmpty() ? null : useMember; brole.Update(role); busersRole.DeleteByRoleID(role.ID); if (!useMember.IsNullOrEmpty()) { busersRole.DeleteByRoleID(role.ID); var users = new MyCreek.Platform.Organize().GetAllUsers(useMember); foreach (var user in users) { MyCreek.Data.Model.UsersRole ur = new MyCreek.Data.Model.UsersRole(); ur.IsDefault = true; ur.MemberID = user.ID; ur.RoleID = role.ID; busersRole.Add(ur); } } scope.Complete(); } ViewBag.Script = "alert('保存成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();"; } if (!Request.Form["Delete"].IsNullOrEmpty()) { using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { brole.Delete(roleGID); new MyCreek.Platform.RoleApp().DeleteByRoleID(roleGID); new MyCreek.Platform.UsersRole().DeleteByRoleID(roleGID); scope.Complete(); } MyCreek.Platform.Log.Add("删除的角色其及相关数据", roleID, MyCreek.Platform.Log.Types.角色应用); ViewBag.Script = "new RoadUI.Window().reloadOpener();new RoadUI.Window().close();"; } ViewBag.RoleOptions = brole.GetRoleOptions("", roleID); return(View(role)); }
protected void Page_Load(object sender, EventArgs e) { MyCreek.Platform.Role brole = new MyCreek.Platform.Role(); MyCreek.Data.Model.Role role = null; string roleID = Request.QueryString["roleid"]; Guid roleGID; string name = string.Empty; string useMember = string.Empty; string note = string.Empty; if (roleID.IsGuid(out roleGID)) { role = brole.Get(roleGID); } if (IsPostBack) { if (!Request.Form["Copy"].IsNullOrEmpty()) { string tpl = Request.Form["ToTpl"]; if (tpl.IsGuid()) { new MyCreek.Platform.RoleApp().CopyRoleApp(roleGID, tpl.ToGuid()); MyCreek.Platform.Log.Add("复制了模板应用", "源:" + roleID + "复制给:" + tpl, MyCreek.Platform.Log.Types.角色应用); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('复制成功!');", true); } } if (!Request.Form["Save"].IsNullOrEmpty() && role != null) { MyCreek.Platform.UsersRole busersRole = new MyCreek.Platform.UsersRole(); using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { name = Request.Form["Name"]; useMember = Request.Form["UseMember"]; note = Request.Form["Note"]; role.Name = name.Trim(); role.Note = note.IsNullOrEmpty() ? null : note.Trim(); role.UseMember = useMember.IsNullOrEmpty() ? null : useMember; brole.Update(role); busersRole.DeleteByRoleID(role.ID); if (!useMember.IsNullOrEmpty()) { busersRole.DeleteByRoleID(role.ID); var users = new MyCreek.Platform.Organize().GetAllUsers(useMember); foreach (var user in users) { MyCreek.Data.Model.UsersRole ur = new MyCreek.Data.Model.UsersRole(); ur.IsDefault = true; ur.MemberID = user.ID; ur.RoleID = role.ID; busersRole.Add(ur); } } scope.Complete(); } Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('保存成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true); } if (!Request.Form["Delete"].IsNullOrEmpty()) { using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope()) { brole.Delete(roleGID); new MyCreek.Platform.RoleApp().DeleteByRoleID(roleGID); new MyCreek.Platform.UsersRole().DeleteByRoleID(roleGID); scope.Complete(); } MyCreek.Platform.Log.Add("删除的角色其及相关数据", roleID, MyCreek.Platform.Log.Types.角色应用); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true); } } if (role != null) { this.Name.Value = role.Name; this.UseMember.Value = role.UseMember; this.Note.Value = role.Note; } this.RoleOptions.Text = brole.GetRoleOptions("", roleID); }