1.修复报工单无法连续制单的问题

This commit is contained in:
qmj
2025-07-25 20:32:33 +08:00
parent ad04f2d658
commit b2121a1afb
11 changed files with 705 additions and 390 deletions
@@ -12,6 +12,21 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -92,5 +107,17 @@
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
@@ -31,6 +31,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL"> <Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
@@ -1,5 +1,4 @@
using System; using System;
using System.Web.UI.WebControls;
using ADODB; using ADODB;
using log4net; using log4net;
using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.Entity;
@@ -14,35 +13,72 @@ using VBLogin = U8Login.clsLogin;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
// ReSharper disable CommentTypo // ReSharper disable CommentTypo
// ReSharper disable FieldCanBeMadeReadOnly.Local // ReSharper disable FieldCanBeMadeReadOnly.Local
// ReSharper disable UnusedMember.Global
namespace UFIDA.U8.Framework.Api.ControlObject.U8M namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{ {
/// <summary>
/// 登录对象帮助类
/// </summary>
public class BaseLogin public class BaseLogin
{ {
private ILog _logInfo = LogManager.GetLogger("logInfo"); private ILog _logInfo = LogManager.GetLogger("logInfo");
/// <summary>
/// 登录对象(NET)
/// </summary>
public NetLogin _netLogin; public NetLogin _netLogin;
/// <summary>
/// 登录对象(VB)
/// </summary>
public VBLogin _vbLogin; public VBLogin _vbLogin;
/// <summary>
/// Net上下文
/// </summary>
public ProductContext _productContext; public ProductContext _productContext;
/// <summary>
/// 数据库连接对象(ADO)
/// </summary>
public Connection Connection; public Connection Connection;
/// <summary>
/// userToken
/// </summary>
public string userToken => _vbLogin.userToken; public string userToken => _vbLogin.userToken;
/// <summary>
/// 业务库连接字符串(ADO)
/// </summary>
public string UfDbName => _vbLogin.UfDbName; public string UfDbName => _vbLogin.UfDbName;
/// <summary>
/// 业务库连接字符串(ADO.Net)
/// </summary>
public string UFDataConnstringForNet => _vbLogin.UFDataConnstringForNet; public string UFDataConnstringForNet => _vbLogin.UFDataConnstringForNet;
/// <summary>
/// 元数据库连接字符串(ADO)
/// </summary>
public string UfMetaName => _vbLogin.UfMetaName; public string UfMetaName => _vbLogin.UfMetaName;
/// <summary>
/// 元数据库连接字符串(ADO.Net)
/// </summary>
public string UFMetaConnstringForNet => _vbLogin.UFMetaConnstringForNet; public string UFMetaConnstringForNet => _vbLogin.UFMetaConnstringForNet;
/// <summary>
/// 系统库连接字符串(ADO)
/// </summary>
public string UfSystemDb => _vbLogin.UfSystemDb; public string UfSystemDb => _vbLogin.UfSystemDb;
/// <summary>
/// 制造上下文
/// </summary>
public IContextContainer callar { get; set; } public IContextContainer callar { get; set; }
/// <summary> /// <summary>
@@ -53,7 +89,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="traceTimes"></param> /// <param name="traceTimes"></param>
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public void Init(LoginParamter paramter,bool bMon=true, int traceTimes=0) public void Init(LoginParamter paramter, bool bMon = true, int traceTimes = 0)
{ {
if (traceTimes > 5) if (traceTimes > 5)
@@ -93,6 +129,13 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}"); throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
} }
_logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}");
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
_logInfo.Debug("VB--完成登录进程");
_netLogin = new NetLogin(); _netLogin = new NetLogin();
_productContext= _netLogin.Login("DP", _vbLogin.userToken); _productContext= _netLogin.Login("DP", _vbLogin.userToken);
@@ -112,15 +155,36 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
//throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); //throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
} }
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}"); #region U8 18.0时需要取消注释
_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
ClientUserContext.Instance.RefreshContext(); var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
U8LoginInfoPool.Add(_netLogin.userToken, info);
_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
ThreadContext.SetLoginInfo(_netLogin.userToken);
_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
//ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程"); _logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer(); callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}"); _logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
#else #else
_netLogin = new NetLogin(); _netLogin = new NetLogin();
@@ -141,32 +205,68 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
} }
#region U8 18.0时需要取消注释
//_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
//var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
//U8LoginInfoPool.Add(_netLogin.userToken, info);
//_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
//_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
//ThreadContext.SetLoginInfo(_netLogin.userToken);
//_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始设置线程信息:{_productContext.calledContext.token}");
//ThreadContext.SetLoginInfo(_netLogin.userToken);
//_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
//var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
//U8LoginInfoPool.Add(_netLogin.userToken, info);
_logInfo.Debug($"Net--开始设置userToken:{_netLogin.userToken}");
Cryptography.m_userToken = _netLogin.userToken;
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}"); _logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext(); ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程"); _logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer(); callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}"); _logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return; return;
#endif #endif
} }
_vbLogin = new VBLogin(); _vbLogin = new VBLogin();
_vbLogin.ClearError(); _vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{_netLogin.userToken}");
_vbLogin.ConstructLogin(_netLogin.userToken);
_logInfo.Debug($"VB--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}"); var taskId = DateTime.Now.Ticks.ToString();
_logInfo.Debug($"VB--设置参数:{taskId}");
_vbLogin.set_TaskId(taskId);
if (!_vbLogin.Login(paramter.pSubId, paramter.pAccId, paramter.pYearId, paramter.pUserId, paramter.pPassword, paramter.pDate, paramter.cSrv, paramter.cSerial) && string.IsNullOrWhiteSpace(_vbLogin.userToken)) //_vbLogin.ClearError();
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}"); //_logInfo.Debug($"VB--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}");
}
//if (!_vbLogin.Login(paramter.pSubId, paramter.pAccId, paramter.pYearId, paramter.pUserId, paramter.pPassword, paramter.pDate, paramter.cSrv, paramter.cSerial) && string.IsNullOrWhiteSpace(_vbLogin.userToken))
//{
// throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
//}
_logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}"); _logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}");
@@ -175,97 +275,90 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_logInfo.Debug("VB--完成登录进程"); _logInfo.Debug("VB--完成登录进程");
return; #region 弃用
//if (!bMon)
//{
// _logInfo.Debug("非生产制造模块无需下面操作");
// //Trace.WriteLine("非生产制造模块无需下面操作");
// return;
//}
//_logInfo.Debug($"U8版本:{_vbLogin.GetVersionInfo()}");
//_logInfo.Debug($"1--登录令牌:{_vbLogin.userToken}");
//if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
//{
// Cryptography.m_userToken = "";
//}
//_productContext = _netLogin.Login("DP", _vbLogin.userToken);
//if (_productContext != null)
//{
// _logInfo.Debug($"222--成功初始化上下文信息:{_vbLogin.userToken}");
// ClientUserContext.Instance.RefreshContext();
// //ThreadContext.ServerToken = _netLogin.userToken;
// Connection = new Connection();
// Connection.Open(_vbLogin.UfDbName);
// _logInfo.Debug($"333--完成局部构建:{_netLogin.userToken}");
// return;
//}
//if (_netLogin.login(paramter.pSubId, paramter.pUserId, paramter.pPassword, paramter.cSrv, paramter.pDate, paramter.pAccId, paramter.cSerial))
//{
// _productContext = _netLogin.SubLogin("AS");
// if (_productContext == null)
// throw new Exception($"11--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
// _logInfo.Debug($"22--登录令牌:{_netLogin.userToken}");
// //Trace.WriteLine($"2--上下文令牌:{_productContext.calledContext.token}");
// //_vbLogin.ClearError();
// //_vbLogin.ConstructLogin(_netLogin.userToken);
// //var taskId = DateTime.Now.Ticks.ToString();
// //_vbLogin.set_TaskId(taskId);
// _logInfo.Debug($"33--登录令牌:{_vbLogin.userToken}");
// _logInfo.Debug($"44--正在创建应用池:{_netLogin.userToken}");
// ClientUserContext.Instance.RefreshContext();
// //ThreadContext.ServerToken = _netLogin.userToken;
// _logInfo.Debug($"55--完成局部构建:{_netLogin.userToken}");
// return;
if (!bMon) //}
{
_logInfo.Debug("非生产制造模块无需下面操作");
//Trace.WriteLine("非生产制造模块无需下面操作");
return;
}
_logInfo.Debug($"U8版本:{_vbLogin.GetVersionInfo()}"); //_productContext = _netLogin.Login("AS", _vbLogin.userToken);
_logInfo.Debug($"1--登录令牌:{_vbLogin.userToken}"); //_logInfo.Debug($"3--上下文令牌:{_productContext.calledContext.token}");
if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken)) //if (_productContext == null)
{ // throw new Exception($"2--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
Cryptography.m_userToken = "";
}
_productContext = _netLogin.Login("DP", _vbLogin.userToken); //ClientUserContext.Instance.RefreshContext();
////ThreadContext.ServerToken = _netLogin.userToken;
//Connection = new Connection();
//Connection.Open(_vbLogin.UfDbName);
if (_productContext != null) #endregion
{
_logInfo.Debug($"222--成功初始化上下文信息:{_vbLogin.userToken}");
ClientUserContext.Instance.RefreshContext();
//ThreadContext.ServerToken = _netLogin.userToken;
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
_logInfo.Debug($"333--完成局部构建:{_netLogin.userToken}");
return;
}
if (_netLogin.login(paramter.pSubId, paramter.pUserId, paramter.pPassword, paramter.cSrv, paramter.pDate, paramter.pAccId, paramter.cSerial))
{
_productContext = _netLogin.SubLogin("AS");
if (_productContext == null)
throw new Exception($"11--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
_logInfo.Debug($"22--登录令牌:{_netLogin.userToken}");
//Trace.WriteLine($"2--上下文令牌:{_productContext.calledContext.token}");
//_vbLogin.ClearError();
//_vbLogin.ConstructLogin(_netLogin.userToken);
//var taskId = DateTime.Now.Ticks.ToString();
//_vbLogin.set_TaskId(taskId);
_logInfo.Debug($"33--登录令牌:{_vbLogin.userToken}");
_logInfo.Debug($"44--正在创建应用池:{_netLogin.userToken}");
ClientUserContext.Instance.RefreshContext();
//ThreadContext.ServerToken = _netLogin.userToken;
_logInfo.Debug($"55--完成局部构建:{_netLogin.userToken}");
return;
}
_productContext = _netLogin.Login("AS", _vbLogin.userToken);
_logInfo.Debug($"3--上下文令牌:{_productContext.calledContext.token}");
if (_productContext == null)
throw new Exception($"2--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
ClientUserContext.Instance.RefreshContext();
//ThreadContext.ServerToken = _netLogin.userToken;
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -275,7 +368,15 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
} }
} }
public void Init(string userToken, bool bMon = true, int traceTimes = 0) /// <summary>
/// 初始化登录信息
/// </summary>
/// <param name="token"></param>
/// <param name="bMon"></param>
/// <param name="traceTimes"></param>
/// <exception cref="Exception"></exception>
/// <exception cref="ArgumentNullException"></exception>
public void Init(string token, bool bMon = true, int traceTimes = 0)
{ {
if (traceTimes > 5) if (traceTimes > 5)
throw new Exception("U8登录异常"); throw new Exception("U8登录异常");
@@ -292,7 +393,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
// ThreadContext.U8LoginInfo = null; // ThreadContext.U8LoginInfo = null;
//} //}
if (string.IsNullOrWhiteSpace(userToken)) throw new ArgumentNullException(nameof(userToken)); if (string.IsNullOrWhiteSpace(token)) throw new ArgumentNullException(nameof(token));
if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken)) if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
{ {
@@ -305,8 +406,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
#if DEBUG #if DEBUG
_vbLogin = new VBLogin(); _vbLogin = new VBLogin();
_vbLogin.ClearError(); _vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{userToken}"); _logInfo.Debug($"VB--开始进行U8登录:{token}");
if (!_vbLogin.ConstructLogin(userToken)) if (!_vbLogin.ConstructLogin(token))
{ {
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}"); throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
} }
@@ -316,40 +417,79 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{ {
_logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); _logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
_logInfo.Debug($"Net--开始进行上下文构建:{userToken}"); _logInfo.Debug($"Net--开始进行上下文构建:{_vbLogin.userToken}");
_productContext = _netLogin.Login("DP", _vbLogin.userToken); _productContext = _netLogin.Login("DP", _vbLogin.userToken);
//throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); //throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
} }
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext(); #region U8 18.0时需要取消注释
_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
U8LoginInfoPool.Add(_netLogin.userToken, info);
_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
ThreadContext.SetLoginInfo(_netLogin.userToken);
_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
//ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程"); _logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer(); callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}"); _logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
#else #else
_netLogin = new NetLogin(); _netLogin = new NetLogin();
_logInfo.Debug($"Net--开始进行U8登录:{userToken}"); _logInfo.Debug($"Net--开始进行U8登录:{token}");
_productContext = _netLogin.Login("DP", userToken); _productContext = _netLogin.Login("DP", token);
if (_productContext == null) if (_productContext == null)
{ {
throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
} }
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}"); #region U8 18.0时需要取消注释
//_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
ClientUserContext.Instance.RefreshContext(); //var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
//U8LoginInfoPool.Add(_netLogin.userToken, info);
//_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
//_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
//ThreadContext.SetLoginInfo(_netLogin.userToken);
//_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
//Cryptography.m_userToken = _netLogin.userToken;
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
//ClientUserContext.Instance.RefreshContext();
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
//ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程"); _logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer(); callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}"); _logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return; return;
@@ -359,8 +499,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_vbLogin = new VBLogin(); _vbLogin = new VBLogin();
_vbLogin.ClearError(); _vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{userToken}"); _logInfo.Debug($"VB--开始进行U8登录:{token}");
if (!_vbLogin.ConstructLogin(userToken)) if (!_vbLogin.ConstructLogin(token))
{ {
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}"); throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
} }
@@ -368,7 +508,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
Connection = new Connection(); Connection = new Connection();
Connection.Open(_vbLogin.UfDbName); Connection.Open(_vbLogin.UfDbName);
_logInfo.Debug("VB--完成登录进程"); _logInfo.Debug("VB--完成登录进程");
return;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -379,15 +518,23 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
throw new Exception("登录使用时间超过系统预置时间,请重新登录!"); throw new Exception("登录使用时间超过系统预置时间,请重新登录!");
} }
Init(userToken, bMon, traceTimes + 1); Init(token, bMon, traceTimes + 1);
} }
} }
/// <summary>
/// 校验制造上下文
/// </summary>
/// <returns></returns>
public bool CheckCallar() public bool CheckCallar()
{ {
return callar != null; return callar != null;
} }
/// <summary>
/// 刷新制造上下文
/// </summary>
/// <param name="paramter"></param>
public void RefreshCallar(LoginParamter paramter) public void RefreshCallar(LoginParamter paramter)
{ {
#if DEBUG #if DEBUG
@@ -411,114 +558,214 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
//throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); //throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
} }
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}"); #region U8 18.0时需要取消注释
_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
ClientUserContext.Instance.RefreshContext(); var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
_logInfo.Debug("Net--完成生产制造登录进程"); U8LoginInfoPool.Add(_netLogin.userToken, info);
_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
ThreadContext.SetLoginInfo(_netLogin.userToken);
_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
//ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer(); callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}"); _logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
#else
_netLogin = new NetLogin();
_logInfo.Debug($"Net--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}");
if (!_netLogin.login(paramter.pSubId, paramter.pUserId, paramter.pPassword, paramter.cSrv, paramter.pDate, paramter.pAccId, paramter.cSerial) && string.IsNullOrWhiteSpace(_netLogin.userToken))
{
throw new Exception($"Net--U8登录失败---{_netLogin.ErrDescript}");
}
_logInfo.Debug($"Net--开始进行上下文构建:{_netLogin.userToken}");
_productContext = _netLogin.SubLogin("DP");
if (_productContext == null)
{
throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
}
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext();
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
#endif
}
public void RefreshCallar(string userToken)
{
#if DEBUG
_netLogin = new NetLogin();
_productContext = _netLogin.Login("DP", _vbLogin.userToken);
if (_productContext == null)
{
_logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
_logInfo.Debug($"Net--开始进行上下文构建:{userToken}");
_productContext = _netLogin.Login("DP", _vbLogin.userToken);
//throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
}
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext();
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
#else #else
_netLogin = new NetLogin(); _netLogin = new NetLogin();
_logInfo.Debug($"Net--开始进行U8登录:{userToken}"); _logInfo.Debug($"Net--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}");
_productContext = _netLogin.Login("DP", userToken); if (!_netLogin.login(paramter.pSubId, paramter.pUserId, paramter.pPassword, paramter.cSrv, paramter.pDate, paramter.pAccId, paramter.cSerial) && string.IsNullOrWhiteSpace(_netLogin.userToken))
{
throw new Exception($"Net--U8登录失败---{_netLogin.ErrDescript}");
}
_logInfo.Debug($"Net--开始进行上下文构建:{_netLogin.userToken}");
_productContext = _netLogin.SubLogin("DP");
if (_productContext == null) if (_productContext == null)
{ {
throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}"); throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
} }
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}"); #region U8 18.0时需要取消注释
_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
ClientUserContext.Instance.RefreshContext(); var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
U8LoginInfoPool.Add(_netLogin.userToken, info);
_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
ThreadContext.SetLoginInfo(_netLogin.userToken);
_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
//ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程"); _logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer(); callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}"); _logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return; return;
#endif #endif
} }
public void ShutDown() /// <summary>
/// 刷新制造上下文
/// </summary>
/// <param name="token"></param>
public void RefreshCallar(string token)
{
#if DEBUG
_netLogin = new NetLogin();
_productContext = _netLogin.Login("DP", token);
if (_productContext == null)
{
_logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
_logInfo.Debug($"Net--开始进行上下文构建:{token}");
_productContext = _netLogin.Login("DP", token);
//throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
}
#region U8 18.0时需要取消注释
_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
U8LoginInfoPool.Add(_netLogin.userToken, info);
_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
ThreadContext.SetLoginInfo(_netLogin.userToken);
_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
//ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
#else
_netLogin = new NetLogin();
_logInfo.Debug($"Net--开始进行U8登录:{token}");
_productContext = _netLogin.Login("DP", token);
if (_productContext == null)
{ {
U8LoginInfoPool.Clear(); throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
ThreadContext.ServerToken = null;
_vbLogin?.ShutDown();
_productContext=null;
_netLogin?.SubLogout("DP");
_netLogin?.ShutDown();
_vbLogin = null;
_netLogin = null;
} }
public bool CheckAccId(string cAccId)
#region U8 18.0时需要取消注释
_logInfo.Debug($"U8M--正在创建应用池:{_netLogin.userToken}");
var info = U8LoginInfo.CreateInstance(_netLogin.userToken);
U8LoginInfoPool.Add(_netLogin.userToken, info);
_logInfo.Debug($"U8M--创建应用池:{info.U8LoginToken}");
_logInfo.Debug($"U8M--正在设置线程登录信息:{_netLogin.userToken}");
ThreadContext.SetLoginInfo(_netLogin.userToken);
_logInfo.Debug($"U8M--设置线程登录信息:{_netLogin.userToken}");
#endregion
#region U8 18.0时需要注释
//_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
#endif
}
/// <summary>
/// 注销登录对象
/// </summary>
public void ShutDown()
{
U8LoginInfoPool.Remove(_netLogin.userToken);
ThreadContext.ServerToken = null;
_vbLogin?.ShutDown();
_productContext = null;
_netLogin?.SubLogout("DP");
_netLogin?.ShutDown();
_netLogin?.Dispose();
_vbLogin = null;
_netLogin = null;
if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
{ {
return _vbLogin.get_cAcc_Id() == cAccId; Cryptography.m_userToken = "";
} }
} }
/// <summary>
/// 校验当前账套
/// </summary>
/// <param name="cAccId"></param>
/// <returns></returns>
public bool CheckAccId(string cAccId)
{
return _vbLogin.get_cAcc_Id() == cAccId;
}
/// <summary>
/// 清理登录上下文
/// </summary>
public void ClearLoginInfoPool()
{
U8LoginInfoPool.Clear();
ThreadContext.ServerToken = null;
_productContext = null;
_netLogin?.SubLogout("DP");
_netLogin?.ShutDown();
_netLogin = null;
}
}
} }
@@ -9,8 +9,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{ {
public interface IBaseBF public interface IBaseBF
{ {
Task<BaseResult<string>> Save(BaseLogin baseLogin,string cCardNum, Dictionary<string, object> input); BaseResult<string> Save(BaseLogin baseLogin,string cCardNum, Dictionary<string, object> input);
Task<BaseResult<string>> Save(BaseLogin baseLogin, string cCardNum, List<Dictionary<string, object>> inputs); BaseResult<string> Save(BaseLogin baseLogin, string cCardNum, List<Dictionary<string, object>> inputs);
} }
} }
@@ -8,6 +8,7 @@ using UFIDA.U8.Framework.Api.ControlObject.Common;
using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.Entity;
using UFIDA.U8.Framework.Api.ControlObject.Json; using UFIDA.U8.Framework.Api.ControlObject.Json;
using UFSoft.U8.Framework.BizBase; using UFSoft.U8.Framework.BizBase;
using UFSoft.U8.Framework.ContextSrv;
using UFSoft.U8.U8M.BFDispatcher; using UFSoft.U8.U8M.BFDispatcher;
using UFSoft.U8.U8M.Common; using UFSoft.U8.U8M.Common;
using UFSoft.U8.U8M.DAC; using UFSoft.U8.U8M.DAC;
@@ -34,26 +35,35 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="callar"></param> /// <param name="callar"></param>
/// <param name="cCardNum"></param> /// <param name="cCardNum"></param>
/// <returns></returns> /// <returns></returns>
private static async Task<MoRoutingBillDs> GetEmptyDs(IContextContainer callar, string cCardNum) private MoRoutingBillDs GetEmptyDs(IContextContainer callar, string cCardNum)
{ {
try try
{ {
_logInfo.Debug($"获取空数据集-----{cCardNum}");
var ds = SFExecutor.BFMoRoutingBill_LoadData("LoadFirst", 0, "", cCardNum, callar); var ds = SFExecutor.BFMoRoutingBill_LoadData("LoadFirst", 0, "", cCardNum, callar);
#region 清除数据集里的数据 #region 清除数据集里的数据
_logInfo.Debug("清空数据集-----MoRoutingBilldetail_ExtraDefine");
if (ds.Tables.Contains("fc_MoRoutingBilldetail_ExtraDefine")) if (ds.Tables.Contains("fc_MoRoutingBilldetail_ExtraDefine"))
{ {
ds.Tables["fc_MoRoutingBilldetail_ExtraDefine"].Clear(); ds.Tables["fc_MoRoutingBilldetail_ExtraDefine"].Clear();
} }
_logInfo.Debug("清空数据集-----MoRoutingBill_ExtraDefine");
if (ds.Tables.Contains("fc_MoRoutingBill_ExtraDefine")) if (ds.Tables.Contains("fc_MoRoutingBill_ExtraDefine"))
{ {
ds.Tables["fc_MoRoutingBill_ExtraDefine"].Clear(); ds.Tables["fc_MoRoutingBill_ExtraDefine"].Clear();
} }
_logInfo.Debug("清空数据集-----MoRoutingBillRes");
ds.MoRoutingBillRes.Clear(); ds.MoRoutingBillRes.Clear();
_logInfo.Debug("清空数据集-----MoRoutingBillDetail");
ds.MoRoutingBillDetail.Clear(); ds.MoRoutingBillDetail.Clear();
_logInfo.Debug("清空数据集-----MoRoutingBill");
ds.MoRoutingBill.Clear(); ds.MoRoutingBill.Clear();
#endregion #endregion
@@ -62,8 +72,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
} }
catch catch
{ {
await Task.Delay(1);
throw; throw;
} }
} }
@@ -76,33 +84,44 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="docNoParam"></param> /// <param name="docNoParam"></param>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
private static async Task<MoRoutingBillDs> GetVoucherDs(IContextContainer callar, string cCardNum, AutoDocNoGenerateParam docNoParam, Dictionary<string, object> input) private MoRoutingBillDs GetVoucherDs(IContextContainer callar, string cCardNum, AutoDocNoGenerateParam docNoParam, Dictionary<string, object> input)
{ {
var ds = await GetEmptyDs(callar, cCardNum); _logInfo.Debug("获取空数据集");
var ds = GetEmptyDs(callar, cCardNum);
var head = ds.MoRoutingBill.NewMoRoutingBillRow(); var head = ds.MoRoutingBill.NewMoRoutingBillRow();
ds.MoRoutingBill.AddMoRoutingBillRow(head); ds.MoRoutingBill.AddMoRoutingBillRow(head);
var docNo = U8MCommonExecutor.BFVoucher_GetVoucherID(cCardNum, docNoParam.Paramaters, false, callar); //_logInfo.Debug($"获取单号规则-----{cCardNum}-----{docNoParam.Paramaters.ToJson()}");
//var hsTable = U8MCommonExecutor.BFVoucher_GetVoucherIDFormula(cCardNum, callar);
//_logInfo.Debug($"获取单号-----{cCardNum}-----{hsTable.ToJson()}");
//var docNo = U8MCommonExecutor.BFVoucher_GetVoucherID(cCardNum, hsTable, false, callar);
var docNo = "";
_logInfo.Debug("BE处理中");
var be = new UFSoft.U8.SF.BE.MoRoutingBill(ds); var be = new UFSoft.U8.SF.BE.MoRoutingBill(ds);
be.cVouchType = cCardNum; be.cVouchType = cCardNum;
be.cVouchCode = ""; be.cVouchCode = "";
_logInfo.Debug("填充表头参数");
var beHead = new BEHelper(be); var beHead = new BEHelper(be);
beHead.SetValue(input); beHead.SetValue(input);
if (string.IsNullOrWhiteSpace(be.cVouchCode)) if (string.IsNullOrWhiteSpace(be.cVouchCode))
{ {
_logInfo.Debug($"设置单号:{docNo}");
be.cVouchCode = docNo; be.cVouchCode = docNo;
} }
var bodys = input["body"] as List<Dictionary<string, object>> ?? $"{input["body"]}".ToObject<List<Dictionary<string, object>>>(); var bodys = input["body"] as List<Dictionary<string, object>> ?? $"{input["body"]}".ToObject<List<Dictionary<string, object>>>();
_logInfo.Debug("填充表体参数");
for (var i = 0; i < bodys.Count; i++) for (var i = 0; i < bodys.Count; i++)
{ {
var body = bodys[i]; var body = bodys[i];
@@ -113,7 +132,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
beBody.SetValue(body); beBody.SetValue(body);
} }
_logInfo.Debug($"获取数据集:{be.DataObject.ToJson()}");
ds = (MoRoutingBillDs)be.DataObject; ds = (MoRoutingBillDs)be.DataObject;
return ds; return ds;
@@ -127,13 +146,13 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async Task<BaseResult<string>> Save(BaseLogin baseLogin, string cCardNum, Dictionary<string, object> input) public BaseResult<string> Save(BaseLogin baseLogin, string cCardNum, Dictionary<string, object> input)
{ {
try try
{ {
var callar = baseLogin.callar; var callar = new DefaultContextContainer();
var docNoParam = new AutoDocNoGenerateParam(EnumAutoDocNoType.HandAuto, cCardNum) var docNoParam = new AutoDocNoGenerateParam(EnumAutoDocNoType.HandAuto, cCardNum,false)
{ {
IsCurrentDocNoByHand = false IsCurrentDocNoByHand = false
}; };
@@ -145,23 +164,21 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
throw new Exception("未能构建数据集"); throw new Exception("未能构建数据集");
} }
_logInfo.Debug($"单据编码:{cCardNum},开始保存"); _logInfo.Debug($"单据编码:{cCardNum},开始保存");
var id = SFExecutor.BFMoRoutingBill_MoRoutingBillSave(ds.Result, docNoParam, callar); var id = SFExecutor.BFMoRoutingBill_MoRoutingBillSave(ds, docNoParam, callar);
var voucherCode = SFExecutor.BFMoRoutingBill_GetCodeById(id, callar);
_logInfo.Debug($"单据编码:{cCardNum},保存完成,id:{id}"); _logInfo.Debug($"单据编码:{cCardNum},保存完成,id:{id},单号:{voucherCode}");
return new BaseResult<string> { bSuccess = true, message = "新增成功", result = $"{id}" }; return new BaseResult<string> { bSuccess = true, message = "新增成功", result = $"{id}",voucherCode = voucherCode,voucherId =$"{id}" };
} }
catch (U8MReferenceBENotExistException ex) catch (U8MReferenceBENotExistException ex)
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
} }
catch (TargetInvocationException ex) catch (TargetInvocationException ex)
@@ -170,16 +187,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{ {
_logInfo.Error(ex.InnerException.Message, ex.InnerException); _logInfo.Error(ex.InnerException.Message, ex.InnerException);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.InnerException.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.InnerException.Message };
} }
else else
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
} }
@@ -189,8 +202,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
} }
} }
@@ -202,20 +213,21 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="cCardNum"></param> /// <param name="cCardNum"></param>
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
public async Task<BaseResult<string>> Save(BaseLogin baseLogin, string cCardNum, List<Dictionary<string, object>> inputs) public BaseResult<string> Save(BaseLogin baseLogin, string cCardNum, List<Dictionary<string, object>> inputs)
{ {
var idList = new List<int>(); var idList = new List<int>();
var codeList = new List<string>();
try try
{ {
foreach (var input in inputs) foreach (var input in inputs)
{ {
var iRes = await Save(baseLogin, cCardNum, input); var iRes = Save(baseLogin, cCardNum, input);
if (!iRes.bSuccess && idList.Count > 0) if (!iRes.bSuccess && idList.Count > 0)
{ {
await Delete(baseLogin, idList); Delete(baseLogin, idList);
return iRes; return iRes;
} }
@@ -224,11 +236,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
return iRes; return iRes;
} }
idList.Add(Convert.ToInt32(iRes.result)); idList.Add(Convert.ToInt32(iRes.voucherId));
codeList.Add(iRes.voucherCode);
} }
return new BaseResult<string> { bSuccess = true, message = "新增成功", result = $"{string.Join(",", idList)}" }; return new BaseResult<string> { bSuccess = true, message = "新增成功", result = $"{string.Join(",", codeList)}" ,voucherCode = $"{string.Join(",", codeList)}",voucherId = $"{string.Join(",", idList)}" };
} }
catch (Exception ex) catch (Exception ex)
@@ -248,7 +261,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async Task<BaseResult<string>> Delete(BaseLogin baseLogin, string cCardNum, List<string> inputs) public BaseResult<string> Delete(BaseLogin baseLogin, string cCardNum, List<string> inputs)
{ {
try try
{ {
@@ -264,7 +277,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
newInput.Add(int.Parse($"{dataReader[0]}")); newInput.Add(int.Parse($"{dataReader[0]}"));
} }
return await Delete(baseLogin, newInput); return Delete(baseLogin, newInput);
} }
catch (U8MReferenceBENotExistException ex) catch (U8MReferenceBENotExistException ex)
{ {
@@ -287,7 +300,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async Task<BaseResult<string>> Delete(BaseLogin baseLogin, List<int> inputs) public BaseResult<string> Delete(BaseLogin baseLogin, List<int> inputs)
{ {
try try
{ {
@@ -309,16 +322,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
} }
catch (Exception ex) catch (Exception ex)
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "删除失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "删除失败", result = ex.Message };
} }
@@ -333,7 +342,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async Task<BaseResult<string>> Verify(BaseLogin baseLogin, string cCardNum, List<string> inputs) public BaseResult<string> Verify(BaseLogin baseLogin, string cCardNum, List<string> inputs)
{ {
try try
{ {
@@ -349,7 +358,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
newInput.Add(int.Parse($"{dataReader[0]}")); newInput.Add(int.Parse($"{dataReader[0]}"));
} }
return await Verify(baseLogin, newInput); return Verify(baseLogin, newInput);
} }
catch (U8MReferenceBENotExistException ex) catch (U8MReferenceBENotExistException ex)
{ {
@@ -372,7 +381,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async Task<BaseResult<string>> Verify(BaseLogin baseLogin, List<int> inputs) public BaseResult<string> Verify(BaseLogin baseLogin, List<int> inputs)
{ {
try try
{ {
@@ -394,16 +403,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
} }
catch (Exception ex) catch (Exception ex)
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "审核失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "审核失败", result = ex.Message };
} }
@@ -418,7 +423,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async Task<BaseResult<string>> UnVerify(BaseLogin baseLogin, string cCardNum, List<string> inputs) public BaseResult<string> UnVerify(BaseLogin baseLogin, string cCardNum, List<string> inputs)
{ {
try try
{ {
@@ -434,14 +439,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
newInput.Add(int.Parse($"{dataReader[0]}")); newInput.Add(int.Parse($"{dataReader[0]}"));
} }
return await UnVerify(baseLogin, newInput); return UnVerify(baseLogin, newInput);
} }
catch (U8MReferenceBENotExistException ex) catch (U8MReferenceBENotExistException ex)
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "弃审失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "弃审失败", result = ex.Message };
} }
catch (Exception ex) catch (Exception ex)
@@ -459,7 +462,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="inputs"></param> /// <param name="inputs"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async Task<BaseResult<string>> UnVerify(BaseLogin baseLogin, List<int> inputs) public BaseResult<string> UnVerify(BaseLogin baseLogin, List<int> inputs)
{ {
try try
{ {
@@ -481,16 +484,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "新增失败", result = ex.Message };
} }
catch (Exception ex) catch (Exception ex)
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = "弃审失败", result = ex.Message }; return new BaseResult<string> { bSuccess = false, message = "弃审失败", result = ex.Message };
} }
@@ -31,6 +31,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <Reference Include="ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
@@ -69,7 +69,8 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
var output = new LoginOutput var output = new LoginOutput
{ {
cAccId = cAccId, cAccId = cAccId,
userToken = CommUnit.GetEncrypt(userToken) userToken = CommUnit.GetEncrypt(userToken),
loginParamter = param
}; };
return new BaseResult<string>() { bSuccess = true, message = "登录成功", result = CommUnit.GetEncrypt(output.ToJson()) }; return new BaseResult<string>() { bSuccess = true, message = "登录成功", result = CommUnit.GetEncrypt(output.ToJson()) };
@@ -50,11 +50,18 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
try try
{ {
var userToken = Request.Headers.GetValues("userToken").First(); try
if (!string.IsNullOrWhiteSpace(userToken))
{ {
return await MoRoutingBillSaveToken(cCardNum, input); var userToken = Request.Headers.GetValues("userToken").First();
if (!string.IsNullOrWhiteSpace(userToken))
{
return await MoRoutingBillSaveToken(cCardNum, input);
}
}
catch (Exception ex)
{
_logInfo.Debug($"作业Id:{workId}-----userToken获取失败,错误信息:{ex.Message}");
} }
_logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillSave,单据类型编码:{cCardNum},报文数据:{input.ToJson()}"); _logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillSave,单据类型编码:{cCardNum},报文数据:{input.ToJson()}");
@@ -62,36 +69,16 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{ {
_logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); throw new Exception("未能加载指定系统号的登录信息");
//可能存在其他的缓存,先清掉
_cache.Clear();
baseLogin = new BaseLogin();
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{
throw new Exception("未能加载指定系统号的登录信息");
}
baseLogin.Init(param);
_cache.Set($"U8_{cAccId}", baseLogin);
} }
if (baseLogin == null) baseLogin.Init(param);
{
throw new Exception("登录对象加载失败");
}
if (!baseLogin.CheckCallar())
{
baseLogin.RefreshCallar(baseLogin.userToken);
}
var bo = new MoRoutingBill(); var bo = new MoRoutingBill();
BaseResult<string> res; BaseResult<string> res;
@@ -101,16 +88,18 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
var inputs = input["inputs"] as List<Dictionary<string, object>> ?? $"{input["inputs"]}".ToObject<List<Dictionary<string, object>>>(); var inputs = input["inputs"] as List<Dictionary<string, object>> ?? $"{input["inputs"]}".ToObject<List<Dictionary<string, object>>>();
_logInfo.Debug($"作业Id:{workId}-----开始保存(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始保存(批量)");
res = await bo.Save(baseLogin, cCardNum, inputs); res = bo.Save(baseLogin, cCardNum, inputs);
_logInfo.Debug($"作业Id:{workId}-----结束保存(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束保存(批量)");
} }
else else
{ {
_logInfo.Debug($"作业Id:{workId}-----开始保存"); _logInfo.Debug($"作业Id:{workId}-----开始保存");
res = await bo.Save(baseLogin, cCardNum, input); res = bo.Save(baseLogin, cCardNum, input);
_logInfo.Debug($"作业Id:{workId}-----结束保存"); _logInfo.Debug($"作业Id:{workId}-----结束保存");
} }
baseLogin.ShutDown();
return res; return res;
} }
@@ -152,29 +141,21 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8_{userToken}_{output.cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = output.loginParamter;
if (param == null)
{ {
_logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); throw new Exception("未能加载指定系统号的登录信息");
//可能存在其他的缓存,先清掉
_cache.Clear();
baseLogin = new BaseLogin();
baseLogin.Init(token, true, 5);
_cache.Set($"U8_{userToken}_{output.cAccId}", baseLogin);
} }
if (baseLogin == null) if (param.pDate != $"{DateTime.Today:yyyy-MM-dd}")
{ {
throw new Exception("登录对象加载失败"); param.pDate = $"{DateTime.Today:yyyy-MM-dd}";
} }
if (!baseLogin.CheckCallar()) baseLogin.Init(param);
{
baseLogin.RefreshCallar(baseLogin.userToken);
}
var bo = new MoRoutingBill(); var bo = new MoRoutingBill();
BaseResult<string> res; BaseResult<string> res;
@@ -183,18 +164,20 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
var inputs = input["inputs"] as List<Dictionary<string, object>> ?? $"{input["inputs"]}".ToObject<List<Dictionary<string, object>>>(); var inputs = input["inputs"] as List<Dictionary<string, object>> ?? $"{input["inputs"]}".ToObject<List<Dictionary<string, object>>>();
_logInfo.Debug($"作业Id:{workId}-----开始保存(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始保存(批量)");
res = await bo.Save(baseLogin, cCardNum, inputs); res = bo.Save(baseLogin, cCardNum, inputs);
_logInfo.Debug($"作业Id:{workId}-----结束保存(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束保存(批量)");
} }
else else
{ {
_logInfo.Debug($"作业Id:{workId}-----开始保存"); _logInfo.Debug($"作业Id:{workId}-----开始保存");
res = await bo.Save(baseLogin, cCardNum, input); res = bo.Save(baseLogin, cCardNum, input);
_logInfo.Debug($"作业Id:{workId}-----结束保存"); _logInfo.Debug($"作业Id:{workId}-----结束保存");
} }
baseLogin.ShutDown();
return res; return res;
} }
@@ -202,6 +185,8 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
{ {
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace }; return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
} }
} }
@@ -299,11 +284,18 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
try try
{ {
var userToken = Request.Headers.GetValues("userToken").First(); try
if (!string.IsNullOrWhiteSpace(userToken))
{ {
return await MoRoutingBillDeleteToken(cCardNum, input); var userToken = Request.Headers.GetValues("userToken").First();
if (!string.IsNullOrWhiteSpace(userToken))
{
return await MoRoutingBillDeleteToken(cCardNum, input);
}
}
catch (Exception ex)
{
_logInfo.Debug($"作业Id:{workId}-----userToken获取失败,错误信息:{ex.Message}");
} }
_logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillDelete,单据类型编码:{cCardNum},报文数据:{input.ToJson()}"); _logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillDelete,单据类型编码:{cCardNum},报文数据:{input.ToJson()}");
@@ -311,36 +303,37 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8M_{cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{ {
baseLogin = new BaseLogin(); throw new Exception("未能加载指定系统号的登录信息");
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{
throw new Exception("未能加载指定系统号的登录信息");
}
baseLogin.Init(param);
_cache.Set($"U8M_{cAccId}", baseLogin);
} }
baseLogin.Init(param);
var bf = new MoRoutingBill(); var bf = new MoRoutingBill();
if (input.cVouchCode != null && input.cVouchCode.Count > 0) if (input.cVouchCode != null && input.cVouchCode.Count > 0)
{ {
_logInfo.Debug($"作业Id:{workId}-----开始删除(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始删除(单号)(批量)");
var res = await bf.Delete(baseLogin, cCardNum, input.cVouchCode); var res = bf.Delete(baseLogin, cCardNum, input.cVouchCode);
_logInfo.Debug($"作业Id:{workId}-----结束删除(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束删除(单号)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
else else
{ {
_logInfo.Debug($"作业Id:{workId}-----开始删除(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始删除(ID)(批量)");
var res = await bf.Delete(baseLogin, input.MID); var res = bf.Delete(baseLogin, input.MID);
_logInfo.Debug($"作业Id:{workId}-----结束删除(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束删除(ID)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
@@ -385,34 +378,42 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8_{userToken}_{output.cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = output.loginParamter;
if (param == null)
{ {
_logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); throw new Exception("未能加载指定系统号的登录信息");
//可能存在其他的缓存,先清掉
_cache.Clear();
baseLogin = new BaseLogin();
baseLogin.Init(token, true, 5);
_cache.Set($"U8_{userToken}_{output.cAccId}", baseLogin);
} }
if (param.pDate != $"{DateTime.Today:yyyy-MM-dd}")
{
param.pDate = $"{DateTime.Today:yyyy-MM-dd}";
}
baseLogin.Init(param);
var bf = new MoRoutingBill(); var bf = new MoRoutingBill();
if (input.cVouchCode != null && input.cVouchCode.Count > 0) if (input.cVouchCode != null && input.cVouchCode.Count > 0)
{ {
_logInfo.Debug($"作业Id:{workId}-----开始删除(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始删除(单号)(批量)");
var res = await bf.Delete(baseLogin, cCardNum, input.cVouchCode); var res = bf.Delete(baseLogin, cCardNum, input.cVouchCode);
_logInfo.Debug($"作业Id:{workId}-----结束删除(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束删除(单号)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
else else
{ {
_logInfo.Debug($"作业Id:{workId}-----开始删除(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始删除(ID)(批量)");
var res = await bf.Delete(baseLogin, input.MID); var res = bf.Delete(baseLogin, input.MID);
_logInfo.Debug($"作业Id:{workId}-----结束删除(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束删除(ID)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
@@ -421,6 +422,8 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
{ {
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace }; return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
} }
@@ -520,11 +523,18 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
try try
{ {
var userToken = Request.Headers.GetValues("userToken").First(); try
if (!string.IsNullOrWhiteSpace(userToken))
{ {
return await MoRoutingBillVerifyToken(cCardNum, input); var userToken = Request.Headers.GetValues("userToken").First();
if (!string.IsNullOrWhiteSpace(userToken))
{
return await MoRoutingBillVerifyToken(cCardNum, input);
}
}
catch (Exception ex)
{
_logInfo.Debug($"作业Id:{workId}-----userToken获取失败,错误信息:{ex.Message}");
} }
_logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillVerify,单据类型编码:{cCardNum},报文数据:{input.ToJson()}"); _logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillVerify,单据类型编码:{cCardNum},报文数据:{input.ToJson()}");
@@ -532,37 +542,32 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8M_{cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{ {
baseLogin = new BaseLogin(); throw new Exception("未能加载指定系统号的登录信息");
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{
throw new Exception("未能加载指定系统号的登录信息");
}
baseLogin.Init(param);
_cache.Set($"U8M_{cAccId}", baseLogin);
} }
baseLogin.Init(param);
var bf = new MoRoutingBill(); var bf = new MoRoutingBill();
if (input.cVouchCode != null && input.cVouchCode.Count > 0) if (input.cVouchCode != null && input.cVouchCode.Count > 0)
{ {
return await bf.Verify(baseLogin, cCardNum, input.cVouchCode); return bf.Verify(baseLogin, cCardNum, input.cVouchCode);
} }
else else
{ {
return await bf.Verify(baseLogin, input.MID); return bf.Verify(baseLogin, input.MID);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace }; return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
} }
@@ -600,34 +605,42 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8_{userToken}_{output.cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = output.loginParamter;
if (param == null)
{ {
_logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); throw new Exception("未能加载指定系统号的登录信息");
//可能存在其他的缓存,先清掉
_cache.Clear();
baseLogin = new BaseLogin();
baseLogin.Init(token, true, 5);
_cache.Set($"U8_{userToken}_{output.cAccId}", baseLogin);
} }
if (param.pDate != $"{DateTime.Today:yyyy-MM-dd}")
{
param.pDate = $"{DateTime.Today:yyyy-MM-dd}";
}
baseLogin.Init(param);
var bf = new MoRoutingBill(); var bf = new MoRoutingBill();
if (input.cVouchCode != null && input.cVouchCode.Count > 0) if (input.cVouchCode != null && input.cVouchCode.Count > 0)
{ {
_logInfo.Debug($"作业Id:{workId}-----开始审核(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始审核(单号)(批量)");
var res = await bf.Verify(baseLogin, cCardNum, input.cVouchCode); var res = bf.Verify(baseLogin, cCardNum, input.cVouchCode);
_logInfo.Debug($"作业Id:{workId}-----结束审核(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束审核(单号)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
else else
{ {
_logInfo.Debug($"作业Id:{workId}-----开始审核(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始审核(ID)(批量)");
var res = await bf.Verify(baseLogin, input.MID); var res = bf.Verify(baseLogin, input.MID);
_logInfo.Debug($"作业Id:{workId}-----结束审核(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束审核(ID)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
@@ -636,6 +649,8 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
{ {
_logInfo.Error(ex.Message, ex); _logInfo.Error(ex.Message, ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace }; return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
} }
@@ -735,11 +750,18 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
try try
{ {
var userToken = Request.Headers.GetValues("userToken").First(); try
if (!string.IsNullOrWhiteSpace(userToken))
{ {
return await MoRoutingBillUnVerifyToken(cCardNum, input); var userToken = Request.Headers.GetValues("userToken").First();
if (!string.IsNullOrWhiteSpace(userToken))
{
return await MoRoutingBillUnVerifyToken(cCardNum, input);
}
}
catch (Exception ex)
{
_logInfo.Debug($"作业Id:{workId}-----userToken获取失败,错误信息:{ex.Message}");
} }
_logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillUnVerify,单据类型编码:{cCardNum},报文数据:{input.ToJson()}"); _logInfo.Debug($"作业Id:{workId}-----当前接口:api/U8/SFC/MoRoutingBillUnVerify,单据类型编码:{cCardNum},报文数据:{input.ToJson()}");
@@ -747,36 +769,37 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8M_{cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{ {
baseLogin = new BaseLogin(); throw new Exception("未能加载指定系统号的登录信息");
var param = await CommUnit.GetLoginParamter(cAccId);
if (param == null)
{
throw new Exception("未能加载指定系统号的登录信息");
}
baseLogin.Init(param);
_cache.Set($"U8M_{cAccId}", baseLogin);
} }
baseLogin.Init(param);
var bf = new MoRoutingBill(); var bf = new MoRoutingBill();
if (input.cVouchCode != null && input.cVouchCode.Count > 0) if (input.cVouchCode != null && input.cVouchCode.Count > 0)
{ {
_logInfo.Debug($"作业Id:{workId}-----开始弃审(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始弃审(单号)(批量)");
var res = await bf.UnVerify(baseLogin, cCardNum, input.cVouchCode); var res = bf.UnVerify(baseLogin, cCardNum, input.cVouchCode);
_logInfo.Debug($"作业Id:{workId}-----结束弃审(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束弃审(单号)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
else else
{ {
_logInfo.Debug($"作业Id:{workId}-----开始弃审(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始弃审(单号)(批量)");
var res = await bf.UnVerify(baseLogin, input.MID); var res = bf.UnVerify(baseLogin, input.MID);
_logInfo.Debug($"作业Id:{workId}-----结束弃审(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束弃审(单号)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
@@ -821,34 +844,42 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92") if (cCardNum != "FC90" && cCardNum != "FC91" && cCardNum != "FC92")
throw new Exception("当前接口不支持此类型的单据"); throw new Exception("当前接口不支持此类型的单据");
if (!_cache.TryGetValue($"U8_{userToken}_{output.cAccId}", out BaseLogin baseLogin)) var baseLogin = new BaseLogin();
var param = output.loginParamter;
if (param == null)
{ {
_logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); throw new Exception("未能加载指定系统号的登录信息");
//可能存在其他的缓存,先清掉
_cache.Clear();
baseLogin = new BaseLogin();
baseLogin.Init(token, true, 5);
_cache.Set($"U8_{userToken}_{output.cAccId}", baseLogin);
} }
if (param.pDate != $"{DateTime.Today:yyyy-MM-dd}")
{
param.pDate = $"{DateTime.Today:yyyy-MM-dd}";
}
baseLogin.Init(param);
var bf = new MoRoutingBill(); var bf = new MoRoutingBill();
if (input.cVouchCode != null && input.cVouchCode.Count > 0) if (input.cVouchCode != null && input.cVouchCode.Count > 0)
{ {
_logInfo.Debug($"作业Id:{workId}-----开始弃审(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始弃审(单号)(批量)");
var res = await bf.UnVerify(baseLogin, cCardNum, input.cVouchCode); var res = bf.UnVerify(baseLogin, cCardNum, input.cVouchCode);
_logInfo.Debug($"作业Id:{workId}-----结束弃审(单号)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束弃审(单号)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
else else
{ {
_logInfo.Debug($"作业Id:{workId}-----开始弃审(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----开始弃审(ID)(批量)");
var res = await bf.UnVerify(baseLogin, input.MID); var res = bf.UnVerify(baseLogin, input.MID);
_logInfo.Debug($"作业Id:{workId}-----结束弃审(ID)(批量)"); _logInfo.Debug($"作业Id:{workId}-----结束弃审(ID)(批量)");
baseLogin.ShutDown();
return res; return res;
} }
@@ -857,10 +888,10 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8
{ {
_logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex);
await Task.Delay(1);
return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace }; return new BaseResult<string> { bSuccess = false, message = ex.Message, result = ex.StackTrace };
} }
} }
/// <summary> /// <summary>
@@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
// ReSharper disable IdentifierTypo
namespace UFIDA.U8.Framework.Api.Entity namespace UFIDA.U8.Framework.Api.Entity
{ {
@@ -51,5 +53,10 @@ namespace UFIDA.U8.Framework.Api.Entity
/// 用户令牌 /// 用户令牌
/// </summary> /// </summary>
public string userToken { get; set; } public string userToken { get; set; }
/// <summary>
/// 登录参数
/// </summary>
public LoginParamter loginParamter { get; set; }
} }
} }
@@ -45,6 +45,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <Reference Include="ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+2 -2
View File
@@ -58,7 +58,7 @@ namespace UFIDA.U8.Framework.Api.Unit
baseLogin.Init(_paramter); baseLogin.Init(_paramter);
return await bf.Save(baseLogin, cCardNum, input); return bf.Save(baseLogin, cCardNum, input);
} }
catch (Exception ex) catch (Exception ex)
@@ -103,7 +103,7 @@ namespace UFIDA.U8.Framework.Api.Unit
baseLogin.Init(_paramter); baseLogin.Init(_paramter);
return await bf.Save(baseLogin, cCardNum, inputs); return bf.Save(baseLogin, cCardNum, inputs);
} }
catch (Exception ex) catch (Exception ex)