增强了实例工程的抽象逻辑

This commit is contained in:
fengjiayi
2024-10-07 15:15:18 +08:00
parent 7a9f7b7bf3
commit 878b1c5893
39 changed files with 1361 additions and 826 deletions

View File

@@ -1,25 +1,29 @@
using Net462DllTest.Device;
using Net462DllTest.Signal;
using Net462DllTest.ViewModel;
using Serein.Library.Api;
using Serein.Library.Attributes;
using Serein.Library.Enums;
using Serein.Library.Ex;
using Serein.Library.Framework.NodeFlow;
using Serein.Library.NodeFlow.Tool;
using Serein.Library.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Net462DllTest.LogicControl
namespace Net462DllTest.LogicControl
{
/// <summary>
/// 视图管理
/// </summary>
[AutoRegister]
public class ViewManagement
public class ViewManagement:ChannelFlowTrigger<CommandSignal>
{
private List<Form> forms = new List<Form>();
private readonly List<Form> forms = new List<Form>();
/// <summary>
/// 打开窗口
/// </summary>
@@ -46,7 +50,7 @@ namespace Net462DllTest.LogicControl
[DynamicFlow]
[DynamicFlow("[View]")]
public class ViewLogicControl
{
private readonly ViewManagement ViewManagement;
@@ -59,12 +63,36 @@ namespace Net462DllTest.LogicControl
public void Init(IDynamicContext context)
{
context.Env.IOC.Register<ViewManagement>();
context.Env.IOC.Register<FromWorkBenchViewModel>();
}
#region
[NodeAction(NodeType.Flipflop, "等待信号触发", ReturnType = typeof(int))]
public async Task<IFlipflopContext> WaitTask(CommandSignal command = CommandSignal.Command_1)
{
try
{
TriggerData triggerData = await ViewManagement.CreateChannelWithTimeoutAsync(command, TimeSpan.FromMinutes(120), 0);
if (triggerData.Type == TriggerType.Overtime)
{
throw new FlipflopException("超时取消");
}
return new FlipflopContext(FlipflopStateType.Succeed, triggerData.Value);
}
catch (FlipflopException)
{
throw;
}
catch (Exception)
{
return new FlipflopContext(FlipflopStateType.Error);
}
}
#endregion
[NodeAction(NodeType.Action, "打开窗体(指定枚举值)")]
public void OpenForm(IDynamicContext context, FromValue fromId = FromValue.None, bool isTop = true)
public void OpenForm(IDynamicContext context, FromValue fromId = FromValue.FromWorkBenchView, bool isTop = true)
{
var fromType = EnumHelper.GetBoundValue<FromValue, Type>(fromId, attr => attr.Value);
if (fromType is null) return;
@@ -83,7 +111,7 @@ namespace Net462DllTest.LogicControl
[NodeAction(NodeType.Action, "关闭窗体")]
public void CloseForm(IDynamicContext context, FromValue fromId = FromValue.None)
public void CloseForm(IDynamicContext context, FromValue fromId = FromValue.FromWorkBenchView)
{
var fromType = EnumHelper.GetBoundValue<FromValue, Type>(fromId, attr => attr.Value);
if (fromType is null) return;