.NET version updates, add database complete email

This commit is contained in:
2022-05-31 12:00:22 -04:00
parent 98092543ab
commit 9924880b51
6 changed files with 133 additions and 140 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<UserSecretsId>f9e2fd37-0f2d-4e3a-955a-8e49a16fce1c</UserSecretsId> <UserSecretsId>f9e2fd37-0f2d-4e3a-955a-8e49a16fce1c</UserSecretsId>
<Configurations>Debug;Release;Also Debug</Configurations> <Configurations>Debug;Release;Also Debug</Configurations>
</PropertyGroup> </PropertyGroup>
@@ -12,11 +12,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Remove="appsettings.development.json" /> <Compile Remove="wwwroot\**" />
<Content Remove="wwwroot\**" />
<EmbeddedResource Remove="wwwroot\**" />
<None Remove="wwwroot\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="wwwroot\" /> <Content Remove="appsettings.development.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -8,46 +8,48 @@ using System.Threading.Tasks;
namespace PartSource.Automation.Jobs namespace PartSource.Automation.Jobs
{ {
public class ExecuteSsisPackages : IAutomationJob public class ExecuteSsisPackages : IAutomationJob
{ {
private readonly FtpService _ftpService; private readonly EmailService _emailService;
private readonly SsisService _ssisService; private readonly FtpService _ftpService;
private readonly ILogger<ExecuteSsisPackages> _logger; private readonly SsisService _ssisService;
private readonly ILogger<ExecuteSsisPackages> _logger;
// TODO: set from config // TODO: set from config
private readonly string[] _ssisPackages = { "Parts Availability" }; private readonly string[] _ssisPackages = { "Parts Price", "Parts Availability" };
public ExecuteSsisPackages(IConfiguration configuration, SsisService ssisService, ILogger<ExecuteSsisPackages> logger) public ExecuteSsisPackages(EmailService emailService, FtpService ftpService, SsisService ssisService, ILogger<ExecuteSsisPackages> logger)
{ {
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AzureConfiguration").Get<FtpConfiguration>(); _ftpService = ftpService;
_emailService = emailService;
_ssisService = ssisService;
_logger = logger;
}
_ftpService = new FtpService(ftpConfiguration); public async Task Run()
_ssisService = ssisService; {
_logger = logger; await Task.Run(() =>
} {
foreach (string package in _ssisPackages)
{
try
{
_ftpService.Download($"{package}.txt");
_ssisService.Execute($"{package}.dtsx");
public async Task Run() _logger.LogInformation("Execution of SSIS package {package} completed successfully.", package);
{ }
await Task.Run(() =>
{
foreach (string package in _ssisPackages)
{
try
{
_ftpService.Download($"{package}.txt");
_ssisService.Execute($"{package}.dtsx");
_logger.LogInformation($"Execution of SSIS package {package} completed successfully."); catch (Exception ex)
} {
_logger.LogError(ex, "Execution of SSIS package {package} failed", package);
catch (Exception ex) throw;
{ }
_logger.LogError($"Execution of SSIS package {package} failed.", ex); }
throw; _emailService.Send("Database Updates Complete", "Database updates to support pricing and availability have completed successfully.");
} });
} }
}); }
}
}
} }

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Configurations>Debug;Release;Also Debug</Configurations> <Configurations>Debug;Release;Also Debug</Configurations>
</PropertyGroup> </PropertyGroup>

View File

