fix: 副实例启动前导出文件校验(避免 NW 原生加载失败弹窗)
背景:model-item-116.nwd 无法打开弹窗为 NW 原生错误对话框(插件无法拦截)。 根因:队列残留项被重置重跑时,旧副实例孤儿进程仍占用导出文件 → 新副实例加载被占用文件失败 → 原生弹窗。 修复:SectionBoxBatchDetector.RunAsync 启动副实例前校验: 1) 导出文件存在且非空 2) 文件未被占用(FileStream 独占探测,IOException = 残留进程持有) → 失败时明确错误信息(提示检查残留 Roamer 进程),不启动副实例 验证:F1 批处理正常路径 30 秒完成(无回归)
This commit is contained in:
parent
e92a01df25
commit
0f7d44dc76
@ -215,6 +215,27 @@ namespace NavisworksTransport.Core.Services
|
|||||||
}
|
}
|
||||||
result.LocalModelPath = localModelPath;
|
result.LocalModelPath = localModelPath;
|
||||||
|
|
||||||
|
// 启动副实例前文件校验(NW 加载失败会弹原生错误窗口,插件无法拦截):
|
||||||
|
// 1) 文件存在且非空;2) 未被其他进程占用(残留副实例可能仍持有导出文件)
|
||||||
|
var exportFileInfo = new FileInfo(localModelPath);
|
||||||
|
if (!exportFileInfo.Exists || exportFileInfo.Length == 0)
|
||||||
|
{
|
||||||
|
result.ErrorMessage = $"导出模型文件无效(不存在或为空): {localModelPath}";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var probe = new FileStream(localModelPath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
result.ErrorMessage = $"导出模型文件被占用(可能有残留副实例进程未退出),请检查残留 Roamer 进程后重试: {localModelPath}";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 导出路径文件(JSON,副实例导入用)
|
// 3. 导出路径文件(JSON,副实例导入用)
|
||||||
new PathDataManager().ExportToJson(new List<PathRoute> { route }, routeFilePath);
|
new PathDataManager().ExportToJson(new List<PathRoute> { route }, routeFilePath);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user