Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DI-1344] Data Import 2.3 .NET 8 Update - Replace deprecated Packages #79

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions DataImport.Common/DataImport.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
<ProjectReference Include="..\DataImport.Models\DataImport.Models.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.39.0" />
<PackageReference Include="Azure.Security.KeyVault.Keys" Version="4.6.0" />
<PackageReference Include="Libuv" Version="1.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.8.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.1" />
<PackageReference Include="Microsoft.Azure.KeyVault.Core" Version="3.0.5" />
<PackageReference Include="Microsoft.Data.Services.Client" Version="5.8.5" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.24" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.22.0.87781">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<ItemGroup>
<PackageReference Include="FluentFTP" Version="49.0.2" />
<PackageReference Include="Libuv" Version="1.10.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Threading;
using System.Threading.Tasks;
using DataImport.Models;
using MediatR;

Expand All @@ -15,7 +17,7 @@ public class Command : IRequest
{
}

public class EventHandler : RequestHandler<Command>
public class EventHandler : IRequestHandler<Command>
{
private readonly DataImportDbContext _dbContext;

Expand All @@ -24,11 +26,12 @@ public EventHandler(DataImportDbContext dbContext)
_dbContext = dbContext;
}

protected override void Handle(Command notification)
public Task Handle(Command request, CancellationToken cancellationToken)
{
var jobStatus = _dbContext.EnsureSingle<JobStatus>();
jobStatus.Completed = DateTimeOffset.Now;
_dbContext.SaveChanges();
return Task.CompletedTask;
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions DataImport.Server.TransformLoad/Features/Events/JobStarted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Threading.Tasks;
using System.Threading;
using DataImport.Models;
using MediatR;

Expand All @@ -15,7 +17,7 @@ public class Command : IRequest
{
}

public class EventHandler : RequestHandler<Command>
public class EventHandler : IRequestHandler<Command>
{
private readonly DataImportDbContext _dbContext;

Expand All @@ -24,12 +26,13 @@ public EventHandler(DataImportDbContext dbContext)
_dbContext = dbContext;
}

protected override void Handle(Command notification)
public Task Handle(Command request, CancellationToken cancellationToken)
{
var jobStatus = _dbContext.EnsureSingle<JobStatus>();
jobStatus.Started = DateTimeOffset.Now;
jobStatus.Completed = null;
_dbContext.SaveChanges();
return Task.CompletedTask;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Command : IRequest
public int ApiServerId { get; set; }
}

public class CommandHandler : AsyncRequestHandler<Command>
public class CommandHandler : IRequestHandler<Command>
{
private readonly ILogger<FileGenerator> _logger;
private readonly DataImportDbContext _dbContext;
Expand All @@ -44,7 +44,7 @@ public CommandHandler(ILogger<FileGenerator> logger, IOptions<AppSettings> optio
_fileService = fileServices(options.Value.FileMode);
}

protected override async Task Handle(Command request, CancellationToken cancellationToken)
public async Task Handle(Command request, CancellationToken cancellationToken)
{
var agents = await _dbContext.Agents
.Include(agent => agent.AgentSchedules)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Command : IRequest
public int ApiServerId { get; set; }
}

public class CommandHandler : AsyncRequestHandler<Command>
public class CommandHandler : IRequestHandler<Command>
{
private readonly ILogger<FileTransporter> _logger;
private readonly DataImportDbContext _dbContext;
Expand All @@ -35,7 +35,7 @@ public CommandHandler(ILogger<FileTransporter> logger, DataImportDbContext dbCon
_dbContext = dbContext;
}

protected override async Task Handle(Command request, CancellationToken cancellationToken)
public async Task Handle(Command request, CancellationToken cancellationToken)
{
var agents = await _dbContext.Agents
.Include(agent => agent.AgentSchedules)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Command : IRequest
public IOdsApi OdsApi { get; set; }
}

public class CommandHandler : AsyncRequestHandler<Command>
public class CommandHandler : IRequestHandler<Command>
{
private readonly ILogger _logger;
private readonly DataImportDbContext _dbContext;
Expand All @@ -79,7 +79,7 @@ public CommandHandler(ILogger<FileProcessor> logger, IOptions<AppSettings> optio
_ingestionLogLevels = LogLevels.GetValidList(options.Value.MinimumLevelIngestionLog);
}

protected override async Task Handle(Command request, CancellationToken cancellationToken)
public async Task Handle(Command request, CancellationToken cancellationToken)
{
List<Agent> enabledAgentsWithFilesToProcess;
var apiServerId = request.OdsApi.Config.ApiServerId;
Expand Down
3 changes: 2 additions & 1 deletion DataImport.Server.TransformLoad/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Collections.Generic;
using System.Reflection;

namespace DataImport.Server.TransformLoad
{
Expand Down Expand Up @@ -106,7 +107,7 @@ public static IServiceCollection ConfigureTransformLoadServices(this IServiceCol
services.AddTransient<IExternalPreprocessorService, ExternalPreprocessorService>();
services.AddTransient<IOAuthRequestWrapper, OAuthRequestWrapper>();

services.AddMediatR(typeof(Startup));
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));

return services;
}
Expand Down
8 changes: 7 additions & 1 deletion DataImport.Web.Tests/Assertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ namespace DataImport.Web.Tests
{
public static class Assertions
{
public static void ShouldValidate(this IRequest message)
=> Validation(message).ShouldBeSuccessful();

public static void ShouldValidate<TResult>(this IRequest<TResult> message)
=> Validation(message).ShouldBeSuccessful();

public static void ShouldNotValidate<TResult>(this IRequest<TResult> message, params string[] expectedErrors)
public static void ShouldNotValidate(this IRequest message, params string[] expectedErrors)
=> Validation(message).ShouldBeFailure(expectedErrors);

public static void ShouldNotValidate<TResponse>(this IRequest<TResponse> message, params string[] expectedErrors)
=> Validation(message).ShouldBeFailure(expectedErrors);

public static void ShouldBeSuccessful(this ValidationResult result)
Expand Down
1 change: 1 addition & 0 deletions DataImport.Web.Tests/Features/Agent/AddEditAgentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using DataImport.Web.Features.Agent;
using DataImport.Web.Features.Preprocessor;
using DataImport.Web.Helpers;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using NUnit.Framework;
Expand Down
2 changes: 1 addition & 1 deletion DataImport.Web/DataImport.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<PackageReference Include="jQuery.Validation" Version="1.20.0" />
<PackageReference Include="Libuv" Version="1.10.0" />
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.405" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" Version="4.0.0" />
<PackageReference Include="Modernizr" Version="2.8.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
Expand Down
12 changes: 8 additions & 4 deletions DataImport.Web/Features/Activity/GetActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace DataImport.Web.Features.Activity
{
Expand Down Expand Up @@ -57,7 +59,7 @@ public class Query : IRequest<ViewModel>, IApiServerSpecificRequest
public int? ApiVersionId { get; set; }
}

public class QueryHandler : RequestHandler<Query, ViewModel>
public class QueryHandler : IRequestHandler<Query, ViewModel>
{
private readonly DataImportDbContext _database;
private readonly IMapper _mapper;
Expand All @@ -70,13 +72,15 @@ public QueryHandler(DataImportDbContext database, IMapper mapper, IClock clock)
_clock = clock;
}

protected override ViewModel Handle(Query request) =>
new ViewModel
public Task<ViewModel> Handle(Query request, CancellationToken cancellationToken)
{
return Task.FromResult(new ViewModel
{
Health = JobHealth(),
Files = Files(request.ApiServerId),
HasRecentFiles = HasRecentFiles()
};
});
}

private HealthModel JobHealth()
{
Expand Down
18 changes: 10 additions & 8 deletions DataImport.Web/Features/Agent/AddAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DataImport.Web.Features.Agent
{
Expand All @@ -24,7 +26,7 @@ public class Query : IRequest<AddEditAgentViewModel>

}

public class QueryHandler : RequestHandler<Query, AddEditAgentViewModel>
public class QueryHandler : IRequestHandler<Query, AddEditAgentViewModel>
{
private readonly AgentSelectListProvider _agentSelectListProvider;

Expand All @@ -33,17 +35,17 @@ public QueryHandler(AgentSelectListProvider agentSelectListProvider)
_agentSelectListProvider = agentSelectListProvider;
}

protected override AddEditAgentViewModel Handle(Query request)
public Task<AddEditAgentViewModel> Handle(Query request, CancellationToken cancellationToken)
{
return new AddEditAgentViewModel
return Task.FromResult(new AddEditAgentViewModel
{
DataMaps = _agentSelectListProvider.GetDataMapList(),
AgentTypes = _agentSelectListProvider.GetAgentTypes(),
RowProcessors = _agentSelectListProvider.GetRowProcessors(),
FileGenerators = _agentSelectListProvider.GetFileGenerators(),
BootstrapDatas = _agentSelectListProvider.GetBootstrapDataList(),
Enabled = true,
};
});
}
}

Expand All @@ -57,7 +59,7 @@ public class Command : IRequest<Response>
public AddEditAgentViewModel ViewModel { get; set; }
}

public class CommandHandler : RequestHandler<Command, Response>
public class CommandHandler : IRequestHandler<Command, Response>
{
private readonly ILogger _logger;
private readonly DataImportDbContext _dataImportDbContext;
Expand All @@ -72,7 +74,7 @@ public CommandHandler(ILogger<AddAgent> logger, DataImportDbContext dataImportDb
_encryptionService = encryptionService;
}

protected override Response Handle(Command request)
public Task<Response> Handle(Command request, CancellationToken cancellationToken)
{
var viewmodel = request.ViewModel;

Expand Down Expand Up @@ -130,11 +132,11 @@ protected override Response Handle(Command request)

_logger.Added(agent, a => a.Name);

return new Response
return Task.FromResult(new Response
{
AgentId = agent.Id,
Message = $"Agent '{agent.Name}' was created."
};
});
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions DataImport.Web/Features/Agent/AgentFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace DataImport.Web.Features.Agent
{
Expand All @@ -38,7 +40,7 @@ public class Query : IRequest<QueryResult>
public string AgentTypeCode { get; set; }
}

public class QueryHandler : RequestHandler<Query, QueryResult>
public class QueryHandler : IRequestHandler<Query, QueryResult>
{
private readonly ILogger _logger;

Expand All @@ -48,7 +50,7 @@ public QueryHandler(ILogger<AgentFiles> logger, IOptions<AppSettings> options)
_allowTestCertificates = options.Value.AllowTestCertificates;
}

protected override QueryResult Handle(Query request)
public Task<QueryResult> Handle(Query request, CancellationToken cancellationToken)
{
try
{
Expand All @@ -63,12 +65,12 @@ protected override QueryResult Handle(Query request)

var files = GetAgentFiles(request.Url, request.Port, request.Username, request.Password, request.Directory, request.FilePattern, request.AgentTypeCode);

return new QueryResult { FileNames = files.Select(x => x) };
return Task.FromResult(new QueryResult { FileNames = files.Select(x => x) });
}
catch (Exception ex)
{
_logger.LogError(ex, "Error retrieving agent files.");
return new QueryResult { ErrorMessage = ex.Message };
return Task.FromResult(new QueryResult { ErrorMessage = ex.Message });
}
}

Expand Down
12 changes: 7 additions & 5 deletions DataImport.Web/Features/Agent/AgentIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DataImport.Models;
using MediatR;

Expand Down Expand Up @@ -34,7 +36,7 @@ public class Query : IRequest<ViewModel>

}

public class QueryHandler : RequestHandler<Query, ViewModel>
public class QueryHandler : IRequestHandler<Query, ViewModel>
{
private readonly DataImportDbContext _database;

Expand All @@ -43,12 +45,12 @@ public QueryHandler(DataImportDbContext database)
_database = database;
}

protected override ViewModel Handle(Query request)
public Task<ViewModel> Handle(Query request, CancellationToken cancellationToken)
{
return new ViewModel
return Task.FromResult(new ViewModel
{
Agents = _database.Agents
.Where(x => x.Archived == false)
.Where(x => !x.Archived)
.OrderBy(x => x.RunOrder == null)
.ThenBy(x => x.RunOrder)
.ThenBy(x => x.Id)
Expand All @@ -63,7 +65,7 @@ protected override ViewModel Handle(Query request)
RunOrder = x.RunOrder,
})
.ToList()
};
});
}
}
}
Expand Down
Loading