예제 #1
0
        public void ViewForm(ProjectFormModel projectForm, string environmentId)
        {
            FormViewViewModel formViewViewModel = _formViewModelFactory();

            ProjectResource project = _repositoryFactory.CurrentInstance.GetProject(projectForm.ProjectId);
            EnvironmentResource environment = _repositoryFactory.CurrentInstance.GetEnvironment(environmentId);
            IEnumerable<MachineResource> machines = _repositoryFactory.CurrentInstance.GetMachines(environmentId);
            List<string> roles = _repositoryFactory.CurrentInstance.GetRoles();
            IList<DeploymentStepResource> deploymentProcessSteps = _repositoryFactory.CurrentInstance.GetDeploymentProcessSteps(project);
            Dictionary<string, string> actionsDictionary = deploymentProcessSteps.GetActionsDictionary();

            Dictionary<ScopeField, ScopeValue> scopeDictionary = new Dictionary<ScopeField, ScopeValue>
            {
                {ScopeField.Environment, new ScopeValue(environmentId)},
                {ScopeField.Machine, new ScopeValue(machines.Select(mc => mc.Id))},
                {ScopeField.Role, new ScopeValue(roles)},
                {ScopeField.Action, new ScopeValue(actionsDictionary.Select(ac => ac.Value))}
            };

            formViewViewModel.Title = $"View Variables - {project.Name} - {environment.Name}";
            formViewViewModel.ProjectId = project.Id;

            List<ResourceVariableSetPair> variableSets = _repositoryFactory.CurrentInstance.GetVariableSetResources(project);

            VariableCollection variables = variableSets.GetProjectVariables(project, scopeDictionary);

            Entities.Form form = _sqlRepository.GetForm(projectForm.FormId);

            FormResources formResources = new FormResources(form, variables, environment, machines, roles, actionsDictionary);

            formViewViewModel.Show(_shellService.ShellView, formResources);
            formViewViewModel.Dispose();
        }
예제 #2
0
 public FieldModel(FormField field, Resource resource, VariableSettings variableSettings, FormResources formResources)
 {
     Settings = variableSettings;
     FormResources = formResources;
     Resource = resource;
     VariableSetId = field.VariableSetId;
     VariableName = field.VariableName;
     LabelContent = field.DisplayName;
     Variables = new ObservableCollection<FieldVariable>();
 }
예제 #3
0
        public ScopeResources(FormResources formResources, VariableInstance variableInstance)
        {
            EnvironmentItems = new ObservableDictionary<string, object>();
            EnvironmentSelectedItems = new ObservableDictionary<string, object>();

            RoleItems = new ObservableDictionary<string, object>();
            RoleSelectedItems = new ObservableDictionary<string, object>();

            MachineItems = new ObservableDictionary<string, object>();
            MachineSelectedItems = new ObservableDictionary<string, object>();

            ActionItems = new ObservableDictionary<string, object>();
            ActionSelectedItems = new ObservableDictionary<string, object>();

            EnvironmentItems.Add(formResources.Environment.Name, formResources.Environment.Id);

            foreach (string role in formResources.Roles)
            {
                RoleItems.Add(role, role);
            }

            foreach (MachineResource machineResource in formResources.Machines)
            {
                MachineItems.Add(machineResource.Name, machineResource.Id);
            }

            foreach (KeyValuePair<string, string> keyValuePair in formResources.Actions)
            {
                ActionItems.Add(keyValuePair.Key, keyValuePair.Value);
            }

            SetSelectedItems(variableInstance.Variable, formResources.Environment.Id, formResources.Environment.Name);

            SetResourceText(variableInstance.Resource);


            SetupEvents();
        }