forked from FarmMaps/FarmMapsApiClient
AW-2834
This commit is contained in:
parent
a1696c38c7
commit
8cebe9f2c2
@ -61,10 +61,12 @@ namespace FarmMapsBlight
|
|||||||
Item cropfieldItem;
|
Item cropfieldItem;
|
||||||
if (string.IsNullOrEmpty(_settings.CropfieldItemCode))
|
if (string.IsNullOrEmpty(_settings.CropfieldItemCode))
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Creating cropfield");
|
_logger.LogInformation("Creating cropfield");
|
||||||
string cropFieldData = "{\"area\":0,\"code\":\"0552ef068b0e4e6590c317a4c662faea\",\"name\":null,\"polygon\":null,\"soilCode\":\"60\",\"soilName\":null,\"fieldCode\":null,\"schemeUrl\":null,\"externalId\":null,\"schemeCode\":null,\"varietyCode\":\"11113\",\"varietyName\":\"Bintje\",\"cropTypeCode\":\"1010101\",\"cropTypeName\":\"Consumptieaardappelen\",\"productionTypeCode\":\"1\",\"productionPurposeCode\":null,\"productionPurposeName\":null,\"productionSequenceCode\":\"HFDTLT\"}";
|
int year = DateTime.Now.Year;
|
||||||
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield Blight", 2020,
|
string emergenDate = new DateTime(year, 4, 25).ToString("o");
|
||||||
@"{""type"":""Polygon"",""coordinates"":[[[4.617786844284247,52.22533706956424],[4.618642601314543,52.225938364585989],[4.6192153806397,52.22563988897754],[4.619192414656403,52.2256242822442],[4.620306732153958,52.225031745661528],[4.620542019225217,52.22519855319158],[4.621157509147853,52.22487436515405],[4.623387917230182,52.22367660757213],[4.624563444939009,52.22304740241544],[4.624562779355982,52.223046635247019],[4.624534908813479,52.22302596787506],[4.627873021330343,52.221240670658399],[4.627504935938338,52.220104419135129],[4.627324878706837,52.22020569669098],[4.627320696113512,52.22020660117888],[4.626707169518044,52.22053923770041],[4.624700376420229,52.221619047547488],[4.623471571183885,52.22227447969577],[4.623471511010673,52.22227500174403],[4.623468838689317,52.22228052566992],[4.617786844284247,52.22533706956424]]]}", cropFieldData);
|
string cropFieldData = "{\"area\":10.96,\"final\":true,\"soilCode\":\"1\",\"soilName\":\"Zand\",\"varietyCode\":\"10019\",\"varietyName\":\"Abana\",\"cropTypeCode\":\"1010101\",\"cropTypeName\":\"Aardappel\",\"rootDepthMax\":45,\"emergenceDate\":\"" + emergenDate + "\",\"productionPurposeCode\":\"003\",\"productionPurposeName\":\"Consumptie\"}";
|
||||||
|
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield Blight", year,
|
||||||
|
@"{""type"":""Polygon"",""coordinates"":[[[4.617786844284247,52.22533706956424],[4.618642601314543,52.225938364585989],[4.6192153806397,52.22563988897754],[4.619192414656403,52.2256242822442],[4.620306732153958,52.225031745661528],[4.620542019225217,52.22519855319158],[4.621157509147853,52.22487436515405],[4.623387917230182,52.22367660757213],[4.624563444939009,52.22304740241544],[4.624562779355982,52.223046635247019],[4.624534908813479,52.22302596787506],[4.627873021330343,52.221240670658399],[4.627504935938338,52.220104419135129],[4.627324878706837,52.22020569669098],[4.627320696113512,52.22020660117888],[4.626707169518044,52.22053923770041],[4.624700376420229,52.221619047547488],[4.623471571183885,52.22227447969577],[4.623471511010673,52.22227500174403],[4.623468838689317,52.22228052566992],[4.617786844284247,52.22533706956424]]]}", cropFieldData);
|
||||||
_settings.CropfieldItemCode = cropfieldItem.Code;
|
_settings.CropfieldItemCode = cropfieldItem.Code;
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
@ -74,11 +76,7 @@ namespace FarmMapsBlight
|
|||||||
cropfieldItem = await _farmmapsApiService.GetItemAsync(_settings.CropfieldItemCode);
|
cropfieldItem = await _farmmapsApiService.GetItemAsync(_settings.CropfieldItemCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime adviceDate = new DateTime(2020, 7, 7);// DateTime.Now.Date;
|
var blightItem = await _blightService.CreateAdvice(cropfieldItem);
|
||||||
DateTime plantingDate = new DateTime(2020, 4, 20);
|
|
||||||
DateTime emergeDate = new DateTime(2020, 5, 20);
|
|
||||||
|
|
||||||
var blightItem = await _blightService.CreateAdvice(cropfieldItem, adviceDate, plantingDate, emergeDate);
|
|
||||||
if (blightItem == null)
|
if (blightItem == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -25,17 +25,13 @@ namespace FarmMapsBlight
|
|||||||
_generalService = generalService;
|
_generalService = generalService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Item> CreateAdvice(Item cropfieldItem, DateTime adviceDate, DateTime plantingDate, DateTime emergeDate)
|
public async Task<Item> CreateAdvice(Item cropfieldItem)
|
||||||
{
|
{
|
||||||
var taskRequest = new TaskRequest()
|
var taskRequest = new TaskRequest()
|
||||||
{
|
{
|
||||||
TaskType = "vnd.farmmaps.task.blight"
|
TaskType = "vnd.farmmaps.task.blight"
|
||||||
};
|
};
|
||||||
|
|
||||||
taskRequest.attributes["d"] = adviceDate.ToUniversalTime().ToString("o");
|
|
||||||
taskRequest.attributes["plantingDate"] = plantingDate.ToUniversalTime().ToString("o");
|
|
||||||
taskRequest.attributes["emergeDate"] = emergeDate.ToUniversalTime().ToString("o");
|
|
||||||
|
|
||||||
var fungicide1 = "{\"ai1\": \"propamocarb\", \"ai2\": \"fluopicolide\", \"ai3\": \"cymoxanil\", \"code\": \"infinito12curz\", \"name\": \"infinito 1,2 l + curzate partner 0,2 kg\", \"maxdose\": \"1\", \"mindose\": \"1\", \"safedays\": \"14\", \"emergence\": true, \"newgrowth\": \"1\", \"contentai1\": \"525.2\", \"contentai2\": \"62.5\", \"contentai3\": \"600\", \"fastgrowth\": true, \"contentunit\": \"l/ha + kg/ha\", \"rainfastness\": \"2.5\", \"tuberfilling\": true, \"aidescription\": \"(propamocarb + fluopicolide) 1.2 l/ha + cymoxanil 0.2 kg/ha\", \"curativescore\": \"2\", \"dryingtimemax\": \"2\", \"dryingtimemin\": \"2\", \"vracompatible\": false, \"maxapplications\": \"4\", \"preventivescore\": \"3\", \"recommendeddose\": \"1\", \"tuberprotection\": \"3.3\", \"eradicativescore\": \"2\", \"earlytubersetting\": true, \"protectioncategory\": \"2\", \"applicationrateunit\": null, \"ctgbregistrationnumber\": \"12927 n + 12755 n\"}";
|
var fungicide1 = "{\"ai1\": \"propamocarb\", \"ai2\": \"fluopicolide\", \"ai3\": \"cymoxanil\", \"code\": \"infinito12curz\", \"name\": \"infinito 1,2 l + curzate partner 0,2 kg\", \"maxdose\": \"1\", \"mindose\": \"1\", \"safedays\": \"14\", \"emergence\": true, \"newgrowth\": \"1\", \"contentai1\": \"525.2\", \"contentai2\": \"62.5\", \"contentai3\": \"600\", \"fastgrowth\": true, \"contentunit\": \"l/ha + kg/ha\", \"rainfastness\": \"2.5\", \"tuberfilling\": true, \"aidescription\": \"(propamocarb + fluopicolide) 1.2 l/ha + cymoxanil 0.2 kg/ha\", \"curativescore\": \"2\", \"dryingtimemax\": \"2\", \"dryingtimemin\": \"2\", \"vracompatible\": false, \"maxapplications\": \"4\", \"preventivescore\": \"3\", \"recommendeddose\": \"1\", \"tuberprotection\": \"3.3\", \"eradicativescore\": \"2\", \"earlytubersetting\": true, \"protectioncategory\": \"2\", \"applicationrateunit\": null, \"ctgbregistrationnumber\": \"12927 n + 12755 n\"}";
|
||||||
var fungicide2 = "{\"ai1\": \"fluazinam\", \"ai2\": \"cymoxanil\", \"ai3\": null, \"code\": \"kunshi\", \"name\": \"kunshi\", \"maxdose\": \"0.5\", \"mindose\": \"0.4\", \"safedays\": \"1\", \"emergence\": false, \"newgrowth\": \"1\", \"contentai1\": \"375\", \"contentai2\": \"250\", \"contentai3\": \"0\", \"fastgrowth\": true, \"contentunit\": \"g/kg\", \"rainfastness\": \"2.5\", \"tuberfilling\": false, \"aidescription\": \"(fluazinam + cymoxanil) 0.5 kg/ha\", \"curativescore\": \"2\", \"dryingtimemax\": \"2\", \"dryingtimemin\": \"1\", \"vracompatible\": true, \"maxapplications\": \"5\", \"preventivescore\": \"2.9\", \"recommendeddose\": \"0.5\", \"tuberprotection\": \"3.3\", \"eradicativescore\": \"1\", \"earlytubersetting\": false, \"protectioncategory\": \"1\", \"applicationrateunit\": \"kg/ha\", \"ctgbregistrationnumber\": \"14371 n\"}";
|
var fungicide2 = "{\"ai1\": \"fluazinam\", \"ai2\": \"cymoxanil\", \"ai3\": null, \"code\": \"kunshi\", \"name\": \"kunshi\", \"maxdose\": \"0.5\", \"mindose\": \"0.4\", \"safedays\": \"1\", \"emergence\": false, \"newgrowth\": \"1\", \"contentai1\": \"375\", \"contentai2\": \"250\", \"contentai3\": \"0\", \"fastgrowth\": true, \"contentunit\": \"g/kg\", \"rainfastness\": \"2.5\", \"tuberfilling\": false, \"aidescription\": \"(fluazinam + cymoxanil) 0.5 kg/ha\", \"curativescore\": \"2\", \"dryingtimemax\": \"2\", \"dryingtimemin\": \"1\", \"vracompatible\": true, \"maxapplications\": \"5\", \"preventivescore\": \"2.9\", \"recommendeddose\": \"0.5\", \"tuberprotection\": \"3.3\", \"eradicativescore\": \"1\", \"earlytubersetting\": false, \"protectioncategory\": \"1\", \"applicationrateunit\": \"kg/ha\", \"ctgbregistrationnumber\": \"14371 n\"}";
|
||||||
|
|
||||||
@ -45,10 +41,6 @@ namespace FarmMapsBlight
|
|||||||
|
|
||||||
taskRequest.attributes["sprays"] = JsonConvert.SerializeObject(sprays);
|
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) =>
|
||||||
{
|
{
|
||||||
|
6
FarmMapsBlight/FarmMapsBlight.csproj.user
Normal file
6
FarmMapsBlight/FarmMapsBlight.csproj.user
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@ -1,18 +1,13 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard1.0</TargetFramework>
|
<TargetFramework>netstandard1.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="appsettings.json" />
|
<None Update="appsettings.json">
|
||||||
<Content Include="appsettings.json">
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
</None>
|
||||||
</Content>
|
</ItemGroup>
|
||||||
<None Remove="appsettings.secrets.json" />
|
|
||||||
<Content Include="appsettings.secrets.json">
|
</Project>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
|
6
Secrets/Secrets.csproj.user
Normal file
6
Secrets/Secrets.csproj.user
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>true</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user