Ejemplo n.º 1
0
        public override string Execute()
        {
            Console.WriteLine($"Trying to queue job \"{Job}\" in project {Project}...");

            string message;

            var project = _projectService.GetProjectByName(Project).Result;

            if (project != null)
            {
                var job = _jobDefinitionService.GetJobDefinitionByName(project.Id, Job).Result;

                if (job != null)
                {
                    var queue = _jobQueueService.CreateJobQueue(project.Id, new NewJobDto
                    {
                        ProjectId       = project.Id,
                        JobDefinitionId = job.Id,
                        OriginUrl       = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Last(a => a.AddressFamily == AddressFamily.InterNetwork).ToString()
                    }).Result;

                    message = queue.ToCliString($"Job {Job} has been queued successfully:", excludedFields: new string[]
                    {
                        "ProjectId",
                        "JobDefinitionId",
                        "JobTasksStatus",
                        "OutputValues",
                        "CatapultEngineId",
                        "CatapultEngineMachineName",
                        "CatapultEngineIPAddress",
                        "CatapultEngineVersion"
                    });
                    Logger.LogInformation(message);

                    message += "\nThe job will be picked up by a running engine shortly.";
                    return(message);
                }
            }

            message = $"Failed to queue job {Job}. Make sure the project and job definition names are correct.";

            return(message);
        }