Added sprays & irrigations

This commit is contained in:
Wilco Krikke 2020-09-26 20:11:22 +02:00 committed by Mark van der Wal
parent 67af431140
commit 67ff626e87
7 changed files with 52 additions and 20 deletions

View File

@ -1,7 +1,10 @@
using FarmmapsApi.Models; using FarmmapsApi.Models;
using FarmmapsApi.Services; using FarmmapsApi.Services;
using FarmMapsBlight.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using static FarmmapsApi.Extensions; using static FarmmapsApi.Extensions;
using static FarmmapsApiSamples.Constants; using static FarmmapsApiSamples.Constants;
@ -32,6 +35,14 @@ namespace FarmMapsBlight
taskRequest.attributes["plantingDate"] = plantingDate.ToUniversalTime().ToString("o"); taskRequest.attributes["plantingDate"] = plantingDate.ToUniversalTime().ToString("o");
taskRequest.attributes["emergeDate"] = emergeDate.ToUniversalTime().ToString("o"); taskRequest.attributes["emergeDate"] = emergeDate.ToUniversalTime().ToString("o");
List<Spray> sprays = new List<Spray>();
sprays.Add(new Spray() { fungicideCode = "FLEX", SprayTime = new DateTime(2020, 9, 1), dose = 0.6, isVRA = false });
taskRequest.attributes["sprays"] = JsonConvert.SerializeObject(sprays);
List<Irrigation> irrigations = new List<Irrigation>();
irrigations.Add(new Irrigation() { startTime = new DateTime(2020, 7, 1, 2, 0, 0), endTime = new DateTime(2020, 7, 1, 14, 0, 0) });
taskRequest.attributes["irrigations"] = JsonConvert.SerializeObject(irrigations);
var taskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, taskRequest); var taskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, taskRequest);
await PollTask(TimeSpan.FromSeconds(3), async (tokenSource) => await PollTask(TimeSpan.FromSeconds(3), async (tokenSource) =>
{ {

View File

@ -0,0 +1,11 @@
using System;
namespace FarmMapsBlight.Models
{
public class Irrigation
{
public DateTime startTime { get; set; }
public DateTime endTime { get; set; }
public double mm { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System;
namespace FarmMapsBlight.Models
{
public class Spray
{
public DateTime SprayTime { get; set; }
public string fungicideCode { get; set; }
public double dose { get; set; }
public bool isVRA { get; set; }
}
}

View File

@ -1,8 +1,6 @@
{ {
"Authority": "https://accounts.farmmaps.awtest.nl/", "Authority": "https://accounts.farmmaps.awtest.nl/",
//"Endpoint": "http://farmmaps.awtest.nl", "Endpoint": "https://farmmaps.awtest.nl/",
//"Endpoint": "http://localhost:8095",
"Endpoint": "http://localhost:8083",
"BasePath": "api/v1", "BasePath": "api/v1",
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration", "DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
"RedirectUri": "http://example.nl/api", "RedirectUri": "http://example.nl/api",

View File

@ -1,6 +1,6 @@
{ {
"Authority": "https://accounts.farmmaps.awtest.nl/", "Authority": "https://accounts.farmmaps.awtest.nl/",
"Endpoint": "http://farmmaps.awtest.nl", "Endpoint": "http://farmmaps.awtest.nl/",
"BasePath": "api/v1", "BasePath": "api/v1",
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration", "DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
"RedirectUri": "http://example.nl/api", "RedirectUri": "http://example.nl/api",

View File

@ -1,6 +1,6 @@
{ {
"Authority": "https://accounts.farmmaps.awtest.nl/", "Authority": "https://accounts.farmmaps.awtest.nl/",
"Endpoint": "http://localhost:8095/", "Endpoint": "https://farmmaps.awtest.nl/",
"BasePath": "api/v1", "BasePath": "api/v1",
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration", "DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
"RedirectUri": "http://example.nl/api", "RedirectUri": "http://example.nl/api",

View File

@ -1,6 +1,6 @@
{ {
"Authority": "https://accounts.farmmaps.awtest.nl/", "Authority": "https://accounts.farmmaps.awtest.nl/",
"Endpoint": "http://localhost:8095/", "Endpoint": "https://farmmaps.awtest.nl/",
"BasePath": "api/v1", "BasePath": "api/v1",
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration", "DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
"RedirectUri": "http://example.nl/api", "RedirectUri": "http://example.nl/api",