| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows;
 
- using Caliburn.Micro.Core;
 
- using Caliburn.Micro;
 
- using FurnaceUI.Models;
 
- using FurnaceUI.Views.Maintenances;
 
- using Aitex.Core.RT.IOCore;
 
- using MECF.Framework.Common.OperationCenter;
 
- using Aitex.Core.Util;
 
- using OpenSEMI.ClientBase;
 
- using MECF.Framework.Common.DataCenter;
 
- using System.Globalization;
 
- using MECF.Framework.UI.Client.ClientBase;
 
- using System.Collections.ObjectModel;
 
- using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;
 
- using FurnaceUI.DataModule;
 
- using System.Windows.Data;
 
- using System.Threading;
 
- using System.IO;
 
- using System.Diagnostics;
 
- using FurnaceUI.Views.Editors;
 
- using System.Windows.Input;
 
- using FurnaceUI.Controls.Common;
 
- namespace FurnaceUI.Views.Parameter
 
- {
 
-     public class BackUpViewModel : FurnaceUIViewModelBase
 
-     {
 
-         [Subscription("Rt.Status")]
 
-         public string RtStatus { get; set; }
 
-         [Subscription("PM1.Status")]
 
-         public string PM1EntityStatus { get; set; }
 
-         private Visibility _gridHistoryVisibility = Visibility.Visible;
 
-         public Visibility GridHistoryVisibility
 
-         {
 
-             get { return _gridHistoryVisibility; }
 
-             set { _gridHistoryVisibility = value; this.NotifyOfPropertyChange(nameof(GridHistoryVisibility)); }
 
-         }
 
-         [Subscription("System.BackUpFileData")]
 
-         public Dictionary<string, List<string>> AllFilesDatas { get; set; }   
 
-         private ObservableCollection<PageDataView> _historyTableDatas = new ObservableCollection<PageDataView>();
 
-         public ObservableCollection<PageDataView> HistoryTableDatas
 
-         {
 
-             get { return _historyTableDatas; }
 
-             set { _historyTableDatas = value; this.NotifyOfPropertyChange(nameof(HistoryTableDatas)); }
 
-         }
 
-         public PageDataView SelectedItemHistory { get; set; }
 
-         private bool _busyIndicatorVisibility = false;
 
-         public bool BusyIndicatorVisibility
 
-         {
 
-             get { return _busyIndicatorVisibility; }
 
-             set { _busyIndicatorVisibility = value; this.NotifyOfPropertyChange(nameof(BusyIndicatorVisibility)); }
 
-         }
 
-         private bool _isAllEnable = true;
 
-         public bool IsAllEnable
 
-         {
 
-             get { return _isAllEnable; }
 
-             set { _isAllEnable = value; this.NotifyOfPropertyChange(nameof(IsAllEnable)); }
 
-         }
 
-         RelayCommand _compareCommand;
 
-         public ICommand CompareCommand
 
-         {
 
-             get
 
-             {
 
-                 if (_compareCommand == null)
 
-                 {
 
-                     _compareCommand = new RelayCommand(param => this.CompareClick(), param => this.CanCompareClick());
 
-                 }
 
-                 return _compareCommand;
 
-             }
 
-         }
 
-         RelayCommand _rollBackCommand;
 
-         public ICommand RollBackCommand
 
-         {
 
-             get
 
-             {
 
-                 if (_rollBackCommand == null)
 
-                 {
 
-                     _rollBackCommand = new RelayCommand(param => this.RollBackClick(), param => this.CanRollBackClick());
 
-                 }
 
-                 return _rollBackCommand;
 
-             }
 
-         }
 
-         protected override void OnActivate()
 
-         {
 
-             base.OnActivate();
 
-             DelayData();
 
-         }
 
-         protected override void OnViewLoaded(object view)
 
-         {
 
-             base.OnViewLoaded(view);
 
-         }
 
-         protected override void OnDeactivate(bool close)
 
-         {
 
-             base.OnDeactivate(close);
 
-         }
 
-         public void CreateZIP()
 
-         {
 
-             var selection = DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM,
 
-               $"Are you sure you want to CreateZIP?");
 
-             if (selection == DialogButton.No)
 
-                 return;
 
-             BusyIndicatorVisibility = true;
 
-             InvokeClient.Instance.Service.DoOperation($"System.CreateZIP");
 
-             DelayData();
 
-         }
 
-         public void BackUpClick()
 
-         {
 
-             var selection = DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM,
 
-               $"Are you sure you want to BackUp?");
 
-             if (selection == DialogButton.No)
 
-                 return;
 
-             BusyIndicatorVisibility = true;
 
-             InvokeClient.Instance.Service.DoOperation($"System.BackUpFileData");
 
-             DelayData(1500);
 
-         }
 
