Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged PR 10546 into this. bump version to 10.0.10 #21

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
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
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.9</Version>
<Version>10.0.10</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>OData Provider</Title>
<Description>The Odata Provider lets you fetch and map data from or to any OData endpoint.</Description>
Expand Down
22 changes: 18 additions & 4 deletions src/ODataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class ODataProvider : BaseProvider, ISource, IDestination, IParameterOpti
internal Schema _schema;
internal Endpoint _endpoint;
internal ICredentials _credentials;
internal ODataSourceReader _endpointSourceReader;
private const string OldBCBatch = "eCom_DataIntegrationERPBatch";
private const string BCBatch = "eCom_DataIntegrationERPBatch_BC";
private const string CRMBatch = "eCom_DataIntegrationERPBatch_CRM";
Expand Down Expand Up @@ -96,6 +95,12 @@ public string EndpointId
[AddInParameterSection("Advanced activity settings")]
public bool DoNotStoreLastResponseInLogFile { get; set; }

[AddInParameter("Delta modifier")]
[AddInParameterEditor(typeof(TextParameterEditor), "infoText=Add your own delta properties. Default looking at these properties: Last_Date_Modified, Order_Date, LastDateTimeModified, lastModifiedDateTime and modifiedon.;inputClass=NewUIinput;")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public string DeltaModifier { get; set; }

#endregion

#region AddInManager/ConfigurableAddIn Destination
Expand Down Expand Up @@ -137,7 +142,7 @@ private string GetMetadataURL()

private string GetEntityName()
{
return new Uri(_endpoint.Url).Segments.LastOrDefault() ?? "";
return new Uri(_endpoint.Url).Segments.LastOrDefault().TrimEnd('/') ?? "";
}

internal void SetCredentials()
Expand Down Expand Up @@ -404,8 +409,8 @@ public override ISourceReader GetReader(Mapping mapping)
RequestIntervals = 0;
DoNotStoreLastResponseInLogFile = false;
}
_endpointSourceReader = new ODataSourceReader(new HttpRestClient(_credentials, RequestTimeout), Logger, mapping, _endpoint, Mode, MaximumPageSize, RunLastRequest, RequestIntervals, DoNotStoreLastResponseInLogFile);
return _endpointSourceReader;

return new ODataSourceReader(new HttpRestClient(_credentials, RequestTimeout), Logger, mapping, _endpoint, Mode, DeltaModifier, MaximumPageSize, RunLastRequest, RequestIntervals, DoNotStoreLastResponseInLogFile);
}

