public void updateContent() { int initCount = incContentOrders.Count; int jobCount = 0; while (incContentOrders.tryReadFifo(out UpdateContentOrder order) && initAskedForUpdate == 0) { float loopStart = Time.realtimeSinceStartup; jobCount++; Dictionary <int, Color> colorsOfCellsIds = new Dictionary <int, Color>(); for (int i = 0; i < order.cellIDs.Count; ++i) { Color c = getColorFor(order.cellCodes[i], order.cellQuantities[i]); colorsOfCellsIds.Add(order.cellIDs[i], c); } UpdateContent up = new UpdateContent(order.combID, colorsOfCellsIds); frameManager.treatOrder(up); } //if (initCount != 0) Debug.Log("Content update took " + (Time.realtimeSinceStartup - updateStartTime) * 1000 + "ms. From " + initCount + " to " + incContentOrders.Count); }
private async Task PatchCore(UpdateContent c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsUpdate); operation.MustHaveData(c.Data); if (!c.DoNotValidate) { await operation.ValidateInputPartialAsync(c.Data, c.OptimizeValidation, Snapshot.IsPublished()); } if (!c.DoNotValidateWorkflow) { await operation.CheckUpdateAsync(); } var newData = c.Data.MergeInto(Snapshot.Data); if (newData.Equals(Snapshot.Data)) { return; } if (!c.DoNotScript) { newData = await operation.ExecuteUpdateScriptAsync(newData); } if (!c.DoNotValidate) { await operation.ValidateContentAsync(newData, c.OptimizeValidation, Snapshot.IsPublished()); } Update(c, newData); }
public void Update(UpdateContent command) { if (!command.Data.Equals(Snapshot.Data)) { RaiseEvent(SimpleMapper.Map(command, new ContentUpdated())); } }
public async Task Update_should_create_proposal_events_and_update_state() { var command = new UpdateContent { Data = otherData, AsDraft = true }; await ExecuteCreateAsync(); await ExecutePublishAsync(); var result = await sut.ExecuteAsync(CreateContentCommand(command)); result.ShouldBeEquivalent(new ContentDataChangedResult(otherData, 2)); Assert.True(sut.Snapshot.IsPending); LastEvents .ShouldHaveSameEvents( CreateContentEvent(new ContentUpdateProposed { Data = otherData }) ); A.CallTo(() => scriptEngine.ExecuteAndTransform(A <ScriptContext> .Ignored, "<update-script>")) .MustHaveHappened(); }
public void CanUpdate_should_throw_exception_if_data_is_null() { var command = new UpdateContent(); ValidationAssert.Throws(() => GuardContent.CanUpdate(command), new ValidationError("Data is required.", "Data")); }
public async Task Update_should_create_events_and_update_new_version_when_draft_available() { var command = new UpdateContent { Data = otherData }; await ExecuteCreateAsync(); await ExecutePublishAsync(); await ExecuteCreateDraftAsync(); var result = await PublishAsync(command); result.ShouldBeEquivalent(sut.Snapshot); Assert.Equal(otherData, sut.Snapshot.NewVersion?.Data); LastEvents .ShouldHaveSameEvents( CreateContentEvent(new ContentUpdated { Data = otherData }) ); A.CallTo(() => scriptEngine.TransformAsync(ScriptContext(otherData, data, Status.Draft), "<update-script>", ScriptOptions())) .MustHaveHappened(); }
private void UpdateContentNow() { if (UpdateContent != null) { UpdateContent.Invoke(this, null); } }
public void CanUpdate_should_not_throw_exception_if_data_is_not_null() { var command = new UpdateContent { Data = new NamedContentData() }; GuardContent.CanUpdate(command); }
public IPageBuilder <T> Update(T page) { var command = new UpdateContent(page); command.Execute(); return(this); }
private void UpdateContentNow() { if (UpdateContent != null) { UpdateContent.Invoke(this, null); } _reloadPending = false; }
public void treatOrder(UpdateContent order) { //CombPointCloud cpc = getCloudOfId(order.combID); //cpc.setColors(getFullArray(order.colorsOfCellIDs, cpc.rows * cpc.columns)); int combID = order.combID; getFrameWithCombID(combID).setColors(order.colorsOfCellIDs, combID); }
public static void CanUpdate(UpdateContent command) { Guard.NotNull(command, nameof(command)); Validate.It(() => "Cannot update content.", e => { ValidateData(command, e); }); }
public async Task <IActionResult> PutContent(string app, string name, DomainId id, [FromBody] NamedContentData request) { var command = new UpdateContent { ContentId = id, Data = request.ToCleaned() }; var response = await InvokeCommandAsync(command); return(Ok(response)); }
public async Task CanUpdate_should_throw_exception_if_data_is_null() { SetupCanUpdate(true); var content = CreateContent(Status.Draft); var command = new UpdateContent(); await ValidationAssert.ThrowsAsync(() => GuardContent.CanUpdate(content, contentWorkflow, command), new ValidationError("Data is required.", "Data")); }
public async Task <IActionResult> PutContent(Guid id, [FromBody] ContentData request) { var command = new UpdateContent { ContentId = id, Data = request.ToCleaned() }; await CommandBus.PublishAsync(command); return(NoContent()); }
public async Task Update_should_throw_when_invalid_data_is_passed() { var command = new UpdateContent { Data = invalidData }; await ExecuteCreateAsync(); await Assert.ThrowsAsync <ValidationException>(() => PublishAsync(command)); }
public async Task CanUpdate_should_not_throw_exception_if_data_is_not_null() { SetupCanUpdate(true); var content = CreateContent(Status.Draft); var command = new UpdateContent { Data = new NamedContentData(), User = user }; await GuardContent.CanUpdate(content, contentWorkflow, command); }
public ContentDomainObject Update(UpdateContent command) { VerifyCreatedAndNotDeleted(); if (!command.Data.Equals(Snapshot.Data)) { RaiseEvent(SimpleMapper.Map(command, new ContentUpdated())); } return(this); }
public async Task Should_not_replace_content_id_with_schema_id_if_placeholder_not_used() { var command = new UpdateContent { ContentId = DomainId.Create("{custom}") }; await HandleAsync(command); Assert.NotEqual(schemaId.Id, command.ContentId); }
public async Task CanUpdate_should_throw_exception_if_workflow_blocks_it() { SetupCanUpdate(false); var content = CreateContent(Status.Draft); var command = new UpdateContent { Data = new NamedContentData() }; await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanUpdate(content, contentWorkflow, command)); }
public static void CanUpdate(UpdateContent command) { Guard.NotNull(command, nameof(command)); Validate.It(() => "Cannot update content.", error => { if (command.Data == null) { error(new ValidationError("Data cannot be null.", nameof(command.Data))); } }); }
public async Task <IActionResult> PutContent(string app, string name, Guid id, [FromBody] NamedContentData request, [FromQuery] bool asDraft = false) { await contentQuery.GetSchemaOrThrowAsync(Context, name); var command = new UpdateContent { ContentId = id, Data = request.ToCleaned(), AsDraft = asDraft }; var response = await InvokeCommandAsync(command); return(Ok(response)); }
private void Update(PageData page, CultureInfo culture, Action <object> build = null) { var command = new UpdateContent(page) { Culture = culture, Build = build }; PageData content = (PageData)command.Execute(); Add(content); }
private void Update(BlockData block, CultureInfo culture, Action <object> build = null) { var command = new UpdateContent((IContent)block) { Culture = culture, Build = build }; BlockData content = (BlockData)command.Execute(); Add(content); }
public static async Task CanUpdate(UpdateContent command, IContentEntity content, IContentWorkflow contentWorkflow) { Guard.NotNull(command, nameof(command)); Validate.It(e => { ValidateData(command, e); }); await ValidateCanUpdate(content, contentWorkflow, command.User); }
public ContentDomainObject Update(UpdateContent command) { Guard.Valid(command, nameof(command), () => "Cannot update content"); VerifyCreatedAndNotDeleted(); if (!command.Data.Equals(Data)) { RaiseEvent(SimpleMapper.Map(command, new ContentUpdated())); } return(this); }
public async Task <IActionResult> PutContent(string app, string name, Guid id, [FromBody] NamedContentData request, [FromQuery] bool asDraft = false) { await contentQuery.ThrowIfSchemaNotExistsAsync(Context().WithSchemaName(name)); var command = new UpdateContent { ContentId = id, Data = request.ToCleaned(), AsDraft = asDraft }; var context = await CommandBus.PublishAsync(command); var result = context.Result <ContentDataChangedResult>(); var response = result.Data; return(Ok(response)); }
public async Task <IActionResult> PutContent(string app, string name, Guid id, [FromBody] NamedContentData request) { await contentQuery.FindSchemaAsync(App, name); var command = new UpdateContent { ContentId = id, Data = request.ToCleaned() }; var context = await CommandBus.PublishAsync(command); var result = context.Result <ContentDataChangedResult>(); var response = result.Data; return(Ok(response)); }
protected async Task On(UpdateContent command, CommandContext context) { await handler.UpdateAsync <ContentDomainObject>(context, async content => { var schemaAndApp = await ResolveSchemaAndAppAsync(command); ExecuteScriptAndTransform(command, content, schemaAndApp.SchemaEntity.ScriptUpdate, "Update"); await ValidateAsync(schemaAndApp, command, () => "Failed to update content", false); content.Update(command); context.Complete(new ContentDataChangedResult(content.Data, content.Version)); }); }
protected async Task On(UpdateContent command, CommandContext context) { await handler.UpdateAsync <ContentDomainObject>(context, async content => { GuardContent.CanUpdate(command); var operationContext = await CreateContext(command, content, () => "Failed to update content."); await operationContext.ValidateAsync(true); await operationContext.ExecuteScriptAndTransformAsync(x => x.ScriptUpdate, "Update"); content.Update(command); context.Complete(new ContentDataChangedResult(content.Snapshot.Data, content.Version)); }); }