protected async Task CreateBuildEngineProjectAsync(Project project)
        {
            var buildEngineProject = new BuildEngineProject
            {
                UserId        = project.Owner.Email,
                GroupId       = project.Group.Abbreviation,
                AppId         = project.Type.Name,
                LanguageCode  = project.Language,
                PublishingKey = project.Owner.PublishingKey,
                ProjectName   = project.Name
            };
            ProjectResponse projectResponse = null;

            if (SetBuildEngineEndpoint(project.Organization))
            {
                projectResponse = BuildEngineApi.CreateProject(buildEngineProject);
            }
            if ((projectResponse != null) && (projectResponse.Id != 0))
            {
                // Set state to active?
                project.WorkflowProjectId = projectResponse.Id;
                await ProjectRepository.UpdateAsync(project);

                var monitorJob = Job.FromExpression <BuildEngineProjectService>(service => service.ManageProject(project.Id));
                RecurringJobManager.AddOrUpdate(GetHangfireToken(project.Id), monitorJob, "* * * * *");
            }
            else
            {
                // TODO: Send Notification
                // Throw Exception to force retry
                throw new Exception("Create project failed");
            }
        }
        protected async Task ProjectCompletedAsync(Project project, ProjectResponse projectResponse)
        {
            project.WorkflowProjectUrl = projectResponse.Url;
            await ProjectRepository.UpdateAsync(project);

            ClearAndExit(project.Id);
        }
        protected ProjectResponse GetBuildEngineProject(Project project)
        {
            if (!SetBuildEngineEndpoint(project.Organization))
            {
                return(null);
            }
            var projectResponse = BuildEngineApi.GetProject(project.WorkflowProjectId);

            return(projectResponse);
        }
Exemple #4
0
 protected async Task ProjectCreationFailedAsync(Project project, ProjectResponse projectResponse)
 {
     var buildEngineUrl = project.Organization.BuildEngineUrl + "/project-admin/view?id=" + project.WorkflowProjectId.ToString();
     var messageParms   = new Dictionary <string, object>()
     {
         { "projectName", project.Name },
         { "projectStatus", projectResponse.Status },
         { "projectError", projectResponse.Error },
         { "buildEngineUrl", buildEngineUrl }
     };
     await SendNotificationSvc.SendNotificationToOrgAdminsAndOwnerAsync(project.Organization, project.Owner, "projectCreationFailedOwner", "projectCreationFailedAdmin", messageParms, buildEngineUrl);
 }
        protected async Task ProjectCreationFailedAsync(Project project, ProjectResponse projectResponse)
        {
            var messageParms = new Dictionary <string, object>()
            {
                { "projectName", project.Name },
                { "projectStatus", projectResponse.Status },
                { "projectError", projectResponse.Error },
                { "buildEngineUrl", project.Organization.BuildEngineUrl }
            };
            await SendNotificationSvc.SendNotificationToOrgAdminsAndOwnerAsync(project.Organization, project.Owner, "projectCreationFailed", messageParms);

            ClearAndExit(project.Id);
        }
        protected async Task ProjectCompletedAsync(Project project, ProjectResponse projectResponse)
        {
            project.WorkflowProjectUrl = projectResponse.Url;
            await ProjectRepository.UpdateAsync(project);

            var messageParms = new Dictionary <string, object>()
            {
                { "projectName", project.Name }
            };
            await SendNotificationSvc.SendNotificationToUserAsync(project.Owner, "projectCreatedSuccessfully", messageParms);

            ClearAndExit(project.Id);
        }
Exemple #7
0
        protected async Task ProjectCompletedAsync(Project project, ProjectResponse projectResponse)
        {
            project.WorkflowProjectUrl = projectResponse.Url;

            // Assign at the same time as WorkflowProjectUrl now that it is available.
            project.WorkflowAppProjectUrl = GetVarOrDefault("UI_URL", "http://localhost:9091") + "/projects/" + project.Id;

            await ProjectRepository.UpdateAsync(project);

            var messageParms = new Dictionary <string, object>()
            {
                { "projectName", project.Name }
            };
            await SendNotificationSvc.SendNotificationToUserAsync(project.Owner, "projectCreatedSuccessfully", messageParms);
        }
