局部图像列表的导入导出
This commit is contained in:
parent
15c422d76d
commit
ff69308edb
@ -256,10 +256,23 @@ namespace PLCSharp.Models
|
||||
RecipeID = v.RecipeID.ToString(),
|
||||
v.Name,
|
||||
v.Comment,
|
||||
v.ControlName,
|
||||
v.SerializedVisionParams,
|
||||
v.SerializedVisionFlows
|
||||
}).ToList();
|
||||
|
||||
// 局部图像(不含图像内容)
|
||||
var visionFuncIds = _DatasContext.VisionFunctions.Where(v => v.RecipeID == recipeId).Select(v => v.ID).ToList();
|
||||
sheets["局部图像"] = _DatasContext.LocalImageDatas
|
||||
.Where(l => visionFuncIds.Contains(l.FuncID))
|
||||
.Select(l => new
|
||||
{
|
||||
ID = l.ID.ToString(),
|
||||
FuncID = l.FuncID.ToString(),
|
||||
l.Name,
|
||||
l.Comment
|
||||
}).ToList();
|
||||
|
||||
// 全局图像
|
||||
sheets["全局图像"] = _DatasContext.ImageDatas
|
||||
.Where(i => i.RecipeID == recipeId)
|
||||
@ -501,11 +514,35 @@ namespace PLCSharp.Models
|
||||
RecipeID = recipeId,
|
||||
Name = name,
|
||||
Comment = (string)row.Comment,
|
||||
ControlName = (string)row.ControlName,
|
||||
SerializedVisionParams = (string)row.SerializedVisionParams,
|
||||
SerializedVisionFlows = (string)row.SerializedVisionFlows
|
||||
});
|
||||
}
|
||||
|
||||
// 局部图像
|
||||
foreach (var row in MiniExcel.Query(dialog.FileName, sheetName: "局部图像"))
|
||||
{
|
||||
var idStr = (string)row.ID;
|
||||
if (string.IsNullOrWhiteSpace(idStr)) continue;
|
||||
if (!Guid.TryParse(idStr, out var id)) continue;
|
||||
if (_DatasContext.LocalImageDatas.Any(l => l.ID == id)) continue;
|
||||
|
||||
var funcIdStr = (string)row.FuncID;
|
||||
if (string.IsNullOrWhiteSpace(funcIdStr)) continue;
|
||||
if (!Guid.TryParse(funcIdStr, out var funcId)) continue;
|
||||
// 对应的 VisionFunction 不存在时跳过,避免孤儿数据
|
||||
if (!_DatasContext.VisionFunctions.Any(v => v.ID == funcId)) continue;
|
||||
|
||||
_DatasContext.LocalImageDatas.Add(new LocalImageData
|
||||
{
|
||||
ID = id,
|
||||
FuncID = funcId,
|
||||
Name = (string)row.Name,
|
||||
Comment = (string)row.Comment
|
||||
});
|
||||
}
|
||||
|
||||
// 全局图像
|
||||
foreach (var row in MiniExcel.Query(dialog.FileName, sheetName: "全局图像"))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user