diff --git a/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj b/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj index 59ef310..bf21b0b 100644 --- a/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj +++ b/src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj @@ -1,6 +1,6 @@  - 10.6.4 + 10.6.5 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 1283c1e..b7b8590 100644 --- a/src/ODataProvider.cs +++ b/src/ODataProvider.cs @@ -102,6 +102,12 @@ public string EndpointId [AddInParameterSection("Advanced activity settings")] public string DeltaModifier { get; set; } + [AddInParameter("Fail job if endpoint is busy or down")] + [AddInParameterEditor(typeof(YesNoParameterEditor), "Tooltip=If endpoint is busy or down during the run time, it will not insert already imported rows.")] + [AddInParameterGroup("Source")] + [AddInParameterSection("Advanced activity settings")] + public bool FailJobOnEndpointIsBusy { get; set; } + #endregion #region AddInManager/ConfigurableAddIn Destination @@ -455,7 +461,7 @@ public override ISourceReader GetReader(Mapping mapping) DoNotStoreLastResponseInLogFile = false; } - return new ODataSourceReader(new HttpRestClient(_credentials, RequestTimeout), Logger, mapping, _endpoint, Mode, DeltaModifier, MaximumPageSize, RunLastRequest, RequestIntervals, DoNotStoreLastResponseInLogFile); + return new ODataSourceReader(new HttpRestClient(_credentials, RequestTimeout), Logger, mapping, _endpoint, Mode, DeltaModifier, MaximumPageSize, RunLastRequest, RequestIntervals, DoNotStoreLastResponseInLogFile, FailJobOnEndpointIsBusy); } /// @@ -541,6 +547,7 @@ public override void UpdateSourceSettings(ISource source) RequestIntervals = newProvider.RequestIntervals; DoNotStoreLastResponseInLogFile = newProvider.DoNotStoreLastResponseInLogFile; EndpointId = newProvider.EndpointId; + FailJobOnEndpointIsBusy = newProvider.FailJobOnEndpointIsBusy; } public ODataProvider() { } @@ -614,6 +621,12 @@ public ODataProvider(XmlNode xmlNode) : this() ContinueOnError = node.FirstChild.Value == "True"; } break; + case "Failjobonendpointisbusy": + if (node.HasChildNodes) + { + FailJobOnEndpointIsBusy = node.FirstChild.Value == "True"; + } + break; } } } @@ -633,6 +646,7 @@ public override string Serialize() root.Add(CreateParameterNode(GetType(), "Predefined endpoint", EndpointId)); root.Add(CreateParameterNode(GetType(), "Destination endpoint", DestinationEndpointId)); root.Add(CreateParameterNode(GetType(), "Continue on error", ContinueOnError.ToString())); + root.Add(CreateParameterNode(GetType(), "Fail job if endpoint is busy or down", FailJobOnEndpointIsBusy.ToString())); return document.ToString(); } @@ -649,6 +663,7 @@ public override void SaveAsXml(XmlTextWriter textWriter) textWriter.WriteElementString("Predefinedendpoint", EndpointId); textWriter.WriteElementString("Destinationendpoint", DestinationEndpointId); textWriter.WriteElementString("Continueonerror", ContinueOnError.ToString()); + textWriter.WriteElementString("Failjobonendpointisbusy", FailJobOnEndpointIsBusy.ToString()); GetSchema().SaveAsXml(textWriter); } diff --git a/src/ODataSourceReader.cs b/src/ODataSourceReader.cs index df75189..d29288d 100644 --- a/src/ODataSourceReader.cs +++ b/src/ODataSourceReader.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Data; -using System.Globalization; using System.IO; using System.Linq; using System.Net; @@ -44,6 +43,7 @@ internal class ODataSourceReader : ISourceReader private bool _requestTimedOutFromGlobalSettings; private readonly int _maximumCharacterLengthOfAutoAddedSelectStatement = 1250; private readonly int _timeoutInMilliseconds; + private readonly bool _failJobOnEndpointIsBusy; internal void SaveRequestResponseFile() { @@ -95,7 +95,7 @@ private void DeleteHighWaterMarkFile() /// The mapping. /// The endpoint. /// Name of the next pagination URL. "odata.nextLink" (case insensitive) is supposed to be a standard. - internal ODataSourceReader(IHttpRestClient httpRestClient, ILogger logger, Mapping mapping, Endpoint endpoint, string mode, string deltaModifier, int maximumPageSize, bool readFromLastRequestResponse, int requestIntervals, bool doNotStoreLastResponseInLogFile, string nextPaginationUrlName = "odata.nextLink") + internal ODataSourceReader(IHttpRestClient httpRestClient, ILogger logger, Mapping mapping, Endpoint endpoint, string mode, string deltaModifier, int maximumPageSize, bool readFromLastRequestResponse, int requestIntervals, bool doNotStoreLastResponseInLogFile, bool failJobOnEndpointIsBusy, string nextPaginationUrlName = "odata.nextLink") { _totalResponseResult = new List>(); _httpRestClient = httpRestClient; @@ -109,6 +109,7 @@ internal ODataSourceReader(IHttpRestClient httpRestClient, ILogger logger, Mappi _requestIntervals = requestIntervals; _doNotStoreLastResponseInLogFile = doNotStoreLastResponseInLogFile; _timeoutInMilliseconds = GetTimeOutInMilliseconds(); + _failJobOnEndpointIsBusy = failJobOnEndpointIsBusy; string logFileName = Scheduling.Task.MakeSafeFileName(mapping.Job.Name) + $"_{_mapping.SourceTable.Name}.log"; IDictionary headers = GetAllHeaders(); @@ -604,7 +605,7 @@ private bool HandleRequest(string url, string loggerInfo, IDictionary