erp服务

This commit is contained in:
tongfei
2023-10-28 09:00:15 +08:00
parent f4293f8862
commit a769e6c711
2 changed files with 11 additions and 16 deletions

View File

@@ -53,21 +53,10 @@ namespace WMS.Web.Domain.Services.Public
this._client = new ERPGWSoapClient(binding, address);
try
{
var appId = "wms";
var cache_key = "erp_accesstoken_"+ appId;
var cache_value = _memoryCache.Get<string>(cache_key);
if (!string.IsNullOrEmpty(cache_value))
return Result<string>.ReSuccess(cache_value);
else
{
var result = await this._client.ValidateSystemAsync(this._erpOptions.UserName, this._erpOptions.Password, this._erpOptions.ErpId, appId);
if (result == null)
return Result<string>.ReFailure(ResultCodes.Erp_Login_Error);
_memoryCache.Set(cache_key, true, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
return Result<string>.ReSuccess(result.AccessToken);
}
var result = await this._client.ValidateSystemAsync(this._erpOptions.UserName, this._erpOptions.Password, this._erpOptions.ErpId, "");
if (result == null)
return Result<string>.ReFailure(ResultCodes.Erp_Login_Error);
return Result<string>.ReSuccess(result.AccessToken);
}
catch (Exception ex)
{
@@ -84,7 +73,7 @@ namespace WMS.Web.Domain.Services.Public
try
{
var token_result = await this.Init();
if(!token_result.IsSuccess)
if (!token_result.IsSuccess)
return ResultList<ErpPurchaseInStockResultDto>.ReFailure(token_result);
var query = new ErpBillQueryDto(token_result.Data);