fix: 副实例导出文件加时间戳后缀(避免同名冲突)

同一 itemId 重复执行(残留 Running 状态重置重跑)时,旧副实例可能
仍持有旧文件句柄——同名覆盖/加载会触发 NW 原生加载失败弹窗。

model/route/secondary db 三个文件统一加 yyyyMMddHHmmssfff 后缀:
- 每次执行文件唯一,不与旧执行冲突
- 工作目录按 item-{Id} 目录清理(不受影响)

验证:F1 批处理 30 秒完成;日志确认新格式
model-item-119-20260806115052022.nwd
This commit is contained in:
tian 2026-08-06 11:51:50 +08:00
parent 0f7d44dc76
commit 68776ef22e

View File

@ -109,9 +109,13 @@ namespace NavisworksTransport.Core.Services
Directory.CreateDirectory(workDirectory);
string safeId = string.IsNullOrWhiteSpace(instanceId) ? Guid.NewGuid().ToString("N") : instanceId;
string localModelPath = Path.Combine(workDirectory, $"model-{safeId}.nwd");
string routeFilePath = Path.Combine(workDirectory, $"route-{safeId}.json");
string secondaryDbPath = Path.Combine(workDirectory, $"secondary-{safeId}.db");
// 文件名带时间戳后缀:同一 itemId 重复执行(残留状态重置重跑)时避免与
// 旧执行的文件重名——旧副实例可能仍持有旧文件句柄,同名覆盖会触发加载失败弹窗
string fileStamp = DateTime.Now.ToString("yyyyMMddHHmmssfff");
string localModelPath = Path.Combine(workDirectory, $"model-{safeId}-{fileStamp}.nwd");
string routeFilePath = Path.Combine(workDirectory, $"route-{safeId}-{fileStamp}.json");
string secondaryDbPath = Path.Combine(workDirectory, $"secondary-{safeId}-{fileStamp}.db");
// 1. 路径剖面盒(复用产品路径盒语义:路径点 + 虚拟物体高度附加点 + 水平 4m/高度 2m 扩展)
// 与 LogisticsControlViewModel.EnableClipBoxForCurrentRoute 一致(地面路径点上方、空中路径下方加物体高度)