public override string Execute()
        {
            Console.WriteLine($"Trying to create project \"{Name}\"...");
            bool          promptAllConfig;
            NewProjectDto projectDto;

            if (!string.IsNullOrEmpty(Template))
            {
                var projectTemplate = _templateWriter.Read(Template);
                projectDto             = DeserializeYaml <NewProjectDto>(projectTemplate);
                projectDto.Name        = Name;
                projectDto.DisplayName = DisplayName;
                projectDto.Client      = Client;

                promptAllConfig = Console.GetYesNo("Do you want to complete the job definition configuration now?", false);
            }
            else
            {
                promptAllConfig = true;
                projectDto      = new NewProjectDto
                {
                    Name        = Name,
                    Client      = Client,
                    DisplayName = DisplayName,
                    Members     = new List <NewProjectMemberDto>()
                };
            }

            projectDto.Members = projectDto.Members ?? new List <NewProjectMemberDto>();
            projectDto.Models  = projectDto.Models ?? new List <CreateProjectDataModelWithPropertiesDto>();
            projectDto.Jobs    = projectDto.Jobs ?? new List <CreateJobDefinitionWithTasksDto>();
            string message;

            if (promptAllConfig)
            {
                message = ValidateTask(projectDto.Jobs);
                if (!string.IsNullOrEmpty(message))
                {
                    return(message);
                }
            }

            var project = _projectService.CreateProject(projectDto).Result;

            message = project.ToCliString(promptAllConfig ?
                                          "Project created:" :
                                          "The project has been successfully created. However, you cannot queue the Default job until you complete the configuration");

            Logger.LogInformation(message);

            RefreshToken();

            return(message);
        }
Beispiel #2
0
        public override string Execute()
        {
            Console.WriteLine($"Trying to create project \"{Name}\"...");

            NewProjectDto projectDto;

            if (!string.IsNullOrEmpty(Template))
            {
                var projectTemplate = _templateWriter.Read(Template);
                projectDto             = DeserializeYaml <NewProjectDto>(projectTemplate);
                projectDto.Name        = Name;
                projectDto.DisplayName = DisplayName;
                projectDto.Client      = Client;
            }
            else
            {
                projectDto = new NewProjectDto
                {
                    Name        = Name,
                    Client      = Client,
                    DisplayName = DisplayName,
                    Members     = new List <NewProjectMemberDto>()
                };
            }

            projectDto.Members = projectDto.Members ?? new List <NewProjectMemberDto>();
            projectDto.Models  = projectDto.Models ?? new List <CreateProjectDataModelWithPropertiesDto>();
            projectDto.Jobs    = projectDto.Jobs ?? new List <CreateJobDefinitionWithTasksDto>();

            var message = ValidateTask(projectDto.Jobs);

            if (!string.IsNullOrEmpty(message))
            {
                return(message);
            }

            var project = _projectService.CreateProject(projectDto).Result;

            message = project.ToCliString("Project created:");
            Logger.LogInformation(message);

            RefreshToken();

            return(message);
        }