コード例 #1
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            RoadFlow.Platform.UsersRole buserRole = new RoadFlow.Platform.UsersRole();
            RoadFlow.Platform.Role      brole     = new RoadFlow.Platform.Role();
            var roles = buserRole.GetByUserID(RoadFlow.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 <RoadFlow.Data.Model.Role> roleList = new List <RoadFlow.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 = RoadFlow.Platform.Users.CurrentUser;

            ViewBag.UserName = user == null ? "" : user.Name;
            ViewBag.DateTime = RoadFlow.Utility.DateTimeNew.Now.ToDateWeekString();

            return(View());
        }
コード例 #2
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            string msg;

            if (!WebMvc.Common.Tools.CheckLogin(out msg))
            {
                return(RedirectToAction("Index", "Login"));
                //return Redirect(Url.Action("Index", "Login"));
            }

            RoadFlow.Platform.UsersRole buserRole = new RoadFlow.Platform.UsersRole();
            RoadFlow.Platform.Role      brole     = new RoadFlow.Platform.Role();
            var roles = buserRole.GetByUserID(RoadFlow.Platform.UsersBLL.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 <RoadFlow.Data.Model.Role> roleList = new List <RoadFlow.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 = RoadFlow.Platform.UsersBLL.CurrentUser;

            ViewBag.UserName = user == null ? "" : user.Name;
            ViewBag.DateTime = DateTime.Now.ToDateWeekString();

            return(View());
        }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: zhibinyu/RoadFlow-2
        protected void Page_Load(object sender, EventArgs e)
        {
            string loginMsg = string.Empty;

            if (!Common.Tools.CheckLogin(out loginMsg))
            {
                Response.Redirect("Login.aspx");
                return;
            }

            #region 得到用户角色相关的信息
            RoadFlow.Platform.UsersRole buserRole = new RoadFlow.Platform.UsersRole();
            RoadFlow.Platform.Role      brole     = new RoadFlow.Platform.Role();
            var roles = buserRole.GetByUserID(RoadFlow.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 <RoadFlow.Data.Model.Role> roleList = new List <RoadFlow.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 = RoadFlow.Utility.DateTimeNew.Now.ToDateWeekString();
            this.RoleOptions.Text = rolesOptions;
        }
コード例 #4
0
        public ActionResult EditRole(FormCollection collection)
        {
            RoadFlow.Platform.Role   brole = new RoadFlow.Platform.Role();
            RoadFlow.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 RoadFlow.Platform.RoleApp().CopyRoleApp(roleGID, tpl.Convert <Guid>());
                    RoadFlow.Platform.Log.Add("复制了模板应用", "源:" + roleID + "复制给:" + tpl, RoadFlow.Platform.Log.Types.角色应用);
                    ViewBag.Script = "alert('复制成功!');";
                }
            }

            if (!Request.Form["Save"].IsNullOrEmpty() && role != null)
            {
                RoadFlow.Platform.UsersRole busersRole = new RoadFlow.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 RoadFlow.Platform.Organize().GetAllUsers(useMember);
                        foreach (var user in users)
                        {
                            RoadFlow.Data.Model.UsersRole ur = new RoadFlow.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 RoadFlow.Platform.RoleApp().DeleteByRoleID(roleGID);
                    new RoadFlow.Platform.UsersRole().DeleteByRoleID(roleGID);
                    scope.Complete();
                }
                RoadFlow.Platform.Log.Add("删除的角色其及相关数据", roleID, RoadFlow.Platform.Log.Types.角色应用);
                ViewBag.Script = "new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
            }
            ViewBag.RoleOptions = brole.GetRoleOptions("", roleID);
            return(View(role));
        }
コード例 #5
0
ファイル: EditRole.aspx.cs プロジェクト: zhibinyu/RoadFlow-2
        protected void Page_Load(object sender, EventArgs e)
        {
            RoadFlow.Platform.Role   brole = new RoadFlow.Platform.Role();
            RoadFlow.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 RoadFlow.Platform.RoleApp().CopyRoleApp(roleGID, tpl.ToGuid());
                        RoadFlow.Platform.Log.Add("复制了模板应用", "源:" + roleID + "复制给:" + tpl, RoadFlow.Platform.Log.Types.角色应用);
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('复制成功!');", true);
                    }
                }

                if (!Request.Form["Save"].IsNullOrEmpty() && role != null)
                {
                    RoadFlow.Platform.UsersRole busersRole = new RoadFlow.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 RoadFlow.Platform.Organize().GetAllUsers(useMember);
                            foreach (var user in users)
                            {
                                RoadFlow.Data.Model.UsersRole ur = new RoadFlow.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 RoadFlow.Platform.RoleApp().DeleteByRoleID(roleGID);
                        new RoadFlow.Platform.UsersRole().DeleteByRoleID(roleGID);
                        scope.Complete();
                    }
                    RoadFlow.Platform.Log.Add("删除的角色其及相关数据", roleID, RoadFlow.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);
        }