-         async void DelayData(int delayTime = 1000)
 
-         {
 
-             await WaitForResultsAsync(delayTime);
 
-             GetDataOfConfigItems();
 
-             BusyIndicatorVisibility = false;
 
-         }
 
-         private async Task WaitForResultsAsync(int delayTime)
 
-         {
 
-             // Simulate waiting for results using a delay
 
-             // In a real-world scenario, you might wait for an event or a specific condition
 
-             await Task.Delay(delayTime);
 
-             // Here you can add logic to check if the results are ready
 
-             // For example, polling or using a completion source
 
-         }
 
-         private void RollBackClick()
 
-         {
 
-             var selection = DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.WARNING,
 
-               $"If you want to RollBack, you must restart after RollBack!");
 
-             if (selection == DialogButton.No)
 
-                 return;
 
-             var selectItem = HistoryTableDatas.Where(a => a.IsSelect == true).Select(a => $"{a.ValueStr}@{a.Name}").FirstOrDefault();
 
-             if (selectItem == null)
 
-             {
 
-                 DialogBox.ShowWarning("Please select at least one");
 
-                 return;
 
-             }
 
-             InvokeClient.Instance.Service.DoOperation($"System.RollBackFileData", selectItem);
 
-             DelayData();
 
-         }
 
-         private void CompareClick()
 
-         {
 
-             var selection = DialogBox.ShowDialog(DialogButton.Yes | DialogButton.No, DialogType.CONFIRM,
 
-            $"Are you sure you want to Compare?");
 
-             if (selection == DialogButton.No)
 
-                 return;
 
-             var selectItems = HistoryTableDatas.Where(a => a.IsSelect == true).Select(a => $"{a.ValueStr}@{a.Name}").ToList();
 
-             InvokeClient.Instance.Service.DoOperation($"System.CompareFileData", string.Join(",", selectItems.ToArray()));
 
-             var windowManager = IoC.Get<IWindowManager>();
 
-             BackUpCompareViewModel backUpCompareViewModel = new BackUpCompareViewModel();
 
-             backUpCompareViewModel.SelectItemNames = HistoryTableDatas.Where(a => a.IsSelect == true).Select(a => $"{a.ValueStr}").ToList();
 
-             var rtn = (windowManager as WindowManager)?.ShowDialogWithTitle(backUpCompareViewModel, null, $"Compare View");
 
-         }
 
-         protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
 
-         {
 
-             base.InvokeAfterUpdateProperty(data);
 
-             //System位于AutoIdle/Idle/Init/ PM位于
 
-             IsAllEnable = this.Permission == 3 && (RtStatus == "Idle" || RtStatus == "AutoIdle" || RtStatus == "Init" || RtStatus == "Error") && (PM1EntityStatus == "Idle");
 
-         }
 
-         private bool CanRollBackClick()
 
-         {
 
-             bool isEnable = false;
 
-             if (HistoryTableDatas != null)
 
-             {
 
-                 int count = HistoryTableDatas.Count(p => p.IsSelect == true);
 
-                 if (count == 1)
 
-                 {
 
-                     isEnable = true;
 
-                 }
 
-             }
 
-             return isEnable;
 
-         }
 
-         private bool CanCompareClick()
 
-         {
 
-             bool isEnable = false;
 
-             if (HistoryTableDatas != null)
 
-             {
 
-                 int count = HistoryTableDatas.Count(p => p.IsSelect == true);
 
-                 if (0 < count && count <= 2)
 
-                 {
 
-                     isEnable = true;
 
-                 }
 
-             }
 
-             return isEnable;
 
-         }
 
-         private void GetDataOfConfigItems()
 
-         {
 
-             HistoryTableDatas.Clear();
 
-             if (AllFilesDatas == null || AllFilesDatas.Count == 0)
 
-             {
 
-                 return;
 
-             }
 
-             foreach (var item in AllFilesDatas["SC"])
 
-             {
 
-                 var nameStr = item.Split('@');
 
-                 var time = nameStr[0];
 
-                 var name = nameStr[1];
 
-                 HistoryTableDatas.Add(new PageDataView() { Name = name, ValueStr = time });
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |