Commit inicial: ITCA_API_SAP_WMS (.NET Core 3.1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
2b82744eb8
168 files changed
+11066
No files matched your search
@@ -0,0 +1,80 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Net.Business.Entities;
|
||||
using Net.Business.Entities.ServicesLayer.Items;
|
||||
using Net.Connection;
|
||||
using Net.CrossCotting;
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Data.WMS.Items
|
||||
{
|
||||
public class ItemsRepository : RepositoryBase<object>, IItemsRepository
|
||||
{
|
||||
#region Variables Globales
|
||||
private string _aplicacionName;
|
||||
private string _metodoName;
|
||||
private readonly Regex regex = new Regex(@"<(\w+)>.*");
|
||||
|
||||
#endregion
|
||||
|
||||
public ItemsRepository(IConnectionSQL context, IHttpClientFactory clientFactory, IConfiguration configuration) : base(context)
|
||||
{
|
||||
_aplicacionName = GetType().Name;
|
||||
}
|
||||
|
||||
public async Task<BE_ResultadoTransaccion<BE_ItemStock>> GetStockItem()
|
||||
{
|
||||
_metodoName = regex.Match(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name).Groups[1].Value.ToString();
|
||||
|
||||
ResultadoTransaccion<BE_ItemStock> resultadoTransaccion = new ResultadoTransaccion<BE_ItemStock>(_metodoName, _aplicacionName);
|
||||
|
||||
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
List<BE_ItemStock> ListaStock = new List<BE_ItemStock>();
|
||||
DataTable dt = new DataTable();
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"CALL\"{LocalData.Schema}\".\"ITCA_WMS_SAP_GetStockConsolidado\"", con);
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
ListaStock.Add(new BE_ItemStock()
|
||||
{
|
||||
BinCode = dt.Rows[x]["BinCode"] != DBNull.Value ? Convert.ToString(dt.Rows[x]["BinCode"]) : string.Empty,
|
||||
DistNumber = dt.Rows[x]["DistNumber"] != DBNull.Value ? Convert.ToString(dt.Rows[x]["DistNumber"]) : string.Empty,
|
||||
ExpDate = dt.Rows[x]["ExpDate"] != DBNull.Value ? Convert.ToDateTime(dt.Rows[x]["ExpDate"]) : DateTime.Now,
|
||||
ItemCode = dt.Rows[x]["ItemCode"] != DBNull.Value ? Convert.ToString(dt.Rows[x]["ItemCode"]) : string.Empty,
|
||||
ItemName = dt.Rows[x]["ItemName"] != DBNull.Value ? Convert.ToString(dt.Rows[x]["ItemName"]) : string.Empty,
|
||||
OnHandQty = dt.Rows[x]["OnHandQty"] != DBNull.Value ? Convert.ToDouble(dt.Rows[x]["OnHandQty"]) : 0,
|
||||
WhsCode = dt.Rows[x]["WhsCode"] != DBNull.Value ? Convert.ToString(dt.Rows[x]["WhsCode"]) : string.Empty,
|
||||
WhsName = dt.Rows[x]["WhsName"] != DBNull.Value ? Convert.ToString(dt.Rows[x]["WhsName"]) : string.Empty,
|
||||
AvgPrice = dt.Rows[x]["AvgPrice"] != DBNull.Value ? Convert.ToDouble(dt.Rows[x]["AvgPrice"]) : 0,
|
||||
});
|
||||
}
|
||||
return resultadoTransaccion.GetInformacionResultado(0, 0, "Datos obtenidos Correctamente", ListaStock);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return resultadoTransaccion.GetInformacionResultado(ex.Message.ToString(), null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user