182 lines
6.1 KiB
C#
182 lines
6.1 KiB
C#
using Microsoft.Extensions.Configuration;
|
|||
|
|
using Net.Connection;
|
||
|
|
using Net.CrossCotting;
|
||
|
|
using Net.Data.Authenticate;
|
||
|
|
using Net.Data.ServicesLayer;
|
||
|
|
using Net.Data.ServicesLayer.CreditNotes;
|
||
|
|
using Net.Data.ServicesLayer.GlobalData;
|
||
|
|
using Net.Data.ServicesLayer.HR;
|
||
|
|
using Net.Data.ServicesLayer.InventoryGenEntries;
|
||
|
|
using Net.Data.ServicesLayer.InventoryGenExits;
|
||
|
|
using Net.Data.ServicesLayer.ReturnRequest;
|
||
|
|
using Net.Data.ServicesLayer.StockTransfer;
|
||
|
|
using Net.Data.WMS.Inventario;
|
||
|
|
using Net.Data.WMS.Items;
|
||
|
|
using Net.Data.WMS.Picking;
|
||
|
|
using Net.Data.WMS.Recibo;
|
||
|
|
using Net.Data.WMS.SolicitudTransferencia;
|
||
|
|
using Net.Data.WMS.Transferencia;
|
||
|
|
using System;
|
||
|
|
using System.Net.Http;
|
||
|
|
|
||
|
|
namespace Net.Data
|
||
|
|
{
|
||
|
|
public class RepositoryWrapper : IRepositoryWrapper
|
||
|
|
{
|
||
|
|
#region Variables de conexion
|
||
|
|
private string _conSQL;
|
||
|
|
//private string _conSAPSQL;
|
||
|
|
|
||
|
|
private readonly string _entorno;
|
||
|
|
private readonly string _Source;
|
||
|
|
private readonly string _Catalog;
|
||
|
|
private readonly string _User;
|
||
|
|
private readonly string _Password;
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
private IConnectionSQL _repoContext;
|
||
|
|
private readonly IConfiguration _configuration;
|
||
|
|
private readonly IHttpClientFactory _clientFactory;
|
||
|
|
|
||
|
|
#region WMS
|
||
|
|
|
||
|
|
private IReciboRepository _Recibo;
|
||
|
|
private ITransferenciaRepository _Transferencia;
|
||
|
|
private IPickingRepository _Picking;
|
||
|
|
private IInventarioRepository _Inventario;
|
||
|
|
private ISolicitudTransferenciaRepository _SolicitudTransferencia;
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region SAP (SERVICES LAYER)
|
||
|
|
|
||
|
|
private IAuthenticateRepository _AuthenticateRepository;
|
||
|
|
private IItemsRepository _Items;
|
||
|
|
private IHRRepository _HR;
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
|
||
|
|
public RepositoryWrapper(IConnectionSQL repoContext, IConfiguration configuration, IHttpClientFactory clientFactory, IServiceProvider serviceProvider)
|
||
|
|
{
|
||
|
|
_repoContext = repoContext;
|
||
|
|
_configuration = configuration;
|
||
|
|
_clientFactory = clientFactory;
|
||
|
|
|
||
|
|
#region Conexion CORS
|
||
|
|
_conSQL = configuration.GetConnectionString("cnnSql");
|
||
|
|
|
||
|
|
/*Obtenemos que ambiente realizaremos la conexión*/
|
||
|
|
_entorno = configuration["EntornoConection:Entorno"];
|
||
|
|
_Source = EncriptaHelper.DecryptStringAES(configuration[string.Format("{0}:Source", _entorno)]);
|
||
|
|
_Catalog = EncriptaHelper.DecryptStringAES(configuration[string.Format("{0}:Catalog", _entorno)]);
|
||
|
|
_User = EncriptaHelper.DecryptStringAES(configuration[string.Format("{0}:User", _entorno)]);
|
||
|
|
_Password = EncriptaHelper.DecryptStringAES(configuration[string.Format("{0}:Password", _entorno)]);
|
||
|
|
_conSQL = _conSQL.Replace("{Source}", _Source).Replace("{Catalog}", _Catalog).Replace("{User}", _User).Replace("{Password}", _Password);
|
||
|
|
#endregion
|
||
|
|
}
|
||
|
|
|
||
|
|
#region WMS
|
||
|
|
public IReciboRepository Recibo
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_Recibo == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_Recibo = new ReciboRepository(_repoContext, _clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _Recibo;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public ITransferenciaRepository Transferencia
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_Transferencia == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_Transferencia = new TransferenciaRepository(_repoContext, _clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _Transferencia;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IItemsRepository Items
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_Items == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_Items = new ItemsRepository(_repoContext, _clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _Items;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IPickingRepository Picking
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_Picking == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_Picking = new PickingRepository(_repoContext, _clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _Picking;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IInventarioRepository Inventario
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_Inventario == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_Inventario = new InventarioRepository(_repoContext, _clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _Inventario;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public ISolicitudTransferenciaRepository SolicitudTransferencia
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_SolicitudTransferencia == null)
|
||
|
|
{
|
||
|
|
_SolicitudTransferencia = new SolicitudTransferenciaRepository(_clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _SolicitudTransferencia;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region SAP (SERVICES LAYER)
|
||
|
|
public IAuthenticateRepository Authenticate
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if(_AuthenticateRepository == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_AuthenticateRepository = new AuthenticateRepository(_repoContext, _clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _AuthenticateRepository;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public IHRRepository HR
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_HR == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_HR = new HRRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
}
|
||
|
|
return _HR;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
}
|
||
|
|
}
|