added debugging str

This commit is contained in:
taywon 2024-05-19 19:23:32 +02:00
parent 3ca5768d6e
commit 6572836716
3 changed files with 10 additions and 6 deletions

View File

@ -16,7 +16,11 @@ public class Transmitter
foreach (Element element in elements) foreach (Element element in elements)
triplets.AddRange(Translator.Encode(element)); triplets.AddRange(Translator.Encode(element));
await Client.PostAsJsonAsync(uri, triplets, cancellationToken: tk); var result = await Client.PostAsJsonAsync(uri, triplets, cancellationToken: tk);
if (!result.IsSuccessStatusCode)
throw new Exception($"SendAsync call return code {result.StatusCode} when call {uri}.");
} }
public async Task SendAsync(Uri uri, IEnumerable<Event> events, CancellationToken tk = default) public async Task SendAsync(Uri uri, IEnumerable<Event> events, CancellationToken tk = default)
@ -31,9 +35,7 @@ public class Transmitter
Uri uri = new Uri(BaseUrl, "Push/Elements"); Uri uri = new Uri(BaseUrl, "Push/Elements");
var result = await Client.PostAsJsonAsync(uri, elements, tk); await SendAsync(uri, elements, tk);
if (!result.IsSuccessStatusCode)
throw new Exception($"SendAsync call return code {result.StatusCode} when call {uri}.");
} }
public async Task SendAsync(Element element, CancellationToken tk = default) public async Task SendAsync(Element element, CancellationToken tk = default)

View File

@ -1,5 +1,5 @@
{ {
"Url":"http://salmon.voie93quarts.fr/api/Push", "Url":"http://salmon.voie93quarts.fr/api/",
"Period":15000, "Period":15000,
"Watch":[ "Watch":[
{ {

View File

@ -32,7 +32,7 @@ public class TripletJsonConverter
Debug.Assert(reader.TokenType == JsonTokenType.String); Debug.Assert(reader.TokenType == JsonTokenType.String);
ret.predicate = reader.GetString(); ret.predicate = reader.GetString();
} }
else if(jsonkey == nameof(Triplet.LastFlush)) else if(jsonkey.ToLower() == nameof(Triplet.LastFlush).ToLower())
{ {
Debug.Assert(reader.TokenType == JsonTokenType.String); Debug.Assert(reader.TokenType == JsonTokenType.String);
ret.LastFlush = reader.GetDateTime(); ret.LastFlush = reader.GetDateTime();
@ -52,6 +52,8 @@ public class TripletJsonConverter
else else
throw new NotImplementedException($"Cannot read Triple.value from token type {reader.TokenType}."); throw new NotImplementedException($"Cannot read Triple.value from token type {reader.TokenType}.");
} }
else
Console.WriteLine($"Unknown triplet field {jsonkey} with token type {reader.TokenType}.");
} }
return ret; return ret;