public void Execute(IList <ServiceDefinition> services)
        {
            var exceededRetry = services.Where(x => x.Retry >= 10).ToList();

            if (exceededRetry.Any())
            {
                exceededRetry.ForEach(x => x.Status = ServiceStatus.Disabled);
                _updateServiceStatus.Execute(exceededRetry);
            }

            var deployed = services.Except(exceededRetry).ToList();

            deployed.ForEach(FetchServiceDefinition);

            var fetched    = deployed.Where(x => x.Status == ServiceStatus.Fetched).ToList();
            var notFetched = deployed.Where(x => x.Status != ServiceStatus.Fetched).ToList();

            if (fetched.Any())
            {
                _updateServiceJson.Execute(fetched);
            }

            if (notFetched.Any())
            {
                _updateServiceStatus.Execute(notFetched);
            }
        }
Exemple #2
0
        public void Execute(IList <ServiceDefinition> services)
        {
            if (services.Count(x => x.Status == ServiceStatus.Fetched || x.Status == ServiceStatus.Done) == 1)
            {
                services.First().Status = ServiceStatus.Done;
                using (var scope = new TransactionScope())
                {
                    _insertMergedSchema.Execute(services.First().JsonData, 1);
                    _updateServiceStatus.Execute(services);

                    scope.Complete();
                }
                return;
            }

            var mainSchema = JObject.Parse(mainSpec);

            services.ForEach(x => MergeServiceIntoMainSchema(mainSchema, x));

            UpdateSchemaMasterData(mainSchema);

            using (var scope = new TransactionScope())
            {
                _insertMergedSchema.Execute(mainSchema.ToString(), services.Count(x => x.Status == ServiceStatus.Done));

                _updateServiceStatus.Execute(services);

                scope.Complete();
            }
        }
Exemple #3
0
        public ActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var services = _getServices.Execute();

            services.ForEach(x => x.Enabled = x.Status != ServiceStatus.Disabled);

            var updates = Services.Where(x => !services.Any(s => x.Id == s.Id && x.Enabled == s.Enabled)).ToList();

            if (updates.Count == 0)
            {
                return(RedirectToPage("List"));
            }

            updates.ForEach(x => x.Status = x.Enabled ? ServiceStatus.Deployed : ServiceStatus.Disabled);

            using (var scope = new TransactionScope())
            {
                _updateServiceStatus.Execute(updates);
                _updateServicesToTriggerMerge.Execute();

                scope.Complete();
            }

            return(RedirectToPage("List"));
        }