当前位置: 首页>>代码示例>>C#>>正文


C# Role.AddPermission方法代码示例

本文整理汇总了C#中Role.AddPermission方法的典型用法代码示例。如果您正苦于以下问题:C# Role.AddPermission方法的具体用法?C# Role.AddPermission怎么用?C# Role.AddPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Role的用法示例。


在下文中一共展示了Role.AddPermission方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateDatabaseAfterUpdateSchema

        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            Employee userAdmin = Session.FindObject<Employee>(new BinaryOperator("UserName", "Admin"));
            if (new XPCollection<Company>(Session).Count == 0)
            {
                using (Role administratorRole = new Role(Session) { Name = "Administrator role" })
                {
                    administratorRole.AddPermission(new EditModelPermission());
                    administratorRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess));
                    administratorRole.Save();
                    using (Role userRole = new Role(Session) { Name = "User" })
                    {
                        userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.Navigate));
                        userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.Read));
                        userRole.Save();
                    }
                    userAdmin = new Employee(Session);
                    userAdmin.UserName = "Admin";
                    userAdmin.FirstName = "Admin";
                    userAdmin.LastName = "";
                    userAdmin.Roles.Add(administratorRole);
                    userAdmin.Save();
                    using (Branch branch1 = new Branch(Session) { Acronym = "WTPR", Branchname = "Roadmax Head Office" })
                    {
                        using (Company company1 = new Company(Session) { CompanyName = "Roadmax Marketing Inc.", Acronym = "WTPR" })
                        {
                            company1.Employees.Add(userAdmin);
                            company1.Branches.Add(branch1);
                            company1.Save();
                            ImportData(company1);
                        }
                    }
                }

                using (Currency curr = new Currency(Session) { CurrencyName = "Peso", CurrencyRate = 1 })
                {
                    curr.Save();
                }

                using (VatCategory vat = new VatCategory(Session) { Acronym = "VAT", Description = "Vatable", Rate = 12 })
                {
                    vat.Save();
                }

            }
            //importReport("SOHeaderPrintOut");
        }
开发者ID:ViniciusConsultor,项目名称:roadmaxweberp,代码行数:48,代码来源:Updater.cs

示例2: CreatePermission

        public static void CreatePermission(Session sess)
        {
            Role roleBasic = sess.FindObject<Role>(new BinaryOperator("Name", "基本"));

            if (roleBasic == null)
            {
                roleBasic = new Role(sess);
                roleBasic.Name = "基本";
                roleBasic.AddPermission(new ObjectAccessPermission(typeof(Barcode), ObjectAccess.Read));
                roleBasic.AddPermission(new ObjectAccessPermission(typeof(FileDataEx), ObjectAccess.AllAccess));
                roleBasic.AddPermission(new ObjectAccessPermission(typeof(SystemSetting), ObjectAccess.Read));
                roleBasic.AddPermission(new ObjectAccessPermission(typeof(Unit), ObjectAccess.Read & ObjectAccess.Navigate));
                roleBasic.AddPermission(new ObjectAccessPermission(typeof(UnitConvert), ObjectAccess.Read & ObjectAccess.Navigate));
                roleBasic.Save();
            }

            Role roleItem = sess.FindObject<Role>(new BinaryOperator("Name", "产品-只读"));
            if (roleItem == null)
            {
                roleItem = new Role(sess);
                roleItem.Name = "产品-只读";
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Item), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(BomLine), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemCategory), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemSetting), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemType), ObjectAccess.Read & ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Lot), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Material), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(PriceCategory), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(RouteLine), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(WorkCenter), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(WorkOper), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.Save();
            }

            roleItem = sess.FindObject<Role>(new BinaryOperator("Name", "产品-修改"));
            if (roleItem == null)
            {
                roleItem = new Role(sess);
                roleItem.Name = "产品-修改";
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Item), ObjectAccess.AllAccess));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(BomLine), ObjectAccess.AllAccess));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(RouteLine), ObjectAccess.AllAccess));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Lot), ObjectAccess.AllAccess));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(PriceCategory), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemCategory), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemSetting), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemType), ObjectAccess.Read & ObjectAccess.Navigate));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Material), ObjectAccess.Read ^ ObjectAccess.Navigate));
                roleItem.Save();
            }

            roleItem = sess.FindObject<Role>(new BinaryOperator("Name", "产品-设定"));
            if (roleItem == null)
            {
                roleItem = new Role(sess);
                roleItem.Name = "产品-设定";
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemCategory), ObjectAccess.AllAccess));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemSetting), ObjectAccess.AllAccess));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(ItemType), ObjectAccess.AllAccess ));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Lot), ObjectAccess.AllAccess ));
                roleItem.AddPermission(new ObjectAccessPermission(typeof(Material), ObjectAccess.AllAccess ));
                roleItem.Save();
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:65,代码来源:Updater.cs

