public void Execute(int WorkflowCount, Func <int, int> randomInt, Action <byte[]> randomBytes)
        {
            var luhnModNConfig             = new LuhnModNConfig();
            var WorkflowKeyGenerator       = new GenerateWorkflowKeys(luhnModNConfig);
            var WorkflowValidatorConfig    = new HardCodedAgWorkflowValidatorConfig();
            var WorkflowKeyValidatorConfig = new HardCodedAgTemporaryExposureKeyValidatorConfig();
            var writer = new WorkflowInsertDbCommand(_DbContextProvider, new StandardUtcDateTimeProvider());
            var c      = new HttpPostWorkflowCommand(
                writer,
                new WorkflowValidator(
                    WorkflowValidatorConfig,
                    new WorkflowAuthorisationTokenLuhnModNValidator(luhnModNConfig),
                    new TemporaryExposureKeyValidator(WorkflowKeyValidatorConfig)),
                _DbContextProvider);

            var keyBuffer = new byte[WorkflowKeyValidatorConfig.DailyKeyByteCount];

            for (var i = 0; i < WorkflowCount; i++)
            {
                var Workflow = new WorkflowArgs
                {
                    Token = WorkflowKeyGenerator.Next(randomInt)
                };

                var keyCount = 1 + randomInt(WorkflowValidatorConfig.WorkflowKeyCountMax - 1);
                var keys     = new List <WorkflowKeyArgs>(keyCount);
                for (var j = 0; j < keyCount; j++)
                {
                    randomBytes(keyBuffer);
                    keys.Add(new WorkflowKeyArgs
                    {
                        KeyData               = Convert.ToBase64String(keyBuffer),
                        RollingStartNumber    = WorkflowKeyValidatorConfig.RollingPeriodMin + j,
                        RollingPeriod         = 11,
                        TransmissionRiskLevel = 2
                    });
                }
                Workflow.Items = keys.ToArray();

                c.Execute(Workflow);

                if (i > 0 && i % 100 == 0)
                {
                    Console.WriteLine($"Workflow count {i}...");
                }
            }
            Console.WriteLine("Generating Workflows finished.");
        }
Exemplo n.º 2
0
 public IActionResult PostWorkflow([FromBody] WorkflowArgs args, [FromServices] HttpPostWorkflowCommand command)
 {
     return(command.Execute(args));
 }