Esempio n. 1
0
        protected async Task CreateBuildEngineProductAsync(Product product)
        {
            var buildEngineJob = new BuildEngineJob
            {
                RequestId   = product.Id.ToString(),
                GitUrl      = product.Project.WorkflowProjectUrl,
                AppId       = product.Project.Type.Name,
                PublisherId = product.Store.Name
            };
            JobResponse jobResponse = null;

            if (SetBuildEngineEndpoint(product.Project.Organization))
            {
                jobResponse = BuildEngineApi.CreateJob(buildEngineJob);
            }
            if ((jobResponse != null) && (jobResponse.Id != 0))
            {
                product.WorkflowJobId = jobResponse.Id;
                await ProductRepository.UpdateAsync(product);

                return;
            }
            else
            {
                // TODO: Send Notification
                throw new Exception("Create job failed");
            }
        }
Esempio n. 2
0
        protected async Task CreateBuildEngineProductAsync(Product product, PerformContext context)
        {
            var buildEngineJob = new BuildEngineJob
            {
                RequestId   = product.Id.ToString(),
                GitUrl      = product.Project.WorkflowProjectUrl,
                AppId       = product.Project.Type.Name,
                PublisherId = product.Store.Name
            };
            JobResponse jobResponse = null;

            if (SetBuildEngineEndpoint(product.Project.Organization))
            {
                jobResponse = BuildEngineApi.CreateJob(buildEngineJob);
            }
            if ((jobResponse != null) && (jobResponse.Id != 0))
            {
                product.WorkflowJobId = jobResponse.Id;

                await ProductRepository.UpdateAsync(product);

                var messageParms = new Dictionary <string, object>()
                {
                    { "projectName", product.Project.Name },
                    { "productName", product.ProductDefinition.Name }
                };
                await sendNotificationService.SendNotificationToUserAsync(product.Project.Owner, "productCreatedSuccessfully", messageParms);

                return;
            }
            else
            {
                var buildEngineUrl = product.Project.Organization.BuildEngineUrl + "/job-admin";
                var messageParms   = new Dictionary <string, object>()
                {
                    { "projectName", product.Project.Name },
                    { "productName", product.ProductDefinition.Name },
                    { "buildEngineUrl", buildEngineUrl }
                };
                await SendNotificationOnFinalRetryAsync(context, product.Project.Organization, product.Project.Owner, "productCreationFailedOwner", "productCreationFailedAdmin", messageParms, buildEngineUrl);

                throw new Exception("Create job failed");
            }
        }