Sfoglia il codice sorgente

禅道bug:1.bug461 带table的recipe增加表同名检测,table1最少保留1步
2.修复bug460和444:recipe步次使用其他步override对象造成的引用bug

huangping 3 settimane fa
parent
commit
653f796815

+ 15 - 12
FrameworkLocal/UIClient/CenterViews/Editors/Recipe/RecipeDataBase.cs

@@ -24,6 +24,7 @@ using Mapster;
 using System.Diagnostics;
 using SciChart.Charting.Common.Extensions;
 using DocumentFormat.OpenXml.EMMA;
+using MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory;
 
 namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
 {
@@ -320,19 +321,21 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
         public void ShallowCopyStep(ref Step destinationStep, Step originalStep)
         {
             int stepNo = destinationStep.StepNo;
-            Type type = originalStep.GetType();
-            PropertyInfo[] properties = type.GetProperties();
-            // 遍历属性并赋值
-            foreach (PropertyInfo property in properties)
-            {
-                // 判断属性是否可写
-                if (property.CanWrite)
-                {
-                    // 设置属性的值
-                    property.SetValue(destinationStep, property.GetValue(originalStep));
-                }
-            }
+            //Type type = originalStep.GetType();
+            //PropertyInfo[] properties = type.GetProperties();
+            //// 遍历属性并赋值
+            //foreach (PropertyInfo property in properties)
+            //{
+            //    // 判断属性是否可写
+            //    if (property.CanWrite)
+            //    {
+            //        // 设置属性的值
+            //        property.SetValue(destinationStep, property.GetValue(originalStep));
+            //    }
+            //}
+            originalStep.Adapt(destinationStep);
             destinationStep.StepNo = stepNo;
+            SetDelegateEvent(destinationStep);
         }
         public void CloneStep(ref Step destinationStep, Step originalStep)
         {

+ 38 - 7
Furnace/FurnaceUI/Views/Recipes/RecipeTableSelectDialogViewModel.cs

@@ -63,20 +63,32 @@ namespace FurnaceUI.Views.Recipes
         }
         public void Clear()
         {
+            if (SelectedIndex < 0)
+            {
+                DialogBox.ShowWarning("No table is selected");
+                return;
+            }
             if (!DialogBox.Confirm("Clear this table?"))
                 return;
             // SelectedTable.Name = "";
             SelectedTable.EndStatus = "";
-            if (SelectedTable.TableData.Steps.Count > 1)
+            if (SelectedTable.TableData.Steps.Count > 0)
             {
-                while (SelectedTable.TableData.Steps.Count > 1)
+                if (SelectedIndex == 0)
                 {
-                    SelectedTable.TableData.Steps.RemoveAt(1);
+                    if (SelectedTable.TableData.Steps.Count < 2)
+                    {
+                        DialogBox.ShowInfo("Table1 have one step at least");
+                        return;
+                    }
+                    var step = SelectedTable.TableData.Steps.First();
+                    if (step != null)
+                    {
+                        SelectedTable.TableData.Steps.Clear();
+                        SelectedTable.TableData.Steps.Add(step);
+                    }
                 }
-            }
-            else
-            {
-                SelectedTable.TableData = new RecipeDataBase();
+                else SelectedTable.TableData.Steps.Clear();
             }
         }
 
@@ -99,6 +111,25 @@ namespace FurnaceUI.Views.Recipes
             }
             else
             {
+                //table名不能重复
+                for (int i = 0; i < Recipe.Tables.Count; i++)
+                {
+                    if (Recipe.Tables[i].TableData?.Steps?.Count > 0)
+                    {
+                        var tablename = Recipe.Tables[i].Name.Trim();
+                        for (int j = i + 1; j < Recipe.Tables.Count; j++)
+                        {
+                            if (Recipe.Tables[j].TableData?.Steps?.Count > 0)
+                            {
+                                if (tablename == Recipe.Tables[j].Name.Trim())
+                                {
+                                    DialogBox.ShowError($"Table{i + 1} and Table{j + 1} couldn't have same table name [{tablename}]");
+                                    return;
+                                }
+                            }
+                        }
+                    }
+                }
                 Recipe.TableIndex = SelectedTable.Index;
                 Recipe.Steps.Clear();
                 SelectedTable.TableData.Steps.ToList().ForEach(x =>