From bab9f04ae0f251acdb759e72fb54d84d042c533e Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 1 Nov 2021 19:44:34 +0200 Subject: Added Ha Amma spool support via sites. --- .../Tango.PPC.MachineSettings.csproj | 2 +- .../ViewModels/MainViewVM.cs | 45 +++++++++++++++++++--- .../Tango.PPC.MachineSettings/Views/MainView.xaml | 4 +- 3 files changed, 42 insertions(+), 9 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj index d6bacb50c..30e2bf8c2 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj @@ -170,7 +170,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index bba5c2e7d..c5e4d46e7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Data; using Tango.BL; +using System.Data.Entity; using Tango.BL.Builders; using Tango.BL.Entities; using Tango.BL.Enumerations; @@ -107,6 +108,13 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _rmls = value; RaisePropertyChangedAuto(); } } + private ObservableCollection _spoolTypes; + public ObservableCollection SpoolTypes + { + get { return _spoolTypes; } + set { _spoolTypes = value; RaisePropertyChangedAuto(); } + } + private bool _enableHotSpot; public bool EnableHotSpot { @@ -170,11 +178,11 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _defaultRML = value; RaisePropertyChangedAuto(); } } - private SpoolType _defaultSpoolType; - public SpoolType DefaultSpoolType + private SpoolType _selectedSpoolType; + public SpoolType SelectedSpoolType { - get { return _defaultSpoolType; } - set { _defaultSpoolType = value; RaisePropertyChangedAuto(); } + get { return _selectedSpoolType; } + set { _selectedSpoolType = value; RaisePropertyChangedAuto(); } } private bool _synchronizeJobs; @@ -303,7 +311,7 @@ namespace Tango.PPC.MachineSettings.ViewModels Settings.LockScreenTimeout = TimeSpan.FromMinutes(LockScreenTimeoutMinutes); Settings.LockScreenPassword = LockScreenPassword; Settings.DefaultRmlGuid = DefaultRML?.Guid; - Settings.DefaultSpoolTypeGuid = DefaultSpoolType?.Guid; + Settings.SpoolTypeGuid = SelectedSpoolType?.Guid; Settings.SynchronizeJobs = SynchronizeJobs; Settings.SynchronizeDiagnostics = SynchronizeDiagnostics; Settings.AutoCheckForUpdates = AutoCheckForUpdates; @@ -457,6 +465,26 @@ namespace Tango.PPC.MachineSettings.ViewModels using (ObservablesContext db = ObservablesContext.CreateDefault()) { Rmls = (await new RmlsCollectionBuilder(db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).OrderBy(x => x.FinalName).ToObservableCollection(); + + try + { + SpoolTypes = (await db.SitesSpoolTypes.Where(x => x.SiteGuid == MachineProvider.Machine.SiteGuid).Include(x => x.SpoolType).Select(x => x.SpoolType).ToListAsync()).OrderBy(x => x.LastUpdated).ToObservableCollection(); + + if (SpoolTypes.Count == 0) + { + SpoolTypes = new ObservableCollection(); + var standardSpool = await db.SpoolTypes.FirstOrDefaultAsync(x => x.Code == (int)BL.Enumerations.SpoolTypes.StandardSpool); + if (standardSpool != null) + { + SpoolTypes.Add(standardSpool); + } + } + + } + catch (Exception ex) + { + LogManager.Log(ex, "Error getting machine site spool types."); + } } } @@ -489,7 +517,12 @@ namespace Tango.PPC.MachineSettings.ViewModels SelectedColorSpaces = new SelectedObjectCollection(Enum.GetValues(typeof(ColorSpaces)).Cast().Where(x => x.IsUserSpace()).ToObservableCollection(), Settings.SupportedColorSpaces.ToObservableCollection()); DefaultRML = Rmls.SingleOrDefault(x => x.Guid == Settings.DefaultRmlGuid); - DefaultSpoolType = Adapter.SpoolTypes.SingleOrDefault(x => x.Guid == Settings.DefaultSpoolTypeGuid); + SelectedSpoolType = SpoolTypes.SingleOrDefault(x => x.Guid == Settings.SpoolTypeGuid); + + if (SelectedSpoolType == null) + { + SelectedSpoolType = SpoolTypes.FirstOrDefault(x => x.Code == (int)BL.Enumerations.SpoolTypes.StandardSpool); + } SynchronizeJobs = Settings.SynchronizeJobs; SynchronizeDiagnostics = Settings.SynchronizeDiagnostics; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 7e67bbf99..0eb93cc45 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -154,8 +154,8 @@ Default Thread - Default Spool - + Spool Type + Default Segment Length -- cgit v1.3.1