Browse Source

Downgrade elastic client.

pull/862/head
Sebastian 4 years ago
parent
commit
e95730dfff
  1. 87
      backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs
  2. 52
      backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj

87
backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs

@ -10,6 +10,7 @@ using Newtonsoft.Json.Linq;
using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Domain.Apps.Core.Rules.EnrichedEvents; using Squidex.Domain.Apps.Core.Rules.EnrichedEvents;
using Squidex.Domain.Apps.Core.Scripting; using Squidex.Domain.Apps.Core.Scripting;
using Squidex.Infrastructure;
#pragma warning disable IDE0059 // Value assigned to symbol is never used #pragma warning disable IDE0059 // Value assigned to symbol is never used
#pragma warning disable MA0048 // File name must match type name #pragma warning disable MA0048 // File name must match type name
@ -41,61 +42,65 @@ namespace Squidex.Extensions.Actions.ElasticSearch
protected override async Task<(string Description, ElasticSearchJob Data)> CreateJobAsync(EnrichedEvent @event, ElasticSearchAction action) protected override async Task<(string Description, ElasticSearchJob Data)> CreateJobAsync(EnrichedEvent @event, ElasticSearchAction action)
{ {
if (@event is IEnrichedEntityEvent entityEvent) var delete = @event.ShouldDelete(scriptEngine, action.Delete);
string contentId;
if (@event is IEnrichedEntityEvent enrichedEntityEvent)
{ {
var delete = @event.ShouldDelete(scriptEngine, action.Delete); contentId = enrichedEntityEvent.Id.ToString();
}
else
{
contentId = DomainId.NewGuid().ToString();
}
var contentId = entityEvent.Id.ToString(); var ruleDescription = string.Empty;
var ruleJob = new ElasticSearchJob
{
IndexName = await FormatAsync(action.IndexName, @event),
ServerHost = action.Host.ToString(),
ServerUser = action.Username,
ServerPassword = action.Password,
ContentId = contentId
};
if (delete)
{
ruleDescription = $"Delete entry index: {action.IndexName}";
}
else
{
ruleDescription = $"Upsert to index: {action.IndexName}";
var ruleDescription = string.Empty; JObject json;
var ruleJob = new ElasticSearchJob try
{ {
IndexName = await FormatAsync(action.IndexName, @event), string jsonString;
ServerHost = action.Host.ToString(),
ServerUser = action.Username,
ServerPassword = action.Password,
ContentId = contentId
};
if (delete)
{
ruleDescription = $"Delete entry index: {action.IndexName}";
}
else
{
ruleDescription = $"Upsert to index: {action.IndexName}";
JObject json; if (!string.IsNullOrEmpty(action.Document))
try
{ {
string jsonString; jsonString = await FormatAsync(action.Document, @event);
jsonString = jsonString?.Trim();
if (!string.IsNullOrEmpty(action.Document))
{
jsonString = await FormatAsync(action.Document, @event);
jsonString = jsonString?.Trim();
}
else
{
jsonString = ToJson(@event);
}
json = JObject.Parse(jsonString);
} }
catch (Exception ex) else
{ {
json = new JObject(new JProperty("error", $"Invalid JSON: {ex.Message}")); jsonString = ToJson(@event);
} }
json.AddFirst(new JProperty("contentId", contentId)); json = JObject.Parse(jsonString);
}
ruleJob.Content = json.ToString(); catch (Exception ex)
{
json = new JObject(new JProperty("error", $"Invalid JSON: {ex.Message}"));
} }
return (ruleDescription, ruleJob); json.AddFirst(new JProperty("contentId", contentId));
ruleJob.Content = json.ToString();
} }
return ("Ignore", new ElasticSearchJob()); return (ruleDescription, ruleJob);
} }
protected override async Task<Result> ExecuteJobAsync(ElasticSearchJob job, protected override async Task<Result> ExecuteJobAsync(ElasticSearchJob job,

52
backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj

@ -10,35 +10,35 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Algolia.Search" Version="6.12.0" /> <PackageReference Include="Algolia.Search" Version="6.12.0" />
<PackageReference Include="Azure.Search.Documents" Version="11.3.0" /> <PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.0.0-beta.3" />
<PackageReference Include="Confluent.Apache.Avro" Version="1.7.7.7" /> <PackageReference Include="Azure.Search.Documents" Version="11.3.0" />
<PackageReference Include="Confluent.Kafka" Version="1.8.2" /> <PackageReference Include="Confluent.Apache.Avro" Version="1.7.7.7" />
<PackageReference Include="Confluent.SchemaRegistry.Serdes" Version="1.3.0" /> <PackageReference Include="Confluent.Kafka" Version="1.8.2" />
<PackageReference Include="CoreTweet" Version="1.0.0.483" /> <PackageReference Include="Confluent.SchemaRegistry.Serdes" Version="1.3.0" />
<PackageReference Include="Elasticsearch.Net" Version="7.17.0" /> <PackageReference Include="CoreTweet" Version="1.0.0.483" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="4.4.0" /> <PackageReference Include="Elasticsearch.Net" Version="7.13.0" />
<PackageReference Include="Google.Cloud.Logging.V2" Version="3.4.0" /> <PackageReference Include="Google.Cloud.Diagnostics.Common" Version="4.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.694"> <PackageReference Include="Google.Cloud.Logging.V2" Version="3.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.694">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" /> <PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" />
<PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.15.0" /> <PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.15.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.10.0" /> <PackageReference Include="Microsoft.OData.Core" Version="7.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NodaTime" Version="3.0.9" /> <PackageReference Include="NodaTime" Version="3.0.9" />
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.0.0-beta.3" /> <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0" /> <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0-beta1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.2.0-beta1" /> <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc8" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc8" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="Squidex.OpenTelemetry.Exporter.Stackdriver" Version="0.0.0-alpha.0.97" />
<PackageReference Include="Squidex.OpenTelemetry.Exporter.Stackdriver" Version="0.0.0-alpha.0.97" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" /> <AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />

Loading…
Cancel
Save