.
This commit is contained in:
@@ -19,7 +19,7 @@ namespace PartSource.Automation.Services
|
||||
_ftpConfiguration = ftpConfiguration;
|
||||
}
|
||||
|
||||
public IList<FtpFileInfo> ListFilesExtended(string directory)
|
||||
public IList<FtpFileInfo> ListFilesExtended(string directory = "")
|
||||
{
|
||||
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{directory}"));
|
||||
request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password);
|
||||
@@ -67,7 +67,7 @@ namespace PartSource.Automation.Services
|
||||
return files;
|
||||
}
|
||||
|
||||
public string[] ListFiles(string directory)
|
||||
public string[] ListFiles(string directory = "")
|
||||
{
|
||||
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{directory}"));
|
||||
request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password);
|
||||
@@ -102,7 +102,12 @@ namespace PartSource.Automation.Services
|
||||
}
|
||||
|
||||
destination = Path.Combine(destination, filename);
|
||||
|
||||
string destinationDirectory = Path.GetDirectoryName(destination);
|
||||
if (!Directory.Exists(destinationDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
}
|
||||
|
||||
using FtpWebResponse response = (FtpWebResponse)request.GetResponse();
|
||||
using Stream responseStream = response.GetResponseStream();
|
||||
using FileStream fileStream = new FileStream(destination, FileMode.Create);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace PartSource.Automation.Services
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "dtexec",
|
||||
FileName = "C:\\Program Files\\Microsoft SQL Server\\150\\DTS\\Binn\\dtexec.exe",
|
||||
Arguments = $"/file \"{_ssisConfiguration.Directory}\\{packageName}\"",
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = false,
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PartSource.Data.Contexts;
|
||||
using PartSource.Data.Dtos;
|
||||
using PartSource.Data.Models;
|
||||
@@ -93,18 +94,19 @@ namespace PartSource.Automation.Services
|
||||
return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToArray();
|
||||
}
|
||||
|
||||
public IList<Vehicle> GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0)
|
||||
public async Task<IList<Vehicle>> GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9\\-]", string.Empty);
|
||||
partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9]", string.Empty);
|
||||
|
||||
IQueryable<string> whiCodes = _fitmentContext.DcfMappings
|
||||
.Where(d => d.LineCode == lineCode)
|
||||
.Select(d => d.WhiCode);
|
||||
IList<string> whiCodes = await _fitmentContext.DcfMappings
|
||||
.Where(dcf => dcf.LineCode == lineCode)
|
||||
.Select(dcf => dcf.WhiCode)
|
||||
.ToListAsync();
|
||||
|
||||
IQueryable<Vehicle> vehicles = _fitmentContext.Fitments
|
||||
.Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode))
|
||||
@@ -122,38 +124,5 @@ namespace PartSource.Automation.Services
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
|
||||
public IList<VehicleFitmentDto> GetVehicleFitmentForPart(string partNumber, string lineCode, int maxVehicles = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9\\-]", string.Empty);
|
||||
|
||||
IQueryable<string> whiCodes = _fitmentContext.DcfMappings
|
||||
.Where(d => d.LineCode == lineCode)
|
||||
.Select(d => d.WhiCode);
|
||||
|
||||
IQueryable<VehicleFitmentDto> vehicles = _fitmentContext.Fitments
|
||||
.Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode))
|
||||
.Join(_fitmentContext.Vehicles,
|
||||
f => new { f.BaseVehicleId, f.EngineConfigId },
|
||||
v => new { v.BaseVehicleId, v.EngineConfigId },
|
||||
(f, v) => new VehicleFitmentDto
|
||||
{
|
||||
Fitment = f,
|
||||
Vehicle = v
|
||||
})
|
||||
.Distinct();
|
||||
|
||||
if (maxVehicles > 0)
|
||||
{
|
||||
vehicles = vehicles.Take(maxVehicles);
|
||||
}
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user