新增以U8登录人为基础的制单功能(ST)

This commit is contained in:
qmj
2025-05-21 21:55:36 +08:00
parent 9e01715ea2
commit b0be43e335
25 changed files with 1038 additions and 41 deletions
@@ -1,4 +1,5 @@
using System;
using System.Web.UI.WebControls;
using ADODB;
using log4net;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
@@ -266,23 +267,128 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
}
}
public void Init(string userToken, bool bMon = true, int traceTimes = 0)
{
if (traceTimes > 5)
throw new Exception("U8登录异常");
try
{
//if (!string.IsNullOrWhiteSpace(ThreadContext.ServerToken))
//{
// ThreadContext.ServerToken = null;
//}
//if (!string.IsNullOrWhiteSpace(ThreadContext.U8LoginInfo!=null))
//{
// ThreadContext.U8LoginInfo = null;
//}
if (string.IsNullOrWhiteSpace(userToken)) throw new ArgumentNullException(nameof(userToken));
if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
{
Cryptography.m_userToken = "";
}
if (bMon)
{
#if DEBUG
_vbLogin = new VBLogin();
_vbLogin.ClearError();
logInfo.Debug($"VB--开始进行U8登录:{userToken}");
if (!_vbLogin.ConstructLogin(userToken))
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
}
_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--完成生产制造登录进程");
#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--完成生产制造登录进程");
return;
#endif
}
_vbLogin = new VBLogin();
_vbLogin.ClearError();
logInfo.Debug($"VB--开始进行U8登录:{userToken}");
if (!_vbLogin.ConstructLogin(userToken))
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
}
logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}");
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
logInfo.Debug("VB--完成登录进程");
return;
}
catch (Exception ex)
{
logInfo.Error($"重试次数:{traceTimes},错误信息:{ex.Message}", ex);
if (ex.Message == "VB--U8登录失败---登录使用时间超过系统预置时间,请重新登录!")
{
throw new Exception("登录使用时间超过系统预置时间,请重新登录!");
}
Init(userToken, bMon, traceTimes + 1);
}
}
public void ShutDown()
{
U8LoginInfoPool.Clear();
ThreadContext.ServerToken = null;
_vbLogin?.ShutDown();
_productContext=null;
_netLogin?.SubLogout("DP");
_netLogin?.ShutDown();
_vbLogin = null;
_netLogin = null;
{
U8LoginInfoPool.Clear();
ThreadContext.ServerToken = null;
_vbLogin?.ShutDown();
_productContext=null;
_netLogin?.SubLogout("DP");
_netLogin?.ShutDown();
_vbLogin = null;
_netLogin = null;
}
public bool CheckAccId(string cAccId)
{
return _vbLogin.get_cAcc_Id() == cAccId;
}
}
public bool CheckAccId(string cAccId)
{
return _vbLogin.get_cAcc_Id() == cAccId;
}
}
}
@@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Debug\UFIDA.U8.Framework.Api.ControlObject.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>