Exemplo n.º 1
0
        public void GenerateSeedData()
        {
            // Features
            using (var featureManager = new FeatureManager())
                using (var operationManager = new OperationManager())
                    using (var versionManager = new VersionManager())
                    {
                        var bexisFeature = featureManager.FindByName("BExIS") ?? featureManager.Create("BExIS", "This is the root!");

                        // Operations


                        var o1 = operationManager.Find("Shell", "Account", "*") ?? operationManager.Create("Shell", "Account", "*");
                        var o2 = operationManager.Find("Shell", "Home", "*") ?? operationManager.Create("Shell", "Home", "*");
                        var o3 = operationManager.Find("Shell", "Error", "*") ?? operationManager.Create("Shell", "Error", "*");
                        var o4 = operationManager.Find("Shell", "TermsAndConditions", "*") ?? operationManager.Create("Shell", "TermsAndConditions", "*");
                        var o5 = operationManager.Find("Shell", "PrivacyPolicy", "*") ?? operationManager.Create("Shell", "PrivacyPolicy", "*");
                        var o6 = operationManager.Find("Shell", "Footer", "*") ?? operationManager.Create("Shell", "Footer", "*");
                        var o7 = operationManager.Find("Shell", "Ldap", "*") ?? operationManager.Create("Shell", "Ldap", "*");
                        var o8 = operationManager.Find("Shell", "Help", "*") ?? operationManager.Create("Shell", "Help", "*");

                        if (!versionManager.Exists("Shell", "2.14.0"))
                        {
                            versionManager.Create("Shell", "2.14.0");
                        }
                    }
        }
        public ActionResult Show(string viewName, string rootMenu, string viewTitle)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant(viewTitle, this.Session.GetTenant());
            bool hasAdminRights = false;

            using (UserManager userManager = new UserManager())
                using (FeaturePermissionManager featurePermissionManager = new FeaturePermissionManager())
                    using (FeatureManager featureManager = new FeatureManager())
                    {
                        var user    = userManager.FindByNameAsync(HttpContext.User.Identity.Name).Result;
                        var feature = featureManager.FindByName(viewName + "Admin");
                        hasAdminRights = featurePermissionManager.HasAccess(user.Id, feature.Id);
                    }

            if (String.IsNullOrEmpty(rootMenu))
            {
                ModelState.AddModelError("Error", "Please enter a menu root to the url!");
            }
            if (String.IsNullOrEmpty(viewName))
            {
                ModelState.AddModelError("Error", "Please enter a view name to the url!");
            }


            MenuHelper         menuHelper = new MenuHelper();
            string             userName   = HttpContext.User.Identity.Name;
            List <FMTMenuItem> menus      = null;

            bool hasUserRights = false;

            if (userName != "" && rootMenu != "")
            {
                hasUserRights = menuHelper.HasUserAccessRights(rootMenu, userName);
            }

            if (!hasUserRights)
            {
                ModelState.AddModelError("Error", "No access rights for this menu and this page!");
            }
            else
            {
                menus = menuHelper.GetMenu(rootMenu, userName);
            }


            //if (string.IsNullOrEmpty(rootMenu))
            ViewBag.UseLayout       = true;
            ViewData["AdminRights"] = hasAdminRights;


            return(View(viewName, menus));
        }
Exemplo n.º 3
0
        public static void Init()
        {
            // Features
            var featureManager = new FeatureManager();
            var bexisFeature   = featureManager.FindByName("BExIS") ?? featureManager.Create("BExIS", "This is the root!");

            // Operations
            var operationManager = new OperationManager();

            var o1 = operationManager.Find("Shell", "Account", "*") ?? operationManager.Create("Shell", "Account", "*");
            var o2 = operationManager.Find("Shell", "Home", "*") ?? operationManager.Create("Shell", "Home", "*");
            var o3 = operationManager.Find("Shell", "Error", "*") ?? operationManager.Create("Shell", "Error", "*");
            var o4 = operationManager.Find("Shell", "Terms", "*") ?? operationManager.Create("Shell", "Terms", "*");
            var o5 = operationManager.Find("Shell", "Footer", "*") ?? operationManager.Create("Shell", "Footer", "*");
            var o6 = operationManager.Find("Shell", "Ldap", "*") ?? operationManager.Create("Shell", "Ldap", "*");
        }
