12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
- using MECF.Framework.UI.Client.ClientBase;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace MECF.Framework.UI.Client.CenterViews.Parameter
- {
- public class StepGroupEditViewModel : ModuleUiViewModelBase
- {
- private List<ConfigItem> _stepIdList = new List<ConfigItem>();
- public List<ConfigItem> StepIdList
- {
- get => _stepIdList;
- set
- {
- _stepIdList = value;
- NotifyOfPropertyChange(nameof(StepIdList));
- }
- }
- public string StepGroupName = "Group1";
- public List<string> HasSelectStepIds = new List<string>();
- public string SelectStepIDStr = "";
- private ConfigNode _rootNode;
- public void Save()
- {
- ((Window)GetView()).DialogResult = true;
- }
- public void Cancle()
- {
- (GetView() as Window).Close();
- }
- protected override void OnInitialize()
- {
- base.OnInitialize();
- this.SystemName = "System";
- _rootNode = SystemConfigProvider.Instance.GetConfig(true);
- var stepNameNode = FindNodeByName(_rootNode, $"PM1.RecipeEditParameter.StepName");
- if (stepNameNode != null && stepNameNode.Items.Count > 0)
- {
- var datas = QueryDataClient.Instance.Service.PollConfig(stepNameNode.Items.Select(a => $"{a.Path}.{a.Name}").ToList());
- foreach (var item in stepNameNode.Items)
- {
- if (HasSelectStepIds != null && HasSelectStepIds.Count > 0)
- {
- if (HasSelectStepIds.Contains(item.Name))
- {
- continue;
- }
- }
- var key = $"{item.Path}.{item.Name}";
- datas.TryGetValue(key, out var value);
- item.CurrentValue = (string)value;
- item.Display = $"{item.Name}:{item.CurrentValue}";
- StepIdList.Add(item);
- }
- }
- }
- protected override void OnActivate()
- {
- base.OnActivate();
- var gropuDataStr = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.RecipeEditParameter.StepGroup.{StepGroupName}");
- if (!string.IsNullOrEmpty(gropuDataStr))
- {
- foreach (var item in gropuDataStr.Split(',').ToList())
- {
- StepIdList.Where(a => a.Name == item).FirstOrDefault().IsExpanded = true;
- }
- }
- }
- private ConfigNode FindNodeByName(ConfigNode parentNode, string strName)
- {
- string strCates = strName.Split('.')[0];
- ConfigNode node = parentNode.SubNodes.Find((x) => x.Name == strCates);
- if (node == null)
- return parentNode;
- else
- return FindNodeByName(node, strName.Replace(strCates + ".", ""));
- }
- }
- }
|