From 8cebe9f2c27aaf2fa3557b31d602a44d33e223a8 Mon Sep 17 00:00:00 2001 From: Wilco Krikke Date: Thu, 16 Dec 2021 12:05:35 +0100 Subject: [PATCH] AW-2834 --- FarmMapsBlight/BlightApplication.cs | 16 +++++------- FarmMapsBlight/BlightService.cs | 10 +------- FarmMapsBlight/FarmMapsBlight.csproj.user | 6 +++++ Secrets/Secrets.csproj | 31 ++++++++++------------- Secrets/Secrets.csproj.user | 6 +++++ 5 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 FarmMapsBlight/FarmMapsBlight.csproj.user create mode 100644 Secrets/Secrets.csproj.user diff --git a/FarmMapsBlight/BlightApplication.cs b/FarmMapsBlight/BlightApplication.cs index 6b034d3..4b96c88 100644 --- a/FarmMapsBlight/BlightApplication.cs +++ b/FarmMapsBlight/BlightApplication.cs @@ -61,10 +61,12 @@ namespace FarmMapsBlight Item cropfieldItem; if (string.IsNullOrEmpty(_settings.CropfieldItemCode)) { - _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\"}"; - cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield Blight", 2020, - @"{""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); + _logger.LogInformation("Creating cropfield"); + int year = DateTime.Now.Year; + string emergenDate = new DateTime(year, 4, 25).ToString("o"); + 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; SaveSettings(); } @@ -74,11 +76,7 @@ namespace FarmMapsBlight cropfieldItem = await _farmmapsApiService.GetItemAsync(_settings.CropfieldItemCode); } - DateTime adviceDate = new DateTime(2020, 7, 7);// DateTime.Now.Date; - DateTime plantingDate = new DateTime(2020, 4, 20); - DateTime emergeDate = new DateTime(2020, 5, 20); - - var blightItem = await _blightService.CreateAdvice(cropfieldItem, adviceDate, plantingDate, emergeDate); + var blightItem = await _blightService.CreateAdvice(cropfieldItem); if (blightItem == null) { return; diff --git a/FarmMapsBlight/BlightService.cs b/FarmMapsBlight/BlightService.cs index dde77f7..84a0cc3 100644 --- a/FarmMapsBlight/BlightService.cs +++ b/FarmMapsBlight/BlightService.cs @@ -25,17 +25,13 @@ namespace FarmMapsBlight _generalService = generalService; } - public async Task CreateAdvice(Item cropfieldItem, DateTime adviceDate, DateTime plantingDate, DateTime emergeDate) + public async Task CreateAdvice(Item cropfieldItem) { var taskRequest = new TaskRequest() { 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 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); - List irrigations = new List(); - 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); await PollTask(TimeSpan.FromSeconds(3), async (tokenSource) => { diff --git a/FarmMapsBlight/FarmMapsBlight.csproj.user b/FarmMapsBlight/FarmMapsBlight.csproj.user new file mode 100644 index 0000000..dc63f8a --- /dev/null +++ b/FarmMapsBlight/FarmMapsBlight.csproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/Secrets/Secrets.csproj b/Secrets/Secrets.csproj index f12914f..cbce5af 100644 --- a/Secrets/Secrets.csproj +++ b/Secrets/Secrets.csproj @@ -1,18 +1,13 @@ - - - - netstandard1.0 - - - - - - Always - - - - Always - - - - + + + + netstandard1.0 + + + + + Always + + + + diff --git a/Secrets/Secrets.csproj.user b/Secrets/Secrets.csproj.user new file mode 100644 index 0000000..429333d --- /dev/null +++ b/Secrets/Secrets.csproj.user @@ -0,0 +1,6 @@ + + + + true + + \ No newline at end of file