1.车间管理调整为异步

2.明确生产制造的部署模式为单账套部署,多账套采用多服务的形式部署
This commit is contained in:
qmj
2025-07-23 08:57:44 +08:00
parent 1141095898
commit b8a9595cc1
12 changed files with 395 additions and 191 deletions
@@ -3,6 +3,7 @@ using System.Web.UI.WebControls;
using ADODB;
using log4net;
using UFIDA.U8.Framework.Api.ControlObject.Entity;
using UFSoft.U8.Framework.BizBase;
using UFSoft.U8.Framework.ContextSrv;
using UFSoft.U8.Framework.Login.UI;
using UFSoft.U8.Framework.LoginContext;
@@ -20,8 +21,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
public class BaseLogin
{
static ILog logInfo = LogManager.GetLogger("logInfo");
private ILog _logInfo = LogManager.GetLogger("logInfo");
public NetLogin _netLogin;
@@ -43,7 +43,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
public string UfSystemDb => _vbLogin.UfSystemDb;
public IContextContainer callar { get; set; }
/// <summary>
/// 初始化生产制造上下文
@@ -86,7 +86,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_vbLogin.ClearError();
logInfo.Debug($"VB--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}");
_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))
{
@@ -99,36 +99,40 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
if (_productContext == null)
{
logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
_logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
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}");
_logInfo.Debug($"Net--开始进行上下文构建:{_netLogin.userToken}");
_productContext = _netLogin.SubLogin("DP") ?? _netLogin.Login("DP", _vbLogin.userToken);
//throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
}
logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext();
logInfo.Debug("Net--完成生产制造登录进程");
_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}");
_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}");
_logInfo.Debug($"Net--开始进行上下文构建:{_netLogin.userToken}");
_productContext = _netLogin.SubLogin("DP");
@@ -138,11 +142,15 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
}
logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext();
logInfo.Debug("Net--完成生产制造登录进程");
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
@@ -153,19 +161,19 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_vbLogin.ClearError();
logInfo.Debug($"VB--开始进行U8登录:{paramter.cSrv}--{paramter.pUserId}--{paramter.pAccId}");
_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}");
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
logInfo.Debug("VB--完成登录进程");
_logInfo.Debug("VB--完成登录进程");
return;
@@ -180,14 +188,14 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
if (!bMon)
{
logInfo.Debug("非生产制造模块无需下面操作");
_logInfo.Debug("非生产制造模块无需下面操作");
//Trace.WriteLine("非生产制造模块无需下面操作");
return;
}
logInfo.Debug($"U8版本:{_vbLogin.GetVersionInfo()}");
_logInfo.Debug($"U8版本:{_vbLogin.GetVersionInfo()}");
logInfo.Debug($"1--登录令牌:{_vbLogin.userToken}");
_logInfo.Debug($"1--登录令牌:{_vbLogin.userToken}");
if (!string.IsNullOrWhiteSpace(Cryptography.m_userToken))
{
@@ -198,7 +206,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
if (_productContext != null)
{
logInfo.Debug($"222--成功初始化上下文信息:{_vbLogin.userToken}");
_logInfo.Debug($"222--成功初始化上下文信息:{_vbLogin.userToken}");
ClientUserContext.Instance.RefreshContext();
//ThreadContext.ServerToken = _netLogin.userToken;
@@ -206,7 +214,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
logInfo.Debug($"333--完成局部构建:{_netLogin.userToken}");
_logInfo.Debug($"333--完成局部构建:{_netLogin.userToken}");
return;
}
@@ -222,7 +230,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
if (_productContext == null)
throw new Exception($"11--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
logInfo.Debug($"22--登录令牌:{_netLogin.userToken}");
_logInfo.Debug($"22--登录令牌:{_netLogin.userToken}");
//Trace.WriteLine($"2--上下文令牌:{_productContext.calledContext.token}");
@@ -232,16 +240,16 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
//_vbLogin.set_TaskId(taskId);
logInfo.Debug($"33--登录令牌:{_vbLogin.userToken}");
_logInfo.Debug($"33--登录令牌:{_vbLogin.userToken}");
logInfo.Debug($"44--正在创建应用池:{_netLogin.userToken}");
_logInfo.Debug($"44--正在创建应用池:{_netLogin.userToken}");
ClientUserContext.Instance.RefreshContext();
//ThreadContext.ServerToken = _netLogin.userToken;
logInfo.Debug($"55--完成局部构建:{_netLogin.userToken}");
_logInfo.Debug($"55--完成局部构建:{_netLogin.userToken}");
return;
@@ -249,7 +257,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_productContext = _netLogin.Login("AS", _vbLogin.userToken);
logInfo.Debug($"3--上下文令牌:{_productContext.calledContext.token}");
_logInfo.Debug($"3--上下文令牌:{_productContext.calledContext.token}");
if (_productContext == null)
throw new Exception($"2--初始化U8登录上下文失败------{_netLogin.ErrDescript}");
@@ -261,7 +269,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
}
catch (Exception ex)
{
logInfo.Error($"重试次数:{traceTimes},错误信息:{ex.Message}", ex);
_logInfo.Error($"重试次数:{traceTimes},错误信息:{ex.Message}", ex);
Init(paramter, bMon, traceTimes + 1);
}
@@ -297,7 +305,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
#if DEBUG
_vbLogin = new VBLogin();
_vbLogin.ClearError();
logInfo.Debug($"VB--开始进行U8登录:{userToken}");
_logInfo.Debug($"VB--开始进行U8登录:{userToken}");
if (!_vbLogin.ConstructLogin(userToken))
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
@@ -306,42 +314,42 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_productContext = _netLogin.Login("DP", _vbLogin.userToken);
if (_productContext == null)
{
logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
_logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
logInfo.Debug($"Net--开始进行上下文构建:{userToken}");
_logInfo.Debug($"Net--开始进行上下文构建:{userToken}");
_productContext = _netLogin.Login("DP", _vbLogin.userToken);
//throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
}
logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext();
logInfo.Debug("Net--完成生产制造登录进程");
_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}");
_logInfo.Debug($"Net--开始进行U8登录:{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");
_productContext = _netLogin.Login("DP", userToken);
if (_productContext == null)
{
throw new Exception($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
}
logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
_logInfo.Debug($"Net--开始进行上下文刷新:{_productContext.calledContext.token}");
ClientUserContext.Instance.RefreshContext();
logInfo.Debug("Net--完成生产制造登录进程");
_logInfo.Debug("Net--完成生产制造登录进程");
callar = new DefaultContextContainer();
_logInfo.Debug($"Net--构建制造上下文:{callar.context.calledContext.token}");
return;
@@ -351,20 +359,20 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
_vbLogin = new VBLogin();
_vbLogin.ClearError();
logInfo.Debug($"VB--开始进行U8登录:{userToken}");
_logInfo.Debug($"VB--开始进行U8登录:{userToken}");
if (!_vbLogin.ConstructLogin(userToken))
{
throw new Exception($"VB--U8登录失败---{_vbLogin.ShareString}");
}
logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}");
_logInfo.Debug($"VB--开始创建连接对象:{_vbLogin.userToken}");
Connection = new Connection();
Connection.Open(_vbLogin.UfDbName);
logInfo.Debug("VB--完成登录进程");
_logInfo.Debug("VB--完成登录进程");
return;
}
catch (Exception ex)
{
logInfo.Error($"重试次数:{traceTimes},错误信息:{ex.Message}", ex);
_logInfo.Error($"重试次数:{traceTimes},错误信息:{ex.Message}", ex);
if (ex.Message == "VB--U8登录失败---登录使用时间超过系统预置时间,请重新登录!")
{
@@ -375,6 +383,128 @@ namespace UFIDA.U8.Framework.Api.ControlObject.U8M
}
}
public bool CheckCallar()
{
return callar != null;
}
public void RefreshCallar(LoginParamter paramter)
{
#if DEBUG
_netLogin = new NetLogin();
_productContext= _netLogin.Login("DP", _vbLogin.userToken);
if (_productContext == null)
{
_logInfo.Debug($"Net--U8上下文构建失败---{_netLogin.ErrDescript}");
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") ?? _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
_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
_netLogin = new NetLogin();
_logInfo.Debug($"Net--开始进行U8登录:{userToken}");
_productContext = _netLogin.Login("DP", userToken);
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 ShutDown()
{
U8LoginInfoPool.Clear();