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
@@ -1,5 +1,4 @@
using System;
using System.Web.UI.WebControls;
using ADODB;
using log4net;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
@@ -14,35 +13,72 @@ using VBLogin = U8Login.clsLogin;
// ReSharper disable InconsistentNaming
// ReSharper disable CommentTypo
// ReSharper disable FieldCanBeMadeReadOnly.Local
// ReSharper disable UnusedMember.Global
namespace UFIDA.U8.Framework.Api.ControlObject.U8M
{
/// <summary>
/// 登录对象帮助类
/// </summary>
public class BaseLogin
{
private ILog _logInfo = LogManager.GetLogger("logInfo");
/// <summary>
/// 登录对象(NET)
/// </summary>
public NetLogin _netLogin;
/// <summary>
/// 登录对象(VB)
/// </summary>
public VBLogin _vbLogin;
/// <summary>
/// Net上下文
/// </summary>
public ProductContext _productContext;
/// <summary>
/// 数据库连接对象(ADO)
/// </summary>
public Connection Connection;
/// <summary>
/// userToken
/// </summary>
public string userToken => _vbLogin.userToken;
/// <summary>
/// 业务库连接字符串(ADO)
/// </summary>
public string UfDbName => _vbLogin.UfDbName;
/// <summary>
/// 业务库连接字符串(ADO.Net)
/// </summary>
public string UFDataConnstringForNet => _vbLogin.UFDataConnstringForNet;
/// <summary>
/// 元数据库连接字符串(ADO)
/// </summary>
public string UfMetaName => _vbLogin.UfMetaName;
/// <summary>
/// 元数据库连接字符串(ADO.Net)
/// </summary>
public string UFMetaConnstringForNet => _vbLogin.UFMetaConnstringForNet;
/// <summary>
/// 系统库连接字符串(ADO)
/// </summary>
public string UfSystemDb => _vbLogin.UfSystemDb;
/// <summary>
/// 制造上下文
/// </summary>
public IContextContainer callar { get; set; }
/// <summary>
@@ -53,7 +89,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
/// <param name="traceTimes"></param>
/// <exception cref="ArgumentNullException"></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)
@@ -93,6 +129,13 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
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();
_productContext= _netLogin.Login("DP", _vbLogin.userToken);
@@ -112,15 +155,36 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
//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--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
_logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
#else
_netLogin = new NetLogin();
@@ -141,32 +205,68 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
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}");
ClientUserContext.Instance.RefreshContext();
#endregion
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
_logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
#endif
}
_vbLogin = new VBLogin();
_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))
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
}
//_vbLogin.ClearError();
//_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}");
@@ -175,97 +275,90 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_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))
{
Cryptography.m_userToken = "";
}
//if (_productContext == null)
// throw new Exception($"2--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
_productContext = _netLogin.Login("DP", _vbLogin.userToken);
//ClientUserContext.Instance.RefreshContext();
////ThreadContext.ServerToken = _netLogin.userToken;
//Connection = new Connection();
//Connection.Open(_vbLogin.UfDbName);
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;
}
_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);
#endregion
}
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)
throw new Exception("U8登录异常");
@@ -292,7 +393,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
// 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))
{
@@ -305,8 +406,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
#if DEBUG
_vbLogin = new VBLogin();
_vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{userToken}");
if (!_vbLogin.ConstructLogin(userToken))
_logInfo.Debug($"VB--开始进行U8登录:{token}");
if (!_vbLogin.ConstructLogin(token))
{
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--开始进行上下文构建:{userToken}");
_logInfo.Debug($"Net--开始进行上下文构建:{_vbLogin.userToken}");
_productContext = _netLogin.Login("DP", _vbLogin.userToken);
//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--完成生产制造登录进程");
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登录:{userToken}");
_logInfo.Debug($"Net--开始进行U8登录:{token}");
_productContext = _netLogin.Login("DP", userToken);
_productContext = _netLogin.Login("DP", token);
if (_productContext == null)
{
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--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
_logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
@@ -359,8 +499,8 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_vbLogin = new VBLogin();
_vbLogin.ClearError();
_logInfo.Debug($"VB--开始进行U8登录:{userToken}");
if (!_vbLogin.ConstructLogin(userToken))
_logInfo.Debug($"VB--开始进行U8登录:{token}");
if (!_vbLogin.ConstructLogin(token))
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
}
@@ -368,7 +508,6 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
_logInfo.Debug("VB--完成登录进程");
return;
}
catch (Exception ex)
{
@@ -379,15 +518,23 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
throw new Exception("登录使用时间超过系统预置时间,请重新登录!");
}
Init(userToken, bMon, traceTimes + 1);
Init(token, bMon, traceTimes + 1);
}
}
/// <summary>
/// 校验制造上下文
/// </summary>
/// <returns></returns>
public bool CheckCallar()
{
return callar != null;
}
/// <summary>
/// 刷新制造上下文
/// </summary>
/// <param name="paramter"></param>
public void RefreshCallar(LoginParamter paramter)
{
#if DEBUG
@@ -411,114 +558,214 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
//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();
_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}");
_logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
#else
_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)
{
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--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
_logInfo.Debug("Net--构建制造上下文");
//_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
#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();
ThreadContext.ServerToken = null;
_vbLogin?.ShutDown();
_productContext=null;
_netLogin?.SubLogout("DP");
_netLogin?.ShutDown();
_vbLogin = null;
_netLogin = null;
throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
}
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;
}
}
}