Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Fixes two problems, needing to use indexers on a dynamic, and a logic… #266

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload)
return await SendPayloadAsync(payload, true);
}

public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload,bool first)
public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload, bool first)
{
try
{
Expand All @@ -45,10 +45,10 @@ public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload,bool
if (response.Success)
{
var cleanPayload = new List<string>();
var invalidPayload = GetInvalidPayloadAsync(response, payload,out cleanPayload);
if ((cleanPayload?.Any() ?? false) && first)
var invalidPayload = GetInvalidPayloadAsync(response, payload, out cleanPayload);
if ((cleanPayload?.Any() == false) && first)
{
await SendPayloadAsync(cleanPayload,false);
await SendPayloadAsync(cleanPayload, false);
}

return new SentPayloadResult(response, true, invalidPayload);
Expand Down Expand Up @@ -85,16 +85,17 @@ private InvalidResult GetInvalidPayloadAsync(DynamicResponse baseResult, List<st
bool hasErrors = false;
foreach (dynamic item in items)
{
long? status = item.index?.status;
var itemIndex = item?["index"];
long? status = itemIndex?["status"];
i++;
if (!status.HasValue || status < 300)
{
continue;
}

hasErrors = true;
var id = item.index?._id;
var error = item.index?.error;
var id = itemIndex?["_id"];
var error = itemIndex?["error"];
if (int.TryParse(id.Split('_')[0], out int index))
{
SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}. Failed payload : {2}.", status, error?.ToString(), payload.ElementAt(index * 2 + 1));
Expand Down