-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VP-364: Added complex data source support; (#19)
* Added complex data source support; * Fixed properties filling script error;
- Loading branch information
Showing
27 changed files
with
293 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
VirtoCommerce.ExportModule.Core/Models/ExportableSearchResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Domain" version="2.25.19" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Platform.Core" version="2.13.39" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Domain" version="2.25.27" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Platform.Core" version="2.13.42" targetFramework="net461" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
VirtoCommerce.ExportModule.Data/Extensions/IPagedDataSourceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using VirtoCommerce.ExportModule.Core.Model; | ||
|
||
namespace VirtoCommerce.ExportModule.Data.Extensions | ||
{ | ||
public static class IPagedDataSourceCollectionExtensions | ||
{ | ||
public static IEnumerable<IExportable> GetItems(this IEnumerable<IPagedDataSource> datasources, int skip, int take) | ||
{ | ||
var taskList = new List<Task<IEnumerable<IExportable>>>(); | ||
|
||
foreach (var datasource in datasources) | ||
{ | ||
var totalCount = datasource.GetTotalCount(); | ||
|
||
var currentSkip = Math.Min(totalCount, skip); | ||
var currentTake = Math.Min(take, Math.Max(0, totalCount - skip)); | ||
|
||
if (currentSkip <= 0 && currentTake <= 0) | ||
{ | ||
break; | ||
} | ||
else if (currentSkip < totalCount && currentTake > 0) | ||
{ | ||
datasource.Skip = currentSkip; | ||
datasource.Take = currentTake; | ||
taskList.Add(Task.Factory.StartNew(() => datasource.Fetch() ? datasource.Items : Array.Empty<IExportable>())); | ||
} | ||
|
||
skip -= currentSkip; | ||
take -= currentTake; | ||
} | ||
|
||
Task.WhenAll(taskList).GetAwaiter().GetResult(); | ||
|
||
return taskList.SelectMany(x => x.Result).ToList(); | ||
} | ||
} | ||
} |
124 changes: 0 additions & 124 deletions
124
VirtoCommerce.ExportModule.Data/Services/ComplexExportPagedDataSource.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Platform.Core" version="2.13.39" targetFramework="net461" /> | ||
<package id="VirtoCommerce.Platform.Core" version="2.13.42" targetFramework="net461" /> | ||
</packages> |
10 changes: 10 additions & 0 deletions
10
...Commerce.ExportModule.Tests/ComplexExportPagedDataSourceTests/Mocks/ITestSearchService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Threading.Tasks; | ||
using VirtoCommerce.ExportModule.Core.Model; | ||
|
||
namespace VirtoCommerce.ExportModule.Tests.ComplexExportPagedDataSourceTests.Mocks | ||
{ | ||
public interface ITestSearchService | ||
{ | ||
Task<ExportableSearchResult> SearchAsync(TestSearchCriteria searchCriteria); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ommerce.ExportModule.Tests/ComplexExportPagedDataSourceTests/Mocks/TestExportDataQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using VirtoCommerce.ExportModule.Core.Model; | ||
|
||
namespace VirtoCommerce.ExportModule.Tests.ComplexExportPagedDataSourceTests.Mocks | ||
{ | ||
public class TestExportDataQuery : ExportDataQuery | ||
{ | ||
} | ||
} |
Oops, something went wrong.