曲线回读+测试报告导出前期工作
This commit is contained in:
@@ -4,7 +4,7 @@ using Common.Tools;
|
||||
using Logger;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Model.Entity;
|
||||
using ORM;
|
||||
using Service.Interface;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -28,6 +28,7 @@ namespace UIShare
|
||||
//private Devices _devices;
|
||||
private IContainerProvider containerProvider;
|
||||
private IEventAggregator _eventAggregator;
|
||||
private ITestReportService _testReportService;
|
||||
|
||||
private readonly Dictionary<Guid, ParameterVM> tmpParameters = [];
|
||||
|
||||
@@ -45,12 +46,13 @@ namespace UIShare
|
||||
private volatile bool _disposed = false;
|
||||
|
||||
public Guid TestRoundID;
|
||||
public StepRunning(ScopedContext ScopedContext, SystemConfig systemConfig,IEventAggregator eventAggregator, DeviceManager deviceManager)
|
||||
public StepRunning(ScopedContext ScopedContext, SystemConfig systemConfig,IEventAggregator eventAggregator, DeviceManager deviceManager, ITestReportService testReportService)
|
||||
{
|
||||
_scopedContext = ScopedContext;
|
||||
_systemConfig = systemConfig;
|
||||
_eventAggregator = eventAggregator;
|
||||
_deviceManager= deviceManager;
|
||||
_testReportService = testReportService;
|
||||
//_devices = containerProvider.Resolve<Devices>();
|
||||
}
|
||||
public async Task<bool> ExecuteErrorSteps(ProgramVM program, int depth = 0, CancellationToken cancellationToken = default)
|
||||
@@ -116,7 +118,7 @@ namespace UIShare
|
||||
step.CurrentLoopCount = context.LoopCount;
|
||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始,共{context.LoopCount}次", depth);
|
||||
index++;
|
||||
SaveStepRecord(step, depth, true);
|
||||
await SaveStepRecordAsync(step, depth, true);
|
||||
}
|
||||
|
||||
// 处理循环结束
|
||||
@@ -127,7 +129,7 @@ namespace UIShare
|
||||
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth: depth);
|
||||
step.Result = 2;
|
||||
index++;
|
||||
SaveStepRecord(step, depth, true);
|
||||
await SaveStepRecordAsync(step, depth, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -142,7 +144,7 @@ namespace UIShare
|
||||
// 继续循环:跳转到循环开始后的第一条指令
|
||||
index = context.StartIndex + 1;
|
||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
|
||||
SaveStepRecord(step, depth, true);
|
||||
await SaveStepRecordAsync(step, depth, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -159,7 +161,7 @@ namespace UIShare
|
||||
program.ErrorStepCollection.First(x => x.ID == step.LoopStartStepId).Result = 1;
|
||||
loopStopwatchStack.Pop();
|
||||
}
|
||||
SaveStepRecord(step, depth, true);
|
||||
await SaveStepRecordAsync(step, depth, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +220,7 @@ namespace UIShare
|
||||
stepStopwatch.Stop();
|
||||
step.RunTime = (int)stepStopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
SaveStepRecord(step, depth, true);
|
||||
await SaveStepRecordAsync(step, depth, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +293,7 @@ namespace UIShare
|
||||
step.CurrentLoopCount = context.LoopCount;
|
||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始({step.Name}),共{context.LoopCount}次", depth);
|
||||
index++;
|
||||
SaveStepRecord(step, depth, false);
|
||||
await SaveStepRecordAsync(step, depth, false);
|
||||
}
|
||||
|
||||
// 处理循环结束
|
||||
@@ -302,7 +304,7 @@ namespace UIShare
|
||||
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth:depth);
|
||||
step.Result = 2;
|
||||
index++;
|
||||
SaveStepRecord(step, depth, false);
|
||||
await SaveStepRecordAsync(step, depth, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -317,7 +319,7 @@ namespace UIShare
|
||||
// 继续循环:跳转到循环开始后的第一条指令
|
||||
index = context.StartIndex + 1;
|
||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
|
||||
SaveStepRecord(step, depth, false);
|
||||
await SaveStepRecordAsync(step, depth, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -334,7 +336,7 @@ namespace UIShare
|
||||
program.StepCollection.First(x => x.ID == step.LoopStartStepId).Result = 1;
|
||||
loopStopwatchStack.Pop();
|
||||
}
|
||||
SaveStepRecord(step, depth, false);
|
||||
await SaveStepRecordAsync(step, depth, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +402,7 @@ namespace UIShare
|
||||
_scopedContext.SingleStep = false;
|
||||
_eventAggregator.GetEvent<RunSingalCompletedEvent>().Publish("Play");
|
||||
}
|
||||
SaveStepRecord(step, depth, false);
|
||||
await SaveStepRecordAsync(step, depth, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -685,7 +687,7 @@ namespace UIShare
|
||||
/// 将单个步骤的执行结果保存到数据库(测试报告)。
|
||||
/// 同一次运行的所有步骤共享 TestRoundID,导出时按此 Guid 查询。
|
||||
/// </summary>
|
||||
private void SaveStepRecord(StepVM step, int depth, bool isErrorStep)
|
||||
private async Task SaveStepRecordAsync(StepVM step, int depth, bool isErrorStep)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -702,6 +704,7 @@ namespace UIShare
|
||||
{
|
||||
TestRoundId = TestRoundID,
|
||||
Scope = _systemConfig.Title,
|
||||
FileName = _systemConfig.CurrentADPFile ?? "",
|
||||
StepIndex = step.Index,
|
||||
StepName = step.Name ?? "",
|
||||
StepType = step.StepType ?? "普通步骤",
|
||||
@@ -723,7 +726,11 @@ namespace UIShare
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
|
||||
SqlSugarContext.DbContext.Insertable(entity).ExecuteCommand();
|
||||
var result = await _testReportService.InsertAsync(entity);
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
LoggerHelper.Error($"保存步骤记录失败 [{step.Index}]: {result.Msg}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace UIShare.GlobalVariable
|
||||
public string TSMasterName { get; set; } = "ADP测试上位机";
|
||||
public string SubProgramFilePath { get; set; } = @"D:\ADP\子程序\";
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string CurrentADPFile { get; set; }
|
||||
public int PerformanceLevel { get; set; } = 50;
|
||||
public string DefaultProgramFilePath { get; set; } = "";
|
||||
public string DefaultBLFFilePath { get; set; } = "";
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<ProjectReference Include="..\DeviceCommand\DeviceCommand.csproj" />
|
||||
<ProjectReference Include="..\Logger\Logger.csproj" />
|
||||
<ProjectReference Include="..\ORM\ORM.csproj" />
|
||||
<ProjectReference Include="..\Service\Service.csproj" />
|
||||
<ProjectReference Include="..\ZLGUSBCANFD\ZLGUSBCANFD.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user