From 70a77f3472b48f3c1402a7635f6646207db8eda0 Mon Sep 17 00:00:00 2001 From: Mark van der Wal Date: Wed, 8 Apr 2020 20:23:22 +0200 Subject: [PATCH] refactored program --- FarmmapsApi/Extensions.cs | 27 ----- FarmmapsApi/FarmmapsProgram.cs | 52 +++++++++ FarmmapsApi/IApplication.cs | 9 ++ FarmmapsApi/Services/GeneralService.cs | 18 +++ FarmmapsApiSamples.sln | 2 +- FarmmapsApiSamples/ITestFlow.cs | 11 -- FarmmapsApiSamples/Program.cs | 78 ------------- .../Data/Herbicide/Lutum.tiff | Bin .../Data/Herbicide/vd_born_lutum.zip | Bin .../Data/Herbicide/vd_born_om.zip | Bin .../Data/Nbs/Scan_1_20190605.zip | Bin .../FarmmapsNbs.csproj | 0 .../HerbicideService.cs | 2 +- .../Models/HerbicideAgent.cs | 0 FarmmapsNbs/NbsApplication.cs | 107 ++++++++++++++++++ .../NitrogenService.cs | 81 +------------ FarmmapsNbs/Program.cs | 23 ++++ .../appsettings.json | 2 +- 18 files changed, 213 insertions(+), 199 deletions(-) create mode 100644 FarmmapsApi/FarmmapsProgram.cs create mode 100644 FarmmapsApi/IApplication.cs delete mode 100644 FarmmapsApiSamples/ITestFlow.cs delete mode 100644 FarmmapsApiSamples/Program.cs rename {FarmmapsApiSamples => FarmmapsNbs}/Data/Herbicide/Lutum.tiff (100%) rename {FarmmapsApiSamples => FarmmapsNbs}/Data/Herbicide/vd_born_lutum.zip (100%) rename {FarmmapsApiSamples => FarmmapsNbs}/Data/Herbicide/vd_born_om.zip (100%) rename {FarmmapsApiSamples => FarmmapsNbs}/Data/Nbs/Scan_1_20190605.zip (100%) rename FarmmapsApiSamples/FarmmapsApiSamples.csproj => FarmmapsNbs/FarmmapsNbs.csproj (100%) rename {FarmmapsApiSamples => FarmmapsNbs}/HerbicideService.cs (99%) rename {FarmmapsApiSamples => FarmmapsNbs}/Models/HerbicideAgent.cs (100%) create mode 100644 FarmmapsNbs/NbsApplication.cs rename {FarmmapsApiSamples => FarmmapsNbs}/NitrogenService.cs (65%) create mode 100644 FarmmapsNbs/Program.cs rename {FarmmapsApiSamples => FarmmapsNbs}/appsettings.json (98%) diff --git a/FarmmapsApi/Extensions.cs b/FarmmapsApi/Extensions.cs index a9b80dd..b15a9d7 100644 --- a/FarmmapsApi/Extensions.cs +++ b/FarmmapsApi/Extensions.cs @@ -1,38 +1,11 @@ using System; -using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using FarmmapsApi.HttpMessageHandlers; -using FarmmapsApi.Models; -using FarmmapsApi.Services; -using IdentityModel.Client; -using Microsoft.Extensions.DependencyInjection; namespace FarmmapsApi { public static class Extensions { - public static IServiceCollection AddFarmmapsServices(this IServiceCollection serviceCollection, - Configuration configuration) - { - return serviceCollection - .AddSingleton(configuration) - .AddSingleton(sp => - { - var httpFactory = sp.GetRequiredService(); - return new DiscoveryCache(configuration.DiscoveryEndpointUrl, - () => httpFactory.CreateClient()); - }) - .AddSingleton() - .AddSingleton() - .AddTransient() - .AddTransient() - .AddTransient() - .AddHttpClient() - .AddHttpMessageHandler() - .Services; - } - public static async Task PollTask(TimeSpan retryTime, Func callback) { var tokenSource = new CancellationTokenSource(); diff --git a/FarmmapsApi/FarmmapsProgram.cs b/FarmmapsApi/FarmmapsProgram.cs new file mode 100644 index 0000000..b1bc874 --- /dev/null +++ b/FarmmapsApi/FarmmapsProgram.cs @@ -0,0 +1,52 @@ +using System.Net.Http; +using System.Threading.Tasks; +using FarmmapsApi.HttpMessageHandlers; +using FarmmapsApi.Models; +using FarmmapsApi.Services; +using IdentityModel.Client; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace FarmmapsApi +{ + public abstract class FarmmapsProgram where T : class, IApplication + { + public async Task Start(string[] args) + { + IConfiguration config = new ConfigurationBuilder() + .AddJsonFile("appsettings.json", false, true) + .Build(); + + var configuration = config.Get(); + + var serviceCollection = new ServiceCollection() + .AddSingleton(configuration) + .AddSingleton(sp => + { + var httpFactory = sp.GetRequiredService(); + return new DiscoveryCache(configuration.DiscoveryEndpointUrl, + () => httpFactory.CreateClient()); + }) + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddTransient() + .AddTransient() + .AddTransient() + .AddHttpClient() + .AddHttpMessageHandler() + .Services; + + + Configure(serviceCollection); + + var serviceProvider = serviceCollection.BuildServiceProvider(); + await serviceProvider.GetService().AuthenticateAsync(); +// await serviceProvider.GetService().StartEventHub(); + + await serviceProvider.GetRequiredService().RunAsync(); + } + + protected abstract void Configure(IServiceCollection serviceCollection); + } +} \ No newline at end of file diff --git a/FarmmapsApi/IApplication.cs b/FarmmapsApi/IApplication.cs new file mode 100644 index 0000000..1760573 --- /dev/null +++ b/FarmmapsApi/IApplication.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace FarmmapsApi +{ + public interface IApplication + { + Task RunAsync(); + } +} \ No newline at end of file diff --git a/FarmmapsApi/Services/GeneralService.cs b/FarmmapsApi/Services/GeneralService.cs index c2ec636..8a8405f 100644 --- a/FarmmapsApi/Services/GeneralService.cs +++ b/FarmmapsApi/Services/GeneralService.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using FarmmapsApi.Models; using Google.Apis.Upload; using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; using static FarmmapsApi.Extensions; using static FarmmapsApiSamples.Constants; @@ -24,6 +25,23 @@ namespace FarmmapsApi.Services _farmmapsApiService = farmmapsApiService; } + public async Task CreateCropfieldItemAsync(string parentItemCode, string name, int year, string fieldGeomJson) + { + var currentYear = new DateTime(year, 1, 1); + var cropfieldItemRequest = new ItemRequest() + { + ParentCode = parentItemCode, + ItemType = CROPFIELD_ITEMTYPE, + Name = name, + DataDate = currentYear, + DataEndDate = currentYear.AddYears(1).AddDays(-1), + Data = JObject.Parse("{}"), + Geometry = JObject.Parse(fieldGeomJson) + }; + + return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest); + } + public async Task UploadDataAsync(UserRoot root, string itemType, string filePath, string itemName) { var startUpload = DateTime.UtcNow; diff --git a/FarmmapsApiSamples.sln b/FarmmapsApiSamples.sln index ccf1ab2..68a518c 100644 --- a/FarmmapsApiSamples.sln +++ b/FarmmapsApiSamples.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmmapsApiSamples", "FarmmapsApiSamples\FarmmapsApiSamples.csproj", "{E08EF7E9-F09E-42D8-825C-164E458C78F4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmmapsNbs", "FarmmapsNbs\FarmmapsNbs.csproj", "{E08EF7E9-F09E-42D8-825C-164E458C78F4}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmmapsApi", "FarmmapsApi\FarmmapsApi.csproj", "{1FA9E50B-F45E-4534-953A-37C783D03C74}" EndProject diff --git a/FarmmapsApiSamples/ITestFlow.cs b/FarmmapsApiSamples/ITestFlow.cs deleted file mode 100644 index 47050bb..0000000 --- a/FarmmapsApiSamples/ITestFlow.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using FarmmapsApi.Models; - -namespace FarmmapsApiSamples -{ - public interface ITestFlow - { - Task TestFlow(List roots); - } -} \ No newline at end of file diff --git a/FarmmapsApiSamples/Program.cs b/FarmmapsApiSamples/Program.cs deleted file mode 100644 index 55e7675..0000000 --- a/FarmmapsApiSamples/Program.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Threading.Tasks; -using FarmmapsApi; -using FarmmapsApi.Models; -using FarmmapsApi.Services; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -namespace FarmmapsApiSamples -{ - class Program - { - private readonly ILogger _logger; - private readonly FarmmapsApiService _farmmapsApiService; - private readonly FarmmapsEventHub _farmmapsEventHub; - private readonly NitrogenService _nitrogenService; - private readonly HerbicideService _herbicideService; - - private static async Task Main(string[] args) - { - IConfiguration config = new ConfigurationBuilder() - .AddJsonFile("appsettings.json", false, true) - .Build(); - - var configuration = config.Get(); - - var serviceProvider = new ServiceCollection() - .AddLogging(opts => opts - .AddConsole() - .AddFilter("System.Net.Http", LogLevel.Warning)) - .AddFarmmapsServices(configuration) - .AddTransient() - .AddTransient() - .AddSingleton() - .BuildServiceProvider(); - - await serviceProvider.GetService().AuthenticateAsync(); -// await serviceProvider.GetService().StartEventHub(); - await serviceProvider.GetService().RunAsync(); - } - - public Program(ILogger logger, FarmmapsApiService farmmapsApiService, - FarmmapsEventHub farmmapsEventHub, NitrogenService nitrogenService, - HerbicideService herbicideService) - { - _logger = logger; - _farmmapsApiService = farmmapsApiService; - _farmmapsEventHub = farmmapsEventHub; - _nitrogenService = nitrogenService; - _herbicideService = herbicideService; - - _farmmapsEventHub.EventCallback += OnEvent; - } - - private void OnEvent(EventMessage @event) - { -// _logger.LogInformation(@event.EventType); - } - - public async Task RunAsync() - { - try - { - // !! this call is needed the first time an api is called with a fresh clientid and secret !! - await _farmmapsApiService.GetCurrentUserCodeAsync(); - var roots = await _farmmapsApiService.GetCurrentUserRootsAsync(); - - await _nitrogenService.TestFlow(roots); -// await _herbicideService.TestFlow(roots); - } - catch (Exception ex) - { - _logger.LogError(ex.Message); - } - } - } -} \ No newline at end of file diff --git a/FarmmapsApiSamples/Data/Herbicide/Lutum.tiff b/FarmmapsNbs/Data/Herbicide/Lutum.tiff similarity index 100% rename from FarmmapsApiSamples/Data/Herbicide/Lutum.tiff rename to FarmmapsNbs/Data/Herbicide/Lutum.tiff diff --git a/FarmmapsApiSamples/Data/Herbicide/vd_born_lutum.zip b/FarmmapsNbs/Data/Herbicide/vd_born_lutum.zip similarity index 100% rename from FarmmapsApiSamples/Data/Herbicide/vd_born_lutum.zip rename to FarmmapsNbs/Data/Herbicide/vd_born_lutum.zip diff --git a/FarmmapsApiSamples/Data/Herbicide/vd_born_om.zip b/FarmmapsNbs/Data/Herbicide/vd_born_om.zip similarity index 100% rename from FarmmapsApiSamples/Data/Herbicide/vd_born_om.zip rename to FarmmapsNbs/Data/Herbicide/vd_born_om.zip diff --git a/FarmmapsApiSamples/Data/Nbs/Scan_1_20190605.zip b/FarmmapsNbs/Data/Nbs/Scan_1_20190605.zip similarity index 100% rename from FarmmapsApiSamples/Data/Nbs/Scan_1_20190605.zip rename to FarmmapsNbs/Data/Nbs/Scan_1_20190605.zip diff --git a/FarmmapsApiSamples/FarmmapsApiSamples.csproj b/FarmmapsNbs/FarmmapsNbs.csproj similarity index 100% rename from FarmmapsApiSamples/FarmmapsApiSamples.csproj rename to FarmmapsNbs/FarmmapsNbs.csproj diff --git a/FarmmapsApiSamples/HerbicideService.cs b/FarmmapsNbs/HerbicideService.cs similarity index 99% rename from FarmmapsApiSamples/HerbicideService.cs rename to FarmmapsNbs/HerbicideService.cs index c42216a..b9999ba 100644 --- a/FarmmapsApiSamples/HerbicideService.cs +++ b/FarmmapsNbs/HerbicideService.cs @@ -14,7 +14,7 @@ using static FarmmapsApiSamples.Constants; namespace FarmmapsApiSamples { - public class HerbicideService : ITestFlow + public class HerbicideService { private readonly ILogger _logger; private readonly FarmmapsApiService _farmmapsApiService; diff --git a/FarmmapsApiSamples/Models/HerbicideAgent.cs b/FarmmapsNbs/Models/HerbicideAgent.cs similarity index 100% rename from FarmmapsApiSamples/Models/HerbicideAgent.cs rename to FarmmapsNbs/Models/HerbicideAgent.cs diff --git a/FarmmapsNbs/NbsApplication.cs b/FarmmapsNbs/NbsApplication.cs new file mode 100644 index 0000000..92ae961 --- /dev/null +++ b/FarmmapsNbs/NbsApplication.cs @@ -0,0 +1,107 @@ +using System; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using FarmmapsApi; +using FarmmapsApi.Services; +using Microsoft.Extensions.Logging; + +namespace FarmmapsApiSamples +{ + public class NbsApplication : IApplication + { + private const string DownloadFolder = "Downloads"; + + private readonly ILogger _logger; + private readonly FarmmapsApiService _farmmapsApiService; + private readonly FarmmapsEventHub _farmmapsEventHub; + private readonly NitrogenService _nitrogenService; + private readonly GeneralService _generalService; + + public NbsApplication(ILogger logger, FarmmapsApiService farmmapsApiService, + GeneralService generalService, NitrogenService nitrogenService) + { + _logger = logger; + _farmmapsApiService = farmmapsApiService; + _generalService = generalService; + _nitrogenService = nitrogenService; + } + + public async Task RunAsync() + { + try + { + // !! this call is needed the first time an api is called with a fresh clientid and secret !! + await _farmmapsApiService.GetCurrentUserCodeAsync(); + var roots = await _farmmapsApiService.GetCurrentUserRootsAsync(); + + if (!Directory.Exists(DownloadFolder)) + Directory.CreateDirectory(DownloadFolder); + + var plantingDate = new DateTime(DateTime.UtcNow.Year, 2, 1); + var measurementDate = plantingDate.AddMonths(5); + + var uploadedRoot = roots.SingleOrDefault(r => r.Name == "Uploaded"); + if (uploadedRoot == null) + { + _logger.LogError("Could not find a needed root item"); + return; + } + + var myDriveRoot = roots.SingleOrDefault(r => r.Name == "My drive"); + if (myDriveRoot == null) + { + _logger.LogError("Could not find a needed root item"); + return; + } + + var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDriveRoot.Code, "VRA NBS cropfield", 2020, + @"{ ""type"": ""Polygon"", ""coordinates"": [ [ [ 3.40843828875524, 50.638966444680605 ], [ 3.408953272886064, 50.639197789621612 ], [ 3.409242951459603, 50.639469958681836 ], [ 3.409328782148028, 50.639612846807708 ], [ 3.409457528180712, 50.639789755314411 ], [ 3.409639918393741, 50.640014292074966 ], [ 3.409833037442765, 50.640211611372706 ], [ 3.410069071836049, 50.640395321698435 ], [ 3.410380208081761, 50.640572227259661 ], [ 3.410605513638958, 50.640715112034222 ], [ 3.411925160474145, 50.641177783561204 ], [ 3.411935889310142, 50.640728720085136 ], [ 3.412590348309737, 50.63948356709389 ], [ 3.413244807309242, 50.638224772339846 ], [ 3.413400375432099, 50.637901562841307 ], [ 3.413539850300779, 50.637449065809889 ], [ 3.413475477284437, 50.637418445552932 ], [ 3.40999396998362, 50.637449065810451 ], [ 3.409940325803365, 50.638102293212661 ], [ 3.409575545377398, 50.638483338338325 ], [ 3.409060561246574, 50.638707881340494 ], [ 3.40843828875524, 50.638966444680605 ] ] ] }"); + + var dataPath = Path.Combine("Data", "Nbs", "Scan_1_20190605.zip"); + var isariaShapeItem = + await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, "Scan_1_20190605"); + if (isariaShapeItem == null) + { + _logger.LogError("Could not find isaria shape item"); + return; + } + + _logger.LogInformation($"Converting shape to geotiff"); + var isariaGeotiffItem = await _generalService.ShapeToGeotiff(isariaShapeItem); + if (isariaGeotiffItem == null) + { + _logger.LogError("Something went wrong with isaria shape to geotiff transformation"); + return; + } + + _logger.LogInformation($"Calculating targetN with targetYield: {60}"); + var targetNItem = await _nitrogenService.CreateTargetNItem(cropfieldItem); + var targetN = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate, measurementDate, + "consumption", "irmi", 60); + _logger.LogInformation($"TargetN: {targetN}"); + + _logger.LogInformation("Calculating uptake map"); + var uptakeMapItem = + await _nitrogenService.CalculateUptakeMap(cropfieldItem, isariaGeotiffItem, plantingDate, measurementDate); + + _logger.LogInformation("Downloading uptake map"); + await _farmmapsApiService.DownloadItemAsync(uptakeMapItem.Code, + Path.Combine(DownloadFolder, $"{uptakeMapItem.Name}.zip")); + + _logger.LogInformation("Calculating appliance map"); + var applianceMapItem = + await _nitrogenService.CalculateApplicationMap(cropfieldItem, isariaGeotiffItem, plantingDate, measurementDate, + "irmi", targetN); + + _logger.LogInformation("Downloading appliance map"); + await _farmmapsApiService.DownloadItemAsync(applianceMapItem.Code, + Path.Combine(DownloadFolder, $"{applianceMapItem.Name}.zip")); + } + catch (Exception ex) + { + _logger.LogError(ex.Message); + } + } + } +} \ No newline at end of file diff --git a/FarmmapsApiSamples/NitrogenService.cs b/FarmmapsNbs/NitrogenService.cs similarity index 65% rename from FarmmapsApiSamples/NitrogenService.cs rename to FarmmapsNbs/NitrogenService.cs index d8481f0..e3d9aad 100644 --- a/FarmmapsApiSamples/NitrogenService.cs +++ b/FarmmapsNbs/NitrogenService.cs @@ -13,7 +13,7 @@ using static FarmmapsApiSamples.Constants; namespace FarmmapsApiSamples { - public class NitrogenService : ITestFlow + public class NitrogenService { private readonly ILogger _logger; private readonly FarmmapsApiService _farmmapsApiService; @@ -27,85 +27,6 @@ namespace FarmmapsApiSamples _generalService = generalService; } - public async Task TestFlow(List roots) - { - var downloadFolder = "Downloads"; - if (!Directory.Exists(downloadFolder)) - Directory.CreateDirectory(downloadFolder); - - var plantingDate = new DateTime(DateTime.UtcNow.Year, 2, 1); - var measurementDate = plantingDate.AddMonths(5); - - var uploadedRoot = roots.SingleOrDefault(r => r.Name == "Uploaded"); - if (uploadedRoot == null) - { - _logger.LogError("Could not find a needed root item"); - return; - } - - var myDriveRoot = roots.SingleOrDefault(r => r.Name == "My drive"); - if (myDriveRoot == null) - { - _logger.LogError("Could not find a needed root item"); - return; - } - - var cropfieldItem = await CreateCropfieldItemAsync(myDriveRoot.Code, "VRA NBS cropfield", 2020, - @"{ ""type"": ""Polygon"", ""coordinates"": [ [ [ 3.40843828875524, 50.638966444680605 ], [ 3.408953272886064, 50.639197789621612 ], [ 3.409242951459603, 50.639469958681836 ], [ 3.409328782148028, 50.639612846807708 ], [ 3.409457528180712, 50.639789755314411 ], [ 3.409639918393741, 50.640014292074966 ], [ 3.409833037442765, 50.640211611372706 ], [ 3.410069071836049, 50.640395321698435 ], [ 3.410380208081761, 50.640572227259661 ], [ 3.410605513638958, 50.640715112034222 ], [ 3.411925160474145, 50.641177783561204 ], [ 3.411935889310142, 50.640728720085136 ], [ 3.412590348309737, 50.63948356709389 ], [ 3.413244807309242, 50.638224772339846 ], [ 3.413400375432099, 50.637901562841307 ], [ 3.413539850300779, 50.637449065809889 ], [ 3.413475477284437, 50.637418445552932 ], [ 3.40999396998362, 50.637449065810451 ], [ 3.409940325803365, 50.638102293212661 ], [ 3.409575545377398, 50.638483338338325 ], [ 3.409060561246574, 50.638707881340494 ], [ 3.40843828875524, 50.638966444680605 ] ] ] }"); - - var dataPath = Path.Combine("Data", "Nbs", "Scan_1_20190605.zip"); - var isariaShapeItem = await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, "Scan_1_20190605"); - if (isariaShapeItem == null) - { - _logger.LogError("Could not find isaria shape item"); - return; - } - - _logger.LogInformation($"Converting shape to geotiff"); - var isariaGeotiffItem = await _generalService.ShapeToGeotiff(isariaShapeItem); - if (isariaGeotiffItem == null) - { - _logger.LogError("Something went wrong with isaria shape to geotiff transformation"); - return; - } - - _logger.LogInformation($"Calculating targetN with targetYield: {60}"); - var targetNItem = await CreateTargetNItem(cropfieldItem); - var targetN = await CalculateTargetN(cropfieldItem, targetNItem, plantingDate, measurementDate, "consumption", "irmi", 60); - _logger.LogInformation($"TargetN: {targetN}"); - - _logger.LogInformation("Calculating uptake map"); - var uptakeMapItem = - await CalculateUptakeMap(cropfieldItem, isariaGeotiffItem, plantingDate, measurementDate); - - _logger.LogInformation("Downloading uptake map"); - await _farmmapsApiService.DownloadItemAsync(uptakeMapItem.Code, Path.Combine(downloadFolder, $"{uptakeMapItem.Name}.zip")); - - _logger.LogInformation("Calculating appliance map"); - var applianceMapItem = - await CalculateApplicationMap(cropfieldItem, isariaGeotiffItem, plantingDate, measurementDate, "irmi", targetN); - - _logger.LogInformation("Downloading appliance map"); - await _farmmapsApiService.DownloadItemAsync(applianceMapItem.Code, Path.Combine(downloadFolder, $"{applianceMapItem.Name}.zip")); - } - - private async Task CreateCropfieldItemAsync(string parentItemCode, string name, int year, string fieldGeomJson) - { - var currentYear = new DateTime(year, 1, 1); - var cropfieldItemRequest = new ItemRequest() - { - ParentCode = parentItemCode, - ItemType = CROPFIELD_ITEMTYPE, - Name = name, - DataDate = currentYear, - DataEndDate = currentYear.AddYears(1).AddDays(-1), - Data = JObject.Parse("{}"), - Geometry = JObject.Parse(fieldGeomJson) - }; - - return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest); - } - public async Task CreateTargetNItem(Item cropfieldItem) { var itemRequest = new ItemRequest() diff --git a/FarmmapsNbs/Program.cs b/FarmmapsNbs/Program.cs new file mode 100644 index 0000000..c5b398b --- /dev/null +++ b/FarmmapsNbs/Program.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using FarmmapsApi; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace FarmmapsApiSamples +{ + class Program : FarmmapsProgram + { + private static async Task Main(string[] args) + { + await new Program().Start(args); + } + + protected override void Configure(IServiceCollection serviceCollection) + { + serviceCollection.AddLogging(opts => opts + .AddConsole() + .AddFilter("System.Net.Http", LogLevel.Warning)) + .AddTransient(); + } + } +} \ No newline at end of file diff --git a/FarmmapsApiSamples/appsettings.json b/FarmmapsNbs/appsettings.json similarity index 98% rename from FarmmapsApiSamples/appsettings.json rename to FarmmapsNbs/appsettings.json index 625a379..caeb12c 100644 --- a/FarmmapsApiSamples/appsettings.json +++ b/FarmmapsNbs/appsettings.json @@ -1,4 +1,4 @@ -{ +{ "Authority": "https://accounts.farmmaps.awtest.nl/", "Endpoint": "https://farmmaps.awtest.nl/", "BasePath": "api/v1",