diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs | 99 |
1 files changed, 83 insertions, 16 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index 164d37b74..458bc913a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -303,11 +303,66 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { - _machines = value; RaisePropertyChanged(nameof(Machines)); + _machines = value; + LoadFilteredMachines(); + RaisePropertyChanged(nameof(Machines)); } } + private ObservableCollection<MachineModel> _filteremachines; + /// <summary> + /// Gets or sets the Machines. + /// </summary> + public ObservableCollection<MachineModel> FilteredMachines + { + get + { + return _filteremachines; + } + + set + { + _filteremachines = value; RaisePropertyChanged(nameof(FilteredMachines)); + } + + } + + private bool _showWithData; + /// <summary> + /// Gets or sets the bool show with data only. + /// </summary> + public bool ShowWithData + { + get { return _showWithData; } + set { + if(_showWithData != value) + { + _showWithData = value; + RaisePropertyChangedAuto(); + LoadFilteredMachines(); + } + } + } + + private void LoadFilteredMachines() + { + if(_showWithData) + FilteredMachines = Machines.Where(x => x.HasRMLTest).OrderBy(x => x.LastUpdated).ToObservableCollection(); + else + { + FilteredMachines = Machines.OrderBy(x=>x.Name).ToObservableCollection(); + } + + } + + private bool _canEdit; + public bool CanEdit + { + get { return _canEdit; } + set { _canEdit = value; + RaisePropertyChangedAuto(); } + } //private MachineTestResultsTabs PreviosSelectedTab { get; set; } //private MachineTestResultsTabs _selectedTab; @@ -792,19 +847,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion - private bool _canEdit; - public bool CanEdit - { - get { return _canEdit; } - set { _canEdit = value; - RaisePropertyChangedAuto(); } - } + public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { _notification = notificationProvider; _authentication = authentication; _actionLogManager = actionLogManager; + _showWithData = false; BackToThreadExtensionViewsCommand = new RelayCommand(BackToThreadExtensionViews, () => IsFree); SaveCommand = new RelayCommand(Save, () => IsFree); @@ -853,7 +903,6 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels AddGlossLevelItemCommand = new RelayCommand(AddGlossLevelItem); EditGlossLevelItemCommand = new RelayCommand(EditGlossLevelItem); - } @@ -924,7 +973,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } } - private void LoadRmlProperties() + private void LoadRmlProperties() { Applications = _active_context.YarnApplications.ToObservableCollection(); Brands = _active_context.YarnBrands.ToObservableCollection(); @@ -942,12 +991,16 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels Texturing = _active_context.YarnTexturings.ToObservableCollection(); YarnTypes = _active_context.YarnTypes.ToObservableCollection(); IndustrySector = _active_context.YarnIndustrysectors.ToObservableCollection(); - Machines = ObservablesStaticCollections.Instance.Machines.Select(x => new MachineModel() + + var machines = new MachinesCollectionBuilder(_active_context).SetAll().WithConfiguration().Build(); + Machines = machines.Select(x => new MachineModel() { Guid = x.Guid, Name = x.Name, SerialNumber = x.SerialNumber, - IdsPacks = x.Configuration.IdsPacks.Where(z => !z.IsEmpty) + IdsPacks = x.Configuration.IdsPacks.Where(z => !z.IsEmpty), + LastUpdated = x.LastUpdated, + HasRMLTest = false }).ToObservableCollection(); } @@ -1014,12 +1067,13 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels guid = rml_extention.Guid; } + + + ActiveRML = await new RmlBuilder(_active_context).Set(SelectedRMLExtension.RMLGuid).WithLiquidFactors().BuildAsync(); + ActiveRMLExtension = await new RmlExtensionsBuilder(_active_context) .Set(guid) - .WithUser() .BuildAsync(); - - ActiveRML = new RmlBuilder(_active_context).Set(SelectedRMLExtension.RMLGuid).WithLiquidFactors().Build(); if (!String.IsNullOrEmpty(ActiveRML.Manufacturer) && false == Manufacturers.Any(x => x == ActiveRML.Manufacturer)) { @@ -1028,6 +1082,17 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels Manufacturers.Add(ActiveRML.Manufacturer); } + //var colorProcessParameters = _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == guid).Select(x=>x.MachineGuid).ToList(); + //var TestResultsCollection = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(guid).BuildAsync(); + //var test1 = TestResultsCollection.Select(x => x.MachineGuid).ToList(); + //var ColorCalibration = await new RMLExtensionColorCalibrationBuilder(_active_context).SetAll().ForRMLExtension(guid).WithTests().BuildAsync(); + //var test12 = ColorCalibration.Where(x=>x.RmlExtensionColorCalibrationsTests!= null && x.RmlExtensionColorCalibrationsTests.Count() > 0).Select(x => x.MachineGuid).ToList(); + //var testResults = await new RMLExtensionColorShadeBuilder(_active_context).SetAll().ForRMLExtension(guid).WithTests().BuildAsync(); + //var test13 = testResults.Where(x => x.RmlExtensionColorShadesTests != null && x.RmlExtensionColorShadesTests.Count() > 0).Select(x => x.MachineGuid).ToList(); + + //var ulist = colorProcessParameters.Union(test1).Union(test12).Union(test13).ToList(); + + var machineIdsHasTest = (from c in _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == guid) select new { MichineGUID = c.MachineGuid }). Union(from p in _active_context.RmlExtensionTestResults.Where(x => x.RmlsExtensionsGuid == guid) @@ -1035,9 +1100,11 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels if (machineIdsHasTest.Count > 0) { + ShowWithData = true; var MachineGuid = machineIdsHasTest.First().MichineGUID; Machines.Where(x => machineIdsHasTest.Any(y => y.MichineGUID == x.Guid)).ToList().ForEach(x => x.HasRMLTest = true); - SelectedMachine = Machines.First(x => x.Guid == MachineGuid); + LoadFilteredMachines(); + SelectedMachine = FilteredMachines.First(); } else { |