Exemplo n.º 4
0
        public void GenerateSeedData()
        {
            // Javad:
            // 1) all the create operations should check for existence of the record
            // 2) failure on creating any record should rollback the whole seed data generation. It is one transaction.
            // 3) failues should throw an exception with enough information to pin point the root cause
            // 4) only seed data related to the functions of this modules should be genereated here.
            // BUG: seed data creation is not working because of the changes that were done in the entities and services.
            // TODO: reimplement the seed data creation method.

            //#region Security

            //// Tasks
            using (OperationManager operationManager = new OperationManager())
                using (FeatureManager featureManager = new FeatureManager())
                    using (var featurePermissionManager = new FeaturePermissionManager())
                    {
                        // find root
                        var root = featureManager.FindRoots().FirstOrDefault();

                        // administration node
                        var administrationFeature = featureManager.FindByName("Administration") ?? featureManager.Create("Administration", "node for all administrative features", root);

                        // users node
                        var userFeature   = featureManager.FindByName("Users") ?? featureManager.Create("Users", "", administrationFeature);
                        var userOperation = operationManager.Find("SAM", "Users", "*") ?? operationManager.Create("SAM", "Users", "*", userFeature);

                        // groups node
                        var groupFeature   = featureManager.FindByName("Groups") ?? featureManager.Create("Groups", "", administrationFeature);
                        var groupOperation = operationManager.Find("SAM", "Groups", "*") ?? operationManager.Create("SAM", "Groups", "*", groupFeature);

                        // feature permissions
                        var featurePermissionFeature   = featureManager.FindByName("Feature Permissions") ?? featureManager.Create("Feature Permissions", "", administrationFeature);
                        var featurePermissionOperation = operationManager.Find("SAM", "FeaturePermissions", "*") ?? operationManager.Create("SAM", "FeaturePermissions", "*", featurePermissionFeature);

                        // Entity Permissions
                        var entityPermissionFeature   = featureManager.FindByName("Entity Permissions") ?? featureManager.Create("Entity Permissions", "", administrationFeature);
                        var entityPermissionOperation = operationManager.Find("SAM", "EntityPermissions", "*") ?? operationManager.Create("SAM", "EntityPermissions", "*", entityPermissionFeature);

                        // User Permissions
                        var userPermissionFeature   = featureManager.FindByName("User Permissions") ?? featureManager.Create("User Permissions", "", administrationFeature);
                        var userPermissionOperation = operationManager.Find("SAM", "UserPermissions", "*") ?? operationManager.Create("SAM", "UserPermissions", "*", userPermissionFeature);

                        // Dataset Management
                        var datasetManagementFeature   = featureManager.FindByName("Dataset Management") ?? featureManager.Create("Dataset Management", "", administrationFeature);
                        var datasetManagementOperation = operationManager.Find("SAM", "Datasets", "*") ?? operationManager.Create("SAM", "Datasets", "*", datasetManagementFeature);

                        // Document Management
                        var documentManagementFeature   = featureManager.FindByName("Document Management") ?? featureManager.Create("Document Management", "", administrationFeature);
                        var documentManagementOperation = operationManager.Find("SAM", "Files", "*") ?? operationManager.Create("SAM", "Files", "*", documentManagementFeature);

                        // Request
                        var requestManagementFeature   = featureManager.FindByName("Request Management") ?? featureManager.Create("Request Management", "", administrationFeature);
                        var requestManagementOperation = operationManager.Find("SAM", "RequestsAdmin", "*") ?? operationManager.Create("SAM", "RequestsAdmin", "*", requestManagementFeature);

                        var requestOperation = operationManager.Find("SAM", "Requests", "*") ?? operationManager.Create("SAM", "Requests", "*");

                        // Help
                        var helpOperation = operationManager.Find("SAM", "Help", "*") ?? operationManager.Create("SAM", "Help", "*");



                        if (!featurePermissionManager.Exists(null, featurePermissionFeature.Id, PermissionType.Grant))
                        {
                            featurePermissionManager.Create(null, featurePermissionFeature.Id, PermissionType.Grant);
                        }
                    }
        }