Compare commits
8 Commits
add1cd95be
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8daa1df8e9 | |||
| 7776e6c7ab | |||
| 2e71f68428 | |||
| 388edd1ada | |||
| 6057a71315 | |||
| 12de1b61e0 | |||
| 95700bfb8c | |||
| 013729003a |
@@ -9,7 +9,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ncalc" Version="1.3.8" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.5-beta1" />
|
||||
<PackageReference Include="System.IO.Ports" Version="11.0.0-preview.4.26230.115" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -69,6 +69,13 @@ namespace ExportModule.ViewModels
|
||||
get => _totalCount;
|
||||
set => SetProperty(ref _totalCount, value);
|
||||
}
|
||||
|
||||
private TestReportModel? _selectedTestReport;
|
||||
public TestReportModel? SelectedTestReport
|
||||
{
|
||||
get => _selectedTestReport;
|
||||
set => SetProperty(ref _selectedTestReport, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 命令
|
||||
@@ -144,24 +151,21 @@ namespace ExportModule.ViewModels
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出 Excel(根据当前筛选条件导出完整实体数据)
|
||||
/// 导出 Excel:根据用户在表格中选中的 TestReportModel.TestRoundId 查询并导出完整步骤数据
|
||||
/// </summary>
|
||||
private async Task OnExport()
|
||||
{
|
||||
DateTime? queryEnd = EndTime;
|
||||
if (queryEnd.HasValue)
|
||||
if (SelectedTestReport == null)
|
||||
{
|
||||
queryEnd = queryEnd.Value.Date.AddDays(1).AddSeconds(-1);
|
||||
ShowErrorMessageBox("请先在列表中选择一条测试记录。", () => { });
|
||||
return;
|
||||
}
|
||||
|
||||
string? scope = SelectedScope == "全部" ? null : SelectedScope;
|
||||
|
||||
// 查询全量实体数据
|
||||
StatusMessage = "正在查询导出数据...";
|
||||
var entityResult = await _testReportService.GetEntitiesByFilter(StartTime, queryEnd, scope);
|
||||
var entityResult = await _testReportService.GetByTestRoundIdAsync(SelectedTestReport.TestRoundId);
|
||||
if (!entityResult.IsSuccess || entityResult.Data == null || entityResult.Data.Count == 0)
|
||||
{
|
||||
ShowErrorMessageBox("没有数据可导出,请先查询或调整筛选条件。", () => { });
|
||||
ShowErrorMessageBox("未找到该测试记录的详细步骤数据。", () => { });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,15 +173,15 @@ namespace ExportModule.ViewModels
|
||||
{
|
||||
Filter = "Excel 工作簿 (*.xlsx)|*.xlsx|所有文件 (*.*)|*.*",
|
||||
DefaultExt = ".xlsx",
|
||||
FileName = $"测试报告_{DateTime.Now:yyyyMMdd_HHmmss}.xlsx"
|
||||
FileName = $"测试报告_{SelectedTestReport.Scope}_{SelectedTestReport.StartTime:yyyyMMdd_HHmmss}.xlsx"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() != true) return;
|
||||
|
||||
var entities = entityResult.Data;
|
||||
StatusMessage = $"正在导出 {entities.Count} 条记录...";
|
||||
StatusMessage = $"正在导出 {entities.Count} 条步骤记录...";
|
||||
await Task.Run(() => ExportToExcel(dialog.FileName, entities));
|
||||
ShowInfoMessageBox($"导出完成,共 {entities.Count} 条记录,已保存至:{dialog.FileName}", () => { });
|
||||
ShowInfoMessageBox($"导出完成,共 {entities.Count} 条步骤记录,已保存至:{dialog.FileName}", () => { });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -135,6 +135,7 @@
|
||||
Background="White"
|
||||
AlternatingRowBackground="#F5F7FA"
|
||||
SelectionMode="Single"
|
||||
SelectedItem="{Binding SelectedTestReport}"
|
||||
Margin="8">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="TestRoundId"
|
||||
|
||||
@@ -69,6 +69,10 @@ namespace MainModule.ViewModels
|
||||
string json = System.IO.File.ReadAllText(filePath);
|
||||
Newtonsoft.Json.JsonConvert.PopulateObject(json, _systemConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
_systemConfig = new SystemConfig();
|
||||
}
|
||||
}
|
||||
//容器解析顺序不要改变!!!
|
||||
_scopedContext = _scope.Resolve<ScopedContext>();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.215-preview13" />
|
||||
<PackageReference Include="System.IO.Ports" Version="11.0.0-preview.4.26230.115" />
|
||||
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -93,7 +93,20 @@ namespace TestingModule.ViewModels.Dialogs
|
||||
var index = Program.Parameters
|
||||
.Select((x, i) => new { x, i })
|
||||
.FirstOrDefault(p => p.x.ID == _ScopedContext.SelectedParameter.ID)?.i;
|
||||
|
||||
if (!_ScopedContext.SelectedParameter.IsEditable)
|
||||
{
|
||||
//公共变量只允许更改ParameterCategory为Input,Temp
|
||||
if (Program.Parameters[index.Value].Value != Parameter.Value
|
||||
|| Program.Parameters[index.Value].UpperLimit != Parameter.UpperLimit
|
||||
|| Program.Parameters[index.Value].LowerLimit != Parameter.LowerLimit
|
||||
|| Program.Parameters[index.Value].Name != Parameter.Name
|
||||
|| Parameter.Category == ParameterCategory.Output
|
||||
|| Program.Parameters[index.Value].Type != Parameter.Type)
|
||||
{
|
||||
RequestClose.Invoke(ButtonResult.Yes);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (index.HasValue)
|
||||
{
|
||||
Program.Parameters[index.Value] = Parameter;
|
||||
|
||||
@@ -190,13 +190,13 @@ namespace TestingModule.ViewModels
|
||||
|
||||
private void ParameterDelete()
|
||||
{
|
||||
if (!_globalInfo.IsAdmin) return;
|
||||
if (!_globalInfo.IsAdmin || !SelectedParameter.IsEditable) return;
|
||||
Program.Parameters.Remove(SelectedParameter);
|
||||
}
|
||||
|
||||
private void ParameterEdit()
|
||||
{
|
||||
if (!_globalInfo.IsAdmin||!SelectedParameter.IsEditable) return;
|
||||
if (!_globalInfo.IsAdmin) return;
|
||||
var param = new DialogParameters
|
||||
{
|
||||
{ "Mode",SelectedParameter==null?"ADD":"Edit" },
|
||||
@@ -207,10 +207,11 @@ namespace TestingModule.ViewModels
|
||||
if (r.Result == ButtonResult.OK)
|
||||
{
|
||||
_eventAggregator.GetEvent<ParamsChangedEvent>().Publish();
|
||||
ShowInfoMessageBox("保存成功", () => { });
|
||||
}
|
||||
else
|
||||
else if (r.Result == ButtonResult.Yes)
|
||||
{
|
||||
|
||||
ShowErrorMessageBox("公共变量只能设置变量类型(Input,Temp)", ()=>{ });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -29,52 +29,7 @@ namespace UIShare.GlobalVariable
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据标题(格子标识)加载独立的配置文件
|
||||
/// </summary>
|
||||
public static SystemConfig Load(string title)
|
||||
{
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
throw new ArgumentException("配置标题不能为空", nameof(title));
|
||||
}
|
||||
|
||||
// 临时实例化一个对象以获取默认的 SystemPath
|
||||
var dummy = new SystemConfig();
|
||||
string configPath = Path.Combine(dummy.SystemPath, $"{title}.json");
|
||||
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
// 如果不存在,创建一个带 Title 的默认配置并保存
|
||||
var defaultConfig = new SystemConfig { Title = title };
|
||||
EnsureDefaultCanDevice(defaultConfig);
|
||||
Save(defaultConfig);
|
||||
return defaultConfig;
|
||||
}
|
||||
|
||||
lock (_fileLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = File.ReadAllText(configPath);
|
||||
var config = JsonConvert.DeserializeObject<SystemConfig>(json, new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.All
|
||||
});
|
||||
|
||||
config ??= new SystemConfig { Title = title };
|
||||
EnsureDefaultCanDevice(config);
|
||||
return config;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelper.ErrorWithNotify(title, $"格子 [{title}] 配置加载失败: {ex.Message}");
|
||||
var fallback = new SystemConfig { Title = title };
|
||||
EnsureDefaultCanDevice(fallback);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存指定的配置实例
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace UIShare.ViewModelBase
|
||||
var dialogParams = new DialogParameters();
|
||||
dialogParams.Add("Title", "错误");
|
||||
dialogParams.Add("Message", Message);
|
||||
dialogParams.Add("Icon", "info");
|
||||
dialogParams.Add("Icon", "error");
|
||||
dialogParams.Add("ShowOk", true);
|
||||
_dialogService.ShowDialog("MessageBox", dialogParams, result =>
|
||||
{
|
||||
|
||||
@@ -619,7 +619,7 @@ namespace ZLGUSBCANFD
|
||||
/// <param name="物理值">要写入的实际物理数值</param>
|
||||
/// <param name="循环发送间隔毫秒">0 = 单次发送;>0 = 周期循环发送(单位毫秒)</param>
|
||||
/// <returns>操作是否成功</returns>
|
||||
public virtual bool 设置报文(uint 通道号, string 帧IDStr, string 信号名称, double 物理值, int 循环发送间隔毫秒 = 0, bool 直接发送=false)
|
||||
public virtual bool 设置报文(uint 通道号, string 帧IDStr, string 信号名称, double 物理值, int 循环发送间隔毫秒 = 0, bool 直接发送 = false)
|
||||
{
|
||||
if (!TryParseFrameId(帧IDStr, out uint 帧ID))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user