diff --git a/ELT.Client/Managers/Insurance/OsagoManager.cs b/ELT.Client/Managers/Insurance/OsagoManager.cs index 5c5667f..9bf3017 100644 --- a/ELT.Client/Managers/Insurance/OsagoManager.cs +++ b/ELT.Client/Managers/Insurance/OsagoManager.cs @@ -33,11 +33,23 @@ namespace ELT.Client.Managers.Insurance var tasks = calculateOsagoRequest.CompanyIds.Distinct().Select(companyId => new Task(() => { - var res = _eltOsagoSoap.OSAGOFullCalculation(osagoParams); - if (string.IsNullOrEmpty(res.Error)) - result.Add(companyId, res); + try + { + osagoParams.InsuranceCompany = companyId; + var res = _eltOsagoSoap.OSAGOFullCalculation(osagoParams); + if (string.IsNullOrEmpty(res.Error)) + result.Add(companyId, res); + } + catch (Exception) + { + + } })); + var tasksArray = tasks as Task[] ?? tasks.ToArray(); + Parallel.ForEach(tasksArray, (t) => t.Start()); + Task.WaitAll(tasksArray.ToArray()); + return result; } } diff --git a/ELT.Tests/Controllers/InsuranceController/Osago.cs b/ELT.Tests/Controllers/InsuranceController/Osago.cs new file mode 100644 index 0000000..7b5f104 --- /dev/null +++ b/ELT.Tests/Controllers/InsuranceController/Osago.cs @@ -0,0 +1,304 @@ +using ELT.Client.Models.Insurance; +using ELT.Client.Models.Insurance.Request; +using ELTOsago; +using System; +using System.Collections.Generic; +using Xunit; + +namespace ELT.Tests.Controllers.InsuranceController +{ + public class Osago + { + [Fact] + public void Test1() + { + var TARGET_INSURANCE_COMPANY = "VSK"; + var request = new CalculateOsagoRequest() + { + CompanyIds = new[] { TARGET_INSURANCE_COMPANY }, + Preparams = new Preparams + { + RegionName = "Рязанская обл", + CityName = "Рязань г", + BrandId = "C3B16998-C04D-484C-A17E-DB2C8FFE6DF3", + ModelId = "29DF0E37-1431-4037-AC0A-0FCA37AD0792" + }, + ELTParams = new OSAGOFullCalculationRequest + { + InsurerType = 1, + OwnerType = 1, + ContractOptionId = 1, + ContractStatusId = 13, + UsagePlace = "6200000100000", + TSToRegistrationPlace = 0, + ContractBeginDate = DateTime.Now, + Duration = 12, + CarInfo = new OSAGOFullCalculationCarInfo + { + Mark = "AUDI", + Model = "A4", + VehicleYear = "2021", + VehiclePower = 160, + TSType = new TSType + { + Category = "B", + Subcategory = "10" + } + }, + GrossViolations = false, + Owner = new PhysicalPerson + { + SubjectTypeSpecified = true, + SubjectType = 1, + OPF = 1, + JuridicalName = "ООО ЛК ЭВОЛЮЦИЯ", + INN = "9724016636", + KPP = "772401001", + OGRN = "1207700245037", + RegistrationDocument = new JuridicalDocument + { + Series = "0", + //Number = "0", + IssuedDate = new DateTime(2020, 07, 20) + }, + RegistrationAddress = new Address + { + Resident = 1, + Country = "Российская Федерация", + Region = "Москва", + City = "Москва", + CityKLADR = "7700000000000", + Street = "ул.Котляковская", + House = "8", + Flat = "337" + }, + FactAddress = new Address + { + Resident = 1, + Country = "Российская Федерация", + Region = "Москва", + City = "Москва", + CityKLADR = "7700000000000", + Street = "ул.Котляковская", + House = "8", + Flat = "337" + }, + Phone = "8 (800) 333-75-75", + Email = "client@evoleasing.ru" + }, + DriversCount = 0, + FullDriversInfo = new FullDriver[] + { + new FullDriver + { + KBM="13" + } + } + + } + }; + + var insuranceController = new ELT.Controllers.InsuranceController(); + Dictionary res + = insuranceController.CalculateOsago(request).Value; + Assert.True(res.Count > 0); + Assert.Equal(String.Empty, res[TARGET_INSURANCE_COMPANY].Error); + Assert.NotEqual(0, res[TARGET_INSURANCE_COMPANY].NumCalc); + + } + [Fact] + public void Test2() + { + var TARGET_INSURANCE_COMPANY = "RESO_GARANTIJA"; + var request = new CalculateOsagoRequest() + { + CompanyIds = new[] { TARGET_INSURANCE_COMPANY }, + Preparams = new Preparams + { + RegionName = "Рязанская обл", + CityName = "Рязань г", + BrandId = "C3B16998-C04D-484C-A17E-DB2C8FFE6DF3", + ModelId = "29DF0E37-1431-4037-AC0A-0FCA37AD0792" + }, + ELTParams = new OSAGOFullCalculationRequest + { + InsurerType = 1, + OwnerType = 1, + ContractOptionId = 1, + ContractStatusId = 13, + UsagePlace = "6200000100000", + TSToRegistrationPlace = 0, + ContractBeginDate = DateTime.Now, + Duration = 12, + CarInfo = new OSAGOFullCalculationCarInfo + { + Mark = "AUDI", + Model = "A4", + VehicleYear = "2021", + VehiclePower = 160, + TSType = new TSType + { + Category = "B", + Subcategory = "10" + } + }, + GrossViolations = false, + Owner = new PhysicalPerson + { + SubjectTypeSpecified = true, + SubjectType = 1, + OPF = 1, + JuridicalName = "ООО ЛК ЭВОЛЮЦИЯ", + INN = "9724016636", + KPP = "772401001", + OGRN = "1207700245037", + RegistrationDocument = new JuridicalDocument + { + Series = "0", + //Number = "0", + IssuedDate = new DateTime(2020, 07, 20) + }, + RegistrationAddress = new Address + { + Resident = 1, + Country = "Российская Федерация", + Region = "Москва", + City = "Москва", + CityKLADR = "7700000000000", + Street = "ул.Котляковская", + House = "8", + Flat = "337" + }, + FactAddress = new Address + { + Resident = 1, + Country = "Российская Федерация", + Region = "Москва", + City = "Москва", + CityKLADR = "7700000000000", + Street = "ул.Котляковская", + House = "8", + Flat = "337" + }, + Phone = "8 (800) 333-75-75", + Email = "client@evoleasing.ru" + }, + DriversCount = 0, + FullDriversInfo = new FullDriver[] + { + new FullDriver + { + KBM="13" + } + } + + } + }; + + var insuranceController = new ELT.Controllers.InsuranceController(); + Dictionary res + = insuranceController.CalculateOsago(request).Value; + Assert.True(res.Count > 0); + Assert.Equal(String.Empty, res[TARGET_INSURANCE_COMPANY].Error); + Assert.NotEqual(0, res[TARGET_INSURANCE_COMPANY].NumCalc); + + } + [Fact] + public void Test3() + { + var TARGET_INSURANCE_COMPANY = "SOGLASIE_MSK"; + var request = new CalculateOsagoRequest() + { + CompanyIds = new[] { TARGET_INSURANCE_COMPANY }, + Preparams = new Preparams + { + RegionName = "Рязанская обл", + CityName = "Рязань г", + BrandId = "C3B16998-C04D-484C-A17E-DB2C8FFE6DF3", + ModelId = "29DF0E37-1431-4037-AC0A-0FCA37AD0792" + }, + ELTParams = new OSAGOFullCalculationRequest + { + InsurerType = 1, + OwnerType = 1, + ContractOptionId = 1, + ContractStatusId = 13, + UsagePlace = "6200000100000", + TSToRegistrationPlace = 0, + ContractBeginDate = DateTime.Now, + Duration = 12, + CarInfo = new OSAGOFullCalculationCarInfo + { + Mark = "AUDI", + Model = "A4", + VehicleYear = "2021", + VehiclePower = 160, + TSType = new TSType + { + Category = "B", + Subcategory = "10" + } + }, + GrossViolations = false, + Owner = new PhysicalPerson + { + SubjectTypeSpecified = true, + SubjectType = 1, + OPF = 1, + JuridicalName = "ООО ЛК ЭВОЛЮЦИЯ", + INN = "9724016636", + KPP = "772401001", + OGRN = "1207700245037", + RegistrationDocument = new JuridicalDocument + { + Series = "0", + //Number = "0", + IssuedDate = new DateTime(2020, 07, 20) + }, + RegistrationAddress = new Address + { + Resident = 1, + Country = "Российская Федерация", + Region = "Москва", + City = "Москва", + CityKLADR = "7700000000000", + Street = "ул.Котляковская", + House = "8", + Flat = "337" + }, + FactAddress = new Address + { + Resident = 1, + Country = "Российская Федерация", + Region = "Москва", + City = "Москва", + CityKLADR = "7700000000000", + Street = "ул.Котляковская", + House = "8", + Flat = "337" + }, + Phone = "8 (800) 333-75-75", + Email = "client@evoleasing.ru" + }, + DriversCount = 0, + FullDriversInfo = new FullDriver[] + { + new FullDriver + { + KBM="13" + } + } + + } + }; + + var insuranceController = new ELT.Controllers.InsuranceController(); + Dictionary res + = insuranceController.CalculateOsago(request).Value; + Assert.True(res.Count > 0); + Assert.Equal(String.Empty, res[TARGET_INSURANCE_COMPANY].Error); + Assert.NotEqual(0, res[TARGET_INSURANCE_COMPANY].NumCalc); + + } + } +}