Add project files.
This commit is contained in:
15
ISW - Carelli/ISW - Carelli.csproj
Normal file
15
ISW - Carelli/ISW - Carelli.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<RootNamespace>ISW___Carelli</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Integry Smart Warehouse\Integry Smart Warehouse.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
11
ISW - Carelli/Program.cs
Normal file
11
ISW - Carelli/Program.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
|
using Integry_Smart_Warehouse.Core.Domain.Impl;
|
||||||
|
|
||||||
|
Console.WriteLine("Hello, World!");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var iswContext = new ISWContext();
|
||||||
|
await iswContext.Init();
|
||||||
|
await iswContext.Start();
|
||||||
31
Integry Smart Warehouse.sln
Normal file
31
Integry Smart Warehouse.sln
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.5.33627.172
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integry Smart Warehouse", "Integry Smart Warehouse\Integry Smart Warehouse.csproj", "{281A1B5D-BCF8-4DD2-A1A8-94DECC6BFB3A}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ISW - Carelli", "ISW - Carelli\ISW - Carelli.csproj", "{B5ABB5A2-D269-424F-ACA0-838F8A591274}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{281A1B5D-BCF8-4DD2-A1A8-94DECC6BFB3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{281A1B5D-BCF8-4DD2-A1A8-94DECC6BFB3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{281A1B5D-BCF8-4DD2-A1A8-94DECC6BFB3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{281A1B5D-BCF8-4DD2-A1A8-94DECC6BFB3A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B5ABB5A2-D269-424F-ACA0-838F8A591274}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B5ABB5A2-D269-424F-ACA0-838F8A591274}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B5ABB5A2-D269-424F-ACA0-838F8A591274}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B5ABB5A2-D269-424F-ACA0-838F8A591274}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {6954509A-3FC0-4570-A879-00C8E78DEA29}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
29
Integry Smart Warehouse/Core/Controller/CompanyController.cs
Normal file
29
Integry Smart Warehouse/Core/Controller/CompanyController.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using Integry_Smart_Warehouse.Core.WebHost.Controller;
|
||||||
|
|
||||||
|
namespace Integry_Smart_Warehouse.Core.Controller;
|
||||||
|
|
||||||
|
[Route("[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces(MediaTypeNames.Application.Json)]
|
||||||
|
public class CompanyController : IntegryControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
[Route("")]
|
||||||
|
public async Task<IActionResult> DetchDefaultData()
|
||||||
|
{
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
nomeDitta = "INTEGRY S.R.L.",
|
||||||
|
indirizzo = "VIA GIOIA, 40",
|
||||||
|
cap = "70017",
|
||||||
|
citta = "PUTIGNANO",
|
||||||
|
prov = "BA",
|
||||||
|
partIva = "05061620729",
|
||||||
|
numTel = "080/4055215",
|
||||||
|
numFax = "080/4933245",
|
||||||
|
eMail = "amministrazione@integry.it"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Integry Smart Warehouse/Core/Domain/IContext.cs
Normal file
12
Integry Smart Warehouse/Core/Domain/IContext.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Integry_Smart_Warehouse.Core.Domain;
|
||||||
|
|
||||||
|
public interface IContext
|
||||||
|
{
|
||||||
|
|
||||||
|
Task Init();
|
||||||
|
|
||||||
|
Task Start();
|
||||||
|
|
||||||
|
Task Stop();
|
||||||
|
|
||||||
|
}
|
||||||
56
Integry Smart Warehouse/Core/Domain/Impl/ISWContext.cs
Normal file
56
Integry Smart Warehouse/Core/Domain/Impl/ISWContext.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using Autofac;
|
||||||
|
using Autofac.Extensions.DependencyInjection;
|
||||||
|
using Integry_Smart_Warehouse.Core.WebHost;
|
||||||
|
using Integry_Smart_Warehouse.Core.WebHost.Converter;
|
||||||
|
|
||||||
|
namespace Integry_Smart_Warehouse.Core.Domain.Impl;
|
||||||
|
|
||||||
|
public class ISWContext : IContext
|
||||||
|
{
|
||||||
|
public async Task Init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Start()
|
||||||
|
{
|
||||||
|
return CreateHostBuilder().Build().RunAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IHostBuilder CreateHostBuilder()
|
||||||
|
{
|
||||||
|
var builder = Host.CreateDefaultBuilder();
|
||||||
|
|
||||||
|
builder.UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
||||||
|
.ConfigureContainer<ContainerBuilder>(configure => { configure.RegisterModule<ISWDataModule>(); });
|
||||||
|
|
||||||
|
|
||||||
|
builder.ConfigureWebHostDefaults(webHost =>
|
||||||
|
{
|
||||||
|
webHost.UseStartup<ISWWebHost>();
|
||||||
|
|
||||||
|
webHost.UseUrls("http://0.0.0.0:5000", "https://0.0.0.0:5001");
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.ConfigureServices(services =>
|
||||||
|
{
|
||||||
|
var mvcBuilder = services.AddControllers();
|
||||||
|
|
||||||
|
mvcBuilder.AddJsonOptions(config =>
|
||||||
|
config.JsonSerializerOptions.Converters.Add(new JsonDateConverter()));
|
||||||
|
|
||||||
|
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
services.AddEndpointsApiExplorer();
|
||||||
|
services.AddSwaggerGen();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task Stop()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Integry Smart Warehouse/Core/Domain/Impl/ISWDataModule.cs
Normal file
24
Integry Smart Warehouse/Core/Domain/Impl/ISWDataModule.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Autofac;
|
||||||
|
using Module = Autofac.Module;
|
||||||
|
|
||||||
|
namespace Integry_Smart_Warehouse.Core.Domain.Impl;
|
||||||
|
|
||||||
|
public class ISWDataModule : Module
|
||||||
|
{
|
||||||
|
|
||||||
|
protected override void Load(ContainerBuilder builder)
|
||||||
|
{
|
||||||
|
base.Load(builder);
|
||||||
|
|
||||||
|
//builder.RegisterType<TuidiApiRestClient>()
|
||||||
|
// .As<ITuidiApiRestClient>()
|
||||||
|
// .SingleInstance()
|
||||||
|
// .OnActivated(x =>
|
||||||
|
// {
|
||||||
|
// x.Instance.BaseUrl = "https://tuidi-essegrande-staging.azurewebsites.net/api/v2/terminal/";
|
||||||
|
// //x.Instance.BaseUrl = "http://192.168.1.107:8080/api/v2/terminal/";
|
||||||
|
// x.Instance.ApiKey = "YjJlYzA2NTc0MjA4NzEwZWM3YmY2NTRlM2MzZmRjY2MgIC0K";
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using Integry_Smart_Warehouse.Core.WebHost.Dto;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace Integry_Smart_Warehouse.Core.WebHost.Controller;
|
||||||
|
|
||||||
|
public class IntegryControllerBase : ControllerBase
|
||||||
|
{
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override OkObjectResult Ok(object? value)
|
||||||
|
{
|
||||||
|
return base.Ok(new ResponseBaseDto()
|
||||||
|
{
|
||||||
|
Dto = value,
|
||||||
|
Esito = 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
protected new OkObjectResult Ok()
|
||||||
|
{
|
||||||
|
return base.Ok(new ResponseBaseDto()
|
||||||
|
{
|
||||||
|
Esito = 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using Integry_Smart_Warehouse.Core.WebHost.Dto;
|
||||||
|
using Microsoft.AspNetCore.Diagnostics;
|
||||||
|
|
||||||
|
namespace Integry_Smart_Warehouse.Core.WebHost.Controller;
|
||||||
|
|
||||||
|
public class ResponseBaseExceptionWrapper
|
||||||
|
{
|
||||||
|
public async Task Invoke(HttpContext context)
|
||||||
|
{
|
||||||
|
var contextFeature = context.Features.Get<IExceptionHandlerFeature>();
|
||||||
|
if (contextFeature is { Error: { } })
|
||||||
|
{
|
||||||
|
context.Response.StatusCode = StatusCodes.Status200OK;
|
||||||
|
context.Response.ContentType = "application/json";
|
||||||
|
|
||||||
|
await context.Response.WriteAsync(JsonSerializer.Serialize(new ResponseBaseDto()
|
||||||
|
{
|
||||||
|
Esito = -1,
|
||||||
|
ErrorMessage = contextFeature.Error.Message
|
||||||
|
}, new JsonSerializerOptions()
|
||||||
|
{
|
||||||
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Integry_Smart_Warehouse.Core.WebHost.Controller;
|
||||||
|
|
||||||
|
public static class ResponseBaseWrapperExtension
|
||||||
|
{
|
||||||
|
public static IApplicationBuilder UseResponseWrapper(this IApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
//return builder.UseMiddleware<ResponseBaseExceptionWrapper>();
|
||||||
|
return builder
|
||||||
|
.UseExceptionHandler(new ExceptionHandlerOptions()
|
||||||
|
{
|
||||||
|
ExceptionHandler = new ResponseBaseExceptionWrapper().Invoke
|
||||||
|
});
|
||||||
|
|
||||||
|
//.UseMiddleware<ResponseBaseWrapper>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Integry_Smart_Warehouse.Core.WebHost.Converter;
|
||||||
|
|
||||||
|
public class JsonDateConverter : JsonConverter<DateTime>
|
||||||
|
{
|
||||||
|
|
||||||
|
private const string DateFormat = "dd/MM/yyyy HH:mm:ss";
|
||||||
|
|
||||||
|
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
using var jsonDoc = JsonDocument.ParseValue(ref reader);
|
||||||
|
var stringValue = jsonDoc.RootElement.GetRawText().Trim('"').Trim('\'');
|
||||||
|
var value = DateTime.ParseExact(stringValue, DateFormat, CultureInfo.InvariantCulture);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
writer.WriteStringValue(value.ToString(DateFormat, CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Integry Smart Warehouse/Core/WebHost/Dto/ResponseBaseDto.cs
Normal file
11
Integry Smart Warehouse/Core/WebHost/Dto/ResponseBaseDto.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Integry_Smart_Warehouse.Core.WebHost.Dto;
|
||||||
|
|
||||||
|
public class ResponseBaseDto
|
||||||
|
{
|
||||||
|
public int Esito { get; set; }
|
||||||
|
|
||||||
|
public string? ErrorMessage { get; set; }
|
||||||
|
|
||||||
|
public object? Dto { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
25
Integry Smart Warehouse/Core/WebHost/ISWWebHost.cs
Normal file
25
Integry Smart Warehouse/Core/WebHost/ISWWebHost.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Integry_Smart_Warehouse.Core.WebHost.Controller;
|
||||||
|
|
||||||
|
namespace Integry_Smart_Warehouse.Core.WebHost;
|
||||||
|
|
||||||
|
public class ISWWebHost
|
||||||
|
{
|
||||||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapControllers();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.UseResponseWrapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
20
Integry Smart Warehouse/Integry Smart Warehouse.csproj
Normal file
20
Integry Smart Warehouse/Integry Smart Warehouse.csproj
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<RootNamespace>Integry_Smart_Warehouse</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Core\Controller\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
2
Integry Smart Warehouse/Program.cs
Normal file
2
Integry Smart Warehouse/Program.cs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
Console.WriteLine("Hello, World!");
|
||||||
12
Integry Smart Warehouse/Properties/launchSettings.json
Normal file
12
Integry Smart Warehouse/Properties/launchSettings.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Integry Smart Warehouse": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"applicationUrl": "https://localhost:51218;http://localhost:51219"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user