コード例 #1
0
    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);
    }
コード例 #2
0
ファイル: ContentDomainObject.cs プロジェクト: jrlost/squidex
        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);
        }
コード例 #3
0
 public void Update(UpdateContent command)
 {
     if (!command.Data.Equals(Snapshot.Data))
     {
         RaiseEvent(SimpleMapper.Map(command, new ContentUpdated()));
     }
 }
コード例 #4
0
        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();
        }
コード例 #5
0
ファイル: GuardContentTests.cs プロジェクト: zxbe/squidex
        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"));
        }
コード例 #6
0
        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();
        }
コード例 #7
0
 private void UpdateContentNow()
 {
     if (UpdateContent != null)
     {
         UpdateContent.Invoke(this, null);
     }
 }
コード例 #8
0
        public void CanUpdate_should_not_throw_exception_if_data_is_not_null()
        {
            var command = new UpdateContent {
                Data = new NamedContentData()
            };

            GuardContent.CanUpdate(command);
        }
コード例 #9
0
        public IPageBuilder <T> Update(T page)
        {
            var command = new UpdateContent(page);

            command.Execute();

            return(this);
        }
コード例 #10
0
        private void UpdateContentNow()
        {
            if (UpdateContent != null)
            {
                UpdateContent.Invoke(this, null);
            }

            _reloadPending = false;
        }
コード例 #11
0
ファイル: FrameManager.cs プロジェクト: Kwarthys/BeeKeeper
    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);
    }
コード例 #12
0
ファイル: GuardContent.cs プロジェクト: mallickhruday/squidex
        public static void CanUpdate(UpdateContent command)
        {
            Guard.NotNull(command, nameof(command));

            Validate.It(() => "Cannot update content.", e =>
            {
                ValidateData(command, e);
            });
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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"));
        }
コード例 #15
0
        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());
        }
コード例 #16
0
        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));
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        public ContentDomainObject Update(UpdateContent command)
        {
            VerifyCreatedAndNotDeleted();

            if (!command.Data.Equals(Snapshot.Data))
            {
                RaiseEvent(SimpleMapper.Map(command, new ContentUpdated()));
            }

            return(this);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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)));
                }
            });
        }
コード例 #22
0
        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));
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        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);
        }
コード例 #25
0
        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);
        }
コード例 #26
0
        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);
        }
コード例 #27
0
        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));
        }
コード例 #28
0
        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));
        }
コード例 #29
0
        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));
            });
        }
コード例 #30
0
        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));
            });
        }