@@ -6,6 +6,7 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using PartSource.Automation.Jobs; using PartSource.Automation.Jobs;
using PartSource.Automation.Jobs.POC; using PartSource.Automation.Jobs.POC;
using PartSource.Automation.Models.Configuration;
using PartSource.Automation.Services; using PartSource.Automation.Services;
using PartSource.Data; using PartSource.Data;
using PartSource.Data.AutoMapper; using PartSource.Data.AutoMapper;
@@ -20,111 +21,96 @@ using System.Threading.Tasks;
namespace PartSource.Automation namespace PartSource.Automation
{ {
class Program class Program
{ {
static async Task Main(string[] args){ static async Task Main(string[] args)
try {
{ try
using IHost host = CreateHostBuilder().Build(); {
using IHost host = CreateHostBuilder().Build();
await host.StartAsync(); await host.StartAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
throw; throw;
} }
} }
private static IHostBuilder CreateHostBuilder() private static IHostBuilder CreateHostBuilder()
{ {
return Host.CreateDefaultBuilder() return Host.CreateDefaultBuilder()
.ConfigureAppConfiguration(builder => .ConfigureAppConfiguration(builder =>
{ {
string environment = Environment.GetEnvironmentVariable("AUTOMATION_ENVIRONMENT"); string environment = Environment.GetEnvironmentVariable("AUTOMATION_ENVIRONMENT");
builder.SetBasePath(Directory.GetCurrentDirectory()) builder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true); .AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true);
}) })
.ConfigureServices((builder, services) => .ConfigureServices((builder, services) =>
{ {
services.AddDbContext<PartSourceContext>(options => services.AddDbContext<PartSourceContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("PartSourceDatabase"), opts => opts.EnableRetryOnFailure()) options.UseSqlServer(builder.Configuration.GetConnectionString("PartSourceDatabase"), opts => opts.EnableRetryOnFailure())
) )
.AddDbContext<FitmentContext>(options => .AddDbContext<FitmentContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("FitmentDatabase"), opts => options.UseSqlServer(builder.Configuration.GetConnectionString("FitmentDatabase"), opts =>
{ {
opts.EnableRetryOnFailure(); opts.EnableRetryOnFailure();
opts.CommandTimeout(600); opts.CommandTimeout(600);
}) })
) )
.AddShopify(options => .AddShopify(options =>
{ {
options.ApiKey = builder.Configuration["Shopify:ApiKey"]; options.ApiKey = builder.Configuration["Shopify:ApiKey"];
options.ApiSecret = builder.Configuration["Shopify:ApiSecret"]; options.ApiSecret = builder.Configuration["Shopify:ApiSecret"];
options.ApiVersion = "2020-01"; options.ApiVersion = "2021-01";
options.ShopDomain = builder.Configuration["Shopify:ShopDomain"]; options.ShopDomain = builder.Configuration["Shopify:ShopDomain"];
//options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed"; //options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed";
//options.ApiSecret = "dc9e28365d9858e544d57ac7af43fee7"; //options.ApiSecret = "dc9e28365d9858e544d57ac7af43fee7";
//options.ApiVersion = "2020-01"; //options.ApiVersion = "2020-01";
//options.ShopDomain = "dev-partsource.myshopify.com"; //options.ShopDomain = "dev-partsource.myshopify.com";
}) })
.AddAutomation(options => .AddAutomation(options =>
{ {
options.HasBaseInterval(new TimeSpan(0, 15, 0)) options.HasBaseInterval(new TimeSpan(0, 15, 0))
.HasMaxFailures(1) .HasMaxFailures(3)
//.HasJob<TestJob>(options => options.HasInterval(new TimeSpan(7, 0, 0, 0))); .HasJob<ExecuteSsisPackages>(options =>
// options.HasInterval(new TimeSpan(24, 0, 0))
//.HasJob<SyncronizeProducts>(options => options.HasInterval(new TimeSpan(24, 0, 0))) .StartsAt(DateTime.Today.AddHours(26))
.HasJob<ProcessWhiFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0))); )
//.HasJob<ProcessWhiVehicles>(options => options.HasInterval(new TimeSpan(24, 0, 0)) .HasJob<UpdatePricing>(options =>
//.HasDependency<SyncronizeProducts>() options.HasInterval(new TimeSpan(24, 0, 0))
//.HasJob<UpdateFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0))); .StartsAt(DateTime.Today.AddHours(27))
//.HasJob<UpdatePositioning>(options => options.HasInterval(new TimeSpan(24, 0, 0)) .HasDependency<ExecuteSsisPackages>()
// .HasDependency<UpdateFitment>() );
// .HasDependency<ProcessWhiFitment>() //.AddApiServer();
// .HasDependency<SyncronizeProducts>() })
// .StartsAt(DateTime.Today.AddHours(8))
//) ;
//.HasJob<StatusCheck>(options => options.HasInterval(new TimeSpan(24, 0, 0))
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
//)
//.HasJob<ExecuteSsisPackages>(options =>
//options.HasInterval(new TimeSpan(24, 0, 0))
// .StartsAt(DateTime.Today.AddHours(5))
// );
//.StartsAt(DateTime.Today.AddHours(26))
//)
//.HasJob<UpdatePricing>(options => options.HasInterval(new TimeSpan(24, 0, 0))
//.HasDependency<ExecuteSsisPackages>()
//.StartsAt(DateTime.Today.AddHours(27)
//)
//);
//.AddApiServer();
})
.AddSingleton<EmailService>() .AddSingleton(builder.Configuration.GetSection("FtpServers:AzureConfiguration").Get<FtpConfiguration>())
.AddSingleton<SsisService>() .AddSingleton<FtpService>()
.AddSingleton<WhiSeoService>() .AddSingleton<EmailService>()
.AddSingleton<VehicleService>() .AddSingleton<SsisService>()
.AddSingleton<NexpartService>() .AddSingleton<WhiSeoService>()
.AddSingleton<VehicleService>()
.AddSingleton<NexpartService>()
.AddAutoMapper(typeof(PartSourceProfile)); .AddAutoMapper(typeof(PartSourceProfile));
}) })
.ConfigureLogging((builder, logging) => .ConfigureLogging((builder, logging) =>
{ {
logging.AddEventLog(); logging.AddEventLog();
logging.AddConsole(); logging.AddConsole();
// logging.AddProvider(new AutomationLoggerProvider()); // logging.AddProvider(new AutomationLoggerProvider());
}); });
} }
} }
} }

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Configurations>Debug;Release;Also Debug</Configurations> <Configurations>Debug;Release;Also Debug</Configurations>
</PropertyGroup> </PropertyGroup>

View File

@@ -1,10 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Configurations>Debug;Release;Also Debug</Configurations> <Configurations>Debug;Release;Also Debug</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="Integrations\**" />
<EmbeddedResource Remove="Integrations\**" />
<None Remove="Integrations\**" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="10.0.0" /> <PackageReference Include="AutoMapper" Version="10.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
@@ -21,8 +27,4 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Integrations\" />
</ItemGroup>
</Project> </Project>