Skip to content

Commit 04e1531

Browse files
committed
Merge branch 'release/v2.2'
2 parents f5cfede + 47a90e6 commit 04e1531

File tree

18 files changed

+321
-23
lines changed

18 files changed

+321
-23
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@ WeatherControl/.idea/
3838
*.user
3939

4040
perfTests/bulk_api_tests/tools/venv/
41+
42+
WeatherControl/Wissance.WeatherControl.SemiAuto.WebApi/bin/
43+
44+
WeatherControl/Wissance.WeatherControl.SemiAuto.WebApi/obj/
45+
46+
WeatherControl/Wissance.WeatherControl.Common/bin/
47+
48+
WeatherControl/Wissance.WeatherControl.Common/obj/

WeatherControl/Wissance.WeatherControl/Config/ApplicationSettings.cs renamed to WeatherControl/Wissance.WeatherControl.Common/Config/ApplicationSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using System.Threading.Tasks;
55

6-
namespace Wissance.WeatherControl.WebApi.Config
6+
namespace Wissance.WeatherControl.Common.Config
77
{
88
public class ApplicationSettings
99
{

WeatherControl/Wissance.WeatherControl/Config/DatabaseSettings.cs renamed to WeatherControl/Wissance.WeatherControl.Common/Config/DatabaseSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using System.Threading.Tasks;
55

6-
namespace Wissance.WeatherControl.WebApi.Config
6+
namespace Wissance.WeatherControl.Common.Config
77
{
88
public class DatabaseSettings
99
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Wissance.WebApiToolkit.Core" Version="5.1.0" />
11+
</ItemGroup>
12+
13+
</Project>

WeatherControl/Wissance.WeatherControl.Data/Wissance.WeatherControl.Data.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
9-
<PackageReference Include="Wissance.WebApiToolkit.Core" Version="5.0.0" />
9+
<PackageReference Include="Wissance.WebApiToolkit.Core" Version="5.1.0" />
1010
</ItemGroup>
1111

1212
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
</PropertyGroup>
66

77
</Project>

WeatherControl/Wissance.WeatherControl.Ef.Data/Wissance.WeatherControl.Ef.Data.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>
20-
<PackageReference Include="Wissance.WebApiToolkit.Data.Ef" Version="5.0.0" />
20+
<PackageReference Include="Wissance.WebApiToolkit.Data.Ef" Version="5.1.0" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Hosting;
10+
using Microsoft.Extensions.Logging;
11+
12+
namespace Wissance.WeatherControl.SemiAuto.WebApi
13+
{
14+
public class Program
15+
{
16+
public static void Main(string[] args)
17+
{
18+
IHostBuilder hostBuilder = CreateWebHostBuilder(args);
19+
hostBuilder.Build().Run();
20+
}
21+
22+
public static IHostBuilder CreateWebHostBuilder(string[] args)
23+
{
24+
//todo: umv: temporarily stub
25+
_environment = "Development";
26+
//webHostBuilder.GetSetting("environment");
27+
28+
IConfiguration configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
29+
.AddJsonFile("appsettings.json")
30+
.AddJsonFile($"appsettings.{_environment}.json")
31+
.Build();
32+
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(builder =>
33+
{
34+
builder.UseConfiguration(configuration);
35+
builder.UseStartup<Startup>();
36+
builder.UseKestrel();
37+
});
38+
return hostBuilder;
39+
}
40+
41+
private static string _environment;
42+
}
43+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "http://localhost:8158",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": true,
17+
"applicationUrl": "https://localhost:7232;http://localhost:5232",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Reflection;
6+
using System.Reflection.Emit;
7+
using System.Reflection.Metadata;
8+
using System.Reflection.PortableExecutable;
9+
using System.Runtime.Serialization;
10+
using System.Runtime.Serialization.Formatters.Binary;
11+
using System.Security.Cryptography.X509Certificates;
12+
using System.Threading.Tasks;
13+
using Microsoft.AspNetCore.Builder;
14+
using Microsoft.AspNetCore.Hosting;
15+
using Microsoft.AspNetCore.Http;
16+
using Microsoft.EntityFrameworkCore;
17+
using Microsoft.EntityFrameworkCore.Metadata.Internal;
18+
using Microsoft.Extensions.Configuration;
19+
using Microsoft.Extensions.DependencyInjection;
20+
using Microsoft.Extensions.Hosting;
21+
using Microsoft.Extensions.Logging;
22+
using Serilog;
23+
using Wissance.WeatherControl.Data;
24+
using Wissance.WeatherControl.Data.Extensions;
25+
using Wissance.WeatherControl.Common.Config;
26+
using Wissance.WeatherControl.Data.Entity;
27+
using Wissance.WebApiToolkit.Core.Data;
28+
using Wissance.WebApiToolkit.Core.Managers;
29+
using Wissance.WebApiToolkit.Ef.Factories;
30+
using Wissance.WebApiToolkit.Ef.Managers;
31+
using Wissance.WebApiToolkit.Ef.Extensions;
32+
using Wissance.WebApiToolkit.Ef.Generators;
33+
34+
namespace Wissance.WeatherControl.SemiAuto.WebApi
35+
{
36+
public class Startup
37+
{
38+
public Startup(IConfiguration configuration, IWebHostEnvironment env)
39+
{
40+
Configuration = configuration;
41+
Environment = env;
42+
Settings = configuration.GetSection("Application").Get<ApplicationSettings>();
43+
}
44+
45+
// This method gets called by the runtime. Use this method to add services to the container.
46+
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
47+
public void ConfigureServices(IServiceCollection services)
48+
{
49+
ConfigureLogging(services);
50+
ConfigureDatabase(services);
51+
ConfigureWebApi(services);
52+
}
53+
54+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
55+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
56+
{
57+
if (env.IsDevelopment())
58+
{
59+
app.UseDeveloperExceptionPage();
60+
}
61+
62+
app.UseSwagger();
63+
app.UseSwaggerUI(c =>
64+
{
65+
c.SwaggerEndpoint("/swagger/v1/swagger.json", AppName);
66+
});
67+
68+
app.UseRouting();
69+
70+
app.UseEndpoints(endpoints =>
71+
{
72+
endpoints.MapControllers();
73+
});
74+
}
75+
76+
private void ConfigureLogging(IServiceCollection services)
77+
{
78+
Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(Configuration).CreateLogger();
79+
services.AddLogging(loggingBuilder => loggingBuilder.AddConfiguration(Configuration).AddConsole());
80+
services.AddLogging(loggingBuilder => loggingBuilder.AddConfiguration(Configuration).AddDebug());
81+
services.AddLogging(loggingBuilder => loggingBuilder.AddConfiguration(Configuration).AddSerilog(dispose: true));
82+
}
83+
84+
private void ConfigureDatabase(IServiceCollection services)
85+
{
86+
services.ConfigureSqlServerDbContext<ModelContext>(Settings.Database.ConnStr);
87+
IServiceProvider serviceProvider = services.BuildServiceProvider();
88+
ModelContext modelContext = serviceProvider.GetRequiredService<ModelContext>();
89+
modelContext.Database.Migrate();
90+
}
91+
92+
private void ConfigureWebApi(IServiceCollection services)
93+
{
94+
services.AddSwaggerGen();
95+
ServiceProvider provider = services.BuildServiceProvider();
96+
Assembly stationControllerAssembly = services.AddSimplifiedAutoController<StationEntity, Guid, EmptyAdditionalFilters>(
97+
provider.GetRequiredService<ModelContext>(), "Station",
98+
ControllerType.FullCrud, null, provider.GetRequiredService<ILoggerFactory>());
99+
Assembly measureUnitControllerAssembly = services.AddSimplifiedAutoController<MeasureUnitEntity, Guid, EmptyAdditionalFilters>(
100+
provider.GetRequiredService<ModelContext>(), "MeasureUnit",
101+
ControllerType.ReadOnly, null, provider.GetRequiredService<ILoggerFactory>());
102+
Assembly sensorControllerAssembly = services.AddSimplifiedAutoController<SensorEntity, Guid, EmptyAdditionalFilters>(
103+
provider.GetRequiredService<ModelContext>(), "Sensor",
104+
ControllerType.FullCrud, null, provider.GetRequiredService<ILoggerFactory>());
105+
Assembly measurementControllerAssembly = services.AddSimplifiedAutoController<MeasurementEntity, Guid, EmptyAdditionalFilters>(
106+
provider.GetRequiredService<ModelContext>(), "Measurement",
107+
ControllerType.Bulk, null, provider.GetRequiredService<ILoggerFactory>());
108+
109+
services.AddControllers().AddApplicationPart(sensorControllerAssembly).AddControllersAsServices();
110+
services.AddControllers().AddApplicationPart(stationControllerAssembly).AddControllersAsServices();
111+
services.AddControllers().AddApplicationPart(measureUnitControllerAssembly).AddControllersAsServices();
112+
services.AddControllers().AddApplicationPart(measurementControllerAssembly).AddControllersAsServices();
113+
}
114+
115+
public ApplicationSettings Settings { get; set; }
116+
private IConfiguration Configuration { get; }
117+
public IWebHostEnvironment Environment { get; }
118+
119+
private const string AppName = "Wissance.WeatherControl";
120+
}
121+
}

0 commit comments

Comments
 (0)