Exemplo n.º 1
0
        private async Task Build()
        {
            var args = _KeyBatch.ToArray();
            var e    = new ExposureKeySetEntity
            {
                Created              = _Start,
                CreatingJobName      = JobName,
                CreatingJobQualifier = ++_Counter,
                //DebugContentJson = _JsonSetFormatter.Build(args),
                AgContent = await _AgSetBuilder.BuildAsync(args)
            };

            _KeyBatch.Clear();

            using (var tx = _JobDbProvider.BeginTransaction())
            {
                await _JobDbProvider.Current.AddAsync(e);

                tx.Commit();
            }

            await WriteUsed();
        }
Exemplo n.º 2
0
        public IActionResult Execute(WorkflowArgs args)
        {
            if (!_WorkflowValidator.Validate(args))
            {
                return(new BadRequestResult());
            }

            using (var tx = _DbContextProvider.BeginTransaction())
            {
                _WorkflowDbInsertCommand.Execute(args).GetAwaiter().GetResult();
                _DbContextProvider.Current.SaveChanges();
                tx.Commit();
            }

            return(new OkResult());
        }
        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();
        }
Exemplo n.º 5
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();
            }
        }