326 lines
11 KiB
C#
326 lines
11 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 IStockTransferRepository _StockTransfer;
|
||
|
|
private IPickingRepository _Picking;
|
||
|
|
private IInventarioRepository _Inventario;
|
||
|
|
private ISolicitudTransferenciaRepository _SolicitudTransferencia;
|
||
|
|
|
||
|
|
#endregion
|
||
|
|
|
||
|
|
#region SAP (SERVICES LAYER)
|
||
|
|
|
||
|
|
private IBusinessPartnersRepository _BusinessPartners;
|
||
|
|
private IPurchaseInvoicesRepository _PurchaseInvoices;
|
||
|
|
private IInvoiceRepository _Invoice;
|
||
|
|
private ICreditNotesRepository _CreditNotes;
|
||
|
|
private IAuthenticateRepository _AuthenticateRepository;
|
||
|
|
private IPurchaseDeliveryNotesRepository _PurchaseDeliveryNotes;
|
||
|
|
private IPurchaseOrdersRepository _PurchaseOrders;
|
||
|
|
private IItemsRepository _Items;
|
||
|
|
private IReturnRequestRepository _ReturnRequest;
|
||
|
|
private IInventoryGenEntriesRepository _InventoryGenEntries;
|
||
|
|
private IInventoryGenExitsRepository _InventoryGenExits;
|
||
|
|
private IHRRepository _HR;
|
||
|
|
private IGlobalDataRepository _GlobalData;
|
||
|
|
|
||
|
|
#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 IBusinessPartnersRepository BusinessPartners
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_BusinessPartners == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_BusinessPartners = new BusinessPartnersRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
}
|
||
|
|
return _BusinessPartners;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public ICreditNotesRepository CreditNotes
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_CreditNotes == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_CreditNotes = new CreditNotesRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
|
||
|
|
}
|
||
|
|
return _CreditNotes;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IInvoiceRepository InvoiceRepository
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_Invoice == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_Invoice = new InvoiceRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
}
|
||
|
|
return _Invoice;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IPurchaseInvoicesRepository PurchaseInvoices
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_PurchaseInvoices == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_PurchaseInvoices = new PurchaseInvoicesRepository(_clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _PurchaseInvoices;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IPurchaseDeliveryNotesRepository PurchaseDeliveryNotes
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_PurchaseDeliveryNotes == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_PurchaseDeliveryNotes = new PurchaseDeliveryNotesRepository(_clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _PurchaseDeliveryNotes;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IPurchaseOrdersRepository PurchaseOrders
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_PurchaseOrders == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_PurchaseOrders = new PurchaseOrdersRepository(_clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _PurchaseOrders;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IAuthenticateRepository Authenticate
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if(_AuthenticateRepository == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_AuthenticateRepository = new AuthenticateRepository(_repoContext, _clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _AuthenticateRepository;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IReturnRequestRepository ReturnRequest
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if(_ReturnRequest == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_ReturnRequest = new ReturnRequestRepository(_clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _ReturnRequest;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IStockTransferRepository StockTransfer
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_StockTransfer == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_StockTransfer = new StockTransferRepository(_clientFactory, _configuration);
|
||
|
|
}
|
||
|
|
return _StockTransfer;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IInventoryGenEntriesRepository InventoryGenEntries
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_InventoryGenEntries == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_InventoryGenEntries = new InventoryGenEntriesRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
}
|
||
|
|
return _InventoryGenEntries;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public IInventoryGenExitsRepository InventoryGenExits
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_InventoryGenExits == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_InventoryGenExits = new InventoryGenExitsRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
}
|
||
|
|
return _InventoryGenExits;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public IHRRepository HR
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_HR == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_HR = new HRRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
}
|
||
|
|
return _HR;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public IGlobalDataRepository GlobalData
|
||
|
|
{
|
||
|
|
get
|
||
|
|
{
|
||
|
|
if (_GlobalData == null)
|
||
|
|
{
|
||
|
|
_repoContext._cnx = _conSQL;
|
||
|
|
_GlobalData = new GlobalDataRepository(_clientFactory, _configuration, _repoContext);
|
||
|
|
}
|
||
|
|
return _GlobalData;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
}
|
||
|
|
}
|