Inital work on breaking out the core logic out of the MVC API Web App in preparation to migrating to minimal API's in a seperate project
This commit is contained in:
22
AS1024.GeoFeed.Core/AS1024.GeoFeed.Core.csproj
Normal file
22
AS1024.GeoFeed.Core/AS1024.GeoFeed.Core.csproj
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AS1024.GeoFeed.Models\AS1024.GeoFeed.Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.GeoFeedLocalCache
|
namespace AS1024.GeoFeed.Core.GeoFeedLocalCache
|
||||||
{
|
{
|
||||||
public class GeoFeedCacheDbContext : DbContext
|
public class GeoFeedCacheDbContext : DbContext
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using AS1024.GeoFeed.Models;
|
using AS1024.GeoFeed.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.GeoFeedLocalCache
|
namespace AS1024.GeoFeed.Core.GeoFeedLocalCache
|
||||||
{
|
{
|
||||||
public class GeoFeedCacheEntry : IPGeoFeed
|
public class GeoFeedCacheEntry : IPGeoFeed
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
using AS1024.GeoFeed.Interfaces;
|
using AS1024.GeoFeed.Core.Interfaces;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.GeoFeedLocalCache
|
namespace AS1024.GeoFeed.Core.GeoFeedLocalCache
|
||||||
{
|
{
|
||||||
public class GeoFeedCacheService : IHostedService
|
public class GeoFeedCacheService : IHostedService
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Design;
|
using Microsoft.EntityFrameworkCore.Design;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.GeoFeedLocalCache
|
namespace AS1024.GeoFeed.Core.GeoFeedLocalCache
|
||||||
{
|
{
|
||||||
public class GeoFeedDesignTimeMigration : IDesignTimeDbContextFactory<GeoFeedCacheDbContext>
|
public class GeoFeedDesignTimeMigration : IDesignTimeDbContextFactory<GeoFeedCacheDbContext>
|
||||||
{
|
{
|
||||||
@@ -1,21 +1,22 @@
|
|||||||
|
using AS1024.GeoFeed.Core.Interfaces;
|
||||||
using AS1024.GeoFeed.Interfaces;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.GeoFeedBuilder
|
namespace AS1024.GeoFeed.Core.GeoFeedPreloader
|
||||||
{
|
{
|
||||||
public class PreLoadGeoFeed : IHostedService
|
public class PreLoadGeoFeed : IHostedService
|
||||||
{
|
{
|
||||||
private readonly ILogger<PreLoadGeoFeed> logger;
|
private readonly ILogger<PreLoadGeoFeed> logger;
|
||||||
private readonly IGeoFeedProvider provider;
|
private readonly IGeoFeedProvider provider;
|
||||||
private readonly IMemoryCache memoryCache;
|
private readonly IMemoryCache memoryCache;
|
||||||
private readonly IWebHostEnvironment environment;
|
private readonly IHostEnvironment environment;
|
||||||
private const string GeoFeedCacheKey = "GeoFeedData";
|
private const string GeoFeedCacheKey = "GeoFeedData";
|
||||||
|
|
||||||
public PreLoadGeoFeed(ILogger<PreLoadGeoFeed> logger,
|
public PreLoadGeoFeed(ILogger<PreLoadGeoFeed> logger,
|
||||||
IGeoFeedProvider provider,
|
IGeoFeedProvider provider,
|
||||||
IMemoryCache memoryCache,
|
IMemoryCache memoryCache,
|
||||||
IWebHostEnvironment environment)
|
IHostEnvironment environment)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
@@ -29,7 +30,8 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
|
|||||||
{
|
{
|
||||||
if (environment.IsProduction())
|
if (environment.IsProduction())
|
||||||
await StartPreLoad();
|
await StartPreLoad();
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogWarning($"Failed to preload, exception settings below:\n{ex}");
|
logger.LogWarning($"Failed to preload, exception settings below:\n{ex}");
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
using AS1024.GeoFeed.Interfaces;
|
using AS1024.GeoFeed.Core.Interfaces;
|
||||||
using AS1024.GeoFeed.Models;
|
using AS1024.GeoFeed.Models;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.GeoFeedBuilder
|
namespace AS1024.GeoFeed.Core.GeoFeedProviders
|
||||||
{
|
{
|
||||||
public class NetBoxGeoFeedProvider : IGeoFeedProvider
|
public class NetBoxGeoFeedProvider : IGeoFeedProvider
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using AS1024.GeoFeed.Models;
|
using AS1024.GeoFeed.Models;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.Interfaces
|
namespace AS1024.GeoFeed.Core.Interfaces
|
||||||
{
|
{
|
||||||
public interface IGeoFeedProvider
|
public interface IGeoFeedProvider
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using AS1024.GeoFeed.GeoFeedLocalCache;
|
using AS1024.GeoFeed.Core.GeoFeedLocalCache;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
@@ -8,11 +8,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.Migrations
|
namespace AS1024.GeoFeed.Core.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(GeoFeedCacheDbContext))]
|
[DbContext(typeof(GeoFeedCacheDbContext))]
|
||||||
[Migration("20240108180753_DiskCacheMigration")]
|
[Migration("20240113204143_InitialMigration")]
|
||||||
partial class DiskCacheMigration
|
partial class InitialMigration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -20,7 +20,7 @@ namespace AS1024.GeoFeed.Migrations
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.0");
|
modelBuilder.HasAnnotation("ProductVersion", "8.0.0");
|
||||||
|
|
||||||
modelBuilder.Entity("AS1024.GeoFeed.GeoFeedLocalCache.GeoFeedCacheEntry", b =>
|
modelBuilder.Entity("AS1024.GeoFeed.Core.GeoFeedLocalCache.GeoFeedCacheEntry", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.Migrations
|
namespace AS1024.GeoFeed.Core.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class DiskCacheMigration : Migration
|
public partial class InitialMigration : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using AS1024.GeoFeed.GeoFeedLocalCache;
|
using AS1024.GeoFeed.Core.GeoFeedLocalCache;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.Migrations
|
namespace AS1024.GeoFeed.Core.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(GeoFeedCacheDbContext))]
|
[DbContext(typeof(GeoFeedCacheDbContext))]
|
||||||
partial class GeoFeedCacheDbContextModelSnapshot : ModelSnapshot
|
partial class GeoFeedCacheDbContextModelSnapshot : ModelSnapshot
|
||||||
@@ -17,7 +17,7 @@ namespace AS1024.GeoFeed.Migrations
|
|||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.0");
|
modelBuilder.HasAnnotation("ProductVersion", "8.0.0");
|
||||||
|
|
||||||
modelBuilder.Entity("AS1024.GeoFeed.GeoFeedLocalCache.GeoFeedCacheEntry", b =>
|
modelBuilder.Entity("AS1024.GeoFeed.Core.GeoFeedLocalCache.GeoFeedCacheEntry", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using AS1024.GeoFeed.Models;
|
using AS1024.GeoFeed.Models;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.GeoFeedBuilder
|
namespace AS1024.GeoFeed.Core.Tools
|
||||||
{
|
{
|
||||||
public static class GeoFeedTools
|
public static class GeoFeedTools
|
||||||
{
|
{
|
||||||
9
AS1024.GeoFeed.Models/AS1024.GeoFeed.Models.csproj
Normal file
9
AS1024.GeoFeed.Models/AS1024.GeoFeed.Models.csproj
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -3,7 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.8.34330.188
|
VisualStudioVersion = 17.8.34330.188
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AS1024.GeoFeed", "AS1024.GeoFeed\AS1024.GeoFeed.csproj", "{6292097C-7F35-45BB-B2B0-1918DF49FE7D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AS1024.GeoFeed", "AS1024.GeoFeed\AS1024.GeoFeed.csproj", "{6292097C-7F35-45BB-B2B0-1918DF49FE7D}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{8BA82A53-29E7-44A2-91BA-57C15BB4B0F5} = {8BA82A53-29E7-44A2-91BA-57C15BB4B0F5}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AS1024.GeoFeed.Models", "AS1024.GeoFeed.Models\AS1024.GeoFeed.Models.csproj", "{8BA82A53-29E7-44A2-91BA-57C15BB4B0F5}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AS1024.GeoFeed.Core", "AS1024.GeoFeed.Core\AS1024.GeoFeed.Core.csproj", "{EE6D6C87-29C4-42A1-8251-7D2BF20F1797}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -15,6 +22,14 @@ Global
|
|||||||
{6292097C-7F35-45BB-B2B0-1918DF49FE7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6292097C-7F35-45BB-B2B0-1918DF49FE7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6292097C-7F35-45BB-B2B0-1918DF49FE7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6292097C-7F35-45BB-B2B0-1918DF49FE7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6292097C-7F35-45BB-B2B0-1918DF49FE7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6292097C-7F35-45BB-B2B0-1918DF49FE7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8BA82A53-29E7-44A2-91BA-57C15BB4B0F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8BA82A53-29E7-44A2-91BA-57C15BB4B0F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8BA82A53-29E7-44A2-91BA-57C15BB4B0F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8BA82A53-29E7-44A2-91BA-57C15BB4B0F5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EE6D6C87-29C4-42A1-8251-7D2BF20F1797}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EE6D6C87-29C4-42A1-8251-7D2BF20F1797}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EE6D6C87-29C4-42A1-8251-7D2BF20F1797}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EE6D6C87-29C4-42A1-8251-7D2BF20F1797}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -21,4 +21,9 @@
|
|||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AS1024.GeoFeed.Core\AS1024.GeoFeed.Core.csproj" />
|
||||||
|
<ProjectReference Include="..\AS1024.GeoFeed.Models\AS1024.GeoFeed.Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using AS1024.GeoFeed.Interfaces;
|
using AS1024.GeoFeed.Core.Interfaces;
|
||||||
using AS1024.GeoFeed.GeoFeedBuilder;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using AS1024.GeoFeed.Models;
|
using AS1024.GeoFeed.Models;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using AS1024.GeoFeed.GeoFeedLocalCache;
|
using AS1024.GeoFeed.Core.GeoFeedLocalCache;
|
||||||
|
using AS1024.GeoFeed.Core.Tools;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed.Controllers
|
namespace AS1024.GeoFeed.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using AS1024.GeoFeed.GeoFeedBuilder;
|
using AS1024.GeoFeed.Core.Interfaces;
|
||||||
using AS1024.GeoFeed.GeoFeedLocalCache;
|
using AS1024.GeoFeed.Core.GeoFeedPreloader;
|
||||||
using AS1024.GeoFeed.Interfaces;
|
using AS1024.GeoFeed.Core.GeoFeedLocalCache;
|
||||||
|
using AS1024.GeoFeed.Core.GeoFeedProviders;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace AS1024.GeoFeed
|
namespace AS1024.GeoFeed
|
||||||
|
|||||||
Reference in New Issue
Block a user