Compare commits

...

8 Commits

Author SHA1 Message Date
vchikalkin
cc78d4e26f SOAP: update KASKO Reference.cs 2024-05-16 11:19:05 +03:00
vchikalkin
3f03f0154a Revert "SOAP: update references"
This reverts commit 3834aa87fe57c87795dff490cd762b4be81c6e8f.
2024-05-16 10:07:57 +03:00
vchikalkin
3834aa87fe SOAP: update references 2024-05-16 09:51:03 +03:00
vchikalkin
7eba0b20ca project: add docker-compose.yml 2023-12-25 18:52:46 +03:00
vchikalkin
3504f9cfb9 SOAP: use https 2023-12-01 10:36:27 +03:00
vchikalkin
82baca1bfd Controllers/Common: return JSON response with error 2023-10-06 12:47:20 +03:00
vchikalkin
564ea80ef7 Controllers: add try/catch to CommonController.cs 2023-10-06 12:40:35 +03:00
vchikalkin
b42a9bb284 merge refactor/common 2023-10-04 17:37:26 +03:00
21 changed files with 3772 additions and 8953 deletions

View File

@ -1,7 +1,9 @@
{
"providerId": "Microsoft.Tools.ServiceModel.Svcutil",
"version": "2.1.0",
"ExtendedData": {
"inputs": [
"http://evolucia.elt-poisk.com/soap.php?wsdl"
"https://evolucia.elt-poisk.com/soap.php?wsdl"
],
"collectionTypes": [
"System.Array",
@ -10,6 +12,7 @@
"namespaceMappings": [
"*, ELTKasko"
],
"outputFile": "Reference",
"sync": true,
"targetFramework": "netcoreapp3.1",
"typeReuseMode": "All"

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
"Version": "15.0.40203.910",
"ExtendedData": {
"inputs": [
"http://evolucia.elt-poisk.com/soaposago.php?wsdl"
"https://evolucia.elt-poisk.com/soaposago.php?wsdl"
],
"collectionTypes": [
"System.Array",

View File

@ -6792,6 +6792,7 @@ namespace ELTOsago
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
@ -6801,7 +6802,7 @@ namespace ELTOsago
{
if ((endpointConfiguration == EndpointConfiguration.EltSoap))
{
return new System.ServiceModel.EndpointAddress("http://evolucia.elt-poisk.com/soaposago.php");
return new System.ServiceModel.EndpointAddress("https://evolucia.elt-poisk.com/soaposago.php");
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}

View File

@ -1,10 +0,0 @@
using System;
namespace ELT.Client.Managers
{
public class AuthInfo
{
public string Login { get; set; }
public string Password { get; set; }
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using ELT.Client.Models.Insurance;
namespace ELT.Client.Managers.Insurance
{
public abstract class InsuranceManager<T1, T2>
{
protected AuthInfo AuthInfo =>
new AuthInfo
{
Login = Environment.GetEnvironmentVariable("eltLogin"),
Password = Environment.GetEnvironmentVariable("eltPassword")
};
public abstract Dictionary<string, T2> Calculate(T1 calculateRequest, ELTPreData preRequestData);
}
}

View File

@ -1,71 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ELT.Client.Models.Insurance;
using ELT.Client.Models.Insurance.Request;
using ELTKasko;
namespace ELT.Client.Managers.Insurance
{
public class KaskoManager : InsuranceManager<CalculateKaskoRequest, KASKOCalculationResult>
{
private readonly EltSoapClient _eltKaskoSoap;
public KaskoManager()
{
_eltKaskoSoap = new EltSoapClient();
}
public override Dictionary<string, KASKOCalculationResult> Calculate(
CalculateKaskoRequest calculateKaskoRequest,
ELTPreData preRequestData)
{
var kaskoParams = calculateKaskoRequest.ELTParams;
kaskoParams.UsageCityKLADR = preRequestData.Kladr;
kaskoParams.Mark = preRequestData.Brand;
kaskoParams.Model = preRequestData.Model;
if (kaskoParams.Modification != null)
kaskoParams.Modification.Name = preRequestData.Modification;
var specialMachinery = calculateKaskoRequest.Preparams.SpecialMachinery;
specialMachinery.SpecialMachineryMark = preRequestData.Brand;
specialMachinery.SpecialMachineryModel = preRequestData.Model;
kaskoParams.SpecialMachinery = specialMachinery;
var result = new Dictionary<string, KASKOCalculationResult>();
var tasks = calculateKaskoRequest.CompanyIds.Distinct().Select(companyId =>
new Task(() =>
{
var res = _eltKaskoSoap.PreliminaryKASKOCalculation(
new ELTKasko.AuthInfo
{
Login = AuthInfo.Login,
Password = AuthInfo.Password
}
, null
, companyId
, 0
, 0
, null
, null
, null
, "13"
, null
, false
, null
, null
, kaskoParams);
result.Add(companyId, res);
}));
var tasksArray = tasks as Task[] ?? tasks.ToArray();
Parallel.ForEach(tasksArray, (t) => t.Start());
Task.WaitAll(tasksArray.ToArray());
return result;
}
}
}

View File

@ -1,49 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ELT.Client.Models.Insurance;
using ELT.Client.Models.Insurance.Request;
using ELTOsago;
namespace ELT.Client.Managers.Insurance
{
public class OsagoManager : InsuranceManager<CalculateOsagoRequest, OSAGOFullCalculationResponse>
{
private readonly EltSoap _eltOsagoSoap;
public OsagoManager()
{
_eltOsagoSoap = new EltSoapClient();
}
public override Dictionary<string, OSAGOFullCalculationResponse> Calculate(
CalculateOsagoRequest calculateOsagoRequest, ELTPreData preRequestData)
{
var result = new Dictionary<string, OSAGOFullCalculationResponse>();
var osagoParams = calculateOsagoRequest.ELTParams;
osagoParams.UsagePlace = preRequestData.Kladr;
osagoParams.CarInfo.Mark = preRequestData.Brand;
osagoParams.CarInfo.Model = preRequestData.Model;
osagoParams.AuthInfo = new ELTOsago.AuthInfo
{
Login = AuthInfo.Login,
Password = AuthInfo.Password
};
var tasks = calculateOsagoRequest.CompanyIds.Distinct().Select(companyId => new Task(() =>
{
osagoParams.InsuranceCompany = companyId;
var res = _eltOsagoSoap.OSAGOFullCalculation(osagoParams);
result.Add(companyId, res);
}));
var tasksArray = tasks as Task[] ?? tasks.ToArray();
Parallel.ForEach(tasksArray, (t) => t.Start());
Task.WaitAll(tasksArray.ToArray());
return result;
}
}
}

View File

@ -1,40 +0,0 @@
using System.Linq;
using ELT.Client.Models.Insurance;
using ELTKasko;
namespace ELT.Client.Managers.Insurance
{
public class PreRequestManager
{
private readonly EltSoap _eltKaskoSoap;
public PreRequestManager()
{
_eltKaskoSoap = new EltSoapClient();
}
public ELTPreData GetPreRequestData(Preparams preparams)
{
var eltPreData = new ELTPreData();
eltPreData.Kladr = preparams.Kladr;
//KLADR
//CAR
var mappedCars = _eltKaskoSoap.MappedCars(new MappedCarsRequest
{
Marka = preparams.BrandId,
Model = preparams.ModelId
});
eltPreData.Brand = mappedCars.Mark;
eltPreData.Model = mappedCars.Model;
if (mappedCars?.Modification?.Name != null)
eltPreData.Modification = mappedCars.Modification.Name;
//CAR
return eltPreData;
}
}
}

View File

@ -0,0 +1,43 @@
using System.ComponentModel.DataAnnotations;
using ELTKasko;
using ELTOsago;
namespace ELT.Client.Models.Common;
public class GetPreRequestDataInput
{
public string Kladr { get; set; }
public string BrandId { get; set; }
public string ModelId { get; set; }
public SpecialMachinery SpecialMachinery { get; set; }
}
public class GetPreRequestDataOutput
{
public string Kladr { get; set; }
[Required]
public string Brand { get; set; }
[Required]
public string Model { get; set; }
public string Modification { get; set; }
}
public class GetKaskoCalculationInput
{
[Required]
public string CompanyId { get; set; }
[Required]
public PreliminaryKASKOCalculationParams Params { get; set; }
[Required]
public GetPreRequestDataInput Preparams { get; set; }
}
public class GetOsagoCalculationInput
{
[Required]
public string CompanyId { get; set; }
[Required]
public OSAGOFullCalculationRequest Params { get; set; }
[Required]
public GetPreRequestDataInput Preparams { get; set; }
}

View File

@ -0,0 +1,6 @@
namespace ELT.Client.Models.Common;
public class ErrorResponse
{
public string Error { get; set; }
}

View File

@ -1,11 +0,0 @@
namespace ELT.Client.Models.Insurance
{
public class ELTPreData
{
public string Kladr { get; set; }
public string Brand { get; set; }
public string Model { get; set; }
public string Modification { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using ELTKasko;
namespace ELT.Client.Models.Insurance
{
public class Preparams
{
public string Kladr { get; set; }
public string BrandId { get; set; }
public string ModelId { get; set; }
public SpecialMachinery SpecialMachinery { get; set; }
}
}

View File

@ -1,8 +0,0 @@
using ELTKasko;
namespace ELT.Client.Models.Insurance.Request
{
public class CalculateKaskoRequest : CalculateRequest<PreliminaryKASKOCalculationParams>
{
}
}

View File

@ -1,8 +0,0 @@
using ELTOsago;
namespace ELT.Client.Models.Insurance.Request
{
public class CalculateOsagoRequest : CalculateRequest<OSAGOFullCalculationRequest>
{
}
}

View File

@ -1,9 +0,0 @@
namespace ELT.Client.Models.Insurance.Request
{
public class CalculateRequest<T>
{
public string[] CompanyIds { get; set; }
public Preparams Preparams { get; set; }
public T ELTParams { get; set; }
}
}

View File

@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ELT", "ELT\ELT.csproj", "{2
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ELT.Client", "ELT.Client\ELT.Client.csproj", "{9EC7C85B-FC9C-4BCE-A587-CB3B75AEE554}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ELT.Tests", "ELT.Tests\ELT.Tests.csproj", "{F86CEFE3-5F4A-4666-94E9-2BB37C83A9CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -23,10 +21,6 @@ Global
{9EC7C85B-FC9C-4BCE-A587-CB3B75AEE554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EC7C85B-FC9C-4BCE-A587-CB3B75AEE554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EC7C85B-FC9C-4BCE-A587-CB3B75AEE554}.Release|Any CPU.Build.0 = Release|Any CPU
{F86CEFE3-5F4A-4666-94E9-2BB37C83A9CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F86CEFE3-5F4A-4666-94E9-2BB37C83A9CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F86CEFE3-5F4A-4666-94E9-2BB37C83A9CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F86CEFE3-5F4A-4666-94E9-2BB37C83A9CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,125 @@
using System;
using ELT.Client.Models.Common;
using ELTKasko;
using ELTOsago;
using Microsoft.AspNetCore.Mvc;
using AuthInfo = ELTOsago.AuthInfo;
using EltKaskoSoap = ELTKasko.EltSoap;
using ELTOsagoSoap = ELTOsago.EltSoap;
namespace ELT.Controllers;
[ApiController]
[Route("api/[controller]")]
public class CommonController : ControllerBase
{
private EltKaskoSoap _eltKaskoClient = new ELTKasko.EltSoapClient();
private ELTOsagoSoap _eltOsagoClient = new ELTOsago.EltSoapClient();
string _login = Environment.GetEnvironmentVariable("eltLogin");
string _password = Environment.GetEnvironmentVariable("eltPassword");
private GetPreRequestDataOutput GetPreRequestData([FromBody] GetPreRequestDataInput data)
{
var mappedCars = _eltKaskoClient.MappedCars(new MappedCarsRequest
{
Marka = data.BrandId,
Model = data.ModelId
});
return new GetPreRequestDataOutput
{
Kladr = data.Kladr,
Brand = mappedCars.Mark,
Model = mappedCars.Model,
Modification = mappedCars.Modification?.Name
};
}
[HttpPost("get-kasko-calculation")]
public ActionResult<KASKOCalculationResult> GetKaskoCalculation([FromBody] GetKaskoCalculationInput data)
{
try
{
var preRequestData = this.GetPreRequestData(data.Preparams);
var request = data.Params;
request.UsageCityKLADR = preRequestData.Kladr;
request.Mark = preRequestData.Brand;
request.Model = preRequestData.Model;
if (request.Modification != null)
request.Modification.Name = preRequestData.Modification;
var specialMachinery = data.Preparams.SpecialMachinery;
specialMachinery.SpecialMachineryMark = preRequestData.Brand;
specialMachinery.SpecialMachineryModel = preRequestData.Model;
request.SpecialMachinery = specialMachinery;
var res = _eltKaskoClient.PreliminaryKASKOCalculation(
new ELTKasko.AuthInfo
{
Login = _login,
Password = _password
}
, null
, data.CompanyId
, 0
, 0
, null
, null
, null
, "13"
, null
, false
, null
, null
, request);
if (res?.Error is { Length: > 0 })
{
return BadRequest(res);
}
return Ok(res);
}
catch (Exception e)
{
return StatusCode(500, new ErrorResponse { Error = e.Message });
}
}
[HttpPost("get-osago-calculation")]
public ActionResult<OSAGOFullCalculationResponse> GetOsagoCalculation([FromBody] GetOsagoCalculationInput data)
{
try
{
var prerequestData = this.GetPreRequestData(data.Preparams);
var request = data.Params;
request.UsagePlace = prerequestData.Kladr;
request.CarInfo.Mark = prerequestData.Brand;
request.CarInfo.Model = prerequestData.Model;
request.AuthInfo = new AuthInfo
{
Login = _login,
Password = _password
};
request.InsuranceCompany ??= data.CompanyId;
var res = _eltOsagoClient.OSAGOFullCalculation(data.Params);
if (res?.Error is { Length: > 0 })
{
return BadRequest(res);
}
return Ok(res);
}
catch (Exception e)
{
return StatusCode(500, new ErrorResponse { Error = e.Message });
}
}
}

View File

@ -1,36 +0,0 @@
using System.Collections.Generic;
using ELT.Client.Managers.Insurance;
using ELT.Client.Models.Insurance.Request;
using ELTKasko;
using ELTOsago;
using Microsoft.AspNetCore.Mvc;
namespace ELT.Controllers
{
[ApiController]
[Route("[controller]")]
public class InsuranceController : ControllerBase
{
[HttpPost("[action]")]
public ActionResult<Dictionary<string, KASKOCalculationResult>> CalculateKasko(
[FromBody] CalculateKaskoRequest calculateKaskoRequest)
{
var preRequestManager = new PreRequestManager();
var preRequestData = preRequestManager.GetPreRequestData(calculateKaskoRequest.Preparams);
var kaskoManager = new KaskoManager();
return kaskoManager.Calculate(calculateKaskoRequest, preRequestData);
}
[HttpPost("[action]")]
public ActionResult<Dictionary<string, OSAGOFullCalculationResponse>> CalculateOsago(
[FromBody] CalculateOsagoRequest calculateOsagoRequest)
{
var preRequestManager = new PreRequestManager();
var preRequestData = preRequestManager.GetPreRequestData(calculateOsagoRequest.Preparams);
var osagoManager = new OsagoManager();
return osagoManager.Calculate(calculateOsagoRequest, preRequestData);
}
}
}

View File

@ -14,17 +14,19 @@
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"eltPassword": "evo12345",
"eltLogin": "dmitrienko"
"eltPassword": "123456",
"eltLogin": "Evo123"
}
},
"ELT": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"eltPassword": "123456",
"eltLogin": "Evo123"
},
"applicationUrl": "http://localhost:5000"
"applicationUrl": "http://localhost:2000"
},
"Docker": {
"commandName": "Docker",

17
docker-compose.yml Normal file
View File

@ -0,0 +1,17 @@
version: '3.3'
services:
elt:
build:
context: .
dockerfile: ./Dockerfile
environment:
- eltLogin=${ELT_LOGIN}
- eltPassword=${ELT_PASSWORD}
restart: always
networks:
- calc_network
networks:
calc_network:
external:
name: calc_network