///// <summary> ///// TODO decide whether we really need to Json version but it is useful to see in a readable form what the content of the zipped AG content is too ///// </summary> ///// <param name="output"></param> ///// <returns></returns> //public static ExposureKeySetConfigEntity ToEntity(this ExposureKeySetOutput output) //{ // var jsonContent = JsonConvert.SerializeObject(output.DebugContentJson); // return new ExposureKeySetConfigEntity // { // Release = output.Created, // CreatingJobQualifier = output.CreatingJobQualifier, // CreatingJobName = output.CreatingJobName, // JsonContent = jsonContent, // AgContent = output.AgContent // }; //} public static KeysFirstWorkflowEntity ToDbEntity(this WorkflowArgs args) { var content = JsonConvert.SerializeObject(args.Items.Select(ToDbEntity).ToArray()); //TODO no envelope? return(new KeysFirstWorkflowEntity { //TODO region? Content = content, AuthorisationToken = args.Token, }); }
/// <summary> /// Passes on the SetFocus to Desktop /// </summary> /// <param name="hostedAppId"></param> public void SetFocus(int hostedAppId) { if (this.InvokeRequired) { SetFocusDelegate setFocus = new SetFocusDelegate(this.SetFocus); this.Invoke(setFocus, hostedAppId); } else { WorkflowArgs e = new WorkflowArgs(); e.ApplicationId = hostedAppId; FocusHostedApp(this, e); } }
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."); }
public static KeysFirstWorkflowEntity ToEntity(this WorkflowArgs args) { var content = args.Items.Select(x => new WorkflowKeyContent { KeyData = x.KeyData, TransmissionRiskLevel = x.TransmissionRiskLevel, RollingPeriod = x.RollingPeriod, RollingStartNumber = x.RollingStartNumber }).ToArray(); return(new KeysFirstWorkflowEntity { AuthorisationToken = args.Token, Content = JsonConvert.SerializeObject(content) //TODO deserialize had better not screw with this cos array... }); }
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(WorkflowArgs args) { var e = _DbContextProvider.Current.TokenFirstWorkflows .SingleOrDefault(x => x.TekWriteAuthorisationToken == args.Token && x.State == TokenFirstWorkflowState.Receiving); if (e == null) { //TODO log miss return; } e.TekWriteAuthorisationToken = null; e.Content = JsonConvert.SerializeObject(args.Items); e.State = TokenFirstWorkflowState.Authorised; _DbContextProvider.Current.TokenFirstWorkflows.Update(e); _DbContextProvider.Current.SaveChangesAsync(); //TODO log hit }
public IActionResult PostWorkflow([FromBody] WorkflowArgs args, [FromServices] HttpPostTokenFirstWorkflowCommand command) { return(command.Execute(args)); }
public void Cancel() { WorkflowArgs.AbortPipeline(); }