diff --git a/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj index 6a59465..d5945fb 100644 --- a/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj +++ b/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj @@ -1,6 +1,6 @@  - 10.0.11 + 10.0.12 1.0.0.0 OData Provider The Odata Provider lets you fetch and map data from or to any OData endpoint. diff --git a/src/ODataProvider.cs b/src/ODataProvider.cs index 9a0dc37..6b9acb0 100644 --- a/src/ODataProvider.cs +++ b/src/ODataProvider.cs @@ -7,6 +7,7 @@ using Dynamicweb.DataIntegration.Providers.ODataProvider.Model; using Dynamicweb.Extensibility.AddIns; using Dynamicweb.Extensibility.Editors; +using Dynamicweb.Logging; using Dynamicweb.Security.Licensing; using System; using System.Collections.Generic; @@ -688,7 +689,8 @@ public override bool RunJob(Job job) catch (Exception e) { Logger?.Log(e.ToString()); - throw; + LogManager.System.GetLogger(LogCategory.Application, "Dataintegration").Error($"{GetType().Name} error: {e.Message} Stack: {e.StackTrace}", e); + return false; } } } diff --git a/src/ODataSourceReader.cs b/src/ODataSourceReader.cs index 26d9e2f..15884b5 100644 --- a/src/ODataSourceReader.cs +++ b/src/ODataSourceReader.cs @@ -322,7 +322,7 @@ private List GetSelectAsParameters() } else { - _logger?.Info("Detected many active column mappings, so will not auto add $select with all active column mappings and by that limit the data recieved from Endpoint."); + _logger?.Info("Detected many active column mappings, so will not auto add $select with all active column mappings and by that limit the data received from Endpoint."); } } return result; diff --git a/src/ODataWriter.cs b/src/ODataWriter.cs index 8cc4349..bbd65a9 100644 --- a/src/ODataWriter.cs +++ b/src/ODataWriter.cs @@ -67,12 +67,8 @@ public void Write(Dictionary Row) var responseFromEndpoint = GetFromEndpoint(url, null); if (!string.IsNullOrEmpty(responseFromEndpoint?.Result?.Error)) { - if (responseFromEndpoint.Result.Status == HttpStatusCode.Unauthorized) - { - throw new Exception(responseFromEndpoint.Result.Error); - } - Logger?.Warn($"Error Url: {url}. Response Error: {responseFromEndpoint.Result.Error}. Status response code: {responseFromEndpoint.Result.Status}"); - return; + Logger?.Error($"Error Url: {url}. Response Error: {responseFromEndpoint.Result.Error}. Status response code: {responseFromEndpoint.Result.Status}"); + throw new Exception(responseFromEndpoint.Result.Error); } var response = responseFromEndpoint?.Result?.Content?.Value; @@ -86,7 +82,7 @@ public void Write(Dictionary Row) } var jsonObject = response[0]; - Logger?.Info($"Recieved response from Endpoint = {jsonObject.ToJsonString()}"); + Logger?.Info($"Received response from Endpoint = {jsonObject.ToJsonString()}"); var patchJson = MapValuesToJSon(columnMappings, Row, true); if (patchJson.Equals(new JsonObject().ToString())) @@ -139,14 +135,15 @@ public void Write(Dictionary Row) awaitResponseFromEndpoint.Wait(); if (!string.IsNullOrEmpty(awaitResponseFromEndpoint?.Result?.Error)) { - Logger?.Warn($"Error Url: {url}. Response Error: {awaitResponseFromEndpoint.Result.Error}. Status response code: {awaitResponseFromEndpoint.Result.Status}"); + Logger?.Error($"Error Url: {url}. Response Error: {awaitResponseFromEndpoint.Result.Error}. Status response code: {awaitResponseFromEndpoint.Result.Status}"); + throw new Exception(awaitResponseFromEndpoint.Result.Error); } PostBackObject = awaitResponseFromEndpoint?.Result?.Content; if (awaitResponseFromEndpoint?.Result?.Status != HttpStatusCode.NoContent) { - Logger?.Info($"Recieved response from Endpoint = {PostBackObject?.ToJsonString()}"); + Logger?.Info($"Received response from Endpoint = {PostBackObject?.ToJsonString()}"); } else if (_responseMappings.Any()) { @@ -154,7 +151,7 @@ public void Write(Dictionary Row) } else { - Logger?.Info($"Recieved no response from Endpoint"); + Logger?.Info($"Received no response from Endpoint"); } } @@ -281,7 +278,7 @@ internal string MapValuesToJSon(ColumnMappingCollection columnMappings, Dictiona } } } - return jsonObject.ToString(); + return jsonObject.ToJsonString(); } public static string GetTheDateTimeInZeroTimeZone(object dateTimeObject, bool isEdmDate)