diff --git a/PARR.EsppApi/EsppApiService.cs b/PARR.EsppApi/EsppApiService.cs index 823b6419..891d2f7b 100644 --- a/PARR.EsppApi/EsppApiService.cs +++ b/PARR.EsppApi/EsppApiService.cs @@ -1,21 +1,33 @@ using Microsoft.Extensions.Logging; using PARR.EsppApi.Models; +using PARR.EsppApi.Services; +using PARR.EsppApi.Settings; namespace PARR.EsppApi { internal class EsppApiService : IEsppApiService { private readonly ILogger logger; + private readonly EsppOrderSettings esppOrderSettings; + private readonly Espp espp; - public EsppApiService(ILogger logger) + public EsppApiService(ILogger logger, EsppOrderSettings esppOrderSettings, Espp espp) { this.logger = logger; + this.esppOrderSettings = esppOrderSettings; + this.espp = espp; } public async Task> FindOrdersByPrefixAsync(string prefix) { logger.LogInformation("Привет!"); - throw new NotImplementedException(); + + // var url = esppOrderSettings.Url; + var aaa = await espp.Get(); + logger.LogInformation($"asdasd: {aaa}"); + + return new List(); + } } } diff --git a/PARR.EsppApi/PARR.EsppApi.csproj b/PARR.EsppApi/PARR.EsppApi.csproj index de5d2b29..7c0a9f66 100644 --- a/PARR.EsppApi/PARR.EsppApi.csproj +++ b/PARR.EsppApi/PARR.EsppApi.csproj @@ -10,12 +10,8 @@ + - - - - - diff --git a/PARR.EsppApi/ParrEsppApiInstaller.cs b/PARR.EsppApi/ParrEsppApiInstaller.cs index 268659b2..cf7006a5 100644 --- a/PARR.EsppApi/ParrEsppApiInstaller.cs +++ b/PARR.EsppApi/ParrEsppApiInstaller.cs @@ -1,5 +1,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using PARR.EsppApi.Services; +using PARR.EsppApi.Settings; namespace PARR.EsppApi { @@ -8,12 +10,14 @@ namespace PARR.EsppApi public static void InstallEsppApiServices(this IServiceCollection services, IConfiguration configuration) { // settings - //SettingsFromDb configuration - //var settingsFromDb = new SettingsFromDb(); - //configuration.GetSection(nameof(SettingsFromDb)).Bind(settingsFromDb); - //services.AddSingleton(settingsFromDb); + var esppSettings = new EsppOrderSettings(); + configuration.GetSection(nameof(EsppOrderSettings)).Bind(esppSettings); + services.AddSingleton(esppSettings); + services.AddTransient(); + + services.AddHttpClient(); //add other services } diff --git a/PARR.EsppApi/Services/Espp.cs b/PARR.EsppApi/Services/Espp.cs new file mode 100644 index 00000000..ab30e83e --- /dev/null +++ b/PARR.EsppApi/Services/Espp.cs @@ -0,0 +1,27 @@ +namespace PARR.EsppApi.Services +{ + internal class Espp + { + private readonly HttpClient httpClient; + + public Espp(HttpClient httpClient) + { + this.httpClient = httpClient; + } + + public async Task Get() + { + //var req = new HttpRequestMessage(HttpMethod.Get, "https://www.google.com"); + + //if (req == null) + // return; + + var response = await httpClient.GetAsync("http://dvocor.dvgd.rzd"); + var content = await response.Content.ReadAsStringAsync(); + + + + return content; + } + } +} diff --git a/PARR.EsppApi/Settings/EsppOrderSettings.cs b/PARR.EsppApi/Settings/EsppOrderSettings.cs new file mode 100644 index 00000000..26296223 --- /dev/null +++ b/PARR.EsppApi/Settings/EsppOrderSettings.cs @@ -0,0 +1,10 @@ +namespace PARR.EsppApi.Settings +{ + internal class EsppOrderSettings + { + public string Url { get; set; } = string.Empty; + + //login, pass + //todo: add othe + } +} diff --git a/PARR.EsppOrderLoader/Class1.cs b/PARR.EsppOrderLoader/Class1.cs deleted file mode 100644 index 5c538c10..00000000 --- a/PARR.EsppOrderLoader/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace PARR.EsppOrderLoader -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/PARR.EsppOrderLoader/PARR.EsppOrderLoader.csproj b/PARR.EsppOrderLoader/PARR.EsppOrderLoader.csproj index cfadb03d..74361878 100644 --- a/PARR.EsppOrderLoader/PARR.EsppOrderLoader.csproj +++ b/PARR.EsppOrderLoader/PARR.EsppOrderLoader.csproj @@ -6,4 +6,10 @@ enable + + + + + + diff --git a/PARR.EsppOrderLoader/ParrEsppOrderLoaderInstaller.cs b/PARR.EsppOrderLoader/ParrEsppOrderLoaderInstaller.cs new file mode 100644 index 00000000..3c87ac1f --- /dev/null +++ b/PARR.EsppOrderLoader/ParrEsppOrderLoaderInstaller.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace PARR.EsppOrderLoader +{ + public static class ParrEsppOrderLoaderInstaller + { + public static void InstallEsppOrderLoaderServices(this IServiceCollection services, IConfiguration configuration) + { + //TODO: добавить настройи bll и dal и espp api + + // settings + //SettingsFromDb configuration + //var settingsFromDb = new SettingsFromDb(); + //configuration.GetSection(nameof(SettingsFromDb)).Bind(settingsFromDb); + //services.AddSingleton(settingsFromDb); + + //add other services + //services.AddTransient(); + } + } +} diff --git a/PARR.EsppOrderManager/Class1.cs b/PARR.EsppOrderManager/Class1.cs deleted file mode 100644 index 3001aed3..00000000 --- a/PARR.EsppOrderManager/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace PARR.EsppOrderManager -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/PARR.EsppOrderManager/PARR.EsppOrderManager.csproj b/PARR.EsppOrderManager/PARR.EsppOrderManager.csproj index cfadb03d..0acb0120 100644 --- a/PARR.EsppOrderManager/PARR.EsppOrderManager.csproj +++ b/PARR.EsppOrderManager/PARR.EsppOrderManager.csproj @@ -6,4 +6,9 @@ enable + + + + + diff --git a/PARR.Master/Class1.cs b/PARR.Master/Class1.cs deleted file mode 100644 index 88b42b79..00000000 --- a/PARR.Master/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace PARR.Master -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/PARR.Master/PARR.Master.csproj b/PARR.Master/PARR.Master.csproj index cfadb03d..21190861 100644 --- a/PARR.Master/PARR.Master.csproj +++ b/PARR.Master/PARR.Master.csproj @@ -6,4 +6,9 @@ enable + + + + + diff --git a/PARR.Test/Worker.cs b/PARR.Test/Worker.cs index 7284e843..8d1cff3a 100644 --- a/PARR.Test/Worker.cs +++ b/PARR.Test/Worker.cs @@ -27,7 +27,7 @@ namespace PARR.Test private async Task TestEsppApi() { - // var orders = await esppApiService.FindOrdersByPrefixAsync("ПАРР__"); + var orders = await esppApiService.FindOrdersByPrefixAsync("ПАРР__"); } } diff --git a/PARR.Test/appsettings.json b/PARR.Test/appsettings.json index b2dcdb67..337c5fd0 100644 --- a/PARR.Test/appsettings.json +++ b/PARR.Test/appsettings.json @@ -4,5 +4,8 @@ "Default": "Information", "Microsoft.Hosting.Lifetime": "Information" } + }, + "EsppOrderSettings": { + "Url": "http://dafsdf" } }