/// <inheritdoc />
Expand Down Expand Up @@ -479,6 +484,7 @@ public override void UpdateSourceSettings(ISource source)
{
ODataProvider newProvider = (ODataProvider)source;
Mode = newProvider.Mode;
DeltaModifier = newProvider.DeltaModifier;
MaximumPageSize = newProvider.MaximumPageSize;
RequestTimeout = newProvider.RequestTimeout;
RunLastRequest = newProvider.RunLastRequest;
Expand All @@ -504,6 +510,12 @@ public ODataProvider(XmlNode xmlNode) : this()
Mode = node.FirstChild.Value;
}
break;
case "Deltamodifier":
if (node.HasChildNodes)
{
DeltaModifier = node.FirstChild.Value;
}
break;
case "Maximumpagesize":
if (node.HasChildNodes)
{
Expand Down Expand Up @@ -556,6 +568,7 @@ public override string Serialize()
var root = new XElement("Parameters");
document.Add(root);
root.Add(CreateParameterNode(GetType(), "Mode", Mode));
root.Add(CreateParameterNode(GetType(), "Delta modifier", DeltaModifier));
root.Add(CreateParameterNode(GetType(), "Maximum page size", MaximumPageSize.ToString()));
root.Add(CreateParameterNode(GetType(), "Request timeout (minutes)", RequestTimeout.ToString()));
root.Add(CreateParameterNode(GetType(), "Run last response", RunLastRequest.ToString()));
Expand All @@ -570,6 +583,7 @@ public override string Serialize()
public override void SaveAsXml(XmlTextWriter textWriter)
{
textWriter.WriteElementString("Mode", Mode);
textWriter.WriteElementString("Deltamodifier", DeltaModifier);
textWriter.WriteElementString("Maximumpagesize", MaximumPageSize.ToString());
textWriter.WriteElementString("Requesttimeout", RequestTimeout.ToString());
textWriter.WriteElementString("Runlastrequest", RunLastRequest.ToString());
Expand Down
57 changes: 38 additions & 19 deletions src/ODataSourceReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal class ODataSourceReader : ISourceReader
private readonly Mapping _mapping;
private readonly Endpoint _endpoint;
private readonly string _mode;
private readonly string _deltaModifier;
private readonly int _maximumPageSize;
private readonly string _nextPaginationUrlName;
private Dictionary<string, object> _nextItem;
Expand Down Expand Up @@ -93,14 +94,15 @@ private void DeleteHighWaterMarkFile()
/// <param name="mapping">The mapping.</param>
/// <param name="endpoint">The endpoint.</param>
/// <param name="nextPaginationUrlName">Name of the next pagination URL. "odata.nextLink" (case insensitive) is supposed to be a standard.</param>
internal ODataSourceReader(IHttpRestClient httpRestClient, ILogger logger, Mapping mapping, Endpoint endpoint, string mode, 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, string nextPaginationUrlName = "odata.nextLink")
{
_totalResponseResult = new List<Dictionary<string, object>>();
_httpRestClient = httpRestClient;
_logger = logger;
_mapping = mapping;
_endpoint = endpoint;
_mode = mode;
_deltaModifier = deltaModifier;
_maximumPageSize = maximumPageSize;
_nextPaginationUrlName = nextPaginationUrlName;
_requestIntervals = requestIntervals;
Expand Down Expand Up @@ -246,29 +248,46 @@ private string GetModeAsParameters()
string dateTimeFilterName = "";
bool isEdmDate = false;

foreach (var column in _mapping.SourceTable.Columns)
if (!string.IsNullOrEmpty(_deltaModifier))
{
switch (column.Name)
List<string> deltaModifiers = _deltaModifier.Split(',').Select(val => val.Trim()).ToList();
foreach (var delta in deltaModifiers)
{
case "Last_Date_Modified":
dateTimeFilterName = "Last_Date_Modified";
isEdmDate = true;
break;
case "Order_Date":
dateTimeFilterName = "Order_Date";
isEdmDate = true;
break;
case "LastDateTimeModified":
dateTimeFilterName = "LastDateTimeModified";
break;
case "lastModifiedDateTime":
dateTimeFilterName = "lastModifiedDateTime";
break;
case "modifiedon":
dateTimeFilterName = "modifiedon";
if (_mapping.SourceTable.Columns.Any(obj => obj.Name.Equals(delta, StringComparison.OrdinalIgnoreCase)))
{
dateTimeFilterName = _mapping.SourceTable.Columns.Where(obj => obj.Name.Equals(delta, StringComparison.OrdinalIgnoreCase)).First().Name;
break;
}
}
}

if (string.IsNullOrWhiteSpace(dateTimeFilterName))
{
foreach (var column in _mapping.SourceTable.Columns)
{
switch (column.Name)
{
case "Last_Date_Modified":
dateTimeFilterName = "Last_Date_Modified";
isEdmDate = true;
break;
case "Order_Date":
dateTimeFilterName = "Order_Date";
isEdmDate = true;
break;
case "LastDateTimeModified":
dateTimeFilterName = "LastDateTimeModified";
break;
case "lastModifiedDateTime":
dateTimeFilterName = "lastModifiedDateTime";
break;
case "modifiedon":
dateTimeFilterName = "modifiedon";
break;
}
}
}

if (!string.IsNullOrWhiteSpace(dateTimeFilterName))
{
if (isEdmDate)
Expand Down