From 89ffc630471605c4757b5854af3d73b5b75e98d6 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 14 Sep 2020 13:47:34 +0300 Subject: New thread loading wizard. --- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 97 ++-------------------- 1 file changed, 5 insertions(+), 92 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index 3b45a0c2b..05fb610c8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -236,102 +236,15 @@ namespace Tango.PPC.UI.ViewModels private void MachineOperator_ThreadLoadingStatusChanged(object sender, PMR.ThreadLoading.StartThreadLoadingResponse e) { - if (e.State == PMR.ThreadLoading.ThreadLoadingState.Preparing) - { - DisplayThreadLoading(); - } + //if (e.State == PMR.ThreadLoading.ThreadLoadingState.Preparing) + //{ + // DisplayThreadLoading(); + //} } private void MachineOperator_ThreadLoadingConfirmationRequired(object sender, ThreadLoadingConfirmationRequiredEventArgs e) { - DisplayThreadLoading(e); - } - - private async void DisplayThreadLoading(ThreadLoadingConfirmationRequiredEventArgs confirmationArgs = null) - { - if (_isThreadLoadingShown) return; - - _isThreadLoadingShown = true; - - LogManager.Log("Thread loading preparation/finalization detected, showing thread loading screen..."); - - if (!Settings.DisplayAutomaticThreadLoadingScreen) - { - _isThreadLoadingShown = false; - LogManager.Log("Thread loading screen disabled. skipping..."); - return; - } - - ThreadLoadingViewVM vm; - - try - { - LogManager.Log("Loading site rmls..."); - - List rmls = new List(); - - using (ObservablesContext db = ObservablesContext.CreateDefault()) - { - rmls = await new RmlsCollectionBuilder(db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().BuildListAsync(); - } - - var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid); - - if (confirmationArgs == null) - { - vm = new ThreadLoadingViewVM(MachineProvider); - } - else - { - vm = new ThreadLoadingViewVM(MachineProvider, confirmationArgs); - } - - vm.Rmls = rmls; - vm.SelectedRml = selectedRml != null ? selectedRml : rmls.FirstOrDefault(); - } - catch (Exception ex) - { - _isThreadLoadingShown = false; - LogManager.Log(ex, "Error initializing thread loading screen."); - return; - } - - InvokeUI(async () => - { - await NotificationProvider.ShowDialog(vm); - - _isThreadLoadingShown = false; - - LogManager.Log("Thread loading screen closed."); - - if (!vm.DialogResult) - { - LogManager.Log("Thread loading screen aborted by user. No operation was performed."); - return; - } - - try - { - if (vm.Result.IsCompleted) - { - await NotificationProvider.ShowSuccess("Thread loading completed successfully."); - } - else - { - await NotificationProvider.ShowError($"Thread loading failed due to the following reason:\n{vm.Result.FailedException.FlattenException()}"); - } - - if (vm.SelectedRml != null) - { - Settings.LoadedRmlGuid = vm.SelectedRml.Guid; - Settings.Save(); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error occurred after thread loading screen closed."); - } - }); +// DisplayThreadLoading(e); } #endregion } -- cgit v1.3.1