From 76cdf188e28544cd5056c30f35d77590d9a79cae Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 20 Dec 2019 21:34:50 +0200 Subject: Improvements to ActionLogs. Implemented ActionLogs for hw comparison. --- .../ViewModels/MainViewVM.cs | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 9a80eb9d9..7c95ce270 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -16,6 +16,9 @@ using Tango.Core.ExtensionMethods; using Tango.MachineStudio.HardwareDesigner.Views; using Microsoft.Win32; using System.IO; +using Tango.BL.ActionLogs; +using Tango.MachineStudio.Common.Authentication; +using Tango.BL.DTO; namespace Tango.MachineStudio.HardwareDesigner.ViewModels { @@ -24,6 +27,9 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels private INotificationProvider _notification; private bool _isNew; private ObservablesContext _db; + private IActionLogManager _actionLogManager; + private IAuthenticationProvider _authentication; + private HardwareVersionDTO _hwBeforeSave; private HardwareVersion _selectedVersion; public HardwareVersion SelectedVersion @@ -45,6 +51,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels get { return _selectedHardwareObject; } set { + _selectedHardwareObject = null; + RaisePropertyChangedAuto(); _selectedHardwareObject = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(SelectedHardwareObjectTypeName)); @@ -113,9 +121,11 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels public RelayCommand ImportHardwareVersionCommand { get; set; } - public MainViewVM(INotificationProvider notification) + public MainViewVM(INotificationProvider notification, IActionLogManager actionLogManager, IAuthenticationProvider authentication) { _notification = notification; + _actionLogManager = actionLogManager; + _authentication = authentication; CurrentVersion = new HardwareVersion(); @@ -337,6 +347,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels }); CurrentVersion.HardwareBreakSensors = CurrentVersion.HardwareBreakSensors.OrderBy(x => x.HardwareBreakSensorType.Code).ToSynchronizedObservableCollection(); + + _hwBeforeSave = HardwareVersionDTO.FromObservable(CurrentVersion); }); } @@ -391,6 +403,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels _db.HardwareVersions.Add(CurrentVersion); _db.SaveChanges(); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionCreated, _authentication.CurrentUser, CurrentVersion.Name, CurrentVersion, "New hardware version created using Machine Studio."); + RefreshVersions(); InvokeUI(() => @@ -420,6 +434,11 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels { CurrentVersion.LastUpdated = DateTime.UtcNow; _db.SaveChanges(); + + var dtoAfter = HardwareVersionDTO.FromObservable(CurrentVersion); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionSaved, _authentication.CurrentUser, CurrentVersion.Name, _hwBeforeSave, dtoAfter, "Hardware Version saved using Machine Studio."); + _hwBeforeSave = dtoAfter; + RefreshVersions(); InvokeUI(() => @@ -461,6 +480,9 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels cloned.Version = HardwareVersions.Max(x => x.Version) + 1; _db.HardwareVersions.Add(cloned); _db.SaveChanges(); + + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionCreated, _authentication.CurrentUser, cloned.Name, cloned, "New hardware version created (cloned) using Machine Studio."); + RefreshVersions(); InvokeUI(() => @@ -496,6 +518,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels await CurrentVersion.DeleteCascadeAsync(_db); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionDeleted, _authentication.CurrentUser, CurrentVersion.Name, _hwBeforeSave, "Hardware version deleted using Machine Studio.", true); + await Task.Factory.StartNew(() => { SelectedVersion = null; -- cgit v1.3.1 From 582c05b00aa1d0fd9086b4a245dcc987eee9fc39 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 21 Dec 2019 19:14:00 +0200 Subject: Working some more on ActionLogs across MS. --- .../ViewModels/MainViewVM.cs | 4 +-- .../ViewModels/MainViewVM.cs | 10 +++--- .../ViewModels/MainViewVM.cs | 6 ++-- .../ViewModels/MainViewVM.cs | 32 +++++++++++++++-- .../ViewModels/MainViewVM.cs | 28 ++++++++++++++- .../ViewModels/MainViewVM.cs | 13 +++++-- .../ViewModels/SiteDetailsViewVM.cs | 42 +++++++++++++++++++--- Software/Visual_Studio/Tango.BL/DTO/CatDTO.cs | 10 ++++++ .../Visual_Studio/Tango.BL/DTO/ConfigurationDTO.cs | 21 +++++++++++ Software/Visual_Studio/Tango.BL/DTO/IdsPackDTO.cs | 25 ++++++++++--- Software/Visual_Studio/Tango.BL/DTO/MachineDTO.cs | 16 +++++++++ Software/Visual_Studio/Tango.BL/DTO/RmlDTO.cs | 4 +++ Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs | 25 +++++++++++++ Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs | 6 +++- Software/Visual_Studio/Tango.BL/DTO/SpoolDTO.cs | 7 ++++ .../Tango.BL/Enumerations/ActionLogType.cs | 6 ++++ .../Controllers/PPCController.cs | 2 ++ 17 files changed, 230 insertions(+), 27 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs index ae763167b..e306d0997 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs @@ -244,7 +244,7 @@ namespace Tango.MachineStudio.Catalogs.ViewModels { IsFree = false; await SelectedCatalog.DeleteCascadeAsync(_catalogsContext); - _actionLogManager.InsertLog(ActionLogType.CatalogDeleted, _authentication.CurrentUser, SelectedCatalog.Name, SelectedCatalog, "Catalog deleted using Machine Studio."); + _actionLogManager.InsertLog(ActionLogType.CatalogDeleted, _authentication.CurrentUser, SelectedCatalog.Name, SelectedCatalog, "Catalog deleted using Machine Studio.", false); SelectedCatalog = null; } catch (Exception ex) @@ -322,7 +322,7 @@ namespace Tango.MachineStudio.Catalogs.ViewModels await _activeCatalogContext.SaveChangesAsync(); var activeCatalogDTO = ColorCatalogDTO.FromObservable(ActiveCatalog); - _actionLogManager.InsertLog(ActionLogType.CatalogSaved, _authentication.CurrentUser, ActiveCatalog.Name, _catalogBeforeSave, activeCatalogDTO, "Catalog created using Machine Studio."); + _actionLogManager.InsertLog(ActionLogType.CatalogSaved, _authentication.CurrentUser, _catalogBeforeSave.Name, _catalogBeforeSave, activeCatalogDTO, "Catalog created using Machine Studio."); _catalogBeforeSave = activeCatalogDTO; await LoadCatalogs(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 8b235a13a..a641c87b6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1726,6 +1726,8 @@ namespace Tango.MachineStudio.Developer.ViewModels using (_notification.PushTaskItem("Saving Parameters Group...")) { + var processGroupBefore = ProcessParametersTablesGroupDTO.FromObservable(SelectedRML.GetActiveProcessGroup()); + using (var db = ObservablesContext.CreateDefault()) { var active_groups = db.ProcessParametersTablesGroups.Where(x => x.RmlGuid == SelectedRML.Guid && x.Active).ToList(); @@ -1753,8 +1755,6 @@ namespace Tango.MachineStudio.Developer.ViewModels tables.Add(newTable); } - var rmlBeforeDTO = RmlDTO.FromObservable(SelectedRML); - group.Active = true; group.ProcessParametersTables = tables.ToSynchronizedObservableCollection(); group.Rml = SelectedRML; @@ -1769,7 +1769,7 @@ namespace Tango.MachineStudio.Developer.ViewModels SelectedRML.ProcessParametersTablesGroups.Add(group); await SelectedRML.SaveAsync(_activeJobDbContext); - _actionLogManager.InsertLog(ActionLogType.RmlSaved, AuthenticationProvider.CurrentUser, SelectedRML.Name, rmlBeforeDTO, RmlDTO.FromObservable(SelectedRML), "Active process parameters changed from Machine Studio Research module."); + _actionLogManager.InsertLog(ActionLogType.RmlActiveProcessParametersChanged, AuthenticationProvider.CurrentUser, SelectedRML.Name, processGroupBefore, ProcessParametersTablesGroupDTO.FromObservable(SelectedRML.GetActiveProcessGroup()), "RML Active process parameters changed from Machine Studio Research module."); InvalidateLiquidFactorsAndProcessTables(); } @@ -2421,7 +2421,7 @@ namespace Tango.MachineStudio.Developer.ViewModels foreach (var job in SelectedJobs) { - _actionLogManager.InsertLog(ActionLogType.JobCreated, AuthenticationProvider.CurrentUser, job.Name, job, "Job created using Machine Studio."); + _actionLogManager.InsertLog(ActionLogType.JobCreated, AuthenticationProvider.CurrentUser, job.Name, job, "Job cloned using Machine Studio."); } CanWork = true; @@ -2664,7 +2664,7 @@ namespace Tango.MachineStudio.Developer.ViewModels foreach (var job in jobsToReport) { - _actionLogManager.InsertLog(ActionLogType.JobImported, AuthenticationProvider.CurrentUser, job.Name, job, "New job imported using Machine Studio."); + _actionLogManager.InsertLog(ActionLogType.JobImported, AuthenticationProvider.CurrentUser, job.Name, job, "Job imported using Machine Studio."); } IsFree = true; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 7c95ce270..0a8780346 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -193,6 +193,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels _db.HardwareVersions.Add(hv); await _db.SaveChangesAsync(); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionImported, _authentication.CurrentUser, CurrentVersion.Name, CurrentVersion, "New hardware version imported using Machine Studio."); + RefreshVersions(); InvokeUI(() => @@ -436,7 +438,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels _db.SaveChanges(); var dtoAfter = HardwareVersionDTO.FromObservable(CurrentVersion); - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionSaved, _authentication.CurrentUser, CurrentVersion.Name, _hwBeforeSave, dtoAfter, "Hardware Version saved using Machine Studio."); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionSaved, _authentication.CurrentUser, _hwBeforeSave.Name, _hwBeforeSave, dtoAfter, "Hardware Version saved using Machine Studio."); _hwBeforeSave = dtoAfter; RefreshVersions(); @@ -481,7 +483,7 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels _db.HardwareVersions.Add(cloned); _db.SaveChanges(); - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionCreated, _authentication.CurrentUser, cloned.Name, cloned, "New hardware version created (cloned) using Machine Studio."); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.HardwareVersionCreated, _authentication.CurrentUser, cloned.Name, cloned, "New hardware version cloned using Machine Studio."); RefreshVersions(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index fd31cd950..7b6ae7ef0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -25,14 +25,21 @@ using Tango.Core.Threading; using Tango.MachineStudio.RML.ViewModels; using Tango.Settings; using Tango.MachineStudio.RML.Models; +using Tango.BL.ActionLogs; +using Tango.MachineStudio.Common.Authentication; +using Tango.BL.DTO; namespace Tango.MachineStudio.MachineDesigner.ViewModels { public class MainViewVM : StudioViewModel { private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + private IAuthenticationProvider _authentication; private ActionTimer _machines_action_timer; private ActionTimer _dispensers_action_timer; + private MachineDTO _machineBeforeSave; + private bool _isNewMachine; #region Properties @@ -233,10 +240,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// /// Initializes a new instance of the class. /// - public MainViewVM(INotificationProvider notification) + public MainViewVM(INotificationProvider notification, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { MachinesAdapter = new ObservablesStaticCollections(ObservablesContext.CreateDefault()); _notification = notification; + _authentication = authentication; + _actionLogManager = actionLogManager; _machines_action_timer = new ActionTimer(TimeSpan.FromMilliseconds(200)); _dispensers_action_timer = new ActionTimer(TimeSpan.FromMilliseconds(200)); @@ -428,6 +437,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private async void LoadSelectedMachine(bool newMachine = false, bool clone = false, MachineVersion selectedVersion = null) { + _isNewMachine = false; + using (_notification.PushTaskItem("Loading machine details...")) { try @@ -462,9 +473,12 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels if (!newMachine) { ActiveMachine = (await new MachineBuilder(ActiveMachineAdapter.Context).Set(SelectedMachine.Guid).WithOrganization().WithConfiguration().WithSpools().BuildAsync()); + _machineBeforeSave = MachineDTO.FromObservable(ActiveMachine); + if (clone) { + _isNewMachine = true; ActiveMachine = ActiveMachine.Clone(); ActiveMachine.Name = ""; ActiveMachine.SerialNumber = ""; @@ -476,6 +490,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } else { + _isNewMachine = true; + if (selectedVersion == null) { ActiveMachine = new Machine(); @@ -668,16 +684,25 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.ConfigurationGuid = ActiveMachine.Configuration.Guid; ActiveMachine.LastUpdated = DateTime.UtcNow; - ActiveMachine.ProductionDate = DateTime.UtcNow; ActiveMachine.SiteGuid = SelectedSite == null ? null : (SelectedSite.ID == -1 ? null : SelectedSite.Guid); ColorCalibrationViewVM.Save(); var hwConfig = HardwareConfigurationViewVM.GetResultingHardwareConfiguration(); ActiveMachine.Configuration.SetHardwareConfiguration(hwConfig); - await ActiveMachineAdapter.Context.SaveChangesAsync(); + if (_isNewMachine) + { + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.MachineCreated, _authentication.CurrentUser, ActiveMachine.Name, ActiveMachine, "New machine created using Machine Studio."); + } + else + { + var machineAfterDTO = MachineDTO.FromObservable(ActiveMachine); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.MachineSaved, _authentication.CurrentUser, _machineBeforeSave.Name, _machineBeforeSave, machineAfterDTO, "Machine saved using Machine Studio."); + _machineBeforeSave = machineAfterDTO; + } + if (SelectedMachine != null) { await SelectedMachine.Reload(MachinesAdapter.Context); @@ -725,6 +750,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels IsFree = false; await SelectedMachine.DeleteCascadeAsync(MachinesAdapter.Context); MachinesAdapter.Context.Machines.Remove(SelectedMachine); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.MachineDeleted, _authentication.CurrentUser, SelectedMachine.Name, SelectedMachine, "Machine deleted using Machine Studio."); } catch (Exception ex) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index 9939e4876..527159aa5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -21,12 +21,18 @@ using Tango.MachineStudio.RML.Views; using Tango.PMR.ColorLab; using System.Data.Entity; using Tango.Core.ExtensionMethods; +using Tango.MachineStudio.Common.Authentication; +using Tango.BL.ActionLogs; +using Tango.BL.DTO; namespace Tango.MachineStudio.RML.ViewModels { public class MainViewVM : StudioViewModel { private INotificationProvider _notification; + private IAuthenticationProvider _authentication; + private IActionLogManager _actionLogManager; + private RmlDTO _rmlBeforeSave; private ObservablesContext _rmls_context; private ObservablesContext _active_context; @@ -185,9 +191,11 @@ namespace Tango.MachineStudio.RML.ViewModels public RelayCommand ImportRMLFileCommand { get; set; } - public MainViewVM(INotificationProvider notificationProvider) + public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { _notification = notificationProvider; + _authentication = authentication; + _actionLogManager = actionLogManager; ManageRmlCommand = new RelayCommand(() => LoadActiveRML(SelectedRML.Guid), () => SelectedRML != null); RemoveRmlCommand = new RelayCommand(RemoveSelectedRml, () => SelectedRML != null); CloneRmlCommand = new RelayCommand(CloneSelectedRml, () => SelectedRML != null); @@ -334,6 +342,8 @@ namespace Tango.MachineStudio.RML.ViewModels LiquidTypesRmls = LiquidTypesRmls, }; + _rmlBeforeSave = RmlDTO.FromObservable(ActiveRML); + View.NavigateTo(RmlNavigationView.RmlView); InvalidateRelayCommands(); @@ -423,6 +433,9 @@ namespace Tango.MachineStudio.RML.ViewModels _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]); _active_context.Rmls.Add(rml); await _active_context.SaveChangesAsync(); + + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlCreated, _authentication.CurrentUser, rml.Name, rml, "Rml created using Machine Studio."); + LoadActiveRML(rml.Guid); IsFree = true; @@ -441,6 +454,9 @@ namespace Tango.MachineStudio.RML.ViewModels try { await SelectedRML.DeleteCascadeAsync(_rmls_context); + + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlDeleted, _authentication.CurrentUser, SelectedRML.Name, SelectedRML, "RML deleted from Machine Studio."); + LoadRmls(); } catch (Exception ex) @@ -504,6 +520,8 @@ namespace Tango.MachineStudio.RML.ViewModels context.Rmls.Add(cloned); await context.SaveChangesAsync(); + + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlCreated, _authentication.CurrentUser, cloned.Name, cloned, "RML cloned from Machine Studio."); } LoadRmls(); @@ -665,7 +683,13 @@ namespace Tango.MachineStudio.RML.ViewModels } } + var rmlAfter = RmlDTO.FromObservable(ActiveRML); + await _active_context.SaveChangesAsync(); + + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlSaved, _authentication.CurrentUser, _rmlBeforeSave.Name, _rmlBeforeSave, rmlAfter, "RML saved using Machine Studio."); + + _rmlBeforeSave = rmlAfter; } } catch (Exception ex) @@ -804,6 +828,8 @@ namespace Tango.MachineStudio.RML.ViewModels var rmlFile = await Rml.FromRmlFile(db, json); db.Rmls.Add(rmlFile); + + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlImported, _authentication.CurrentUser, rmlFile.Name, rmlFile, "RML imported from Machine Studio."); } await db.SaveChangesAsync(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs index 486c8b46f..bcbcb6d16 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs @@ -5,10 +5,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL; +using Tango.BL.ActionLogs; using Tango.BL.Entities; using Tango.Core.Commands; using Tango.Core.Threading; using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Sites.Contracts; using Tango.MachineStudio.Sites.Models; @@ -19,6 +21,8 @@ namespace Tango.MachineStudio.Sites.ViewModels { private ObservablesContext _db; private INotificationProvider _notification; + private IAuthenticationProvider _authentication; + private IActionLogManager _actionLogManager; private ActionTimer _filter_timer; private List _sites; @@ -57,9 +61,11 @@ namespace Tango.MachineStudio.Sites.ViewModels public RelayCommand BackToSitesCommand { get; set; } - public MainViewVM(INotificationProvider notificationProvider) + public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { _notification = notificationProvider; + _authentication = authentication; + _actionLogManager = actionLogManager; _filter_timer = new ActionTimer(TimeSpan.FromMilliseconds(500)); ManageSiteCommand = new RelayCommand(() => LoadSelectedSite(), () => SelectedSite != null); @@ -82,6 +88,7 @@ namespace Tango.MachineStudio.Sites.ViewModels var site = _db.Sites.SingleOrDefault(x => x.Guid == SelectedSite.Guid); site.Delete(_db); _db.SaveChanges(); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteDeleted, _authentication.CurrentUser, site.Name, site, "Site deleted using Machine Studio."); Sites.Remove(SelectedSite); LoadSites(); }); @@ -110,7 +117,7 @@ namespace Tango.MachineStudio.Sites.ViewModels IsFree = false; SiteDetailsViewVM = new SiteDetailsViewVM(); SiteDetailsViewVM.Saved += SiteDetailsViewVM_Saved; - await SiteDetailsViewVM.Init(SelectedSite?.Guid, _notification, true, name); + await SiteDetailsViewVM.Init(SelectedSite?.Guid, _notification, _authentication, _actionLogManager, true, name); View.NavigateTo(SitesNavigationView.SiteDetailsView); } } @@ -134,7 +141,7 @@ namespace Tango.MachineStudio.Sites.ViewModels IsFree = false; SiteDetailsViewVM = new SiteDetailsViewVM(); SiteDetailsViewVM.Saved += SiteDetailsViewVM_Saved; - await SiteDetailsViewVM.Init(SelectedSite.Guid, _notification, false); + await SiteDetailsViewVM.Init(SelectedSite.Guid, _notification, _authentication, _actionLogManager, false); View.NavigateTo(SitesNavigationView.SiteDetailsView); } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs index 0e4dcbb47..73d4c49cb 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs @@ -10,6 +10,9 @@ using Tango.SharedUI; using Tango.SharedUI.Components; using System.Data.Entity; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.Authentication; +using Tango.BL.ActionLogs; +using Tango.BL.DTO; namespace Tango.MachineStudio.Sites.ViewModels { @@ -17,6 +20,10 @@ namespace Tango.MachineStudio.Sites.ViewModels { private ObservablesContext _db; private INotificationProvider _notification; + private IAuthenticationProvider _authentication; + private IActionLogManager _actionLogManager; + private bool _isNew; + private SiteDTO _siteBeforeSave; public event EventHandler Saved; @@ -69,9 +76,11 @@ namespace Tango.MachineStudio.Sites.ViewModels SaveCommand = new RelayCommand(Save, () => IsFree); } - public async Task Init(String siteGuid, INotificationProvider notification, bool isNew, string newSiteName = null) + public async Task Init(String siteGuid, INotificationProvider notification, IAuthenticationProvider authentication, IActionLogManager actionLogManager, bool isNew, string newSiteName = null) { _notification = notification; + _authentication = authentication; + _actionLogManager = actionLogManager; _db = ObservablesContext.CreateDefault(); Organizations = await _db.Organizations.ToListAsync(); @@ -82,9 +91,12 @@ namespace Tango.MachineStudio.Sites.ViewModels Site.Name = newSiteName; Site.Description = "My site description"; _db.Sites.Add(Site); + + _isNew = true; } else { + _isNew = false; Site = await _db.Sites.SingleOrDefaultAsync(x => x.Guid == siteGuid); } @@ -100,6 +112,8 @@ namespace Tango.MachineStudio.Sites.ViewModels Catalogs = new SelectedObjectCollection(catalogs.ToObservableCollection(), catalogs.Where(catalog => site_catalogs.Exists(siteCatalog => siteCatalog.CatalogGuid == catalog.Guid)).ToObservableCollection()); SelectedOrganization = Organizations.SingleOrDefault(x => x.Guid == Site.OrganizationGuid); + + _siteBeforeSave = SiteDTO.FromObservable(Site, site_rmls, site_catalogs, SelectedOrganization.Name); } private async void Save() @@ -121,20 +135,38 @@ namespace Tango.MachineStudio.Sites.ViewModels var site_rmls = await _db.SitesRmls.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); var site_catalogs = await _db.SitesCatalogs.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); - _db.SitesRmls.RemoveRange(site_rmls); - _db.SitesCatalogs.RemoveRange(site_catalogs); + //_db.SitesRmls.RemoveRange(site_rmls); + //_db.SitesCatalogs.RemoveRange(site_catalogs); + + //Remove site rmls. + site_rmls.ToList().Where(x => !Rmls.SynchedSource.ToList().Exists(y => y.Guid == x.RmlGuid)).ToList().ForEach(x => _db.SitesRmls.Remove(x)); + site_catalogs.ToList().Where(x => !Catalogs.SynchedSource.ToList().Exists(y => y.Guid == x.CatalogGuid)).ToList().ForEach(x => _db.SitesCatalogs.Remove(x)); - foreach (var selectedRml in Rmls.SynchedSource) + foreach (var selectedRml in Rmls.SynchedSource.Where(x => !site_rmls.Exists(y => y.RmlGuid == x.Guid))) { _db.SitesRmls.Add(new SitesRml() { SiteGuid = Site.Guid, RmlGuid = selectedRml.Guid }); } - foreach (var selectedCatalog in Catalogs.SynchedSource) + foreach (var selectedCatalog in Catalogs.SynchedSource.Where(x => !site_catalogs.Exists(y => y.CatalogGuid == x.Guid))) { _db.SitesCatalogs.Add(new SitesCatalog() { SiteGuid = Site.Guid, CatalogGuid = selectedCatalog.Guid }); } await _db.SaveChangesAsync(); + + var final_site_rmls = _db.SitesRmls.ToList(); + var final_site_catalogs = _db.SitesCatalogs.ToList(); + + if (_isNew) + { + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteCreated, _authentication.CurrentUser, Site.Name, Site, "Site created using Machine Studio."); + } + else + { + SiteDTO siteAfter = SiteDTO.FromObservable(Site, final_site_rmls, final_site_catalogs, SelectedOrganization.Name); + _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteSaved, _authentication.CurrentUser, _siteBeforeSave.Name, _siteBeforeSave, siteAfter, "Site saved using Machine Studio."); + _siteBeforeSave = siteAfter; + } } _db.Dispose(); Saved?.Invoke(this, new EventArgs()); diff --git a/Software/Visual_Studio/Tango.BL/DTO/CatDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/CatDTO.cs index 43d24848b..b5dc8e264 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/CatDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/CatDTO.cs @@ -4,11 +4,21 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { public class CatDTO : CatDTOBase { + [ObservableDTOProperty(MapsTo = nameof(Cat.LiquidType) + "." + nameof(Cat.LiquidType.Name))] + public String LiquidTypeName { get; set; } + [ObservableDTOProperty(MapsTo = nameof(Cat.Rml) + "." + nameof(Cat.Rml.Name))] + public String RmlName { get; set; } + + protected override string OnGetActionLogName() + { + return $"'{RmlName}' => '{LiquidTypeName}' Calibration"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/ConfigurationDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/ConfigurationDTO.cs index 605a905db..75049fa88 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/ConfigurationDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/ConfigurationDTO.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { @@ -11,9 +12,29 @@ namespace Tango.BL.DTO { public List IdsPacks { get; set; } + [ObservableDTOProperty(MapsTo = nameof(Configuration.ApplicationDisplayPanelVersion) + "." + nameof(Configuration.ApplicationDisplayPanelVersion.Name))] + public String ApplicationDisplayPanelVersionName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(Configuration.ApplicationFirmwareVersion) + "." + nameof(Configuration.ApplicationFirmwareVersion.Name))] + public String ApplicationFirmwareVersionName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(Configuration.ApplicationOsVersion) + "." + nameof(Configuration.ApplicationOsVersion.Name))] + public String ApplicationOsVersionName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(Configuration.EmbeddedFirmwareVersion) + "." + nameof(Configuration.EmbeddedFirmwareVersion.Name))] + public String EmbeddedFirmwareVersionName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(Configuration.HardwareVersion) + "." + nameof(Configuration.HardwareVersion.Name))] + public String HardwareVersionName { get; set; } + public ConfigurationDTO() { IdsPacks = new List(); } + + protected override string OnGetActionLogName() + { + return "Configuration"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/IdsPackDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/IdsPackDTO.cs index 3ca1e798b..071eb8bdf 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/IdsPackDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/IdsPackDTO.cs @@ -4,15 +4,30 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { public class IdsPackDTO : IdsPackDTOBase { - public CartridgeTypeDTO CartridgeType { get; set; } - public IdsPackFormulaDTO IdsPackFormula { get; set; } - public LiquidTypeDTO LiquidType { get; set; } - public MidTankTypeDTO MidTankType { get; set; } - public DispenserDTO Dispenser { get; set; } + [ObservableDTOProperty(MapsTo = nameof(IdsPack.CartridgeType) + "." + nameof(IdsPack.CartridgeType.Name))] + public String CartridgeTypeName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(IdsPack.IdsPackFormula) + "." + nameof(IdsPack.IdsPackFormula.Name))] + public String IdsPackFormulaName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(IdsPack.LiquidType) + "." + nameof(IdsPack.LiquidType.Name))] + public String LiquidTypeName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(IdsPack.MidTankType) + "." + nameof(IdsPack.MidTankType.Name))] + public String MidTankTypeName { get; set; } + + [ObservableDTOProperty(MapsTo = nameof(IdsPack.Dispenser) + "." + nameof(IdsPack.Dispenser.SerialNumber))] + public String DispenserSerialNumber { get; set; } + + protected override string OnGetActionLogName() + { + return $"IDS Pack '{PackIndex}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/MachineDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/MachineDTO.cs index 41eca6693..43535074d 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/MachineDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/MachineDTO.cs @@ -9,6 +9,22 @@ namespace Tango.BL.DTO { public class MachineDTO : MachineDTOBase { + public ConfigurationDTO Configuration { get; set; } + //This is a bit more complicated to support. + //public List Cats { get; set; } + + public List Spools { get; set; } + + public MachineDTO() + { + //Cats = new List(); + Spools = new List(); + } + + protected override string OnGetActionLogName() + { + return $"Machine '{SerialNumber}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlDTO.cs index a221a760c..8931a4b3e 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlDTO.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { @@ -13,6 +14,9 @@ namespace Tango.BL.DTO public List LiquidTypesRmls { get; set; } + [ObservableDTOProperty(MapsTo = nameof(Rml.Cct) + "." + nameof(Rml.Cct.FileName))] + public String CctFileName { get; set; } + public RmlDTO() { ProcessParametersTablesGroups = new List(); diff --git a/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs index 320de2763..2ba9ca693 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs @@ -4,11 +4,36 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { public class SiteDTO : SiteDTOBase { + public List SiteRmls { get; set; } + public List SiteCatalogs { get; set; } + + public String OrganizationName { get; set; } + + public SiteDTO() + { + SiteRmls = new List(); + SiteCatalogs = new List(); + } + + public static SiteDTO FromObservable(Site observable, IEnumerable siteRmls, IEnumerable siteCatalogs, String organizationName) + { + SiteDTO dto = FromObservable(observable); + dto.OrganizationName = organizationName; + dto.SiteRmls = siteRmls.Select(x => SitesRmlDTO.FromObservable(x)).ToList(); + dto.SiteCatalogs = siteCatalogs.Select(x => SitesCatalogDTO.FromObservable(x)).ToList(); + return dto; + } + + protected override string OnGetActionLogName() + { + return $"Site '{Name}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs index 527d710d0..0a5089072 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs @@ -4,11 +4,15 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { public class SitesRmlDTO : SitesRmlDTOBase { - + protected override string OnGetActionLogName() + { + return $"RML '{RmlGuid}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SpoolDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SpoolDTO.cs index bf25d1e71..d6d79b1be 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SpoolDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SpoolDTO.cs @@ -4,11 +4,18 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { public class SpoolDTO : SpoolDTOBase { + [ObservableDTOProperty(MapsTo = nameof(Spool.SpoolType) + "." + nameof(Spool.SpoolType.Name))] + public String SpoolTypeName { get; set; } + protected override string OnGetActionLogName() + { + return $"'{(SpoolTypeName != null ? SpoolTypeName : SpoolTypeGuid)}' Calibration"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs b/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs index 5114538ef..76c790a9f 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/ActionLogType.cs @@ -34,6 +34,8 @@ namespace Tango.BL.Enumerations HardwareVersionDeleted = 101, [Description("Hardware Version Saved")] HardwareVersionSaved = 102, + [Description("Hardware Version Imported")] + HardwareVersionImported = 103, //RML [Description("RML Created")] @@ -42,6 +44,10 @@ namespace Tango.BL.Enumerations RmlDeleted = 201, [Description("RML Saved")] RmlSaved = 202, + [Description("RML Imported")] + RmlImported = 203, + [Description("RML Active Process Parameters Changed")] + RmlActiveProcessParametersChanged = 204, //Jobs [Description("Job Created")] diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 10a732221..ade8f88bc 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -160,6 +160,8 @@ namespace Tango.MachineService.Controllers tangoUpdate.UpdateStatus = TangoUpdateStatuses.SetupStarted; db.TangoUpdates.Add(tangoUpdate); + machine.ProductionDate = DateTime.UtcNow; + db.SaveChanges(); _pendingUpdates.Add(new PPCPendingUpdate() -- cgit v1.3.1 From aeb55d27a8abf291913724fc1676ecbf27cb2c1a Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 21 Dec 2019 22:39:08 +0200 Subject: Refactored Site Rmls & Catalogs to FK. Implemented Sites & Site Builders. Implemented DTO's and ActionLogs. Changed SQLExaminer scripts accordingly. --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/TCC/TCC.mdf | Bin 8388608 -> 8388608 bytes Software/DB/TCC/TCC_log.ldf | Bin 8388608 -> 8388608 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../ViewModels/MainViewVM.cs | 1 + .../ViewModels/SiteDetailsViewVM.cs | 50 ++---- .../Views/SiteDetailsView.xaml | 2 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 2 +- .../Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 4 +- .../ViewModels/MainViewVM.cs | 2 +- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 6 +- .../Tango.BL/Builders/CatalogsCollectionBuilder.cs | 4 +- .../Tango.BL/Builders/RmlsCollectionBuilder.cs | 2 +- .../Visual_Studio/Tango.BL/Builders/SiteBuilder.cs | 58 +++++++ .../Tango.BL/Builders/SitesCollectionBuilder.cs | 42 +++++ Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs | 18 +- .../Visual_Studio/Tango.BL/DTO/SitesCatalogDTO.cs | 7 + .../Tango.BL/DTO/SitesCatalogDTOBase.cs | 4 +- Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs | 5 +- .../Tango.BL/Entities/ColorCatalogBase.cs | 38 ++++ .../Tango.BL/Entities/HardwareBlowerBase.cs | 4 + .../Tango.BL/Entities/OrganizationBase.cs | 38 ++++ .../Visual_Studio/Tango.BL/Entities/RmlBase.cs | 38 ++++ .../Visual_Studio/Tango.BL/Entities/SiteBase.cs | 121 +++++++++++++ .../Tango.BL/Entities/SitesCatalogBase.cs | 102 ++++++++++- .../Tango.BL/Entities/SitesRmlBase.cs | 88 ++++++++++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 4 +- .../Tango.DAL.Remote/DB/COLOR_CATALOGS.cs | 3 + .../Tango.DAL.Remote/DB/ORGANIZATION.cs | 3 + Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs | 3 + .../Tango.DAL.Remote/DB/RemoteADO.Designer.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 192 ++++++++++++++++++++- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 161 ++++++++--------- Software/Visual_Studio/Tango.DAL.Remote/DB/SITE.cs | 13 ++ .../Tango.DAL.Remote/DB/SITES_CATALOGS.cs | 5 +- .../Tango.DAL.Remote/DB/SITES_RMLS.cs | 3 + .../Configurations/ProvisionMachine.xml | Bin 87410 -> 87446 bytes .../SQLExaminer/Configurations/UpdateMachine.xml | Bin 54676 -> 54712 bytes 40 files changed, 874 insertions(+), 151 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/Builders/SiteBuilder.cs create mode 100644 Software/Visual_Studio/Tango.BL/Builders/SitesCollectionBuilder.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 4d696d2c1..5badddf75 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 9e60e0704..970fecb23 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf index 5746eb81e..183ae0d56 100644 Binary files a/Software/DB/TCC/TCC.mdf and b/Software/DB/TCC/TCC.mdf differ diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf index bb7c5c203..7e66b1381 100644 Binary files a/Software/DB/TCC/TCC_log.ldf and b/Software/DB/TCC/TCC_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 2b528cbe0..502353550 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 869e50d97..be848ac71 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs index bcbcb6d16..5db5e004d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Tango.BL; using Tango.BL.ActionLogs; +using Tango.BL.Builders; using Tango.BL.Entities; using Tango.Core.Commands; using Tango.Core.Threading; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs index 73d4c49cb..92dd8273d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs @@ -13,6 +13,7 @@ using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.Authentication; using Tango.BL.ActionLogs; using Tango.BL.DTO; +using Tango.BL.Builders; namespace Tango.MachineStudio.Sites.ViewModels { @@ -41,13 +42,6 @@ namespace Tango.MachineStudio.Sites.ViewModels set { _organizations = value; RaisePropertyChangedAuto(); } } - private Organization _selectedOrganization; - public Organization SelectedOrganization - { - get { return _selectedOrganization; } - set { _selectedOrganization = value; RaisePropertyChangedAuto(); } - } - private SelectedObjectCollection _rmls; public SelectedObjectCollection Rmls { @@ -97,31 +91,30 @@ namespace Tango.MachineStudio.Sites.ViewModels else { _isNew = false; - Site = await _db.Sites.SingleOrDefaultAsync(x => x.Guid == siteGuid); + Site = await new SiteBuilder(_db).Set(siteGuid) + .WithSiteCatalogs() + .WithCatalogs() + .WithSiteRmls() + .WithRmls() + .WithOrganization() + .BuildAsync(); } Machines = await _db.Machines.Where(x => x.SiteGuid == Site.Guid).Include(x => x.Organization).ToListAsync(); - var site_rmls = await _db.SitesRmls.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); - var site_catalogs = await _db.SitesCatalogs.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); - var rmls = await _db.Rmls.OrderBy(x => x.Name).ToListAsync(); var catalogs = await _db.ColorCatalogs.OrderBy(x => x.Name).ToListAsync(); - Rmls = new SelectedObjectCollection(rmls.ToObservableCollection(), rmls.Where(rml => site_rmls.Exists(siteRml => siteRml.RmlGuid == rml.Guid)).ToObservableCollection()); - Catalogs = new SelectedObjectCollection(catalogs.ToObservableCollection(), catalogs.Where(catalog => site_catalogs.Exists(siteCatalog => siteCatalog.CatalogGuid == catalog.Guid)).ToObservableCollection()); - - SelectedOrganization = Organizations.SingleOrDefault(x => x.Guid == Site.OrganizationGuid); + Rmls = new SelectedObjectCollection(rmls.ToObservableCollection(), Site.SitesRmls.Select(x => x.Rml).ToObservableCollection()); + Catalogs = new SelectedObjectCollection(catalogs.ToObservableCollection(), Site.SitesCatalogs.Select(x => x.ColorCatalog).ToObservableCollection()); - _siteBeforeSave = SiteDTO.FromObservable(Site, site_rmls, site_catalogs, SelectedOrganization.Name); + _siteBeforeSave = SiteDTO.FromObservable(Site); } private async void Save() { try { - Site.OrganizationGuid = SelectedOrganization?.Guid; - if (!Site.Validate(_db)) { _notification.ShowError(String.Join("\n", Site.ValidationErrors)); @@ -132,38 +125,29 @@ namespace Tango.MachineStudio.Sites.ViewModels using (_notification.PushTaskItem("Saving site details...")) { - var site_rmls = await _db.SitesRmls.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); - var site_catalogs = await _db.SitesCatalogs.Where(x => x.SiteGuid == Site.Guid).ToListAsync(); - - //_db.SitesRmls.RemoveRange(site_rmls); - //_db.SitesCatalogs.RemoveRange(site_catalogs); - //Remove site rmls. - site_rmls.ToList().Where(x => !Rmls.SynchedSource.ToList().Exists(y => y.Guid == x.RmlGuid)).ToList().ForEach(x => _db.SitesRmls.Remove(x)); - site_catalogs.ToList().Where(x => !Catalogs.SynchedSource.ToList().Exists(y => y.Guid == x.CatalogGuid)).ToList().ForEach(x => _db.SitesCatalogs.Remove(x)); + Site.SitesRmls.ToList().Where(x => !Rmls.SynchedSource.ToList().Exists(y => y.Guid == x.RmlGuid)).ToList().ForEach(x => _db.SitesRmls.Remove(x)); + Site.SitesCatalogs.ToList().Where(x => !Catalogs.SynchedSource.ToList().Exists(y => y.Guid == x.ColorCatalogGuid)).ToList().ForEach(x => _db.SitesCatalogs.Remove(x)); - foreach (var selectedRml in Rmls.SynchedSource.Where(x => !site_rmls.Exists(y => y.RmlGuid == x.Guid))) + foreach (var selectedRml in Rmls.SynchedSource.Where(x => !Site.SitesRmls.ToList().Exists(y => y.RmlGuid == x.Guid))) { _db.SitesRmls.Add(new SitesRml() { SiteGuid = Site.Guid, RmlGuid = selectedRml.Guid }); } - foreach (var selectedCatalog in Catalogs.SynchedSource.Where(x => !site_catalogs.Exists(y => y.CatalogGuid == x.Guid))) + foreach (var selectedCatalog in Catalogs.SynchedSource.Where(x => !Site.SitesCatalogs.ToList().Exists(y => y.ColorCatalogGuid == x.Guid))) { - _db.SitesCatalogs.Add(new SitesCatalog() { SiteGuid = Site.Guid, CatalogGuid = selectedCatalog.Guid }); + _db.SitesCatalogs.Add(new SitesCatalog() { SiteGuid = Site.Guid, ColorCatalogGuid = selectedCatalog.Guid }); } await _db.SaveChangesAsync(); - var final_site_rmls = _db.SitesRmls.ToList(); - var final_site_catalogs = _db.SitesCatalogs.ToList(); - if (_isNew) { _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteCreated, _authentication.CurrentUser, Site.Name, Site, "Site created using Machine Studio."); } else { - SiteDTO siteAfter = SiteDTO.FromObservable(Site, final_site_rmls, final_site_catalogs, SelectedOrganization.Name); + SiteDTO siteAfter = SiteDTO.FromObservable(Site); _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteSaved, _authentication.CurrentUser, _siteBeforeSave.Name, _siteBeforeSave, siteAfter, "Site saved using Machine Studio."); _siteBeforeSave = siteAfter; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml index b3496a5e2..182f05be0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml @@ -84,7 +84,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index 0175b949e..1b80eed35 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -468,7 +468,7 @@ namespace Tango.PPC.Jobs.ViewModels Job.ValidateOnPropertyChanged = true; LogManager.Log("Loading RMLS..."); - Rmls = (await new RmlsCollectionBuilder(_db).SetAll().WithActiveParametersGroup().WithCAT(Job.MachineGuid).WithCCT().WithLiquidFactors().WithSite(MachineProvider.Machine.SiteGuid).BuildAsync()).ToList(); + Rmls = (await new RmlsCollectionBuilder(_db).SetAll().WithActiveParametersGroup().WithCAT(Job.MachineGuid).WithCCT().WithLiquidFactors().ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).ToList(); LogManager.Log("Loading Color Spaces..."); ColorSpaces = await _db.ColorSpaces.ToListAsync(); LogManager.Log("Loading Spool Types..."); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index 109e3e27a..fb3818e41 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -736,8 +736,8 @@ namespace Tango.PPC.Jobs.ViewModels //Load catalogs. using (ObservablesContext db = ObservablesContext.CreateDefault()) { - _catalogs = await new CatalogsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildAsync(); - _rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildAsync(); + _catalogs = await new CatalogsCollectionBuilder(db).SetAll().ForSite(MachineProvider.Machine.SiteGuid).BuildAsync(); + _rmls = await new RmlsCollectionBuilder(db).SetAll().ForSite(MachineProvider.Machine.SiteGuid).BuildAsync(); } MachineDataSynchronizer.SynchronizationEnded += MachineDataSynchronizer_SynchronizationEnded; 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 5077fd884..8b48c51aa 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 @@ -235,7 +235,7 @@ namespace Tango.PPC.MachineSettings.ViewModels using (ObservablesContext db = ObservablesContext.CreateDefault()) { - Rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildAsync(); + Rmls = await new RmlsCollectionBuilder(db).SetAll().ForSite(MachineProvider.Machine.SiteGuid).BuildAsync(); } } 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 eeb11ffab..f78a7f334 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -118,7 +118,7 @@ namespace Tango.PPC.UI.ViewModels using (ObservablesContext db = ObservablesContext.CreateDefault()) { - rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).BuildListAsync(); + rmls = await new RmlsCollectionBuilder(db).SetAll().ForSite(MachineProvider.Machine.SiteGuid).BuildListAsync(); } var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid); @@ -156,7 +156,7 @@ namespace Tango.PPC.UI.ViewModels else { LogManager.Log("Selected minimal temperature..."); - var rmlsToAvg = new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().Build(); + var rmlsToAvg = new RmlsCollectionBuilder(db).SetAll().ForSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().Build(); processTables = rmlsToAvg.Select(x => x.GetActiveProcessGroup()).SelectMany(x => x.ProcessParametersTables).ToList(); } @@ -198,7 +198,7 @@ namespace Tango.PPC.UI.ViewModels using (ObservablesContext db = ObservablesContext.CreateDefault()) { - rmls = await new RmlsCollectionBuilder(db).SetAll().WithSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().BuildListAsync(); + rmls = await new RmlsCollectionBuilder(db).SetAll().ForSite(MachineProvider.Machine.SiteGuid).WithActiveParametersGroup().BuildListAsync(); } var selectedRml = rmls.SingleOrDefault(x => x.Guid == Settings.LoadedRmlGuid); diff --git a/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs index 9b24899c4..fb690eb99 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/CatalogsCollectionBuilder.cs @@ -14,13 +14,13 @@ namespace Tango.BL.Builders { } - public virtual CatalogsCollectionBuilder WithSite(String siteGuid) + public virtual CatalogsCollectionBuilder ForSite(String siteGuid) { return AddQueryStep(1, (query) => { if (siteGuid != null) { - var siteCatalogsGuids = Context.SitesCatalogs.Where(x => x.SiteGuid == siteGuid).ToList().Select(x => x.CatalogGuid).Where(x => x != null).Distinct().ToArray(); + var siteCatalogsGuids = Context.SitesCatalogs.Where(x => x.SiteGuid == siteGuid).ToList().Select(x => x.ColorCatalogGuid).Where(x => x != null).Distinct().ToArray(); if (siteCatalogsGuids.Length > 0) { diff --git a/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs index 9408d714b..b23eb9507 100644 --- a/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs +++ b/Software/Visual_Studio/Tango.BL/Builders/RmlsCollectionBuilder.cs @@ -14,7 +14,7 @@ namespace Tango.BL.Builders { } - public virtual RmlsCollectionBuilder WithSite(String siteGuid) + public virtual RmlsCollectionBuilder ForSite(String siteGuid) { return AddQueryStep(1, (query) => { diff --git a/Software/Visual_Studio/Tango.BL/Builders/SiteBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/SiteBuilder.cs new file mode 100644 index 000000000..938598fc6 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/SiteBuilder.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Data.Entity; +using Tango.BL.Entities; + +namespace Tango.BL.Builders +{ + public class SiteBuilder : EntityBuilderBase + { + public SiteBuilder(ObservablesContext context) : base(context) + { + + } + + public virtual SiteBuilder WithSiteCatalogs() + { + return AddQueryStep(1, (query) => + { + return query.Include(x => x.SitesCatalogs); + }); + } + + public virtual SiteBuilder WithCatalogs() + { + return AddQueryStep(2, (query) => + { + return query.Include(x => x.SitesCatalogs.Select(y => y.ColorCatalog)); + }); + } + + public virtual SiteBuilder WithSiteRmls() + { + return AddQueryStep(3, (query) => + { + return query.Include(x => x.SitesRmls); + }); + } + + public virtual SiteBuilder WithRmls() + { + return AddQueryStep(4, (query) => + { + return query.Include(x => x.SitesRmls.Select(y => y.Rml)); + }); + } + + public virtual SiteBuilder WithOrganization() + { + return AddQueryStep(5, (query) => + { + return query.Include(x => x.Organization); + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Builders/SitesCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/SitesCollectionBuilder.cs new file mode 100644 index 000000000..0c80b5a37 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/SitesCollectionBuilder.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class SitesCollectionBuilder : EntityCollectionBuilderBase + { + public SitesCollectionBuilder(ObservablesContext context) : base(context) + { + + } + + public virtual SitesCollectionBuilder WithSiteCatalogs() + { + return AddQueryStep(1, (query) => + { + return query.Include(x => x.SitesCatalogs); + }); + } + + public virtual SitesCollectionBuilder WithSiteRmls() + { + return AddQueryStep(2, (query) => + { + return query.Include(x => x.SitesRmls); + }); + } + + public virtual SitesCollectionBuilder WithOrganization() + { + return AddQueryStep(3, (query) => + { + return query.Include(x => x.Organization); + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs index 2ba9ca693..4d09bda9c 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SiteDTO.cs @@ -10,25 +10,17 @@ namespace Tango.BL.DTO { public class SiteDTO : SiteDTOBase { - public List SiteRmls { get; set; } + public List SitesRmls { get; set; } - public List SiteCatalogs { get; set; } + public List SitesCatalogs { get; set; } + [ObservableDTOProperty(MapsTo = nameof(Site.Organization) + "." + nameof(Site.Organization.Name))] public String OrganizationName { get; set; } public SiteDTO() { - SiteRmls = new List(); - SiteCatalogs = new List(); - } - - public static SiteDTO FromObservable(Site observable, IEnumerable siteRmls, IEnumerable siteCatalogs, String organizationName) - { - SiteDTO dto = FromObservable(observable); - dto.OrganizationName = organizationName; - dto.SiteRmls = siteRmls.Select(x => SitesRmlDTO.FromObservable(x)).ToList(); - dto.SiteCatalogs = siteCatalogs.Select(x => SitesCatalogDTO.FromObservable(x)).ToList(); - return dto; + SitesRmls = new List(); + SitesCatalogs = new List(); } protected override string OnGetActionLogName() diff --git a/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTO.cs index 4e1d44e6d..3c22989d8 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTO.cs @@ -4,11 +4,18 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; namespace Tango.BL.DTO { public class SitesCatalogDTO : SitesCatalogDTOBase { + [ObservableDTOProperty(MapsTo = nameof(SitesCatalog.ColorCatalog) + "." + nameof(SitesCatalog.ColorCatalog.Name))] + public String CatalogName { get; set; } + protected override string OnGetActionLogName() + { + return $"Catalog '{(CatalogName != null ? CatalogName : ColorCatalogGuid)}'"; + } } } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTOBase.cs index b673d5660..8cff3d047 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SitesCatalogDTOBase.cs @@ -30,9 +30,9 @@ namespace Tango.BL.DTO } /// - /// catalog guid + /// color catalog guid /// - public String CatalogGuid + public String ColorCatalogGuid { get; set; } diff --git a/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs b/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs index 0a5089072..fa67f0b3c 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/SitesRmlDTO.cs @@ -10,9 +10,12 @@ namespace Tango.BL.DTO { public class SitesRmlDTO : SitesRmlDTOBase { + [ObservableDTOProperty(MapsTo = nameof(SitesRml.Rml) + "." + nameof(SitesRml.Rml.Name))] + public String RmlName { get; set; } + protected override string OnGetActionLogName() { - return $"RML '{RmlGuid}'"; + return $"RML '{(RmlName != null ? RmlName : RmlGuid)}'"; } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogBase.cs b/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogBase.cs index da3c15c5c..f19eda455 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/ColorCatalogBase.cs @@ -44,6 +44,8 @@ namespace Tango.BL.Entities public event EventHandler> JobsChanged; + public event EventHandler> SitesCatalogsChanged; + protected String _company; /// @@ -281,6 +283,31 @@ namespace Tango.BL.Entities } } + protected SynchronizedObservableCollection _sitescatalogs; + + /// + /// Gets or sets the colorcatalogbase sites catalogs. + /// + + public virtual SynchronizedObservableCollection SitesCatalogs + { + get + { + return _sitescatalogs; + } + + set + { + if (_sitescatalogs != value) + { + _sitescatalogs = value; + + OnSitesCatalogsChanged(value); + + } + } + } + /// /// Called when the Company has changed. /// @@ -362,6 +389,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Jobs)); } + /// + /// Called when the SitesCatalogs has changed. + /// + protected virtual void OnSitesCatalogsChanged(SynchronizedObservableCollection sitescatalogs) + { + SitesCatalogsChanged?.Invoke(this, sitescatalogs); + RaisePropertyChanged(nameof(SitesCatalogs)); + } + /// /// Initializes a new instance of the class. /// @@ -374,6 +410,8 @@ namespace Tango.BL.Entities Jobs = new SynchronizedObservableCollection(); + SitesCatalogs = new SynchronizedObservableCollection(); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/HardwareBlowerBase.cs b/Software/Visual_Studio/Tango.BL/Entities/HardwareBlowerBase.cs index c6c166498..bbc55d245 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/HardwareBlowerBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/HardwareBlowerBase.cs @@ -129,6 +129,10 @@ namespace Tango.BL.Entities /// [Column("VOLTAGE")] + + [Description("Voltage Description")] + [Range(-10000,1000000)] + public Double Voltage { get diff --git a/Software/Visual_Studio/Tango.BL/Entities/OrganizationBase.cs b/Software/Visual_Studio/Tango.BL/Entities/OrganizationBase.cs index b19cb6fc1..c83d1a7c9 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/OrganizationBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/OrganizationBase.cs @@ -36,6 +36,8 @@ namespace Tango.BL.Entities public event EventHandler> MachinesChanged; + public event EventHandler> SitesChanged; + public event EventHandler> UsersChanged; protected String _name; @@ -231,6 +233,31 @@ namespace Tango.BL.Entities } } + protected SynchronizedObservableCollection _sites; + + /// + /// Gets or sets the organizationbase sites. + /// + + public virtual SynchronizedObservableCollection Sites + { + get + { + return _sites; + } + + set + { + if (_sites != value) + { + _sites = value; + + OnSitesChanged(value); + + } + } + } + protected SynchronizedObservableCollection _users; /// @@ -301,6 +328,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Machines)); } + /// + /// Called when the Sites has changed. + /// + protected virtual void OnSitesChanged(SynchronizedObservableCollection sites) + { + SitesChanged?.Invoke(this, sites); + RaisePropertyChanged(nameof(Sites)); + } + /// /// Called when the Users has changed. /// @@ -320,6 +356,8 @@ namespace Tango.BL.Entities Machines = new SynchronizedObservableCollection(); + Sites = new SynchronizedObservableCollection(); + Users = new SynchronizedObservableCollection(); } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs index 853372bba..86545b913 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlBase.cs @@ -90,6 +90,8 @@ namespace Tango.BL.Entities public event EventHandler> ProcessParametersTablesGroupsChanged; + public event EventHandler> SitesRmlsChanged; + protected String _name; /// @@ -1159,6 +1161,31 @@ namespace Tango.BL.Entities } } + protected SynchronizedObservableCollection _sitesrmls; + + /// + /// Gets or sets the rmlbase sites rmls. + /// + + public virtual SynchronizedObservableCollection SitesRmls + { + get + { + return _sitesrmls; + } + + set + { + if (_sitesrmls != value) + { + _sitesrmls = value; + + OnSitesRmlsChanged(value); + + } + } + } + /// /// Called when the Name has changed. /// @@ -1447,6 +1474,15 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(ProcessParametersTablesGroups)); } + /// + /// Called when the SitesRmls has changed. + /// + protected virtual void OnSitesRmlsChanged(SynchronizedObservableCollection sitesrmls) + { + SitesRmlsChanged?.Invoke(this, sitesrmls); + RaisePropertyChanged(nameof(SitesRmls)); + } + /// /// Initializes a new instance of the class. /// @@ -1465,6 +1501,8 @@ namespace Tango.BL.Entities ProcessParametersTablesGroups = new SynchronizedObservableCollection(); + SitesRmls = new SynchronizedObservableCollection(); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/SiteBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SiteBase.cs index 4294b2daf..f4881ae79 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SiteBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SiteBase.cs @@ -30,6 +30,12 @@ namespace Tango.BL.Entities public event EventHandler DescriptionChanged; + public event EventHandler OrganizationChanged; + + public event EventHandler> SitesCatalogsChanged; + + public event EventHandler> SitesRmlsChanged; + protected String _organizationguid; /// @@ -37,6 +43,7 @@ namespace Tango.BL.Entities /// [Column("ORGANIZATION_GUID")] + [ForeignKey("Organization")] public String OrganizationGuid { @@ -109,6 +116,88 @@ namespace Tango.BL.Entities } } + protected Organization _organization; + + /// + /// Gets or sets the sitebase organization. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual Organization Organization + { + get + { + return _organization; + } + + set + { + if (_organization != value) + { + _organization = value; + + if (Organization != null) + { + OrganizationGuid = Organization.Guid; + } + + OnOrganizationChanged(value); + + } + } + } + + protected SynchronizedObservableCollection _sitescatalogs; + + /// + /// Gets or sets the sitebase sites catalogs. + /// + + public virtual SynchronizedObservableCollection SitesCatalogs + { + get + { + return _sitescatalogs; + } + + set + { + if (_sitescatalogs != value) + { + _sitescatalogs = value; + + OnSitesCatalogsChanged(value); + + } + } + } + + protected SynchronizedObservableCollection _sitesrmls; + + /// + /// Gets or sets the sitebase sites rmls. + /// + + public virtual SynchronizedObservableCollection SitesRmls + { + get + { + return _sitesrmls; + } + + set + { + if (_sitesrmls != value) + { + _sitesrmls = value; + + OnSitesRmlsChanged(value); + + } + } + } + /// /// Called when the Name has changed. /// @@ -127,11 +216,43 @@ namespace Tango.BL.Entities RaisePropertyChanged(nameof(Description)); } + /// + /// Called when the Organization has changed. + /// + protected virtual void OnOrganizationChanged(Organization organization) + { + OrganizationChanged?.Invoke(this, organization); + RaisePropertyChanged(nameof(Organization)); + } + + /// + /// Called when the SitesCatalogs has changed. + /// + protected virtual void OnSitesCatalogsChanged(SynchronizedObservableCollection sitescatalogs) + { + SitesCatalogsChanged?.Invoke(this, sitescatalogs); + RaisePropertyChanged(nameof(SitesCatalogs)); + } + + /// + /// Called when the SitesRmls has changed. + /// + protected virtual void OnSitesRmlsChanged(SynchronizedObservableCollection sitesrmls) + { + SitesRmlsChanged?.Invoke(this, sitesrmls); + RaisePropertyChanged(nameof(SitesRmls)); + } + /// /// Initializes a new instance of the class. /// public SiteBase() : base() { + + SitesCatalogs = new SynchronizedObservableCollection(); + + SitesRmls = new SynchronizedObservableCollection(); + } } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/SitesCatalogBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SitesCatalogBase.cs index 85175d6ad..15f7ef6df 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SitesCatalogBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SitesCatalogBase.cs @@ -26,6 +26,10 @@ namespace Tango.BL.Entities public abstract class SitesCatalogBase : ObservableEntity { + public event EventHandler ColorCatalogChanged; + + public event EventHandler SiteChanged; + protected String _siteguid; /// @@ -33,6 +37,7 @@ namespace Tango.BL.Entities /// [Column("SITE_GUID")] + [ForeignKey("Site")] public String SiteGuid { @@ -51,31 +56,114 @@ namespace Tango.BL.Entities } } - protected String _catalogguid; + protected String _colorcatalogguid; /// - /// Gets or sets the sitescatalogbase catalog guid. + /// Gets or sets the sitescatalogbase color catalog guid. /// - [Column("CATALOG_GUID")] + [Column("COLOR_CATALOG_GUID")] + [ForeignKey("ColorCatalog")] + + public String ColorCatalogGuid + { + get + { + return _colorcatalogguid; + } + + set + { + if (_colorcatalogguid != value) + { + _colorcatalogguid = value; + + } + } + } + + protected ColorCatalog _colorcatalog; + + /// + /// Gets or sets the sitescatalogbase color catalogs. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual ColorCatalog ColorCatalog + { + get + { + return _colorcatalog; + } + + set + { + if (_colorcatalog != value) + { + _colorcatalog = value; + + if (ColorCatalog != null) + { + ColorCatalogGuid = ColorCatalog.Guid; + } + + OnColorCatalogChanged(value); + + } + } + } + + protected Site _site; + + /// + /// Gets or sets the sitescatalogbase site. + /// - public String CatalogGuid + [XmlIgnore] + [JsonIgnore] + public virtual Site Site { get { - return _catalogguid; + return _site; } set { - if (_catalogguid != value) + if (_site != value) { - _catalogguid = value; + _site = value; + + if (Site != null) + { + SiteGuid = Site.Guid; + } + + OnSiteChanged(value); } } } + /// + /// Called when the ColorCatalog has changed. + /// + protected virtual void OnColorCatalogChanged(ColorCatalog colorcatalog) + { + ColorCatalogChanged?.Invoke(this, colorcatalog); + RaisePropertyChanged(nameof(ColorCatalog)); + } + + /// + /// Called when the Site has changed. + /// + protected virtual void OnSiteChanged(Site site) + { + SiteChanged?.Invoke(this, site); + RaisePropertyChanged(nameof(Site)); + } + /// /// Initializes a new instance of the class. /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/SitesRmlBase.cs b/Software/Visual_Studio/Tango.BL/Entities/SitesRmlBase.cs index 0538069b4..6893099e4 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/SitesRmlBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/SitesRmlBase.cs @@ -26,6 +26,10 @@ namespace Tango.BL.Entities public abstract class SitesRmlBase : ObservableEntity { + public event EventHandler RmlChanged; + + public event EventHandler SiteChanged; + protected String _siteguid; /// @@ -33,6 +37,7 @@ namespace Tango.BL.Entities /// [Column("SITE_GUID")] + [ForeignKey("Site")] public String SiteGuid { @@ -58,6 +63,7 @@ namespace Tango.BL.Entities /// [Column("RML_GUID")] + [ForeignKey("Rml")] public String RmlGuid { @@ -76,6 +82,88 @@ namespace Tango.BL.Entities } } + protected Rml _rml; + + /// + /// Gets or sets the sitesrmlbase rml. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual Rml Rml + { + get + { + return _rml; + } + + set + { + if (_rml != value) + { + _rml = value; + + if (Rml != null) + { + RmlGuid = Rml.Guid; + } + + OnRmlChanged(value); + + } + } + } + + protected Site _site; + + /// + /// Gets or sets the sitesrmlbase site. + /// + + [XmlIgnore] + [JsonIgnore] + public virtual Site Site + { + get + { + return _site; + } + + set + { + if (_site != value) + { + _site = value; + + if (Site != null) + { + SiteGuid = Site.Guid; + } + + OnSiteChanged(value); + + } + } + } + + /// + /// Called when the Rml has changed. + /// + protected virtual void OnRmlChanged(Rml rml) + { + RmlChanged?.Invoke(this, rml); + RaisePropertyChanged(nameof(Rml)); + } + + /// + /// Called when the Site has changed. + /// + protected virtual void OnSiteChanged(Site site) + { + SiteChanged?.Invoke(this, site); + RaisePropertyChanged(nameof(Site)); + } + /// /// Initializes a new instance of the class. /// diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 5c599bb5e..b55d66606 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -100,6 +100,8 @@ + + @@ -592,7 +594,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_CATALOGS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_CATALOGS.cs index 31989101d..86c0156b7 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_CATALOGS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/COLOR_CATALOGS.cs @@ -20,6 +20,7 @@ namespace Tango.DAL.Remote.DB this.BRUSH_STOPS = new HashSet(); this.COLOR_CATALOGS_GROUPS = new HashSet(); this.JOBS = new HashSet(); + this.SITES_CATALOGS = new HashSet(); } public int ID { get; set; } @@ -38,5 +39,7 @@ namespace Tango.DAL.Remote.DB public virtual ICollection COLOR_CATALOGS_GROUPS { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection JOBS { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection SITES_CATALOGS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/ORGANIZATION.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/ORGANIZATION.cs index 0073f82ef..71be380f5 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/ORGANIZATION.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/ORGANIZATION.cs @@ -19,6 +19,7 @@ namespace Tango.DAL.Remote.DB { this.CUSTOMERS = new HashSet(); this.MACHINES = new HashSet(); + this.SITES = new HashSet(); this.USERS = new HashSet(); } @@ -36,6 +37,8 @@ namespace Tango.DAL.Remote.DB [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection MACHINES { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection SITES { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection USERS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs index 063cd7f8e..15c59c062 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML.cs @@ -23,6 +23,7 @@ namespace Tango.DAL.Remote.DB this.LIQUID_TYPES_RMLS = new HashSet(); this.MACHINES = new HashSet(); this.PROCESS_PARAMETERS_TABLES_GROUPS = new HashSet(); + this.SITES_RMLS = new HashSet(); } public int ID { get; set; } @@ -74,5 +75,7 @@ namespace Tango.DAL.Remote.DB public virtual MEDIA_PURPOSES MEDIA_PURPOSES { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection PROCESS_PARAMETERS_TABLES_GROUPS { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection SITES_RMLS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs index 17bc2683d..d26e67908 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.Designer.cs @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'D:\Development\Tango\Software\Visual_Studio\Tango.DAL.Remote\DB\RemoteADO.edmx'. +// T4 code generation is enabled for model 'C:\DATA\Development\Tango\Software\Visual_Studio\Tango.DAL.Remote\DB\RemoteADO.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index eb161228c..9b55ede6e 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -957,7 +957,7 @@ - + @@ -2115,6 +2115,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2601,6 +2669,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -2790,6 +2878,10 @@ + + + + @@ -3014,6 +3106,10 @@ + + + + @@ -3030,6 +3126,10 @@ + + + + @@ -3038,6 +3138,14 @@ + + + + + + + + @@ -3226,6 +3334,7 @@ + @@ -3992,6 +4101,7 @@ + @@ -4097,6 +4207,7 @@ + @@ -4147,6 +4258,9 @@ + + + @@ -4156,7 +4270,9 @@ - + + + @@ -4167,6 +4283,8 @@ + + @@ -4595,6 +4713,20 @@ + + + + + + + + + + + + + + @@ -5319,6 +5451,18 @@ + + + + + + + + + + + + @@ -5373,6 +5517,20 @@ + + + + + + + + + + + + + + @@ -5401,6 +5559,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6463,7 +6649,7 @@ - + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index a9ff9aacf..77bf89743 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,84 +5,84 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -100,6 +100,7 @@ + @@ -156,12 +157,16 @@ + + + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SITE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SITE.cs index 10dcaef11..c0aa38e97 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SITE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SITE.cs @@ -14,11 +14,24 @@ namespace Tango.DAL.Remote.DB public partial class SITE { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public SITE() + { + this.SITES_CATALOGS = new HashSet(); + this.SITES_RMLS = new HashSet(); + } + public int ID { get; set; } public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } public string ORGANIZATION_GUID { get; set; } public string NAME { get; set; } public string DESCRIPTION { get; set; } + + public virtual ORGANIZATION ORGANIZATION { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection SITES_CATALOGS { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection SITES_RMLS { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_CATALOGS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_CATALOGS.cs index df712045c..4868cf35a 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_CATALOGS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_CATALOGS.cs @@ -18,6 +18,9 @@ namespace Tango.DAL.Remote.DB public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } public string SITE_GUID { get; set; } - public string CATALOG_GUID { get; set; } + public string COLOR_CATALOG_GUID { get; set; } + + public virtual COLOR_CATALOGS COLOR_CATALOGS { get; set; } + public virtual SITE SITE { get; set; } } } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_RMLS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_RMLS.cs index ea22adbf8..945dd8bf9 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_RMLS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/SITES_RMLS.cs @@ -19,5 +19,8 @@ namespace Tango.DAL.Remote.DB public System.DateTime LAST_UPDATED { get; set; } public string SITE_GUID { get; set; } public string RML_GUID { get; set; } + + public virtual RML RML { get; set; } + public virtual SITE SITE { get; set; } } } diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml index 3f61fe617..a2221c619 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml differ diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml index 97dad3717..8812256d5 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml differ -- cgit v1.3.1 From cd670d0404673efd095ae2baec1873b916c49c81 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 21 Dec 2019 23:17:25 +0200 Subject: Implemented not existing deleted RML check for PPC update and error message. Added proper notification when trying to remove used RML onMS. --- .../ViewModels/MainViewVM.cs | 10 +++++++++- .../MachineUpdate/MachineUpdateManager.cs | 1 + .../Tango.PPC.Common/Web/CheckForUpdateRequest.cs | 2 ++ .../Tango.PPC.Common/Web/CheckForUpdateResponse.cs | 2 ++ .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 23 ++++++++++++++++++++++ .../Controllers/PPCController.cs | 4 ++++ 6 files changed, 41 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs index 527159aa5..5c55892ba 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs @@ -445,7 +445,7 @@ namespace Tango.MachineStudio.RML.ViewModels private async void RemoveSelectedRml() { - if (_notification.ShowQuestion("Removing the selected RML will result in the loss of all related process parameters and default calibration data. Are you sure you want to delete the selected RML?")) + if (_notification.ShowQuestion("Removing the selected thread will result in the loss of all related process parameters and default calibration data. Are you sure you want to delete the selected RML?")) { IsFree = false; @@ -453,6 +453,14 @@ namespace Tango.MachineStudio.RML.ViewModels { try { + var rml_jobs = await _rmls_context.Jobs.Where(x => x.RmlGuid == SelectedRML.Guid).Include(x => x.Machine).OrderBy(x => x.Machine.SerialNumber).ToListAsync(); + + if (rml_jobs.Count > 0) + { + _notification.ShowError($"The following jobs must be removed or change thread type before the selected thread can be deleted:\n{String.Join("\n",rml_jobs.Select(x => $"{x.Machine.SerialNumber} => {x.Name}"))}"); + return; + } + await SelectedRML.DeleteCascadeAsync(_rmls_context); _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlDeleted, _authentication.CurrentUser, SelectedRML.Name, SelectedRML, "RML deleted from Machine Studio."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index d0424254b..8d6e02020 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -852,6 +852,7 @@ namespace Tango.PPC.Common.MachineUpdate request.Rmls = db.Rmls.ToList().Select(x => new UpdatedEntity(x)).ToList(); request.HardwareVersions = db.HardwareVersions.ToList().Select(x => new UpdatedEntity(x)).ToList(); request.Catalogs = db.ColorCatalogs.ToList().Select(x => new UpdatedEntity(x)).ToList(); + request.UsedRmlsGuids = db.Jobs.Select(x => x.RmlGuid).Distinct().ToList(); } } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs index 3d606b918..0d86fa117 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateRequest.cs @@ -16,12 +16,14 @@ namespace Tango.PPC.Common.Web public List HardwareVersions { get; set; } public List Catalogs { get; set; } public DateTime MachineLastUpdated { get; set; } + public List UsedRmlsGuids { get; set; } public CheckForUpdateRequest() { Rmls = new List(); HardwareVersions = new List(); Catalogs = new List(); + UsedRmlsGuids = new List(); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs index a857a20a1..2fb33ebdc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/CheckForUpdateResponse.cs @@ -16,10 +16,12 @@ namespace Tango.PPC.Common.Web public bool SetupFirmware { get; set; } public bool SetupFPGA { get; set; } public UpdateDBResponse UpdateDBResponse { get; set; } + public List UsedNotExistingRmlsGuids { get; set; } public CheckForUpdateResponse() { UpdateDBResponse = new UpdateDBResponse(); + UsedNotExistingRmlsGuids = new List(); } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index 49b2aef89..0af977614 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; +using System.Data.Entity; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; using Tango.Core.Commands; using Tango.Core.Helpers; using Tango.Explorer; @@ -156,6 +158,27 @@ namespace Tango.PPC.UI.ViewModels } var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber); + + try + { + if (response.UsedNotExistingRmlsGuids.Count > 0) + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var arr = response.UsedNotExistingRmlsGuids.ToArray(); + var jobs = await db.Jobs.Where(x => arr.Contains(x.RmlGuid)).ToListAsync(); + FailedError = $"The following jobs must be removed or change thread type before the system can be updated:\n{String.Join("\n", jobs.Select(x => x.Name))}"; + _isChecking = false; + await NavigateTo(MachineUpdateView.UpdateFailedView); + return; + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error on used RML check procedure."); + } + _checkUpdateResponse = response; if (response.IsUpdateAvailable) diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index ade8f88bc..1bb025217 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -330,6 +330,10 @@ namespace Tango.MachineService.Controllers var hardwareVersions = db.HardwareVersions.Select(x => new { x.Guid, x.LastUpdated }).ToList(); var catalogs = db.ColorCatalogs.Select(x => new { x.Guid, x.LastUpdated }).ToList(); + var arr = request.UsedRmlsGuids.ToArray(); + var existingRml = db.Rmls.Where(x => arr.Contains(x.Guid)).Select(x => x.Guid).Distinct().ToList(); + response.UsedNotExistingRmlsGuids = arr.Where(x => !existingRml.Exists(y => y == x)).ToList(); + bool hasDatabaseUpdates = false; hasDatabaseUpdates = machine.LastUpdated > request.MachineLastUpdated; -- cgit v1.3.1