Example #1
0
        private void AddPermission(Entity ent, List <PrivilegeSet> privileges)
        {
            var logicalName = ((AliasedValue)ent.Attributes["objecttype.objecttypecode"]).Value.ToString();

            if (CustomisationList.Contains(logicalName))
            {
                logicalName = "Customizations";
            }

            var priSet = privileges.FirstOrDefault(i => i.Name == logicalName);

            if (priSet == null)
            {
                priSet = new PrivilegeSet(
                    logicalName,
                    chkLocalised.Checked
                        ? (Entities.FirstOrDefault(entity => entity.LogicalName == logicalName)?.DisplayName?.UserLocalizedLabel?.Label ??
                           logicalName)
                        : logicalName);
                privileges.Add(priSet);

                //check = true;
            }

            PopulatePrivilege(priSet, ent, privileges);
        }
Example #2
0
        private void AddTablePermission(Entity rolePriv, List <PrivilegeSet> privileges)
        {
            var roleName = ((AliasedValue)rolePriv.Attributes["RoleName"]).Value.ToString();

            var priSet = privileges.FirstOrDefault(i => i.Name == roleName);

            if (priSet == null)
            {
                priSet = new PrivilegeSet(roleName);
                privileges.Add(priSet);
            }

            PopulatePrivilege(priSet, rolePriv, privileges);
        }
Example #3
0
        private void PopulatePrivilege(PrivilegeSet priSet, Entity ent, List <PrivilegeSet> privileges)
        {
            #region Switch Case
            switch (((AliasedValue)ent.Attributes["AccessRight"]).Value.ToString())
            {
            case "1":                                                       //READ
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.Read     = Resources.user;
                    priSet.Read.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.Read     = Resources.BU;
                    priSet.Read.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.Read     = Resources.P_BU;
                    priSet.Read.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.Read     = Resources.organization;
                    priSet.Read.Tag = "Organization";
                }
                break;

            case "2":                                                       //WRITE
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.Write     = Resources.user;
                    priSet.Write.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.Write     = Resources.BU;
                    priSet.Write.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.Write     = Resources.P_BU;
                    priSet.Write.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.Write     = Resources.organization;
                    priSet.Write.Tag = "Organization";
                }
                break;

            case "4":                                                       //APPEND
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.Append     = Resources.user;
                    priSet.Append.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.Append     = Resources.BU;
                    priSet.Append.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.Append     = Resources.P_BU;
                    priSet.Append.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.Append     = Resources.organization;
                    priSet.Append.Tag = "Organization";
                }
                break;

            case "16":                                                      //APPENDTO
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.AppendTo     = Resources.user;
                    priSet.AppendTo.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.AppendTo     = Resources.BU;
                    priSet.AppendTo.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.AppendTo     = Resources.P_BU;
                    priSet.AppendTo.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.AppendTo     = Resources.organization;
                    priSet.AppendTo.Tag = "Organization";
                }
                break;

            case "32":                                                      //CREATE
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.Create     = Resources.user;
                    priSet.Create.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.Create     = Resources.BU;
                    priSet.Create.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.Create     = Resources.P_BU;
                    priSet.Create.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.Create     = Resources.organization;
                    priSet.Create.Tag = "Organization";
                }
                break;

            case "65536":                                                   //DELETE
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.Delete     = Resources.user;
                    priSet.Delete.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.Delete     = Resources.BU;
                    priSet.Delete.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.Delete   = Resources.P_BU;
                    priSet.Read.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.Delete     = Resources.organization;
                    priSet.Delete.Tag = "Organization";
                }
                break;

            case "262144":                                                  //SHARE
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.Share     = Resources.user;
                    priSet.Share.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.Share     = Resources.BU;
                    priSet.Share.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.Share     = Resources.P_BU;
                    priSet.Share.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.Share     = Resources.organization;
                    priSet.Share.Tag = "Organization";
                }
                break;

            case "524288":                                                  //ASSIGN
                if (ent.Attributes["privilegedepthmask"].ToString() == "1") //User
                {
                    priSet.Assign     = Resources.user;
                    priSet.Assign.Tag = "User";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "2")    //Business Unit
                {
                    priSet.Assign     = Resources.BU;
                    priSet.Assign.Tag = "Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "4")    //Parent: Child Business Unit
                {
                    priSet.Assign     = Resources.P_BU;
                    priSet.Assign.Tag = "Parent: Child Business Unit";
                }
                if (ent.Attributes["privilegedepthmask"].ToString() == "8")    //Organisation
                {
                    priSet.Assign     = Resources.organization;
                    priSet.Assign.Tag = "Organization";
                }
                break;
            }
            #endregion
        }