bool IsActive(ChoiceActionItem choiceActionItem)
        {
            var iStateMachine = (choiceActionItem.Data as IStateMachine);

            if (iStateMachine != null)
            {
                var boolList = new BoolList(true, BoolListOperatorType.Or);
                boolList.BeginUpdate();
                foreach (var item in choiceActionItem.Items)
                {
                    var iTransition          = ((ITransition)item.Data);
                    var choiceActionItemArgs = new ChoiceActionItemArgs(iTransition, item.Active);
                    OnRequestActiveState(choiceActionItemArgs);
                    boolList.SetItemValue(ObjectSpace.GetKeyValueAsString(iTransition), item.Active.ResultValue);
                }
                boolList.EndUpdate();
                return(boolList.ResultValue);
            }
            var transition = choiceActionItem.Data as ITransition;

            if (transition != null)
            {
                var choiceActionItemArgs = new ChoiceActionItemArgs(transition, choiceActionItem.Active);
                OnRequestActiveState(choiceActionItemArgs);
                return(choiceActionItem.Active);
            }
            throw new NotImplementedException();
        }
        private void EditAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            ViewUrlHelper urlHelper = (ViewUrlHelper)((BlazorApplication)Application).ServiceProvider.GetService(typeof(ViewUrlHelper));
            string        viewId    = Application.GetDetailViewId(View.ObjectTypeInfo.Type);
            string        objectKey = ObjectSpace.GetKeyValueAsString(e.CurrentObject);

            urlHelper.NavigateToView(viewId, objectKey);
        }
        private IModelWebDashboardState GetDasbhoardSettings(bool create)
        {
            if (Application.Model.Options is IModelOptionsXtraDashboards options)
            {
                string id       = ObjectSpace.GetKeyValueAsString(ViewCurrentObject);
                var    settings = options.XtraDashboards[id] as IModelWebDashboardState;
                if (settings == null && create)
                {
                    settings = options.XtraDashboards.AddNode <IModelXtraDashboardPreferences>(id) as IModelWebDashboardState;
                }

                return(settings);
            }

            return(null);
        }
        private void OnCustomProcessSelectedItem(object sender, CustomProcessListViewSelectedItemEventArgs e)
        {
            e.Handled = true;
            var    shortcut       = new ViewShortcut(GetViewId(e.InnerArgs.CurrentObject), ObjectSpace.GetKeyValueAsString(e.InnerArgs.CurrentObject));
            var    requestManager = ((WebApplication)Application).RequestManager;
            string hashUrl        = requestManager.GetQueryString(shortcut);
            var    script         = $"window.open('{HttpContext.Current.Request.Url}#{hashUrl}','_blank');";

            WebWindow.CurrentRequestWindow.RegisterStartupScript($"WindowOpen{View.ObjectTypeInfo.FullName}-{ObjectSpace.GetKeyValue(e.InnerArgs.CurrentObject)}", script, true);
        }
Beispiel #5
0
        private void CreateUser()
        {
            ApplicationUser sampleUser = ObjectSpace.FirstOrDefault <ApplicationUser>(u => u.UserName == "User");

            if (sampleUser == null)
            {
                sampleUser          = ObjectSpace.CreateObject <ApplicationUser>();
                sampleUser.UserName = "******";
                sampleUser.SetPassword("");
                ((ISecurityUserWithLoginInfo)sampleUser).CreateUserLoginInfo(SecurityDefaults.PasswordAuthentication, ObjectSpace.GetKeyValueAsString(sampleUser));
            }
            PermissionPolicyRole defaultRole = CreateDefaultRole();

            sampleUser.Roles.Add(defaultRole);
        }
Beispiel #6
0
        private void CreateAdmin()
        {
            ApplicationUser userAdmin = ObjectSpace.FirstOrDefault <ApplicationUser>(u => u.UserName == "Admin");

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <ApplicationUser>();
                userAdmin.UserName = "******";
                userAdmin.SetPassword("");
                ((ISecurityUserWithLoginInfo)userAdmin).CreateUserLoginInfo(SecurityDefaults.PasswordAuthentication, ObjectSpace.GetKeyValueAsString(userAdmin));
            }
            PermissionPolicyRole adminRole = CreateAdminRole();

            userAdmin.Roles.Add(adminRole);
        }
        private void CreateSecurityObjects()
        {
            ApplicationUser sampleUser = ObjectSpace.FirstOrDefault <ApplicationUser>(u => u.UserName == "User");

            if (sampleUser == null)
            {
                sampleUser          = ObjectSpace.CreateObject <ApplicationUser>();
                sampleUser.UserName = "******";
                // Set a password if the standard authentication type is used
                sampleUser.SetPassword("");

                // The UserLoginInfo object requires a user object Id (Oid).
                // Commit the user object to the database before you create a UserLoginInfo object. This will correctly initialize the user key property.
                ObjectSpace.CommitChanges(); //This line persists created object(s).
                ((ISecurityUserWithLoginInfo)sampleUser).CreateUserLoginInfo(SecurityDefaults.PasswordAuthentication, ObjectSpace.GetKeyValueAsString(sampleUser));
            }
            PermissionPolicyRole defaultRole = CreateDefaultRole();

            sampleUser.Roles.Add(defaultRole);

            ApplicationUser userAdmin = ObjectSpace.FirstOrDefault <ApplicationUser>(u => u.UserName == "Admin");

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <ApplicationUser>();
                userAdmin.UserName = "******";
                // Set a password if the standard authentication type is used
                userAdmin.SetPassword("");

                // The UserLoginInfo object requires a user object Id (Oid).
                // Commit the user object to the database before you create a UserLoginInfo object. This will correctly initialize the user key property.
                ObjectSpace.CommitChanges(); //This line persists created object(s).
                ((ISecurityUserWithLoginInfo)userAdmin).CreateUserLoginInfo(SecurityDefaults.PasswordAuthentication, ObjectSpace.GetKeyValueAsString(userAdmin));
            }
            // If a role with the Administrators name doesn't exist in the database, create this role
            PermissionPolicyRole adminRole = ObjectSpace.FirstOrDefault <PermissionPolicyRole>(r => r.Name == "Administrators");

            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                adminRole.Name = "Administrators";
            }
            adminRole.IsAdministrative = true;
            userAdmin.Roles.Add(adminRole);
        }
Beispiel #8
0
 private string GetDashboardId()
 {
     return(ObjectSpace.GetKeyValueAsString(ViewCurrentObject));
 }
        protected override void OnActivated()
        {
            base.OnActivated();
            Contact johnNilsen = ObjectSpace.FindObject <Contact>(CriteriaOperator.Parse("LastName == 'Nilsen'"));

            if (johnNilsen != null)
            {
                goToJohnNilsenAction.Active.RemoveItem("JohnNilsenIsNotExist");
                ViewShortcut viewShortcut = new ViewShortcut(Application.GetDetailViewId(typeof(Contact)), ObjectSpace.GetKeyValueAsString(johnNilsen));
                string       url          = ((WebApplication)Application).ViewUrlManager.GetUrl(viewShortcut);
                goToJohnNilsenAction.SetClientScript($"window.open('{url}', '_blank')", false);
            }
            else
            {
                goToJohnNilsenAction.Active["JohnNilsenIsNotExist"] = false;
            }
        }