From 63b88cb8fb919df4344a884000a7f723b1c0302a Mon Sep 17 00:00:00 2001 From: SL <123@123.com> Date: Thu, 21 Sep 2023 14:14:06 +0800 Subject: [PATCH] =?UTF-8?q?[UI.Client]=20=E4=BF=AE=E6=AD=A3RecipeEditor?= =?UTF-8?q?=E5=92=8CPMProcess=E8=A7=86=E5=9B=BE=E4=B8=ADRecipe=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E8=A1=A8=E6=A0=BC=E7=9A=84=E8=A1=8C=E4=B8=8D=E9=9A=8F?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=8F=98=E6=9B=B4=E5=AE=9E=E6=97=B6=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editors/Recipe/RecipeEditorViewModel.cs | 8 +- .../Modules/PM/PMProcessViewModel.cs | 106 +++++++----------- 2 files changed, 48 insertions(+), 66 deletions(-) diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs index 29bc9c5..52a1782 100644 --- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs +++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs @@ -428,10 +428,10 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe MultiChamberVisibility = Chambers.Count > 1 ? Visibility.Visible : Visibility.Collapsed; SelectedChamber = Chambers[0]; + var role = AccountClient.Instance.Service.GetRoleByID(BaseApp.Instance.UserContext.Role.RoleId); // 如果RecipeData为空,则先创建其实例 if (CurrentRecipe == null) { - var role = AccountClient.Instance.Service.GetRoleByID(BaseApp.Instance.UserContext.Role.RoleId); var recipeData = new RecipeData(_recipeGasFlowCalculator, CurrentProcessType); recipeData.BuildFormat($"{CurrentChamberType}\\{CurrentProcessType}", SelectedChamber, role); recipeData.OnValidated += (sender, args) => @@ -448,6 +448,12 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe _editMode = EditMode.None; } + else + { + CurrentRecipe.UpdatePermission(role); + } + + } /// diff --git a/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessViewModel.cs index 7305845..17a17b0 100644 --- a/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessViewModel.cs +++ b/MECF.Framework.UI.Client/CenterViews/Modules/PM/PMProcessViewModel.cs @@ -43,20 +43,21 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM private double _sih4FlowRatio = 1; private double _pn2FlowRatio = 1; - private bool _isHideRecipeValue = false; private bool _allowSaveRecipe = false; private bool _allowRipRecipe = false; + + private int x = 0; + private DispatcherTimer timer; + private readonly object _lockerLoadingRecipe = new(); private readonly IRecipeGasFlowCalculator _recipeGasFlowCalculator; private string _currentProcessingRecipe; + private string _selectedRecipe; + private bool _needLoadRecipe = false; private IProgress _progressRecipeStepChanged; private IProgress _progressLoadRecipe; - private readonly object _lockerLoadingRecipe = new(); - CancellationTokenSource cts = new(); - - - public string title { get; set; } = "123"; + private CancellationTokenSource _cts; public PMProcessViewModel() { @@ -68,10 +69,13 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM IsBusyGasFlowSum = e.Message == "" ? false : true; BusyIndicatorContent = e.Message; }); + + _progressLoadRecipe = new Progress(ProgLoadRecipeOnUiThread); + _progressRecipeStepChanged = new Progress(RecipeStepInProcessChanged); } - #region properties - + #region Properties + public bool AllowSaveRecipe { get => _allowSaveRecipe; @@ -112,18 +116,10 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM public float[] RecipeData1 => RecipeData; public float[] RecipeData = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 1, 1, 1, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - - private string selectedRecipe; public string SelectedRecipe { - set - { - selectedRecipe = value; - } - get - { - return selectedRecipe; - } + set => _selectedRecipe = value; + get => _selectedRecipe; } @@ -176,19 +172,11 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM get { if (IsPMProcess) - { return $"{RecipeStepNumber}"; - } else if (IsPreProcess) - { return "0"; - } return "--"; - } - set - { - } } @@ -271,16 +259,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM } } - - //qbh 20220523 - private int x = 0; - private DispatcherTimer timer; - - - - - // + public RecipeData CurrentRecipe { get; set; } + public List Columns { get; set; } = new List(); private RecipeFormatBuilder _recipeFormatBuilder = new (); @@ -347,7 +328,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM public string CurrentProcessType { get; set; } - private bool needLoadRecipe = false; + #endregion @@ -357,10 +338,10 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM /// private void LoadRolePermissions() { - var roleID = BaseApp.Instance.UserContext.Role.RoleId; - _isHideRecipeValue = AccountClient.Instance.Service.GetMenuPermission(roleID, "Recipe.Behaviour.ShowValueInProcessView") == (int)MenuPermissionEnum.MP_NONE; - AllowSaveRecipe = AccountClient.Instance.Service.GetMenuPermission(roleID, "Recipe.Behaviour.AllowSaveInProcessView") != (int)MenuPermissionEnum.MP_NONE; - AllowRipRecipe = AccountClient.Instance.Service.GetMenuPermission(roleID, "Recipe.Behaviour.AllowRipInProcessView") != (int)MenuPermissionEnum.MP_NONE; + var roleId = BaseApp.Instance.UserContext.Role.RoleId; + _isHideRecipeValue = AccountClient.Instance.Service.GetMenuPermission(roleId, "Recipe.Behaviour.ShowValueInProcessView") == (int)MenuPermissionEnum.MP_NONE; + AllowSaveRecipe = AccountClient.Instance.Service.GetMenuPermission(roleId, "Recipe.Behaviour.AllowSaveInProcessView") != (int)MenuPermissionEnum.MP_NONE; + AllowRipRecipe = AccountClient.Instance.Service.GetMenuPermission(roleId, "Recipe.Behaviour.AllowRipInProcessView") != (int)MenuPermissionEnum.MP_NONE; } @@ -372,15 +353,17 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM if (string.IsNullOrEmpty(DisplayingRecipeName)) { - needLoadRecipe = false; + _needLoadRecipe = false; var recipeName = (string)QueryDataClient.Instance.Service.GetConfig($"PM.{SystemName}.LastRecipeName"); DisplayingRecipeName = recipeName; - selectedRecipe = recipeName; + _selectedRecipe = recipeName; } // 更新Recipe参数值显示状态 SetRecipeValueVisibilityByCurrentRole(); + + UpdateRecipeFormat(); ((PMProcessView)View)?.recipeLocker.Lock(); @@ -402,22 +385,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM ActiveUpdateData = true; base.OnDeactivate(close); } - - protected override void OnInitialize() - { - base.OnInitialize(); - - //权限 - var roleID = BaseApp.Instance.UserContext.Role.RoleId; - StepsVisibility = RoleAccountProvider.Instance.GetMenuPermission(roleID, "PM1.Process.Steps") == MenuPermissionEnum.MP_READ_WRITE; - _progressLoadRecipe = new Progress(ProgLoadRecipeOnUiThread); - _progressRecipeStepChanged = new Progress(RecipeStepInProcessChanged); - - UpdateRecipeFormat(); - } - public bool StepsVisibility { get; private set; } - protected override void Poll() { try @@ -437,8 +405,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM if (data.TryGetValue("System.IsEngMode", out var isEngMode) && isEngMode is bool b) IsEngMode = b; - if (needLoadRecipe) - needLoadRecipe = false; + if (_needLoadRecipe) + _needLoadRecipe = false; base.InvokeAfterUpdateProperty(data); } @@ -655,8 +623,16 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM public void UpdateRecipeFormat() { var role = AccountClient.Instance.Service.GetRoleByID(BaseApp.Instance.UserContext.Role.RoleId); - CurrentRecipe = new RecipeData(_recipeGasFlowCalculator, RecipeType.Process); - CurrentRecipe.BuildFormat($"Sic\\Process", SystemName, role); + + if (CurrentRecipe == null) + { + CurrentRecipe = new RecipeData(_recipeGasFlowCalculator, RecipeType.Process); + CurrentRecipe.BuildFormat($"Sic\\Process", SystemName, role); + } + else + { + CurrentRecipe.UpdatePermission(role); + } } /// @@ -1725,7 +1701,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM return; } - cts = new CancellationTokenSource(); + _cts = new CancellationTokenSource(); Task.Run(() => { @@ -1739,9 +1715,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM { Task.Run(() => { - if (cts?.Token.CanBeCanceled == true) + if (_cts?.Token.CanBeCanceled == true) { - cts.Cancel(); + _cts.Cancel(); } Thread.Sleep(200); @@ -1757,7 +1733,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM //按天查询数据库,单天返回数据类型为List foreach (var daySlice in daySlices) { - if (cts.IsCancellationRequested) + if (_cts.IsCancellationRequested) return ; gasFlowRunVent.Add( GasFlowSqlHelp.GetDayGasFlowSum(daySlice, SystemName, GasFlowSumList));