✨ feat(*): 添加管理员解锁与 SFTP 探活能力
* 新增管理员解锁弹窗、手动操作权限控制与倒计时状态 * 支持系统设置页测试 SFTP 连接,并在启动时执行探活 * 补充设计时服务、全局异常兜底与相关单元测试
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using AxiOmron.PcbCheck.Services.Interfaces;
|
||||
|
||||
namespace AxiOmron.PcbCheck.DesignTime;
|
||||
|
||||
/// <summary>
|
||||
/// 提供设计时管理员解锁弹窗服务占位实现。
|
||||
/// </summary>
|
||||
public sealed class DesignTimeAdminUnlockDialogService : IAdminUnlockDialogService
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示管理员密码输入弹窗并校验是否通过。
|
||||
/// </summary>
|
||||
/// <param name="expectedPassword">期望密码。</param>
|
||||
/// <param name="sessionTimeout">本次解锁会话持续时间。</param>
|
||||
/// <returns>设计时固定返回 <see langword="false"/>。</returns>
|
||||
public bool ShowUnlockDialog(string expectedPassword, TimeSpan sessionTimeout)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public sealed class DesignTimeAppConfigService : IAppConfigService
|
||||
_config.Sftp = config.Sftp;
|
||||
_config.Andon = config.Andon;
|
||||
_config.Workflow = config.Workflow;
|
||||
_config.Security = config.Security;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,11 +99,13 @@ public sealed class DesignTimeAppConfigService : IAppConfigService
|
||||
Andon = new AndonOptions
|
||||
{
|
||||
Enable = true,
|
||||
Url = "http://10.10.20.50/api/andon/alarm",
|
||||
Url = "https://shp.prod.aliyun.mit.uaes.com/api/mit/MAE/Station/Status/alarm",
|
||||
Method = "POST",
|
||||
TimeoutMs = 3000,
|
||||
StationCode = "OMRON-L01",
|
||||
StationName = "欧姆龙 PCB 检测",
|
||||
AndonTheme = "SS7_Auto_Andon",
|
||||
Eid = "PR1965269806334783488",
|
||||
FromSign = "IOT",
|
||||
ServiceId = "4dccd822-86b2-47dd-89bd-ca472ba0d14d",
|
||||
EnableScanFailAlarm = true,
|
||||
EnableFileNotFoundAlarm = true
|
||||
},
|
||||
@@ -114,6 +117,11 @@ public sealed class DesignTimeAppConfigService : IAppConfigService
|
||||
RequireManualResetAfterFault = true,
|
||||
MaxUiLogEntries = 200,
|
||||
MaxBoardRecords = 100
|
||||
},
|
||||
Security = new SecurityOptions
|
||||
{
|
||||
AdminPassword = "AxiOmron@123",
|
||||
AdminSessionTimeoutMinutes = 15
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using AxiOmron.PcbCheck.Models;
|
||||
using AxiOmron.PcbCheck.Options;
|
||||
using AxiOmron.PcbCheck.Services.Interfaces;
|
||||
|
||||
namespace AxiOmron.PcbCheck.DesignTime;
|
||||
|
||||
/// <summary>
|
||||
/// 为设计器提供 SFTP 测试结果的设计时服务。
|
||||
/// </summary>
|
||||
public sealed class DesignTimeSftpLookupService : ISftpLookupService
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回设计时文件校验结果。
|
||||
/// </summary>
|
||||
/// <param name="barcode">条码。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>固定设计时结果。</returns>
|
||||
public Task<SftpCheckOutcome> CheckFileAsync(string barcode, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(new SftpCheckOutcome
|
||||
{
|
||||
Exists = true,
|
||||
ConnectionSucceeded = true,
|
||||
MatchedFilePath = $"/pcb/{barcode}.txt"
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回设计时连接测试结果。
|
||||
/// </summary>
|
||||
/// <param name="options">SFTP 配置。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
/// <returns>固定成功结果。</returns>
|
||||
public Task<SftpConnectionTestOutcome> TestConnectionAsync(SftpOptions? options, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(new SftpConnectionTestOutcome
|
||||
{
|
||||
IsSuccess = true,
|
||||
ConnectionSucceeded = true,
|
||||
RootPathAccessible = true,
|
||||
StatusMessage = "设计时 SFTP 连接成功。"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using AxiOmron.PcbCheck.Options;
|
||||
using AxiOmron.PcbCheck.Services.Interfaces;
|
||||
using AxiOmron.PcbCheck.ViewModels;
|
||||
|
||||
namespace AxiOmron.PcbCheck.DesignTime;
|
||||
@@ -12,6 +13,8 @@ public sealed class DesignTimeViewModelLocator
|
||||
private readonly DesignTimeDispatcherService _dispatcherService = new();
|
||||
private readonly DesignTimeWorkflowControlService _workflowControlService = new();
|
||||
private readonly DesignTimeAppConfigService _appConfigService = new();
|
||||
private readonly DesignTimeAdminUnlockDialogService _adminUnlockDialogService = new();
|
||||
private readonly DesignTimeSftpLookupService _sftpLookupService = new();
|
||||
private MainWindowViewModel? _mainWindowViewModel;
|
||||
private SystemSettingViewModel? _systemSettingViewModel;
|
||||
|
||||
@@ -25,7 +28,7 @@ public sealed class DesignTimeViewModelLocator
|
||||
/// 获取系统设置设计时视图模型。
|
||||
/// </summary>
|
||||
public SystemSettingViewModel SystemSettingViewModel
|
||||
=> _systemSettingViewModel ??= new SystemSettingViewModel(_appConfigService);
|
||||
=> _systemSettingViewModel ??= new SystemSettingViewModel(_appConfigService, _sftpLookupService);
|
||||
|
||||
/// <summary>
|
||||
/// 创建首页设计时视图模型。
|
||||
@@ -34,6 +37,6 @@ public sealed class DesignTimeViewModelLocator
|
||||
private MainWindowViewModel CreateMainWindowViewModel()
|
||||
{
|
||||
AppConfig config = _appConfigService.Load();
|
||||
return new MainWindowViewModel(_appStateStore, _dispatcherService, _workflowControlService, config);
|
||||
return new MainWindowViewModel(_appStateStore, _dispatcherService, _workflowControlService, config, _adminUnlockDialogService);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user