修复配方bug
This commit is contained in:
parent
9a91cdec0a
commit
15c422d76d
@ -110,8 +110,9 @@ namespace PLCSharp.Models
|
||||
}
|
||||
else
|
||||
{
|
||||
var camera = _DatasContext.Recipes.Where(c => c.ID == item.ID).FirstOrDefault();
|
||||
camera.Comment = item.Comment;
|
||||
var recipe = _DatasContext.Recipes.Where(c => c.ID == item.ID).FirstOrDefault();
|
||||
recipe.Name = item.Name;
|
||||
recipe.Comment = item.Comment;
|
||||
}
|
||||
}
|
||||
RecipeSelected.Prompt = "";
|
||||
@ -126,21 +127,36 @@ namespace PLCSharp.Models
|
||||
break;
|
||||
if (RecipeSelected.ID != CurrentRecipe.ID)
|
||||
{
|
||||
var recipeId = RecipeSelected.ID;
|
||||
|
||||
// 级联删除配方关联的所有数据
|
||||
_DatasContext.Variables.RemoveRange(_DatasContext.Variables.Where(v => v.RecipeID == recipeId));
|
||||
_DatasContext.SystemVariables.RemoveRange(_DatasContext.SystemVariables.Where(v => v.RecipeID == recipeId));
|
||||
_DatasContext.Workflows.RemoveRange(_DatasContext.Workflows.Where(w => w.RecipeID == recipeId));
|
||||
_DatasContext.ImageDatas.RemoveRange(_DatasContext.ImageDatas.Where(i => i.RecipeID == recipeId));
|
||||
_DatasContext.AxisPoints.RemoveRange(_DatasContext.AxisPoints.Where(a => a.RecipeID == recipeId));
|
||||
_DatasContext.Matrices.RemoveRange(_DatasContext.Matrices.Where(m => m.RecipeID == recipeId));
|
||||
_DatasContext.InterpolationGroups.RemoveRange(_DatasContext.InterpolationGroups.Where(g => g.RecipeID == recipeId));
|
||||
_DatasContext.RobotPoints.RemoveRange(_DatasContext.RobotPoints.Where(r => r.RecipeID == recipeId));
|
||||
_DatasContext.RobotMatrices.RemoveRange(_DatasContext.RobotMatrices.Where(m => m.RecipeID == recipeId));
|
||||
_DatasContext.CanvasConfigs.RemoveRange(_DatasContext.CanvasConfigs.Where(c => c.RecipeID == recipeId));
|
||||
_DatasContext.CustomControls.RemoveRange(_DatasContext.CustomControls.Where(c => c.RecipeID == recipeId));
|
||||
// VisionFunction 有关联的 LocalImageData(通过 FuncID),需先收集 ID 再级联删除
|
||||
var visionFuncIds = _DatasContext.VisionFunctions.Where(v => v.RecipeID == recipeId).Select(v => v.ID).ToList();
|
||||
_DatasContext.LocalImageDatas.RemoveRange(_DatasContext.LocalImageDatas.Where(l => visionFuncIds.Contains(l.FuncID)));
|
||||
_DatasContext.VisionFunctions.RemoveRange(_DatasContext.VisionFunctions.Where(v => v.RecipeID == recipeId));
|
||||
|
||||
var recipe = _DatasContext.Recipes.FirstOrDefault(r => r.ID == recipeId);
|
||||
if (recipe != null)
|
||||
{
|
||||
var recipe = _DatasContext.Recipes.Where
|
||||
(r => r.ID == RecipeSelected.ID).FirstOrDefault();
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
_DatasContext.Recipes.Remove(recipe);
|
||||
}
|
||||
|
||||
var name = RecipeSelected.Name;
|
||||
Recipes.Remove(RecipeSelected);
|
||||
SendInfoDialog($"已删除:{name}");
|
||||
RecipeSelected = null;
|
||||
_DatasContext.Save();
|
||||
_DatasContext.Recipes.Remove(recipe);
|
||||
}
|
||||
|
||||
var name = RecipeSelected.Name;
|
||||
Recipes.Remove(RecipeSelected);
|
||||
RecipeSelected = null;
|
||||
_DatasContext.Save();
|
||||
SendInfoDialog($"已删除配方:{name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -156,10 +172,16 @@ namespace PLCSharp.Models
|
||||
{
|
||||
item.Current = false;
|
||||
}
|
||||
foreach (var item in Recipes)
|
||||
{
|
||||
item.Current = false;
|
||||
}
|
||||
var current = _DatasContext.Recipes.Where(r => r.ID == RecipeSelected.ID).FirstOrDefault();
|
||||
if (current != null)
|
||||
{
|
||||
current.Current = true;
|
||||
var uiCurrent = Recipes.FirstOrDefault(r => r.ID == RecipeSelected.ID);
|
||||
if (uiCurrent != null) uiCurrent.Current = true;
|
||||
if (current != CurrentRecipe)
|
||||
{
|
||||
CurrentRecipe = current;
|
||||
@ -774,12 +796,6 @@ namespace PLCSharp.Models
|
||||
CustomControls.Add(item.DeepCopy());
|
||||
|
||||
}
|
||||
var config = _DatasContext.CanvasConfigs.Where(c => c.RecipeID == CurrentRecipe.ID).FirstOrDefault();
|
||||
if (config != null)
|
||||
{
|
||||
CurrentCanvasConfig.Rows = config.Rows;
|
||||
CurrentCanvasConfig.Columns = config.Columns;
|
||||
}
|
||||
|
||||
_EventAggregator.GetEvent<MessageEvent>().Publish(new()
|
||||
{
|
||||
|
||||
@ -77,6 +77,7 @@ namespace PLCSharp.Models
|
||||
RecipeSelected = CurrentRecipe;
|
||||
ExecuteRecipeManage("Save");
|
||||
}
|
||||
RecipeSelected ??= CurrentRecipe;
|
||||
}
|
||||
|
||||
VariablesModel = container.Resolve<VariablesModel>();
|
||||
|
||||
@ -23,11 +23,10 @@ namespace PLCSharp.VVMs.Recipe
|
||||
get { return _Name; }
|
||||
set
|
||||
{
|
||||
if (_Name != value)
|
||||
if (SetProperty(ref _Name, value))
|
||||
{
|
||||
Prompt = "已修改,请保存";
|
||||
}
|
||||
SetProperty(ref _Name, value);
|
||||
}
|
||||
}
|
||||
private string _Comment;
|
||||
@ -35,16 +34,14 @@ namespace PLCSharp.VVMs.Recipe
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Comment
|
||||
|
||||
{
|
||||
get { return _Comment; }
|
||||
set
|
||||
{
|
||||
if (_Comment != value)
|
||||
if (SetProperty(ref _Comment, value))
|
||||
{
|
||||
Prompt = "已修改,请保存";
|
||||
}
|
||||
SetProperty(ref _Comment, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user