Пример #1
0
        public async Task ManageProductAsync(Guid productId, PerformContext context)
        {
            var product = await ProductRepository.Get()
                          .Where(p => p.Id == productId)
                          .Include(p => p.Project)
                          .ThenInclude(pr => pr.Type)
                          .Include(p => p.Project)
                          .ThenInclude(pr => pr.Organization)
                          .Include(p => p.Project)
                          .ThenInclude(pr => pr.Owner)
                          .Include(p => p.Store)
                          .Include(p => p.ProductDefinition)
                          .FirstOrDefaultAsync();

            if (product == null)
            {
                // Don't send exception because if the record is not there
                // there doesn't seem much point in retrying
                var messageParms = new Dictionary <string, object>
                {
                    { "productId", productId.ToString() }
                };
                await sendNotificationService.SendNotificationToSuperAdminsAsync("productRecordNotFound",
                                                                                 messageParms);

                return;
            }
            if (!BuildEngineLinkAvailable(product.Project.Organization))
            {
                // If the build engine isn't available, there is no point in continuing
                // Notifications for this are handled by the monitor
                var messageParms = new Dictionary <string, object>()
                {
                    { "projectName", product.Project.Name },
                    { "productName", product.ProductDefinition.Name }
                };
                await SendNotificationOnFinalRetryAsync(context, product.Project.Organization, product.Project.Owner, "productFailedUnableToConnect", messageParms);

                // Throw exception to retry
                throw new Exception("Connection not available");
            }
            if (!ProjectUrlSet(product.Project))
            {
                // If the Project URL is not set yet, then don't try to create the job.
                // Throw exception to retry
                var messageParms = new Dictionary <string, object>()
                {
                    { "projectName", product.Project.Name },
                    { "productName", product.ProductDefinition.Name }
                };
                await SendNotificationOnFinalRetryAsync(context, product.Project.Organization, product.Project.Owner, "productProjectUrlNotSet", messageParms);

                throw new Exception("Project URL not set");
            }
            await CreateBuildEngineProductAsync(product, context);
        }
Пример #2
0
        public async Task CreateReleaseAsync(Guid productId, Dictionary <string, object> paramsDictionary, PerformContext context)
        {
            var product = await ProductRepository.Get()
                          .Where(p => p.Id == productId)
                          .Include(p => p.ProductDefinition)
                          .Include(p => p.Project)
                          .ThenInclude(pr => pr.Organization)
                          .Include(p => p.Project)
                          .ThenInclude(pr => pr.Owner)
                          .FirstOrDefaultAsync();

            if ((product == null) || (product.WorkflowJobId == 0) || (product.WorkflowBuildId == 0))
            {
                // Can't find the product record associated with
                // this process or there is no job created for this product.
                // 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>
                {
                    { "productId", productId.ToString() }
                };
                await sendNotificationService.SendNotificationToSuperAdminsAsync("releaseProductRecordNotFound",
                                                                                 messageParms);

                return;
            }
            if (!BuildEngineLinkAvailable(product.Project.Organization))
            {
                // If the build engine isn't available, there is no point in continuing
                // Throw exception to retry
                var messageParms = new Dictionary <string, object>()
                {
                    { "projectName", product.Project.Name },
                    { "productName", product.ProductDefinition.Name }
                };
                await SendNotificationOnFinalRetryAsync(context, product.Project.Organization, product.Project.Owner, "releaseFailedUnableToConnect", messageParms);

                throw new Exception("Connection not available");
            }
            await CreateBuildEngineReleaseAsync(product, paramsDictionary, context);

            return;
        }