示例3: AddRoleToUser

        private void AddRoleToUser(Role userRole)
        {
            //userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess, ObjectAccessModifier.Deny));
            userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess));
            userRole.AddPermission(new ObjectAccessPermission(typeof(IXPSimpleObject), ObjectAccess.NoAccess));

            userRole.AddPermission(new ObjectAccessPermission(typeof(MyNote), ObjectAccess.AllAccess, ObjectAccessModifier.Allow));
            userRole.AddPermission(new ObjectAccessPermission(typeof(MyNote), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            userRole.AddPermission(new ObjectAccessPermission(typeof(MyHelp), ObjectAccess.AllAccess, ObjectAccessModifier.Allow));
            userRole.AddPermission(new ObjectAccessPermission(typeof(MyHelp), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            userRole.AddPermission(new ObjectAccessPermission(typeof(PopUpMessage), ObjectAccess.AllAccess, ObjectAccessModifier.Allow));
            userRole.AddPermission(new ObjectAccessPermission(typeof(PopUpMessage), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));

            userRole.AddPermission(new ObjectAccessPermission(typeof(User), ObjectAccess.AllAccess));
            userRole.AddPermission(new ObjectAccessPermission(typeof(User), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));

            //userRole.AddPermission(new ObjectAccessPermission(typeof(Student), ObjectAccess.AllAccess));
            //userRole.AddPermission(new ObjectAccessPermission(typeof(Student), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            userRole.AddPermission(new EditModelPermission(ModelAccessModifier.Deny));
        }
开发者ID:dedangkyphanmem,项目名称:vidodkmh,代码行数:20,代码来源:Updater.cs

示例4: CreateUser

        public static void CreateUser(Session sess)
        {
            Role role = sess.FindObject<Role>(new BinaryOperator("Name", "administrator"));
            User user = sess.FindObject<User>(new BinaryOperator("UserName", "Kenneth"));

            if (role == null)
            {
                role = new Role(sess);
                role.Name = "administrator";
                role.AddPermission(new ObjectAccessPermission(typeof(Object), ObjectAccess.AllAccess));
            }

            if (user == null)
            {
                user = new User(sess);
                user.UserName = "Kenneth";
                user.Roles.Add(role);
                user.Save();
                //                DevExpress.XtraEditors.XtraMessageBox.Show("User Kenneth created");
            }

            User userAdmin = sess.FindObject<User>(new BinaryOperator("UserName", "admin"));

            if (userAdmin != null)
            {
                userAdmin.Roles.Add(role);
                userAdmin.Save();
                //                DevExpress.XtraEditors.XtraMessageBox.Show("User admin created");
            }
        }
开发者ID:kamchung322,项目名称:Namwah,代码行数:30,代码来源:Updater.cs

示例5: AddRoleToStudent

        private void AddRoleToStudent(Role studentRole)
        {
            studentRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(IXPSimpleObject), ObjectAccess.NoAccess));

            studentRole.AddPermission(new ObjectAccessPermission(typeof(User), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(User), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Role), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Role), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Student), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Student), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(RegisterDetail), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(RegisterDetail), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(PopUpMessage), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(PopUpMessage), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));

            studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentAccumulation), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentAccumulation), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentResult), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentResult), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(AccountTransaction), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(AccountTransaction), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));

            studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentClass), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentClass), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Subject), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Subject), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Branch), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Branch), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Semester), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Semester), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Department), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Department), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Lesson), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Lesson), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Teacher), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Teacher), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(TkbLesson), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(TkbLesson), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(TkbSemester), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(TkbSemester), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Classroom), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Classroom), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Office), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(Office), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(RegisterState), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(RegisterState), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(RegisterTime), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(RegisterTime), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(MyNote), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(MyNote), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(MyHelp), ObjectAccess.AllAccess));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(MyHelp), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(WeekReportData), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(WeekReportData), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(AccountTransactionTracking), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(AccountTransactionTracking), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(ClassTransactionTracking), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(ClassTransactionTracking), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(AccountTransactionFile), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(AccountTransactionFile), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentFile), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentFile), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(TeacherFile), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(TeacherFile), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(SubjectFile), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(SubjectFile), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentResultFile), ObjectAccess.AllAccess ^ ObjectAccess.Navigate));
            //studentRole.AddPermission(new ObjectAccessPermission(typeof(StudentResultFile), ObjectAccess.ChangeAccess, ObjectAccessModifier.Deny));
            studentRole.AddPermission(new ObjectAccessPermission(typeof(RegisterDetailReportParametersObject), ObjectAccess.AllAccess));

            studentRole.AddPermission(new EditModelPermission(ModelAccessModifier.Deny));
        }
开发者ID:dedangkyphanmem,项目名称:vidodkmh,代码行数:73,代码来源:Updater.cs


注:本文中的Role.AddPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。