Beispiel #1
0
        public ManifestEntity Execute()
        {
            var now           = _DateTimeProvider.Now();
            var releaseCutoff = now - TimeSpan.FromHours(_AgConfig.ManifestLifeTimeHours);

            var e = _DbContext.Current.ManifestContent
                    .Where(x => x.Release > releaseCutoff)
                    .OrderByDescending(x => x.Release)
                    .Take(1)
                    .SingleOrDefault();

            if (e != null)
            {
                return(e);
            }

            _DbContext.Current.BulkDelete(_DbContext.Current.ManifestContent.ToList()); //TODO execute sql.
            var content = JsonConvert.SerializeObject(_ManifestBuilder.Execute());
            var bytes   = Encoding.UTF8.GetBytes(content);

            e = new ManifestEntity
            {
                Release         = now,
                ContentTypeName = ContentHeaderValues.Json,
                Content         = bytes,
                Region          = DefaultValues.Region,
            };
            e.PublishingId = _PublishingIdCreator.Create(e);
            _DbContext.Current.ManifestContent.Add(e);
            _DbContext.SaveAndCommit();

            return(e);
        }
        public IActionResult Execute(WorkflowArgs args)
        {
            if (!_Validator.Validate(args))
            {
                //TODO log bad request
                return(new OkResult());
            }

            if (!_Validator.Validate(args))
            {
                return(new BadRequestResult());
            }

            _DbContextProvider.BeginTransaction();
            _Writer.Execute(args);
            _DbContextProvider.SaveAndCommit();
            return(new OkResult());
        }
        public void Execute(int pAuthorise, Random r)
        {
            _DbContextProvider.BeginTransaction();
            var unauthorised = _DbContextProvider.Current.Set <KeysFirstWorkflowEntity>()
                               .Where(x => x.Authorised == false)
                               .Select(x => x.AuthorisationToken)
                               .ToArray();

            var authorised = unauthorised
                             .Where(x => r.Next(100) <= pAuthorise);

            foreach (var i in authorised)
            {
                _Writer.Execute(new WorkflowAuthorisationArgs {
                    Token = i
                }).GetAwaiter().GetResult();
            }

            _DbContextProvider.SaveAndCommit();
        }
Beispiel #4
0
        public void Write(ExposureKeySetEntity[] things)
        {
            var entities = things.Select(x => new ExposureKeySetContentEntity
            {
                Content              = x.AgContent,
                CreatingJobName      = x.CreatingJobName,
                CreatingJobQualifier = x.CreatingJobQualifier,
                Region  = x.Region,
                Release = x.Created,
            });

            foreach (var i in entities)
            {
                i.PublishingId = _PublishingIdCreator.Create(i);
            }

            using (_DbContext.BeginTransaction())
            {
                _DbContext.Current.BulkInsertAsync(entities.ToList());
                _DbContext.SaveAndCommit();
            }
        }