public async Task UpdateProjectAsync(int projectId)
        {
            var project = await ProjectRepository.Get()
                          .Where(p => p.Id == projectId)
                          .Include(p => p.Organization)
                          .Include(p => p.Owner)
                          .FirstOrDefaultAsync();

            if (project == null)
            {
                // Can't find the project record whose creation should have
                // triggered this process.  Exception will trigger retry
                // TODO: Send notification record
                // Don't send exception because there doesn't seem to be a point in retrying
                ClearAndExit(projectId);
                return;
            }
            var buildEngineProject = new BuildEngineProject
            {
                UserId        = project.Owner.Email,
                PublishingKey = project.Owner.PublishingKey,
            };

            if (SetBuildEngineEndpoint(project.Organization))
            {
                var projectResponse = BuildEngineApi.UpdateProject(project.WorkflowProjectId, buildEngineProject);
            }
        }
示例#2
0
        public void ModifyTestProject(int projectId, string newUserId)
        {
            var client  = new BuildEngineApi(BaseUrl, ApiAccessKey);
            var project = new Project
            {
                UserId        = newUserId,
                PublishingKey = this.PublishingKey
            };
            var response = client.UpdateProject(projectId, project);

            Assert.NotNull(response);
            Assert.Equal(response.Id, projectId);
        }
        public async Task UpdateProjectAsync(int projectId, PerformContext context)
        {
            var project = await ProjectRepository.Get()
                          .Where(p => p.Id == projectId)
                          .Include(p => p.Organization)
                          .Include(p => p.Owner)
                          .FirstOrDefaultAsync();

            if (project == null)
            {
                // Can't find the project record whose creation should have
                // triggered this process.  Exception will trigger retry
                // Don't send exception because there doesn't seem to be a point in retrying
                var messageParms = new Dictionary <string, object>()
                {
                    { "projectId", projectId.ToString() }
                };
                await SendNotificationSvc.SendNotificationToSuperAdminsAsync("projectRecordNotFound",
                                                                             messageParms);

                ClearAndExit(projectId);
                return;
            }
            var buildEngineProject = new BuildEngineProject
            {
                UserId        = project.Owner.Email,
                PublishingKey = project.Owner.PublishingKey,
            };

            if (!BuildEngineLinkAvailable(project.Organization))
            {
                if (IsFinalRetry(context))
                {
                    var messageParms = new Dictionary <string, object>()
                    {
                        { "projectName", project.Name }
                    };
                    await SendNotificationSvc.SendNotificationToOrgAdminsAndOwnerAsync(project.Organization, project.Owner,
                                                                                       "projectUpdateFailedBuildEngine",
                                                                                       messageParms);
                }
                // Throw Exception to force retry
                throw new Exception("Connection not available");
            }

            if (SetBuildEngineEndpoint(project.Organization))
            {
                var projectResponse = BuildEngineApi.UpdateProject(project.WorkflowProjectId, buildEngineProject);
                if (projectResponse.Status == "completed" && projectResponse.Result == "SUCCESS")
                {
                    var messageParms = new Dictionary <string, object>()
                    {
                        { "projectName", project.Name }
                    };
                    await SendNotificationSvc.SendNotificationToUserAsync(project.Owner, "projectUpdateComplete",
                                                                          messageParms);
                }
                else
                {
                    var messageParms = new Dictionary <string, object>()
                    {
                        { "projectName", project.Name },
                        { "buildEngineProjectId", project.WorkflowProjectId.ToString() },
                        { "status", projectResponse.Status ?? "null" },
                        { "result", projectResponse.Result ?? "null" }
                    };
                    await SendNotificationSvc.SendNotificationToOrgAdminsAndOwnerAsync(project.Organization, project.Owner, "projectUpdateFailed",
                                                                                       messageParms);
                }
            }
        }