| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 | using Aitex.Core.Util;using Caliburn.Micro;using Caliburn.Micro.Core;using MECF.Framework.Common.DataCenter;using MECF.Framework.Common.OperationCenter;using MECF.Framework.Common.RecipeCenter;using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;using MECF.Framework.UI.Client.ClientBase;using OpenSEMI.ClientBase;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Xml;using System.Windows;using FurnaceUI.Models;using FurnaceUI.Views.Recipes;using ProcessTypeFileItems = MECF.Framework.UI.Client.CenterViews.Editors.Recipe.ProcessTypeFileItem;using System.Text.RegularExpressions;using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;using FurnaceUI.Views.Editors;namespace FurnaceUI.Views.Recipes{    public class RecipeJobEditViewModel : FurnaceUIViewModelBase    {        public RecipeJobEditViewModel(string strPrefixPath, string strRecipeName,string permission="")        {            CurrentRecipe.PrefixPath = strPrefixPath;            CurrentRecipe.Name = strRecipeName;            CurrentRecipe.RecipePermission = permission;        }        private readonly RecipeProvider _recipeProvider = new RecipeProvider();        public string SelectRecipeType { get; set; }        public RecipeDataJob CurrentRecipe { get; set; } = new RecipeDataJob();        private string _coolTime;        private WindowManager windowManager;        public string CoolTime        {            get => _coolTime;            set            {                _coolTime = value;                NotifyOfPropertyChange(nameof(CoolTime));            }        }        public bool IsEnable => CGlobal.RecipeJobEditViewEnable;//是否是View模式        protected override void OnInitialize()        {            base.OnInitialize();            LoadData();        }        private void LoadData()        {            CurrentRecipe.Clear();            var recipeContent = _recipeProvider.LoadRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name);            if (string.IsNullOrEmpty(recipeContent))            {                System.Windows.MessageBox.Show($"{CurrentRecipe.PrefixPath}\\{CurrentRecipe.Name} is empty, please confirm the file is valid.");                return;            }            CurrentRecipe.RecipeChamberType = "OriginChamber";            CurrentRecipe.InitData(CurrentRecipe.PrefixPath, CurrentRecipe.Name, recipeContent, "PM1");            if (SystemConfigProvider.Instance.GetValueByName($"PM1.RecipeEditParameter.CoolTime.{CurrentRecipe.CoolTime}").Length > 0)                CoolTime = CurrentRecipe.CoolTime + ":" + SystemConfigProvider.Instance.GetValueByName($"PM1.RecipeEditParameter.CoolTime.{CurrentRecipe.CoolTime}");            else                CoolTime = "Value:" + CurrentRecipe.CoolTime;        }        public void SelectProcessRecipe()        {            RecipeSelectDialogViewModel dialog = new RecipeSelectDialogViewModel();            dialog.DisplayName = "Select Process Recipe";            var recipeProvider = new RecipeProvider();            var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedProcessType");            if (processType == null)            {                processType = "Process";            }            var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItems>();            string[] recipeProcessType = ((string)processType).Split(',');            for (int i = 0; i < recipeProcessType.Length; i++)            {                var type = new ProcessTypeFileItems();                type.ProcessType = recipeProcessType[i];                var prefix = $"Furnace\\{recipeProcessType[i]}";                var recipes = recipeProvider.GetXmlRecipeList(prefix);                type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes)[0].Files;                ProcessTypeFileList.Add(type);            }            dialog.ProcessTypeFileList = ProcessTypeFileList;            WindowManager wm = new WindowManager();            bool? bret = wm.ShowDialog(dialog);            if ((bool)bret)            {                //var array = dialog.DialogResult.Split(new char[] { '\\' });                //CurrentRecipe.ProcessRecipe = array[array.Length - 1];                CurrentRecipe.ProcessRecipe = dialog.DialogResult;            }        }        public void SelectLayoutRecipe()        {            RecipeSelectDialogViewModel dialog = new RecipeSelectDialogViewModel();            dialog.DisplayName = "Select Layout Recipe";            var recipeProvider = new RecipeProvider();            //var processType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedLayoutType");            if (SelectRecipeType == null)            {                SelectRecipeType = "Layout";            }            var ProcessTypeFileList = new ObservableCollection<ProcessTypeFileItems>();            string[] recipeProcessType = ((string)SelectRecipeType).Split(',');            for (int i = 0; i < recipeProcessType.Length; i++)            {                var type = new ProcessTypeFileItems();                type.ProcessType = recipeProcessType[i];                var prefix = $"Furnace\\{recipeProcessType[i]}";                var recipes = recipeProvider.GetXmlRecipeList(prefix);                type.FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes)[0].Files;                ProcessTypeFileList.Add(type);            }            dialog.ProcessTypeFileList = ProcessTypeFileList;            WindowManager wm = new WindowManager();            bool? bret = wm.ShowDialog(dialog);            if ((bool)bret)            {                //var array = dialog.DialogResult.Split(new char[] { '\\' });                //CurrentRecipe.LayoutRecipe = array[array.Length - 1];                CurrentRecipe.LayoutRecipe = dialog.DialogResult;            }        }        public void CoolTimeEdit()        {            var windowManager = IoC.Get<IWindowManager>();            RecipeStepTimeViewModel recipeStepTimeViewModel = new RecipeStepTimeViewModel("CoolTime");            recipeStepTimeViewModel.SelectTime = CurrentRecipe.CoolTime;            (windowManager as WindowManager)?.ShowDialogWithTitle(recipeStepTimeViewModel, null, "Cooling Time Set");            if (recipeStepTimeViewModel.IsSave)            {                if (recipeStepTimeViewModel.SelectTime == "Value")                {                    CoolTime = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.SelectValueTime;                    CurrentRecipe.CoolTime = recipeStepTimeViewModel.SelectValueTime;                }                else                {                    CoolTime = recipeStepTimeViewModel.SelectTime + ":" + recipeStepTimeViewModel.RecipeStepTime[recipeStepTimeViewModel.SelectTime];                    CurrentRecipe.CoolTime = recipeStepTimeViewModel.SelectTime;                }            }        }        public void SaveCmd()        {            RecipePermissionSelectViewModel dialog = new RecipePermissionSelectViewModel("Save recipe and permission", CurrentRecipe.RecipePermission);            WindowManager wm = new WindowManager();            bool? dialogReturn = wm.ShowDialog(dialog);            if (!dialogReturn.HasValue || !dialogReturn.Value)                return;            if (string.IsNullOrEmpty(CurrentRecipe.ProcessRecipe))            {                DialogBox.ShowWarning("Process recipe is empty");                return;            }            if (string.IsNullOrEmpty(CurrentRecipe.LayoutRecipe))            {                DialogBox.ShowWarning("Layout recipe is empty");                return;            }            if (string.IsNullOrEmpty(CurrentRecipe.CoolTime))            {                DialogBox.ShowWarning("Cool time is empty");                return;            }            //if (!CheckTimeFormat())            //{            //    DialogBox.ShowWarning("Cool time format is error");            //    return;            //}            CurrentRecipe.LastReviseBy = BaseApp.Instance.UserContext.LoginName;            CurrentRecipe.LastRevisionTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");            this.CurrentRecipe.RecipeLevel = this.LevelDisplay;            this.CurrentRecipe.RecipePermission = dialog.RecipePermission;            _recipeProvider.SaveRecipe(CurrentRecipe.PrefixPath, CurrentRecipe.Name, CurrentRecipe.GetXmlString());            ((Window)GetView()).DialogResult = true;        }        private bool CheckTimeFormat()        {            bool bResult, bTimeH = true, bTimeM = true, bTimeS = true;            string pattern = "^[0-9]*$";            Regex rex = new Regex(pattern);            //if (!rex.IsMatch(CurrentRecipe.CoolTimeH))            //{            //    bTimeH = false;            //}            //if (!rex.IsMatch(CurrentRecipe.CoolTimeM))            //{            //    bTimeM = false;            //}            //if (!rex.IsMatch(CurrentRecipe.CoolTimeS))            //{            //    bTimeS = false;            //}            bResult = bTimeH && bTimeM && bTimeS;            return bResult;        }        public void ClosedCmd()        {            if (DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM, " You confirm that you want to unsave the recipe and exit the interface?") == DialogButton.No)                return;            ((Window)GetView()).DialogResult = false;        }    }}
 |