Merge remote-tracking branch 'upstream/master'
This commit is contained in:
		| @@ -40,9 +40,9 @@ namespace FarmMapsBlight | ||||
|             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\"}"; | ||||
|  | ||||
|             List<Spray> sprays = new List<Spray>(); | ||||
|             sprays.Add(new Spray() { fungicide = JsonConvert.DeserializeObject<Fungicide>(fungicide1), sprayTime = new DateTime(2020, 6, 24), dose = 0.6, isVRA = false }); | ||||
|             sprays.Add(new Spray() { fungicide = JsonConvert.DeserializeObject<Fungicide>(fungicide2), sprayTime = new DateTime(2020, 7, 2), dose = 0.6, isVRA = false }); | ||||
|             //sprays.Add(new Spray() { fungicideCode = "FLEX", SprayTime = new DateTime(2020, 7, 1), dose = 0.6, isVRA = false }); | ||||
|             sprays.Add(new Spray() { fungicide = JsonConvert.DeserializeObject<Fungicide>(fungicide1), sprayTime = new DateTime(2020, 9, 1), dose = 0.6, isVRA = false }); | ||||
|             sprays.Add(new Spray() { fungicide = JsonConvert.DeserializeObject<Fungicide>(fungicide2), sprayTime = new DateTime(2020, 9, 1), dose = 0.6, isVRA = false }); | ||||
|  | ||||
|             taskRequest.attributes["sprays"] = JsonConvert.SerializeObject(sprays); | ||||
|  | ||||
|             List<Irrigation> irrigations = new List<Irrigation>(); | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <None Update="appsettings.json"> | ||||
|       <CopyToOutputDirectory>>always</CopyToOutputDirectory> | ||||
|       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||
|     </None> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   | ||||
| @@ -2,8 +2,10 @@ | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
|  | ||||
| namespace FarmMapsBlight.Models { | ||||
|     public class Fungicide { | ||||
| namespace FarmMapsBlight.Models | ||||
| { | ||||
|     public class Fungicide | ||||
|     { | ||||
|         public string code { get; set; } | ||||
|         public string name { get; set; } | ||||
|         public string ctgbregistrationnumber { get; set; } | ||||
| @@ -35,8 +37,10 @@ namespace FarmMapsBlight.Models { | ||||
|         public bool earlytubersetting { get; set; } | ||||
|         public bool tuberfilling { get; set; } | ||||
|         public int? safedays { get; set; } | ||||
|         public double takeback { | ||||
|             get { | ||||
|         public double takeback | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return curativescore * 6; | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -5,7 +5,6 @@ namespace FarmMapsBlight.Models | ||||
|     public class Spray | ||||
|     { | ||||
|         public DateTime sprayTime { get; set; } | ||||
|         public string fungicideCode { get; set; } | ||||
|         public Fungicide fungicide { get; set; } | ||||
|         public double dose { get; set; } | ||||
|         public bool isVRA { get; set; } | ||||
|   | ||||
| @@ -6,13 +6,15 @@ | ||||
|  | ||||
|     <ItemGroup> | ||||
|         <PackageReference Include="Google.Apis" Version="1.44.1" /> | ||||
|         <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.2" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.2" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.2" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.2" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.2" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.2" /> | ||||
|         <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.14" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.14" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.14" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.14" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.14" /> | ||||
|         <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.14" /> | ||||
|         <PackageReference Include="IdentityModel.OidcClient" Version="3.1.2" /> | ||||
|         <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> | ||||
|         <PackageReference Include="Serilog.Sinks.File" Version="4.1.0" /> | ||||
|         <PackageReference Include="Winista.MimeDetect" Version="1.0.1" /> | ||||
|     </ItemGroup> | ||||
|  | ||||
|   | ||||
| @@ -1,3 +1,4 @@ | ||||
| using System; | ||||
| using System.Net.Http; | ||||
| using System.Threading.Tasks; | ||||
| using FarmmapsApi.HttpMessageHandlers; | ||||
| @@ -6,6 +7,10 @@ using FarmmapsApi.Services; | ||||
| using IdentityModel.Client; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using Serilog; | ||||
| using Serilog.Events; | ||||
| using Serilog.Filters; | ||||
|  | ||||
| namespace FarmmapsApi | ||||
| { | ||||
| @@ -37,10 +42,12 @@ namespace FarmmapsApi | ||||
|                 .AddHttpMessageHandler<FarmmapsAuthenticationHandler>() | ||||
|                 .Services; | ||||
|  | ||||
|  | ||||
|             Configure(serviceCollection); | ||||
|  | ||||
|             var serviceProvider = serviceCollection.BuildServiceProvider(); | ||||
|  | ||||
|             ConfigureLogger(serviceProvider); | ||||
|  | ||||
|             await serviceProvider.GetService<FarmmapsApiService>().AuthenticateAsync(); | ||||
| //            await serviceProvider.GetService<FarmmapsEventHub>().StartEventHub(); | ||||
|  | ||||
| @@ -48,5 +55,24 @@ namespace FarmmapsApi | ||||
|         } | ||||
|  | ||||
|         protected abstract void Configure(IServiceCollection serviceCollection); | ||||
|  | ||||
|         private static void ConfigureLogger(IServiceProvider serviceProvider) | ||||
|         { | ||||
|             var isMicrosoftNamespace = Matching.FromSource("Microsoft"); | ||||
|             var isSystem = Matching.FromSource("System"); | ||||
|  | ||||
|             Log.Logger = new LoggerConfiguration() | ||||
|                 .MinimumLevel.Verbose() | ||||
|                 .WriteTo.Logger(l =>  | ||||
|                     l.WriteTo.Logger(l2 => l2 | ||||
|                             .Filter.ByExcluding(v => isMicrosoftNamespace(v) || isSystem(v)) | ||||
|                             .WriteTo.Console()) | ||||
|                     ) | ||||
|                 .WriteTo.File(path: "Logs/log.log", rollingInterval: RollingInterval.Day) | ||||
|                 .CreateLogger(); | ||||
|  | ||||
|             var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>(); | ||||
|             loggerFactory.AddSerilog(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -283,7 +283,8 @@ namespace FarmmapsApi.Services | ||||
|         /// <param name="progressCallback"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="FileNotFoundException"></exception> | ||||
|         public async Task<UploadResults> UploadFile(string filePath, string parentItemCode, string geoJsonString, | ||||
|         public async Task<UploadResults> UploadFile(string filePath, string parentItemCode, | ||||
|             string geoJsonString = null, | ||||
|             Action<IUploadProgress> progressCallback = null) | ||||
|         { | ||||
|             if (!File.Exists(filePath)) | ||||
| @@ -301,7 +302,7 @@ namespace FarmmapsApi.Services | ||||
|                 Name = Path.GetFileName(filePath), | ||||
|                 ParentCode = parentItemCode, | ||||
|                 Size = uploadStream.Length, | ||||
|                 Geometry = JObject.Parse(geoJsonString) | ||||
|                 Geometry = string.IsNullOrEmpty(geoJsonString) ? null : JObject.Parse(geoJsonString) | ||||
|             }; | ||||
|  | ||||
|             using var httpClient = CreateConfigurableHttpClient(_httpClient); | ||||
|   | ||||
| @@ -51,7 +51,8 @@ namespace FarmmapsApi.Services | ||||
|                      i.Name.ToLower().Contains(itemName.ToLower())); | ||||
|         } | ||||
|  | ||||
|         public async Task<Item> UploadZipWithShapeAsync(UserRoot root, string filePath, string itemName, string geoJsonString = null) { | ||||
|         public async Task<Item> UploadZipWithShapeAsync(UserRoot root, string filePath, string itemName, string geoJsonString = null) | ||||
|         { | ||||
|             var startUpload = DateTime.UtcNow.AddSeconds(-3); | ||||
|             var result = await _farmmapsApiService.UploadFile(filePath, root.Code, geoJsonString, | ||||
|                 progress => _logger.LogInformation($"Status: {progress.Status} - BytesSent: {progress.BytesSent}")); | ||||
| @@ -64,7 +65,8 @@ namespace FarmmapsApi.Services | ||||
|                      i.Name.ToLower().Contains(itemName.ToLower())); ; | ||||
|         } | ||||
|  | ||||
|         public async Task<Item> ShapeToGeotiff(Item shapeItem) { | ||||
|         public async Task<Item> ShapeToGeotiff(Item shapeItem) | ||||
|         { | ||||
|             var startUpload = DateTime.UtcNow.AddSeconds(-3); | ||||
|             await RunAndWaitForTask(shapeItem, "vnd.farmmaps.task.shapetogeotiff"); | ||||
|  | ||||
| @@ -74,9 +76,9 @@ namespace FarmmapsApi.Services | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public async Task<Item> GeotiffToShape(Item tiffItem) { | ||||
|         public async Task<Item> GeotiffToShape(Item tiffItem) | ||||
|         { | ||||
|             var taskmapRequest = new TaskRequest {TaskType = TASKMAP_TASK}; | ||||
|              | ||||
|             taskmapRequest.attributes["cellWidth"] = "3"; | ||||
|             taskmapRequest.attributes["cellHeight"] = "1"; | ||||
|             taskmapRequest.attributes["angle"] = "0"; | ||||
| @@ -163,6 +165,7 @@ namespace FarmmapsApi.Services | ||||
|             } | ||||
|             else if (outputType== "shape") { | ||||
|             taskMapItem = await FindChildItemAsync(tiffItem.ParentCode, | ||||
|  | ||||
|                 SHAPE_PROCESSED_ITEMTYPE, itemName); | ||||
|             } | ||||
|             else | ||||
|   | ||||
| @@ -14,9 +14,7 @@ namespace FarmmapsVRApoten | ||||
|  | ||||
|         protected override void Configure(IServiceCollection serviceCollection) | ||||
|         { | ||||
|             serviceCollection.AddLogging(opts => opts | ||||
|                     .AddConsole() | ||||
|                     .AddFilter("System.Net.Http", LogLevel.Warning)) | ||||
|             serviceCollection.AddLogging() | ||||
|                 .AddTransient<PotenService>(); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -27,5 +27,4 @@ | ||||
| 		<Folder Include="Data" /> | ||||
| 	</ItemGroup> | ||||
|  | ||||
|  | ||||
| </Project> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user