aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.JobProgressTester.UI/MainWindowVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.JobProgressTester.UI/MainWindowVM.cs')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.JobProgressTester.UI/MainWindowVM.cs160
1 files changed, 0 insertions, 160 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.JobProgressTester.UI/MainWindowVM.cs b/Software/Visual_Studio/Utilities/Tango.JobProgressTester.UI/MainWindowVM.cs
deleted file mode 100644
index d21500685..000000000
--- a/Software/Visual_Studio/Utilities/Tango.JobProgressTester.UI/MainWindowVM.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data.Entity;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using Tango.BL;
-using Tango.BL.Builders;
-using Tango.BL.Entities;
-using Tango.Core;
-using Tango.Integration.Operation;
-using Tango.Logging;
-using Tango.PMR.Printing;
-using Tango.PPC.Jobs.ViewModels;
-using Tango.SharedUI;
-
-namespace Tango.JobProgressTester.UI
-{
- public class MainWindowVM : ViewModel
- {
- private DataSource _dataSource;
-
- private List<Job> _jobs;
- public List<Job> Jobs
- {
- get { return _jobs; }
- set { _jobs = value; RaisePropertyChangedAuto(); }
- }
-
- private Job _selectedJob;
- public Job SelectedJob
- {
- get { return _selectedJob; }
- set { _selectedJob = value; RaisePropertyChangedAuto(); OnSelectedJobChanged(); }
- }
-
- private Job _activeJob;
- public Job ActiveJob
- {
- get { return _activeJob; }
- set { _activeJob = value; RaisePropertyChangedAuto(); }
- }
-
- private JobProgressViewVM _jobProgressViewVM;
- public JobProgressViewVM JobProgressViewVM
- {
- get { return _jobProgressViewVM; }
- set { _jobProgressViewVM = value; RaisePropertyChangedAuto(); }
- }
-
- private JobHandler2 _jobHandler;
- public JobHandler2 JobHandler
- {
- get { return _jobHandler; }
- set { _jobHandler = value; RaisePropertyChangedAuto(); }
- }
-
- private double _progress;
- public double Progress
- {
- get { return _progress; }
- set { _progress = value; RaisePropertyChangedAuto(); OnProgressChanged(); }
- }
-
- public MainWindowVM()
- {
- Application.Current.MainWindow.ContentRendered += (_, __) => Init();
- }
-
- private async void Init()
- {
- LogManager.RegisterLogger(new VSOutputLogger());
-
- _dataSource = new DataSource()
- {
- Address = "localhost\\SQLPPC",
- Catalog = "Tango",
- IntegratedSecurity = true
- };
-
- try
- {
- IsFree = false;
- ObservablesContext.OverrideSettingsDataSource(_dataSource);
-
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- Jobs = await db.Jobs.ToListAsync();
- }
- }
- catch (Exception ex)
- {
- ShowError(ex.FlattenMessage());
- }
- finally
- {
- IsFree = true;
- }
- }
-
- private async void OnSelectedJobChanged()
- {
- if (SelectedJob != null)
- {
- try
- {
- IsFree = false;
-
- using (ObservablesContext db = ObservablesContext.CreateDefault())
- {
- ActiveJob = await new JobBuilder(db)
- .Set(SelectedJob)
- .WithConfiguration()
- .WithBrushStops()
- .WithRML()
- .WithSegments()
- .WithUser()
- .BuildAsync();
-
- JobHandler = new JobHandler2(() => { }, ActiveJob, null, ActiveJob.Rml.GetActiveProcessGroup().ProcessParametersTables.First(), JobHandlerModes.SettingUp);
-
- JobProgressViewVM = new JobProgressViewVM()
- {
- Job = ActiveJob,
- RunningJobStatus = JobHandler.Status,
- };
-
- Progress = 0.1;
- }
- }
- catch (Exception ex)
- {
- ShowError(ex.FlattenMessage());
- }
- finally
- {
- IsFree = true;
- }
- }
- }
-
- private void OnProgressChanged()
- {
- if(JobHandler != null)
- {
- JobHandler.RaiseStatusReceived(new JobStatus()
- {
- Progress = Progress,
- });
- }
-
- }
-
- private void ShowError(String message)
- {
- MessageBox.Show(Application.Current.MainWindow, message, "Job Progress Tester", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-}