Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -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
|
||||
{
|
||||
@@ -36,11 +41,13 @@ namespace FarmmapsApi
|
||||
.AddHttpClient<FarmmapsApiService>()
|
||||
.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) {
|
||||
var taskmapRequest = new TaskRequest { TaskType = TASKMAP_TASK };
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user