diff --git a/AS1024.GeoFeed.Core/AS1024.GeoFeed.Core.csproj b/AS1024.GeoFeed.Core/AS1024.GeoFeed.Core.csproj new file mode 100644 index 0000000..2e82e62 --- /dev/null +++ b/AS1024.GeoFeed.Core/AS1024.GeoFeed.Core.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + diff --git a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheDbContext.cs b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheDbContext.cs similarity index 86% rename from AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheDbContext.cs rename to AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheDbContext.cs index d23188e..460f75e 100644 --- a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheDbContext.cs +++ b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheDbContext.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace AS1024.GeoFeed.GeoFeedLocalCache +namespace AS1024.GeoFeed.Core.GeoFeedLocalCache { public class GeoFeedCacheDbContext : DbContext { diff --git a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheEntry.cs b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheEntry.cs similarity index 79% rename from AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheEntry.cs rename to AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheEntry.cs index 363692f..3032f2f 100644 --- a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheEntry.cs +++ b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheEntry.cs @@ -1,7 +1,7 @@ using AS1024.GeoFeed.Models; using System.ComponentModel.DataAnnotations; -namespace AS1024.GeoFeed.GeoFeedLocalCache +namespace AS1024.GeoFeed.Core.GeoFeedLocalCache { public class GeoFeedCacheEntry : IPGeoFeed { diff --git a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheService.cs b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheService.cs similarity index 94% rename from AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheService.cs rename to AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheService.cs index ac5a52b..16ff656 100644 --- a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedCacheService.cs +++ b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedCacheService.cs @@ -1,8 +1,11 @@ -using AS1024.GeoFeed.Interfaces; +using AS1024.GeoFeed.Core.Interfaces; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using System.Runtime.CompilerServices; -namespace AS1024.GeoFeed.GeoFeedLocalCache +namespace AS1024.GeoFeed.Core.GeoFeedLocalCache { public class GeoFeedCacheService : IHostedService { diff --git a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedDesignTimeMigration.cs b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedDesignTimeMigration.cs similarity index 90% rename from AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedDesignTimeMigration.cs rename to AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedDesignTimeMigration.cs index f79d0b6..1207fc2 100644 --- a/AS1024.GeoFeed/GeoFeedLocalCache/GeoFeedDesignTimeMigration.cs +++ b/AS1024.GeoFeed.Core/GeoFeedLocalCache/GeoFeedDesignTimeMigration.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; -namespace AS1024.GeoFeed.GeoFeedLocalCache +namespace AS1024.GeoFeed.Core.GeoFeedLocalCache { public class GeoFeedDesignTimeMigration : IDesignTimeDbContextFactory { diff --git a/AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs b/AS1024.GeoFeed.Core/GeoFeedPreloader/PreloadGeoFeed.cs similarity index 83% rename from AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs rename to AS1024.GeoFeed.Core/GeoFeedPreloader/PreloadGeoFeed.cs index 28f76b8..ee3e9c7 100644 --- a/AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs +++ b/AS1024.GeoFeed.Core/GeoFeedPreloader/PreloadGeoFeed.cs @@ -1,21 +1,22 @@ - -using AS1024.GeoFeed.Interfaces; +using AS1024.GeoFeed.Core.Interfaces; 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 { private readonly ILogger logger; private readonly IGeoFeedProvider provider; private readonly IMemoryCache memoryCache; - private readonly IWebHostEnvironment environment; + private readonly IHostEnvironment environment; private const string GeoFeedCacheKey = "GeoFeedData"; public PreLoadGeoFeed(ILogger logger, IGeoFeedProvider provider, IMemoryCache memoryCache, - IWebHostEnvironment environment) + IHostEnvironment environment) { this.logger = logger; this.provider = provider; @@ -29,7 +30,8 @@ namespace AS1024.GeoFeed.GeoFeedBuilder { if (environment.IsProduction()) await StartPreLoad(); - } catch (Exception ex) + } + catch (Exception ex) { logger.LogWarning($"Failed to preload, exception settings below:\n{ex}"); } diff --git a/AS1024.GeoFeed/GeoFeedBuilder/NetBoxGeoFeedProvider.cs b/AS1024.GeoFeed.Core/GeoFeedProviders/NetBoxGeoFeedProvider.cs similarity index 96% rename from AS1024.GeoFeed/GeoFeedBuilder/NetBoxGeoFeedProvider.cs rename to AS1024.GeoFeed.Core/GeoFeedProviders/NetBoxGeoFeedProvider.cs index 607c36a..9e44f28 100644 --- a/AS1024.GeoFeed/GeoFeedBuilder/NetBoxGeoFeedProvider.cs +++ b/AS1024.GeoFeed.Core/GeoFeedProviders/NetBoxGeoFeedProvider.cs @@ -1,11 +1,13 @@ -using AS1024.GeoFeed.Interfaces; +using AS1024.GeoFeed.Core.Interfaces; using AS1024.GeoFeed.Models; using System.Text.Json; using System.Net.Http.Headers; using System.Net.Sockets; using System.Web; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; -namespace AS1024.GeoFeed.GeoFeedBuilder +namespace AS1024.GeoFeed.Core.GeoFeedProviders { public class NetBoxGeoFeedProvider : IGeoFeedProvider { diff --git a/AS1024.GeoFeed/Interfaces/GeoFeedProvider.cs b/AS1024.GeoFeed.Core/Interfaces/GeoFeedProvider.cs similarity index 82% rename from AS1024.GeoFeed/Interfaces/GeoFeedProvider.cs rename to AS1024.GeoFeed.Core/Interfaces/GeoFeedProvider.cs index f547e95..719fb20 100644 --- a/AS1024.GeoFeed/Interfaces/GeoFeedProvider.cs +++ b/AS1024.GeoFeed.Core/Interfaces/GeoFeedProvider.cs @@ -1,6 +1,6 @@ using AS1024.GeoFeed.Models; -namespace AS1024.GeoFeed.Interfaces +namespace AS1024.GeoFeed.Core.Interfaces { public interface IGeoFeedProvider { diff --git a/AS1024.GeoFeed/Migrations/20240108180753_DiskCacheMigration.Designer.cs b/AS1024.GeoFeed.Core/Migrations/20240113204143_InitialMigration.Designer.cs similarity index 84% rename from AS1024.GeoFeed/Migrations/20240108180753_DiskCacheMigration.Designer.cs rename to AS1024.GeoFeed.Core/Migrations/20240113204143_InitialMigration.Designer.cs index ae8e9c7..57f28fc 100644 --- a/AS1024.GeoFeed/Migrations/20240108180753_DiskCacheMigration.Designer.cs +++ b/AS1024.GeoFeed.Core/Migrations/20240113204143_InitialMigration.Designer.cs @@ -1,6 +1,6 @@ // using System; -using AS1024.GeoFeed.GeoFeedLocalCache; +using AS1024.GeoFeed.Core.GeoFeedLocalCache; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -8,11 +8,11 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; #nullable disable -namespace AS1024.GeoFeed.Migrations +namespace AS1024.GeoFeed.Core.Migrations { [DbContext(typeof(GeoFeedCacheDbContext))] - [Migration("20240108180753_DiskCacheMigration")] - partial class DiskCacheMigration + [Migration("20240113204143_InitialMigration")] + partial class InitialMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -20,7 +20,7 @@ namespace AS1024.GeoFeed.Migrations #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); - modelBuilder.Entity("AS1024.GeoFeed.GeoFeedLocalCache.GeoFeedCacheEntry", b => + modelBuilder.Entity("AS1024.GeoFeed.Core.GeoFeedLocalCache.GeoFeedCacheEntry", b => { b.Property("Id") .ValueGeneratedOnAdd() diff --git a/AS1024.GeoFeed/Migrations/20240108180753_DiskCacheMigration.cs b/AS1024.GeoFeed.Core/Migrations/20240113204143_InitialMigration.cs similarity index 93% rename from AS1024.GeoFeed/Migrations/20240108180753_DiskCacheMigration.cs rename to AS1024.GeoFeed.Core/Migrations/20240113204143_InitialMigration.cs index 2a350f5..4662ece 100644 --- a/AS1024.GeoFeed/Migrations/20240108180753_DiskCacheMigration.cs +++ b/AS1024.GeoFeed.Core/Migrations/20240113204143_InitialMigration.cs @@ -2,10 +2,10 @@ #nullable disable -namespace AS1024.GeoFeed.Migrations +namespace AS1024.GeoFeed.Core.Migrations { /// - public partial class DiskCacheMigration : Migration + public partial class InitialMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) diff --git a/AS1024.GeoFeed/Migrations/GeoFeedCacheDbContextModelSnapshot.cs b/AS1024.GeoFeed.Core/Migrations/GeoFeedCacheDbContextModelSnapshot.cs similarity index 88% rename from AS1024.GeoFeed/Migrations/GeoFeedCacheDbContextModelSnapshot.cs rename to AS1024.GeoFeed.Core/Migrations/GeoFeedCacheDbContextModelSnapshot.cs index f01917f..08ab2c9 100644 --- a/AS1024.GeoFeed/Migrations/GeoFeedCacheDbContextModelSnapshot.cs +++ b/AS1024.GeoFeed.Core/Migrations/GeoFeedCacheDbContextModelSnapshot.cs @@ -1,13 +1,13 @@ // using System; -using AS1024.GeoFeed.GeoFeedLocalCache; +using AS1024.GeoFeed.Core.GeoFeedLocalCache; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; #nullable disable -namespace AS1024.GeoFeed.Migrations +namespace AS1024.GeoFeed.Core.Migrations { [DbContext(typeof(GeoFeedCacheDbContext))] partial class GeoFeedCacheDbContextModelSnapshot : ModelSnapshot @@ -17,7 +17,7 @@ namespace AS1024.GeoFeed.Migrations #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); - modelBuilder.Entity("AS1024.GeoFeed.GeoFeedLocalCache.GeoFeedCacheEntry", b => + modelBuilder.Entity("AS1024.GeoFeed.Core.GeoFeedLocalCache.GeoFeedCacheEntry", b => { b.Property("Id") .ValueGeneratedOnAdd() diff --git a/AS1024.GeoFeed/GeoFeedBuilder/GeoFeedTools.cs b/AS1024.GeoFeed.Core/Tools/GeoFeedTools.cs similarity index 92% rename from AS1024.GeoFeed/GeoFeedBuilder/GeoFeedTools.cs rename to AS1024.GeoFeed.Core/Tools/GeoFeedTools.cs index 458189c..ee19c89 100644 --- a/AS1024.GeoFeed/GeoFeedBuilder/GeoFeedTools.cs +++ b/AS1024.GeoFeed.Core/Tools/GeoFeedTools.cs @@ -1,7 +1,7 @@ using AS1024.GeoFeed.Models; using System.Text; -namespace AS1024.GeoFeed.GeoFeedBuilder +namespace AS1024.GeoFeed.Core.Tools { public static class GeoFeedTools { diff --git a/AS1024.GeoFeed.Models/AS1024.GeoFeed.Models.csproj b/AS1024.GeoFeed.Models/AS1024.GeoFeed.Models.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/AS1024.GeoFeed.Models/AS1024.GeoFeed.Models.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/AS1024.GeoFeed/Models/GeoFeed.cs b/AS1024.GeoFeed.Models/GeoFeed.cs similarity index 100% rename from AS1024.GeoFeed/Models/GeoFeed.cs rename to AS1024.GeoFeed.Models/GeoFeed.cs diff --git a/AS1024.GeoFeed.sln b/AS1024.GeoFeed.sln index 848634e..dd95a8e 100644 --- a/AS1024.GeoFeed.sln +++ b/AS1024.GeoFeed.sln @@ -3,7 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34330.188 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 Global 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}.Release|Any CPU.ActiveCfg = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AS1024.GeoFeed/AS1024.GeoFeed.csproj b/AS1024.GeoFeed/AS1024.GeoFeed.csproj index c98cdbf..34ca58a 100644 --- a/AS1024.GeoFeed/AS1024.GeoFeed.csproj +++ b/AS1024.GeoFeed/AS1024.GeoFeed.csproj @@ -21,4 +21,9 @@ + + + + + diff --git a/AS1024.GeoFeed/Controllers/GeofeedController.cs b/AS1024.GeoFeed/Controllers/GeofeedController.cs index 3d58028..f9aa0a9 100644 --- a/AS1024.GeoFeed/Controllers/GeofeedController.cs +++ b/AS1024.GeoFeed/Controllers/GeofeedController.cs @@ -1,10 +1,10 @@ using Microsoft.AspNetCore.Mvc; -using AS1024.GeoFeed.Interfaces; -using AS1024.GeoFeed.GeoFeedBuilder; +using AS1024.GeoFeed.Core.Interfaces; using Microsoft.Extensions.Caching.Memory; using AS1024.GeoFeed.Models; using System.Text; -using AS1024.GeoFeed.GeoFeedLocalCache; +using AS1024.GeoFeed.Core.GeoFeedLocalCache; +using AS1024.GeoFeed.Core.Tools; namespace AS1024.GeoFeed.Controllers { diff --git a/AS1024.GeoFeed/Program.cs b/AS1024.GeoFeed/Program.cs index 13fa4d5..a203edf 100644 --- a/AS1024.GeoFeed/Program.cs +++ b/AS1024.GeoFeed/Program.cs @@ -1,6 +1,7 @@ -using AS1024.GeoFeed.GeoFeedBuilder; -using AS1024.GeoFeed.GeoFeedLocalCache; -using AS1024.GeoFeed.Interfaces; +using AS1024.GeoFeed.Core.Interfaces; +using AS1024.GeoFeed.Core.GeoFeedPreloader; +using AS1024.GeoFeed.Core.GeoFeedLocalCache; +using AS1024.GeoFeed.Core.GeoFeedProviders; using Microsoft.EntityFrameworkCore; namespace AS1024.GeoFeed