mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
parent
03f93c8175
commit
e4da4a799a
10 changed files with 93 additions and 24 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -297,4 +297,5 @@ __pycache__/
|
|||
# FilterLists Custom Ignores
|
||||
gs/Private.gs
|
||||
src/FilterLists.Api/appsettings.Development.json
|
||||
src/FilterLists.Api/appsettings.Production.json
|
||||
src/FilterLists.Api/appsettings.Production.json
|
||||
src/FilterLists.DataLoad/appsettings.json
|
||||
|
|
|
|||
|
|
@ -28,5 +28,10 @@
|
|||
<ProjectReference Include="..\FilterLists.Data\FilterLists.Data.csproj" />
|
||||
<ProjectReference Include="..\FilterLists.Services\FilterLists.Services.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public Startup(IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|||
.AddEnvironmentVariables();
|
||||
Configuration = builder.Build();
|
||||
|
||||
//TODO: replace below with serilog
|
||||
//TODO: replace with serilog
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
loggerFactory.AddDebug();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
using FilterLists.Services.Contracts;
|
||||
using FilterLists.Services.Implementations;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FilterLists.DataLoad
|
||||
{
|
||||
//TODO: trigger on job or ideally via GitHub webhook when any .csv is updated
|
||||
internal class DataLoad
|
||||
{
|
||||
private static void Main()
|
||||
{
|
||||
var serviceProvider = new ServiceCollection()
|
||||
.AddLogging()
|
||||
.AddSingleton<ITableService, TableService>()
|
||||
.BuildServiceProvider();
|
||||
serviceProvider.GetService<ITableService>().UpdateTables();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FilterLists.DataLoad.DependencyInjection.Extensions
|
||||
{
|
||||
public static class ConfigureServicesCollection
|
||||
{
|
||||
public static void AddFilterListsDataLoad(this IServiceCollection services)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,8 +5,20 @@
|
|||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="10.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
26
src/FilterLists.DataLoad/Program.cs
Normal file
26
src/FilterLists.DataLoad/Program.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using FilterLists.Services.Contracts;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FilterLists.DataLoad
|
||||
{
|
||||
//TODO: trigger on job or ideally via GitHub webhook when any .csv is updated in master
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
IServiceCollection services = new ServiceCollection();
|
||||
var startup = new Startup();
|
||||
startup.ConfigureServices(services);
|
||||
var serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
//TODO: replace with serilog
|
||||
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
|
||||
var logger = loggerFactory.CreateLogger<Program>();
|
||||
|
||||
logger.LogInformation("Updating Tables");
|
||||
var tableService = serviceProvider.GetService<ITableService>();
|
||||
tableService.UpdateTables();
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/FilterLists.DataLoad/Startup.cs
Normal file
32
src/FilterLists.DataLoad/Startup.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System.IO;
|
||||
using FilterLists.Data.DependencyInjection.Extensions;
|
||||
using FilterLists.DataLoad.DependencyInjection.Extensions;
|
||||
using FilterLists.Services.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FilterLists.DataLoad
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup()
|
||||
{
|
||||
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", false, true);
|
||||
Configuration = builder.Build();
|
||||
}
|
||||
|
||||
private IConfigurationRoot Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
var loggerFactory = new LoggerFactory().AddConsole().AddDebug();
|
||||
services.AddSingleton(loggerFactory);
|
||||
services.AddLogging();
|
||||
services.AddFilterListsRepositories(Configuration);
|
||||
services.AddFilterListsServices();
|
||||
services.AddFilterListsDataLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ public static class ConfigureServicesCollection
|
|||
public static void AddFilterListsServices(this IServiceCollection services)
|
||||
{
|
||||
services.TryAddScoped<IListService, ListService>();
|
||||
services.TryAddScoped<ITableService, TableService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,11 +9,11 @@ namespace FilterLists.Services.Implementations
|
|||
{
|
||||
public class TableService : ITableService
|
||||
{
|
||||
//private readonly IListRepository _listRepository;
|
||||
private readonly IListRepository _listRepository;
|
||||
|
||||
public TableService(/*IListRepository listRepository*/)
|
||||
public TableService(IListRepository listRepository)
|
||||
{
|
||||
//_listRepository = listRepository;
|
||||
_listRepository = listRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue