Compare commits
2 Commits
bcf9f1b58c
...
a11ef73f1c
| Author | SHA1 | Date | |
|---|---|---|---|
| a11ef73f1c | |||
| 0a1d027407 |
@@ -1284,7 +1284,7 @@ namespace Lskj.Main
|
|||||||
DialogResult result = MessageUtil.Show(ResourceKeys.IsExit, MessageBoxButtons.YesNo);
|
DialogResult result = MessageUtil.Show(ResourceKeys.IsExit, MessageBoxButtons.YesNo);
|
||||||
if (result == DialogResult.Yes)
|
if (result == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
Process[] p = Process.GetProcessesByName("Ls_ERP");
|
Process[] p = Manager.GetApplicationProcesses();
|
||||||
foreach (Process item in p)
|
foreach (Process item in p)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -1920,4 +1920,4 @@ namespace Lskj.Main
|
|||||||
isPlaintextPwd = !isPlaintextPwd;
|
isPlaintextPwd = !isPlaintextPwd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ namespace Lskj.Main
|
|||||||
|
|
||||||
//记录登出日志
|
//记录登出日志
|
||||||
LogUtil.WriteDebug("", "退出软件", "软件退出", "系统登录");
|
LogUtil.WriteDebug("", "退出软件", "软件退出", "系统登录");
|
||||||
Process[] p = Process.GetProcessesByName("Ls_ERP");
|
Process[] p = Manager.GetApplicationProcesses();
|
||||||
foreach (Process item in p)
|
foreach (Process item in p)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -716,4 +716,4 @@ namespace Lskj.Main
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Lskj.Main.Hosting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 旧启动流程与可选新主界面之间的中立扩展点。
|
||||||
|
/// 此接口只使用 .NET Framework 4.0/WinForms 基础类型,不引用 WPF 或 DevExpress 25.2。
|
||||||
|
/// </summary>
|
||||||
|
public interface IExternalMainShell
|
||||||
|
{
|
||||||
|
bool IsOpen { get; }
|
||||||
|
|
||||||
|
DialogResult ShowDialog();
|
||||||
|
|
||||||
|
void RequestRelogin();
|
||||||
|
|
||||||
|
void RequestExit(string message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using Lskj.Main.Model;
|
||||||
|
|
||||||
|
namespace Lskj.Main.Hosting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 为独立的新启动程序公开原 Ls_ERP 初始化和登录流程。
|
||||||
|
/// </summary>
|
||||||
|
public static class LegacyApplicationHost
|
||||||
|
{
|
||||||
|
public static void Run(string[] args, IExternalMainShell externalMainShell)
|
||||||
|
{
|
||||||
|
if (externalMainShell == null)
|
||||||
|
throw new ArgumentNullException("externalMainShell");
|
||||||
|
if (Manager.ExternalMainShell != null)
|
||||||
|
throw new InvalidOperationException("旧程序已经由另一个外部主界面托管。");
|
||||||
|
|
||||||
|
Manager.ExternalMainShell = externalMainShell;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Program.RunFromExternalHost(args);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Manager.ExternalMainShell = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# 外部主界面兼容层
|
||||||
|
|
||||||
|
这个目录只为旧 `.NET Framework 4.0` 启动流程提供一个可选扩展点,不引用 WPF 或 DevExpress 25.2。
|
||||||
|
|
||||||
|
## 默认路线
|
||||||
|
|
||||||
|
直接运行 `Ls_ERP.exe` 时,`Manager.ExternalMainShell` 为 `null`:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Program.Main
|
||||||
|
-> Manager.StartForm
|
||||||
|
-> FrmLogin
|
||||||
|
-> Manager.RunMainForm
|
||||||
|
-> FrmMain
|
||||||
|
```
|
||||||
|
|
||||||
|
这条路线不加载任何 WPF 程序集,并保持 DevExpress WinForms 15.2。
|
||||||
|
|
||||||
|
## 外部宿主路线
|
||||||
|
|
||||||
|
`.NET Framework 4.8` 的独立启动程序通过 `LegacyApplicationHost.Run` 注入 `IExternalMainShell`。旧程序仍负责 CEF、全局异常、配置、数据库、登录和子系统选择,只在 `RunMainForm` 位置回调外部主界面。
|
||||||
|
|
||||||
|
`IExternalMainShell` 当前承担:
|
||||||
|
|
||||||
|
- 同步显示外部主窗口;
|
||||||
|
- 返回普通关闭或重新登录结果;
|
||||||
|
- 处理旧插件发起的重新登录;
|
||||||
|
- 在强制下线时通知外部主窗口退出。
|
||||||
|
|
||||||
|
## 修改规则
|
||||||
|
|
||||||
|
- 此层必须继续可以在 .NET Framework 4.0 下编译。
|
||||||
|
- 禁止引用 `Lserp.Wpf.*`、WPF 类型或 DevExpress 25.2。
|
||||||
|
- 新界面特有实现放在独立 WPF 解决方案的 `Lserp.Wpf.Legacy.WinForms`。
|
||||||
|
- 新增兼容能力时优先扩展中立接口,不要在旧工程中直接调用 WPF。
|
||||||
@@ -276,6 +276,8 @@
|
|||||||
<Compile Include="Model\BitMapHelper.cs" />
|
<Compile Include="Model\BitMapHelper.cs" />
|
||||||
<Compile Include="Model\Manager.cs" />
|
<Compile Include="Model\Manager.cs" />
|
||||||
<Compile Include="Model\winApi.cs" />
|
<Compile Include="Model\winApi.cs" />
|
||||||
|
<Compile Include="Hosting\IExternalMainShell.cs" />
|
||||||
|
<Compile Include="Hosting\LegacyApplicationHost.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="Control\AwaitScreenControl.resx">
|
<EmbeddedResource Include="Control\AwaitScreenControl.resx">
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Lskj.Control;
|
|||||||
using Lskj.Control.Model;
|
using Lskj.Control.Model;
|
||||||
using Lskj.Core;
|
using Lskj.Core;
|
||||||
using Lskj.Data;
|
using Lskj.Data;
|
||||||
|
using Lskj.Main.Hosting;
|
||||||
using Lskj.Model;
|
using Lskj.Model;
|
||||||
using Lskj.Util;
|
using Lskj.Util;
|
||||||
using Lskj.Web.Core.Util;
|
using Lskj.Web.Core.Util;
|
||||||
@@ -55,6 +56,10 @@ namespace Lskj.Main.Model
|
|||||||
public static int isAwaitTime = 10;
|
public static int isAwaitTime = 10;
|
||||||
public static int RefreshTime = 0;
|
public static int RefreshTime = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 由外部启动程序提供的可选主界面。默认为 null,旧 Ls_ERP.exe 仍打开 FrmMain。
|
||||||
|
/// </summary>
|
||||||
|
public static IExternalMainShell ExternalMainShell { get; internal set; }
|
||||||
|
/// <summary>
|
||||||
/// 默认下载地址
|
/// 默认下载地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string filePath = string.Empty;
|
private static string filePath = string.Empty;
|
||||||
@@ -190,7 +195,12 @@ namespace Lskj.Main.Model
|
|||||||
if (isStart)
|
if (isStart)
|
||||||
{
|
{
|
||||||
// 直接进入主界面
|
// 直接进入主界面
|
||||||
RunMainForm();
|
result = RunMainForm();
|
||||||
|
if (result == DialogResult.Retry)
|
||||||
|
{
|
||||||
|
StartForm();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ERPInfo.Instance.SubMenuCount > 1)
|
if (ERPInfo.Instance.SubMenuCount > 1)
|
||||||
{
|
{
|
||||||
ReStartMain();
|
ReStartMain();
|
||||||
@@ -686,6 +696,10 @@ namespace Lskj.Main.Model
|
|||||||
/// <returns>DialogResult.</returns>
|
/// <returns>DialogResult.</returns>
|
||||||
private static DialogResult RunMainForm()
|
private static DialogResult RunMainForm()
|
||||||
{
|
{
|
||||||
|
IExternalMainShell externalMainShell = ExternalMainShell;
|
||||||
|
if (externalMainShell != null)
|
||||||
|
return externalMainShell.ShowDialog();
|
||||||
|
|
||||||
_frmMain = new FrmMain();
|
_frmMain = new FrmMain();
|
||||||
return _frmMain.ShowDialog();
|
return _frmMain.ShowDialog();
|
||||||
}
|
}
|
||||||
@@ -909,6 +923,11 @@ namespace Lskj.Main.Model
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
else if (ExternalMainShell != null && ExternalMainShell.IsOpen)
|
||||||
|
{
|
||||||
|
ExternalMainShell.RequestExit($"当前用户在另一电脑登录\r\nClientIp:{clientip}\r\nMacAdress:{loginMacAdress}\r\n当前系统即将关闭");
|
||||||
|
isClose = true;
|
||||||
|
}
|
||||||
else if (_frmMain != null && _frmMain.Visible == true)
|
else if (_frmMain != null && _frmMain.Visible == true)
|
||||||
{
|
{
|
||||||
_frmMain.Invoke(new Action(() =>
|
_frmMain.Invoke(new Action(() =>
|
||||||
@@ -953,7 +972,7 @@ namespace Lskj.Main.Model
|
|||||||
}
|
}
|
||||||
//记录登出日志
|
//记录登出日志
|
||||||
LogUtil.WriteDebug("", "退出软件", "软件退出", "系统登录");
|
LogUtil.WriteDebug("", "退出软件", "软件退出", "系统登录");
|
||||||
Process[] p = Process.GetProcessesByName("Ls_ERP");
|
Process[] p = GetApplicationProcesses();
|
||||||
foreach (Process item in p)
|
foreach (Process item in p)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -1107,6 +1126,12 @@ namespace Lskj.Main.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ReLogin()
|
public static void ReLogin()
|
||||||
{
|
{
|
||||||
|
IExternalMainShell externalMainShell = ExternalMainShell;
|
||||||
|
if (externalMainShell != null && externalMainShell.IsOpen)
|
||||||
|
{
|
||||||
|
externalMainShell.RequestRelogin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_frmMain != null)
|
if (_frmMain != null)
|
||||||
{
|
{
|
||||||
if (ERPInfo.Instance.WatermarkForm != null)
|
if (ERPInfo.Instance.WatermarkForm != null)
|
||||||
@@ -1121,5 +1146,16 @@ namespace Lskj.Main.Model
|
|||||||
StartForm();
|
StartForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回当前启动路线需要退出的主进程。
|
||||||
|
/// 旧入口保持原有 Ls_ERP 进程名语义,外部宿主只退出当前 WPF 进程。
|
||||||
|
/// </summary>
|
||||||
|
internal static Process[] GetApplicationProcesses()
|
||||||
|
{
|
||||||
|
return ExternalMainShell == null
|
||||||
|
? Process.GetProcessesByName("Ls_ERP")
|
||||||
|
: new[] { Process.GetCurrentProcess() };
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,14 @@ namespace Lskj.Main
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 允许 .NET Framework 4.8 外部宿主复用原程序的 CEF、皮肤、异常、注册和登录初始化。
|
||||||
|
/// 正常启动 Ls_ERP.exe 仍由 Main 直接进入,不经过此方法。
|
||||||
|
/// </summary>
|
||||||
|
internal static void RunFromExternalHost(string[] args)
|
||||||
|
{
|
||||||
|
Main(args ?? new string[0]);
|
||||||
|
}
|
||||||
#region 浏览器处理类
|
#region 浏览器处理类
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>说明:浏览器处理类</para>
|
/// <para>说明:浏览器处理类</para>
|
||||||
|
|||||||
Reference in New Issue
Block a user