142 lines
4.9 KiB
C#
Executable File
142 lines
4.9 KiB
C#
Executable File
using Microsoft.Extensions.DependencyInjection;
|
|
using Opsoft.Data;
|
|
using Opsoft.NetCore.O3App.Domain;
|
|
using Opsoft.NetCore.O3App.Domain.Interface;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.WMS.IRepositories;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.WMS.Model;
|
|
using Opsoft.NetCore.O3App.Shared;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Opsoft.NetCore.O3App.Repositories.WMS
|
|
{
|
|
[MapTo(typeof(IPickInventoryRepository), ServiceLifetime.Transient)]
|
|
public class PickInventoryRepository : RepositoryBase<BaseEntity>, IPickInventoryRepository
|
|
{
|
|
public DataTable SqlQuery(string sql)
|
|
{
|
|
try
|
|
{
|
|
using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
|
|
return dbContext.Database.SqlQuery(sql);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public List<T> SqlQuery<T>(string sql) where T : class, new()
|
|
{
|
|
try
|
|
{
|
|
using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
|
|
return dbContext.Database.SqlQuery<T>(sql);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public async Task<List<T>> SqlQueryAsync<T>(string sql) where T : class, new()
|
|
{
|
|
try
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
|
|
return await dbContext.Database.SqlQueryAsync<T>(sql);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public List<PickInventoryBarcodeInfo> GetBarcodeInfos(string sql)
|
|
{
|
|
try
|
|
{
|
|
using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
|
|
return dbContext.Database.SqlQuery<PickInventoryBarcodeInfo>(sql);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public async Task<int> ExecuteSqlAsync(List<string> sqlList)
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
var count = 0;
|
|
await dbContext.Database.BeginTransactionAsync().ConfigureAwait(false);
|
|
foreach (var sql in sqlList)
|
|
{
|
|
await dbContext.Database.SqlNonQueryAsync(sql);
|
|
}
|
|
await dbContext.Database.CommitTransactionAsync().ConfigureAwait(false);
|
|
return count;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
await dbContext.Database.RollbackTransactionAsync().ConfigureAwait(false);
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public async Task<int> ExecuteSqlAsync(string sql)
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
var count = 0;
|
|
await dbContext.Database.BeginTransactionAsync().ConfigureAwait(false);
|
|
|
|
await dbContext.Database.SqlNonQueryAsync(sql);
|
|
|
|
await dbContext.Database.CommitTransactionAsync().ConfigureAwait(false);
|
|
return count;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
await dbContext.Database.RollbackTransactionAsync().ConfigureAwait(false);
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public async Task<string> CreateBillNo(string billInfoJson)
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
return CreateBilllNO(dbContext, billInfoJson, "STK_PICKINVENTORY", "T_STK_PICKINVENTORY", "FBILLNO", null, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public decimal QtyUnitConvert(string materialId, string unitFrom, string unitTo, decimal qty)
|
|
{
|
|
using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
return GetMaterQty2(dbContext, materialId, unitFrom, unitTo, qty);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|