Exemple #8
0
        protected async Task CreateBuildEngineProjectAsync(Project project, PerformContext context)
        {
            var buildEngineProject = new BuildEngineProject
            {
                AppId        = project.Type.Name,
                LanguageCode = project.Language,
                ProjectName  = project.Name,
                StorageType  = "s3"
            };
            ProjectResponse projectResponse = null;

            if (SetBuildEngineEndpoint(project.Organization))
            {
                projectResponse = BuildEngineApi.CreateProject(buildEngineProject);
            }
            if ((projectResponse != null) && (projectResponse.Id != 0))
            {
                // Set state to active?
                project.WorkflowProjectId = projectResponse.Id;
                if (projectResponse.Status == "completed")
                {
                    if (projectResponse.Result == "SUCCESS")
                    {
                        await ProjectCompletedAsync(project, projectResponse);
                    }
                    else
                    {
                        await ProjectCreationFailedAsync(project, projectResponse);
                    }
                    return;
                }
            }
            if (IsFinalRetry(context))
            {
                var messageParms = new Dictionary <string, object>()
                {
                    { "projectName", project.Name }
                };
                await SendNotificationSvc.SendNotificationToOrgAdminsAndOwnerAsync(project.Organization, project.Owner,
                                                                                   "projectFailedUnableToCreate",
                                                                                   messageParms);
            }
            // Throw Exception to force retry
            throw new Exception("Create project failed");
        }
        protected async Task CreateBuildEngineProjectAsync(Project project, PerformContext context)
        {
            var buildEngineProject = new BuildEngineProject
            {
                UserId        = project.Owner.Email,
                GroupId       = project.Group.Abbreviation,
                AppId         = project.Type.Name,
                LanguageCode  = project.Language,
                PublishingKey = project.Owner.PublishingKey,
                ProjectName   = project.Name
            };
            ProjectResponse projectResponse = null;

            if (SetBuildEngineEndpoint(project.Organization))
            {
                projectResponse = BuildEngineApi.CreateProject(buildEngineProject);
            }
            if ((projectResponse != null) && (projectResponse.Id != 0))
            {
                // Set state to active?
                project.WorkflowProjectId = projectResponse.Id;
                await ProjectRepository.UpdateAsync(project);

                var monitorJob = Job.FromExpression <BuildEngineProjectService>(service => service.ManageProject(project.Id, null));
                RecurringJobManager.AddOrUpdate(GetHangfireToken(project.Id), monitorJob, "* * * * *");
            }
            else
            {
                if (IsFinalRetry(context))
                {
                    var messageParms = new Dictionary <string, object>()
                    {
                        { "projectName", project.Name }
                    };
                    await SendNotificationSvc.SendNotificationToOrgAdminsAndOwnerAsync(project.Organization, project.Owner,
                                                                                       "projectFailedUnableToCreate",
                                                                                       messageParms);
                }
                // Throw Exception to force retry
                throw new Exception("Create project failed");
            }
        }
        protected async Task CheckExistingProjectAsync(Project project)
        {
            var buildEngineProject = GetBuildEngineProject(project);

            if ((buildEngineProject == null) || (buildEngineProject.Id == 0))
            {
                // Attempt to get project failed, retry in one minute
                return;
            }
            if (buildEngineProject.Status == "completed")
            {
                if (buildEngineProject.Result == "SUCCESS")
                {
                    await ProjectCompletedAsync(project, buildEngineProject);
                }
                else
                {
                    ProjectCreationFailed(project, buildEngineProject);
                }
            }
            return;
        }
        protected async Task CheckExistingProjectAsync(Project project)
        {
            var buildEngineProject = GetBuildEngineProject(project);

            if ((buildEngineProject == null) || (buildEngineProject.Id == 0))
            {
                // Attempt to get project failed, retry in one minute
                // This is normal since it will take some time for the build engine
                // to actually create the project
                return;
            }
            if (buildEngineProject.Status == "completed")
            {
                if (buildEngineProject.Result == "SUCCESS")
                {
                    await ProjectCompletedAsync(project, buildEngineProject);
                }
                else
                {
                    await ProjectCreationFailedAsync(project, buildEngineProject);
                }
            }
            return;
        }
 protected bool BuildEngineProjectCreated(Project project)
 {
     return(project.WorkflowProjectId != 0);
 }
 protected void ProjectCreationFailed(Project project, ProjectResponse projectResponse)
 {
     ClearAndExit(project.Id);
 }