forked from FarmMaps/FarmMapsApiClient
		
	Added sprays & irrigations
This commit is contained in:
		@@ -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) =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								FarmMapsBlight/Models/Irrigation.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								FarmMapsBlight/Models/Irrigation.cs
									
									
									
									
									
										Normal 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; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										12
									
								
								FarmMapsBlight/Models/Spray.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								FarmMapsBlight/Models/Spray.cs
									
									
									
									
									
										Normal 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; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -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",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "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",
 | 
				
			||||||
  "ClientId": "",
 | 
					    "ClientId": "",
 | 
				
			||||||
  "ClientSecret": "",
 | 
					    "ClientSecret": "",
 | 
				
			||||||
  "Scopes": ["api"]
 | 
					    "Scopes": [ "api" ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "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",
 | 
				
			||||||
  "ClientId": "",
 | 
					    "ClientId": "",
 | 
				
			||||||
  "ClientSecret": "",
 | 
					    "ClientSecret": "",
 | 
				
			||||||
  "Scopes": ["api"]
 | 
					    "Scopes": [ "api" ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user