private static RefToken Client(string identifier) { return(RefToken.Client(identifier)); }
public static IEnrichedContentEntity Create(DomainId id, DomainId refId = default, DomainId assetId = default, ContentData?data = null) { var now = SystemClock.Instance.GetCurrentInstant(); data ??= new ContentData() .AddField("my-localized-string", new ContentFieldData() .AddLocalized("de-DE", "de-DE")) .AddField("my-string", new ContentFieldData() .AddInvariant(null)) .AddField("my-string-enum", new ContentFieldData() .AddInvariant("EnumA")) .AddField("my-assets", new ContentFieldData() .AddInvariant(JsonValue.Array(assetId.ToString()))) .AddField("my-number", new ContentFieldData() .AddInvariant(1.0)) .AddField("my-boolean", new ContentFieldData() .AddInvariant(true)) .AddField("my-datetime", new ContentFieldData() .AddInvariant(now)) .AddField("my-tags", new ContentFieldData() .AddInvariant(JsonValue.Array("tag1", "tag2"))) .AddField("my-tags-enum", new ContentFieldData() .AddInvariant(JsonValue.Array("EnumA", "EnumB"))) .AddField("my-references", new ContentFieldData() .AddInvariant(JsonValue.Array(refId.ToString()))) .AddField("my-union", new ContentFieldData() .AddInvariant(JsonValue.Array(refId.ToString()))) .AddField("my-geolocation", new ContentFieldData() .AddInvariant( JsonValue.Object() .Add("latitude", 10) .Add("longitude", 20))) .AddField("my-component", new ContentFieldData() .AddInvariant( JsonValue.Object() .Add(Component.Discriminator, TestSchemas.Ref1.Id) .Add("schemaRef1Field", "Component1"))) .AddField("my-components", new ContentFieldData() .AddInvariant( JsonValue.Array( JsonValue.Object() .Add(Component.Discriminator, TestSchemas.Ref1.Id) .Add("schemaRef1Field", "Component1"), JsonValue.Object() .Add(Component.Discriminator, TestSchemas.Ref2.Id) .Add("schemaRef2Field", "Component2")))) .AddField("my-json", new ContentFieldData() .AddInvariant( JsonValue.Object() .Add("value", 1))) .AddField("my-array", new ContentFieldData() .AddInvariant(JsonValue.Array( JsonValue.Object() .Add("nested-number", 10) .Add("nested-boolean", true), JsonValue.Object() .Add("nested-number", 20) .Add("nested-boolean", false)))); var content = new ContentEntity { Id = id, AppId = TestApp.DefaultId, Version = 1, Created = now, CreatedBy = RefToken.User("user1"), EditToken = $"token_{id}", LastModified = now, LastModifiedBy = RefToken.Client("client1"), Data = data, SchemaId = TestSchemas.DefaultId, Status = Status.Draft, StatusColor = "red", NewStatus = Status.Published, NewStatusColor = "blue" }; return(content); }
public static IEnrichedContentEntity Create(NamedId <DomainId> appId, NamedId <DomainId> schemaId, DomainId id, DomainId refId, DomainId assetId, ContentData?data = null) { var now = SystemClock.Instance.GetCurrentInstant(); data ??= new ContentData() .AddField("my-string", new ContentFieldData() .AddLocalized("de", "value")) .AddField("my-string2", new ContentFieldData() .AddInvariant(null)) .AddField("my-assets", new ContentFieldData() .AddInvariant(JsonValue.Array(assetId.ToString()))) .AddField("2_numbers", new ContentFieldData() .AddInvariant(22)) .AddField("2-numbers", new ContentFieldData() .AddInvariant(23)) .AddField("content", new ContentFieldData() .AddInvariant(24)) .AddField("my-number", new ContentFieldData() .AddInvariant(1.0)) .AddField("my_number", new ContentFieldData() .AddInvariant(null)) .AddField("my-boolean", new ContentFieldData() .AddInvariant(true)) .AddField("my-datetime", new ContentFieldData() .AddInvariant(now)) .AddField("my-tags", new ContentFieldData() .AddInvariant(JsonValue.Array("tag1", "tag2"))) .AddField("my-references", new ContentFieldData() .AddInvariant(JsonValue.Array(refId.ToString()))) .AddField("my-union", new ContentFieldData() .AddInvariant(JsonValue.Array(refId.ToString()))) .AddField("my-geolocation", new ContentFieldData() .AddInvariant(JsonValue.Object().Add("latitude", 10).Add("longitude", 20))) .AddField("my-json", new ContentFieldData() .AddInvariant(JsonValue.Object().Add("value", 1))) .AddField("my-localized", new ContentFieldData() .AddLocalized("de-DE", "de-DE")) .AddField("my-array", new ContentFieldData() .AddInvariant(JsonValue.Array( JsonValue.Object() .Add("nested-number", 10) .Add("nested_number", null) .Add("nested-boolean", true), JsonValue.Object() .Add("nested-number", 20) .Add("nested_number", null) .Add("nested-boolean", false)))); var content = new ContentEntity { Id = id, AppId = appId, Version = 1, Created = now, CreatedBy = RefToken.User("user1"), LastModified = now, LastModifiedBy = RefToken.Client("client1"), Data = data, SchemaId = schemaId, Status = Status.Draft, StatusColor = "red" }; return(content); }
private RefToken ClientActor() { return(RefToken.Client(clientId)); }
public async Task UpdateAsync() { var apps = new Dictionary <NamedId <DomainId>, Dictionary <DomainId, (string Name, string Pattern, string?Message)> >(); await eventStore.QueryAsync(storedEvent => { var @event = eventDataFormatter.ParseIfKnown(storedEvent); if (@event != null) { switch (@event.Payload) { case AppPatternAdded patternAdded: { var patterns = apps.GetOrAddNew(patternAdded.AppId); patterns[patternAdded.PatternId] = (patternAdded.Name, patternAdded.Pattern, patternAdded.Message); break; } case AppPatternUpdated patternUpdated: { var patterns = apps.GetOrAddNew(patternUpdated.AppId); patterns[patternUpdated.PatternId] = (patternUpdated.Name, patternUpdated.Pattern, patternUpdated.Message); break; } case AppPatternDeleted patternDeleted: { var patterns = apps.GetOrAddNew(patternDeleted.AppId); patterns.Remove(patternDeleted.PatternId); break; } case AppArchived appArchived: { apps.Remove(appArchived.AppId); break; } } } return(Task.CompletedTask); }, "^app\\-"); var actor = RefToken.Client("Migrator"); foreach (var(appId, patterns) in apps) { if (patterns.Count > 0) { var settings = new AppSettings { Patterns = patterns.Values.Select(x => new Pattern(x.Name, x.Pattern) { Message = x.Message }).ToReadOnlyCollection() }; await commandBus.PublishAsync(new UpdateAppSettings { AppId = appId, Settings = settings, FromRule = true, Actor = actor }); } } }