From 9259bc36791a7084ae33bcf0a698101ddb24d28f Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 5 Dec 2019 18:06:21 +0200 Subject: Integrated CDN downloads to PPC and MS. --- .../MachineSetup/MachineSetupManager.cs | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 537e652e6..cce6c32ab 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -249,27 +249,29 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log("Downloading software package..."); - long fileSize = 0; - UpdateProgress("Downloading software package", "Downloading...", false); + AutoFileDownloader downloader = new AutoFileDownloader(setup_response.BlobAddress, setup_response.CdnAddress, tempFile); + await downloader.ResolveMode(); - await Task.Factory.StartNew(() => + if (downloader.Mode == AutoFileDownloader.DownloadMode.Standard) { - using (FileStreamWrapper fs = new FileStreamWrapper(tempFile.Path, FileMode.Create, (current) => - { - UpdateProgress("Downloading software package", "Downloading...", false, current, fileSize); - })) - { + LogManager.Log($"Connecting to storage CDN with address {downloader.Address}"); + } + else + { + LogManager.Log($"Connecting to storage blob with address {downloader.Address}"); + } - LogManager.Log($"Connecting to storage blob with address {setup_response.BlobAddress}"); - CloudBlockBlob blob = new CloudBlockBlob(new Uri(setup_response.BlobAddress)); - LogManager.Log("Fetching blob attributes..."); - blob.FetchAttributes(); - fileSize = blob.Properties.Length; - LogManager.Log("Download size: " + fileSize + " bytes."); - LogManager.Log("Starting blob download..."); - blob.DownloadToStream(fs); - } - }); + downloader.Progress += (x, e) => + { + UpdateProgress("Downloading software package", "Downloading...", false, e.Current, e.Total); + }; + + var size = await downloader.GetFileSize(); + LogManager.Log("Download size: " + size + " bytes."); + LogManager.Log("Starting file download..."); + await downloader.Download(); + + downloader.Dispose(); UpdateProgress("Downloading software package", "Extracting package..."); -- cgit v1.3.1 From 97d65296c4cc85ad62e0cd11e430bdf9d3b1b160 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 5 Dec 2019 18:12:50 +0200 Subject: Improved PPC cdn integration... --- .../MachineSetup/MachineSetupManager.cs | 38 +++++++++++----------- .../MachineUpdate/MachineUpdateManager.cs | 38 +++++++++++----------- 2 files changed, 38 insertions(+), 38 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index cce6c32ab..10418fdcb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -249,29 +249,29 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log("Downloading software package..."); - AutoFileDownloader downloader = new AutoFileDownloader(setup_response.BlobAddress, setup_response.CdnAddress, tempFile); - await downloader.ResolveMode(); - - if (downloader.Mode == AutoFileDownloader.DownloadMode.Standard) - { - LogManager.Log($"Connecting to storage CDN with address {downloader.Address}"); - } - else + using (AutoFileDownloader downloader = new AutoFileDownloader(setup_response.BlobAddress, setup_response.CdnAddress, tempFile)) { - LogManager.Log($"Connecting to storage blob with address {downloader.Address}"); - } + await downloader.ResolveMode(); - downloader.Progress += (x, e) => - { - UpdateProgress("Downloading software package", "Downloading...", false, e.Current, e.Total); - }; + if (downloader.Mode == AutoFileDownloader.DownloadMode.Standard) + { + LogManager.Log($"Connecting to storage CDN with address {downloader.Address}"); + } + else + { + LogManager.Log($"Connecting to storage blob with address {downloader.Address}"); + } - var size = await downloader.GetFileSize(); - LogManager.Log("Download size: " + size + " bytes."); - LogManager.Log("Starting file download..."); - await downloader.Download(); + downloader.Progress += (x, e) => + { + UpdateProgress("Downloading software package", "Downloading...", false, e.Current, e.Total); + }; - downloader.Dispose(); + var size = await downloader.GetFileSize(); + LogManager.Log("Download size: " + size + " bytes."); + LogManager.Log("Starting file download..."); + await downloader.Download(); + } UpdateProgress("Downloading software package", "Extracting package..."); 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 333fb261d..f00efb22c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -331,29 +331,29 @@ namespace Tango.PPC.Common.MachineUpdate UpdateProgress("Downloading software package", "Downloading...", false); - AutoFileDownloader downloader = new AutoFileDownloader(update_response.BlobAddress, update_response.CdnAddress, tempFile); - await downloader.ResolveMode(); - - if (downloader.Mode == AutoFileDownloader.DownloadMode.Standard) - { - LogManager.Log($"Connecting to storage CDN with address {downloader.Address}"); - } - else + using (AutoFileDownloader downloader = new AutoFileDownloader(update_response.BlobAddress, update_response.CdnAddress + "123", tempFile)) { - LogManager.Log($"Connecting to storage blob with address {downloader.Address}"); - } + await downloader.ResolveMode(); - downloader.Progress += (x, e) => - { - UpdateProgress("Downloading software package", "Downloading...", false, e.Current, e.Total); - }; + if (downloader.Mode == AutoFileDownloader.DownloadMode.Standard) + { + LogManager.Log($"Connecting to storage CDN with address {downloader.Address}"); + } + else + { + LogManager.Log($"Connecting to storage blob with address {downloader.Address}"); + } - var size = await downloader.GetFileSize(); - LogManager.Log("Download size: " + size + " bytes."); - LogManager.Log("Starting file download..."); - await downloader.Download(); + downloader.Progress += (x, e) => + { + UpdateProgress("Downloading software package", "Downloading...", false, e.Current, e.Total); + }; - downloader.Dispose(); + var size = await downloader.GetFileSize(); + LogManager.Log("Download size: " + size + " bytes."); + LogManager.Log("Starting file download..."); + await downloader.Download(); + } UpdateProgress("Downloading software package", "Extracting package..."); -- cgit v1.3.1 From a6e6af346bf160b4a83163a6f1b268920cf2005c Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 7 Dec 2019 20:10:55 +0200 Subject: Implemented machine updates history on machine designer. Related Work Items: #1618 --- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Tango.MachineStudio.MachineDesigner.csproj | 18 ++- .../ViewModels/MachineUpdateDetailsDialogVM.cs | 20 +++ .../ViewModels/MachineUpdatesViewVM.cs | 142 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 13 +- .../Views/MachineDetailsView.xaml | 3 + .../Views/MachineUpdateDetailsDialog.xaml | 85 ++++++++++++ .../Views/MachineUpdateDetailsDialog.xaml.cs | 28 ++++ .../Views/MachineUpdatesView.xaml | 98 ++++++++++++++ .../Views/MachineUpdatesView.xaml.cs | 28 ++++ .../MachineSetup/MachineSetupManager.cs | 24 ++++ .../MachineUpdate/MachineUpdateManager.cs | 29 ++++- .../Web/MachineUpdateCompletedResponse.cs | 2 +- .../Builders/TangoUpdatesCollectionBuilder.cs | 26 ++++ .../Visual_Studio/Tango.BL/Entities/TangoUpdate.cs | 79 +++++++++++- .../Tango.BL/Enumerations/TangoUpdateStatuses.cs | 10 ++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 3 +- .../Converters/StringEllipsisConverter.cs | 9 +- .../Converters/StringToOneLineConverter.cs | 50 ++++++++ .../Tango.SharedUI/Tango.SharedUI.csproj | 1 + 23 files changed, 658 insertions(+), 10 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml.cs create mode 100644 Software/Visual_Studio/Tango.BL/Builders/TangoUpdatesCollectionBuilder.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs') diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index 5fc6097f0..de2de9f2b 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 d987dddda..d7d04ca21 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 8ea68035a..f50c8b7fb 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 d0c2d75ef..5b78ee141 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.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index d80060831..6225bd7ad 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -89,6 +89,8 @@ + + @@ -97,6 +99,9 @@ HardwareConfigurationView.xaml + + MachineUpdateDetailsDialog.xaml + MachineCreationDialog.xaml @@ -122,6 +127,9 @@ MainView.xaml + + MachineUpdatesView.xaml + SpoolsView.xaml @@ -137,6 +145,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -169,6 +181,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -308,7 +324,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs new file mode 100644 index 000000000..49d410cdf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdateDetailsDialogVM.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.ViewModels +{ + public class MachineUpdateDetailsDialogVM : DialogViewVM + { + private TangoUpdate _update; + public TangoUpdate Update + { + get { return _update; } + set { _update = value; RaisePropertyChangedAuto(); } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs new file mode 100644 index 000000000..7ff64c505 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineUpdatesViewVM.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.MachineDesigner.Views; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.ViewModels +{ + public class MachineUpdatesViewVM : ViewModel + { + private INotificationProvider _notification; + + #region Properties + + private Machine _machine; + public Machine Machine + { + get { return _machine; } + set { _machine = value; RaisePropertyChangedAuto(); } + } + + private List _updates; + public List Updates + { + get { return _updates; } + set { _updates = value; RaisePropertyChangedAuto(); } + } + + private ICollectionView _updatesView; + public ICollectionView UpdatesView + { + get { return _updatesView; } + set { _updatesView = value; RaisePropertyChangedAuto(); } + } + + + private TangoUpdate _selectedUpdate; + public TangoUpdate SelectedUpdate + { + get { return _selectedUpdate; } + set { _selectedUpdate = value; RaisePropertyChangedAuto(); OnSelectedUpdateChanged(); } + } + + private bool _displayMachineSetups; + public bool DisplayMachineSetups + { + get { return _displayMachineSetups; } + set { _displayMachineSetups = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private bool _displayApplicationUpdates; + public bool DisplayApplicationUpdates + { + get { return _displayApplicationUpdates; } + set { _displayApplicationUpdates = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private bool _displayDatabaseUpdates; + public bool DisplayDatabaseUpdates + { + get { return _displayDatabaseUpdates; } + set { _displayDatabaseUpdates = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + #endregion + + #region Constructors + + public MachineUpdatesViewVM() + { + DisplayApplicationUpdates = true; + DisplayMachineSetups = true; + DisplayDatabaseUpdates = true; + } + + public MachineUpdatesViewVM(INotificationProvider notificationProvider) : this() + { + _notification = notificationProvider; + } + + #endregion + + #region Public Methods + + public async Task Init(Machine machine, ObservablesContext context) + { + Machine = machine; + Updates = (await new TangoUpdatesCollectionBuilder(context).Set(x => x.MachineGuid == machine.Guid).BuildAsync()).OrderByDescending(x => x.StartDate).ToList(); + UpdatesView = CollectionViewSource.GetDefaultView(Updates); + UpdatesView.Filter = UpdatesFilter; + OnFilterChanged(); + } + + #endregion + + #region Private Methods + + private void OnFilterChanged() + { + if (UpdatesView != null) + { + UpdatesView.Refresh(); + } + } + + private bool UpdatesFilter(object obj) + { + TangoUpdate update = obj as TangoUpdate; + if (update != null) + { + if (!DisplayMachineSetups && update.IsSetup) return false; + if (!DisplayApplicationUpdates && update.IsUpdate) return false; + if (!DisplayDatabaseUpdates && update.IsDataBase) return false; + return true; + } + else + { + return false; + } + } + + private void OnSelectedUpdateChanged() + { + if (SelectedUpdate == null) return; + + var selectedUpdate = SelectedUpdate; + SelectedUpdate = null; + + _notification.ShowModalDialog(new MachineUpdateDetailsDialogVM() { Update = selectedUpdate }, (vm) => { }, () => { }); + } + + #endregion + } +} 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 5fd086198..820950290 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 @@ -123,7 +123,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } private HardwareConfigurationViewVM _hardwareConfigurationViewVM; - public HardwareConfigurationViewVM HardwareConfigurationViewVM { get { return _hardwareConfigurationViewVM; } @@ -134,6 +133,13 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + private MachineUpdatesViewVM _machineUpdatesViewVM; + public MachineUpdatesViewVM MachineUpdatesViewVM + { + get { return _machineUpdatesViewVM; } + set { _machineUpdatesViewVM = value; RaisePropertyChangedAuto(); } + } + #endregion @@ -225,6 +231,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null); CloneMachineCommand = new RelayCommand(CloneMachine, () => SelectedMachine != null); ResetDeviceRegistrationCommand = new RelayCommand(ResetDeviceRegistration); + + MachineUpdatesViewVM = new MachineUpdatesViewVM(_notification); } #endregion @@ -469,6 +477,9 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels HardwareConfigurationViewVM = new HardwareConfigurationViewVM(_notification); HardwareConfigurationViewVM.Init(ActiveMachine.Configuration); + await MachineUpdatesViewVM.Init(ActiveMachine, ActiveMachineAdapter.Context); + + ActiveMachine.Configuration.HardwareVersionChanged += Configuration_HardwareVersionChanged; View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml index 1f748fe9f..666a4ee4a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -61,6 +61,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml new file mode 100644 index 000000000..9d60d36f8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml.cs new file mode 100644 index 000000000..8bb051c51 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdateDetailsDialog.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for MachineCreationDialog.xaml + /// + public partial class MachineUpdateDetailsDialog : UserControl + { + public MachineUpdateDetailsDialog() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml new file mode 100644 index 000000000..d9ea2cb44 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Machine Setups + Software Updates + Database Updates + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml.cs new file mode 100644 index 000000000..d13ef2d0e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineUpdatesView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for SpoolsView.xaml + /// + public partial class MachineUpdatesView : UserControl + { + public MachineUpdatesView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 10418fdcb..f1c722d96 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -17,6 +17,7 @@ using Tango.Core.ExtensionMethods; using Tango.Core.Helpers; using Tango.Core.IO; using Tango.Integration.Operation; +using Tango.Logging; using Tango.PMR.Synchronization; using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; @@ -42,6 +43,7 @@ namespace Tango.PPC.Common.MachineSetup private IUnifiedWriteFilterManager _uwf; private IOperationSystemManager _windows_manager; private PPCWebClient _client; + private List _logs; #region Events @@ -80,6 +82,18 @@ namespace Tango.PPC.Common.MachineSetup _remoteAssistance = remoteAssistance; _uwf = unifiedWriterFilterManager; _windows_manager = operationSystemManager; + + _logs = new List(); + LogManager.NewLog += LogManager_NewLog; + } + + #endregion + + #region Event Handlers + + private void LogManager_NewLog(object sender, LogItemBase e) + { + _logs.Add(e); } #endregion @@ -114,6 +128,7 @@ namespace Tango.PPC.Common.MachineSetup Token = response.NotifyCompletedToken, Status = BL.Enumerations.TangoUpdateStatuses.SetupFailed, FailedReason = ex.FlattenMessage(), + FailedLog = GetLogsStringAndClear(), }); } catch (Exception xx) @@ -144,6 +159,13 @@ namespace Tango.PPC.Common.MachineSetup } } + private String GetLogsStringAndClear() + { + String logsString = String.Join(Environment.NewLine, _logs.ToList().Select(x => x.ToString())); + _logs.Clear(); + return logsString; + } + #endregion #region Public Methods @@ -156,6 +178,8 @@ namespace Tango.PPC.Common.MachineSetup /// public async Task Setup(string serialNumber) { + _logs.Clear(); + TaskCompletionSource result = new TaskCompletionSource(); MachineSetupResponse setup_response = null; 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 f00efb22c..658c323de 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -16,6 +16,7 @@ using Tango.Core.Helpers; using Tango.Core.IO; using Tango.Integration.Operation; using Tango.Integration.Upgrade; +using Tango.Logging; using Tango.PMR.Synchronization; using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; @@ -34,8 +35,8 @@ namespace Tango.PPC.Common.MachineUpdate private IPPCApplicationManager _app_manager; private IMachineProvider _machineProvider; private IPackageRunner _packageRunner; - private INavigationManager _navigationManager; private PPCWebClient _client; + private List _logs; #region Events @@ -68,13 +69,16 @@ namespace Tango.PPC.Common.MachineUpdate /// Initializes a new instance of the class. /// /// The application manager. - public MachineUpdateManager(PPCWebClient ppcWebClient, IPPCApplicationManager applicationManager, IMachineProvider machineProvider, IPackageRunner packageRunner, INavigationManager navigationManager) + public MachineUpdateManager(PPCWebClient ppcWebClient, IPPCApplicationManager applicationManager, IMachineProvider machineProvider, IPackageRunner packageRunner) { _client = ppcWebClient; _machineProvider = machineProvider; _app_manager = applicationManager; _packageRunner = packageRunner; _packageRunner.PackageStateChanged += _packageRunner_PackageStateChanged; + + _logs = new List(); + LogManager.NewLog += LogManager_NewLog; } #endregion @@ -86,6 +90,11 @@ namespace Tango.PPC.Common.MachineUpdate UpdateProgress(e.PackageType == PackageType.Pre ? "Preparing" : "Finalizing", e.PackageName); } + private void LogManager_NewLog(object sender, LogItemBase e) + { + _logs.Add(e); + } + #endregion #region Private Methods @@ -142,6 +151,7 @@ namespace Tango.PPC.Common.MachineUpdate Token = response.NotifyCompletedToken, Status = BL.Enumerations.TangoUpdateStatuses.UpdateFailed, FailedReason = ex.FlattenMessage(), + FailedLog = GetLogsStringAndClear(), }); } catch (Exception xx) @@ -238,6 +248,7 @@ namespace Tango.PPC.Common.MachineUpdate Token = response.NotifyCompletedToken, Status = BL.Enumerations.TangoUpdateStatuses.DatabaseFailed, FailedReason = ex.FlattenMessage(), + FailedLog = GetLogsStringAndClear(), }).Result; } catch (Exception xx) @@ -247,6 +258,13 @@ namespace Tango.PPC.Common.MachineUpdate } } + private String GetLogsStringAndClear() + { + String logsString = String.Join(Environment.NewLine, _logs.ToList().Select(x => x.ToString())); + _logs.Clear(); + return logsString; + } + #endregion #region Public Methods @@ -266,6 +284,8 @@ namespace Tango.PPC.Common.MachineUpdate /// Database tango does not exists. public async Task Update(String serialNumber, bool setupFirmware, bool setupFPGA) { + _logs.Clear(); + TaskCompletionSource result = new TaskCompletionSource(); var localDataSource = SettingsManager.Default.GetOrCreate().DataSource; @@ -331,7 +351,7 @@ namespace Tango.PPC.Common.MachineUpdate UpdateProgress("Downloading software package", "Downloading...", false); - using (AutoFileDownloader downloader = new AutoFileDownloader(update_response.BlobAddress, update_response.CdnAddress + "123", tempFile)) + using (AutoFileDownloader downloader = new AutoFileDownloader(update_response.BlobAddress, update_response.CdnAddress, tempFile)) { await downloader.ResolveMode(); @@ -361,7 +381,6 @@ namespace Tango.PPC.Common.MachineUpdate //Extract software package. ZipFile.ExtractToDirectory(tempFile, _newPackageTempFolder); - LogManager.Log("Copying latest updater utility to application path..."); //Copy new updater utility to app path. File.Copy(Path.Combine(_newPackageTempFolder, "Tango.PPC.Updater.exe"), Path.Combine(PathHelper.GetStartupPath(), "Tango.PPC.Updater.exe"), true); @@ -571,6 +590,8 @@ namespace Tango.PPC.Common.MachineUpdate /// public Task UpdateDB(DbCompareResult dbCompareResult, String serialNumber) { + _logs.Clear(); + return Task.Factory.StartNew(() => { UpdateDBResponse update_response = null; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineUpdateCompletedResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineUpdateCompletedResponse.cs index 1017ffdb2..72517d108 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineUpdateCompletedResponse.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/MachineUpdateCompletedResponse.cs @@ -10,6 +10,6 @@ namespace Tango.PPC.Common.Web { public class MachineUpdateCompletedResponse : WebResponseMessage { - public String ReportBlobAddress { get; set; } + } } diff --git a/Software/Visual_Studio/Tango.BL/Builders/TangoUpdatesCollectionBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/TangoUpdatesCollectionBuilder.cs new file mode 100644 index 000000000..5bc510474 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/TangoUpdatesCollectionBuilder.cs @@ -0,0 +1,26 @@ +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 TangoUpdatesCollectionBuilder : EntityCollectionBuilderBase + { + public TangoUpdatesCollectionBuilder(ObservablesContext context) : base(context) + { + + } + + //public virtual TangoUpdatesCollectionBuilder ForMachine(String machineGuid) + //{ + // return AddQueryStep(1, (query) => + // { + // return query.Where(x => x.MachineGuid == machineGuid); + // }); + //} + } +} diff --git a/Software/Visual_Studio/Tango.BL/Entities/TangoUpdate.cs b/Software/Visual_Studio/Tango.BL/Entities/TangoUpdate.cs index 076ba268f..5c254a6a9 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/TangoUpdate.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/TangoUpdate.cs @@ -11,7 +11,6 @@ namespace Tango.BL.Entities { public class TangoUpdate : TangoUpdateBase { - [NotMapped] [JsonIgnore] public TangoUpdateStatuses UpdateStatus @@ -27,6 +26,84 @@ namespace Tango.BL.Entities } } + [NotMapped] + [JsonIgnore] + public bool IsSetup + { + get + { + return + UpdateStatus == TangoUpdateStatuses.SetupStarted || + UpdateStatus == TangoUpdateStatuses.SetupCompleted || + UpdateStatus == TangoUpdateStatuses.SetupFailed; + } + } + + [NotMapped] + [JsonIgnore] + public bool IsUpdate + { + get + { + return + UpdateStatus == TangoUpdateStatuses.UpdateStarted || + UpdateStatus == TangoUpdateStatuses.UpdateCompleted || + UpdateStatus == TangoUpdateStatuses.UpdateFailed; + } + } + + [NotMapped] + [JsonIgnore] + public bool IsDataBase + { + get + { + return + UpdateStatus == TangoUpdateStatuses.DatabaseStarted || + UpdateStatus == TangoUpdateStatuses.DatabaseCompleted || + UpdateStatus == TangoUpdateStatuses.DatabaseFailed; + } + } + + [NotMapped] + [JsonIgnore] + public bool IsStarted + { + get + { + return + UpdateStatus == TangoUpdateStatuses.SetupStarted || + UpdateStatus == TangoUpdateStatuses.UpdateStarted || + UpdateStatus == TangoUpdateStatuses.DatabaseStarted; + } + } + + [NotMapped] + [JsonIgnore] + public bool IsCompleted + { + get + { + return + UpdateStatus == TangoUpdateStatuses.SetupCompleted || + UpdateStatus == TangoUpdateStatuses.UpdateCompleted || + UpdateStatus == TangoUpdateStatuses.DatabaseCompleted; + } + } + + [NotMapped] + [JsonIgnore] + public bool IsFailed + { + get + { + return + UpdateStatus == TangoUpdateStatuses.SetupFailed || + UpdateStatus == TangoUpdateStatuses.UpdateFailed || + UpdateStatus == TangoUpdateStatuses.DatabaseFailed; + } + } + protected override void OnStatusChanged(int status) { base.OnStatusChanged(status); diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/TangoUpdateStatuses.cs b/Software/Visual_Studio/Tango.BL/Enumerations/TangoUpdateStatuses.cs index ee657e0a9..30d324317 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/TangoUpdateStatuses.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/TangoUpdateStatuses.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -8,16 +9,25 @@ namespace Tango.BL.Enumerations { public enum TangoUpdateStatuses { + [Description("Setup started but did not complete")] SetupStarted = 0, + [Description("Setup completed successfully")] SetupCompleted = 1, + [Description("Setup failed")] SetupFailed = 2, + [Description("Software updated started but did not complete")] UpdateStarted = 100, + [Description("Software update completed successfully")] UpdateCompleted = 101, + [Description("Software update failed")] UpdateFailed = 102, + [Description("Database update started but did not complete")] DatabaseStarted = 200, + [Description("Database update completed successfully")] DatabaseCompleted = 201, + [Description("Database update failed")] DatabaseFailed = 202, } } diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 2bca408a4..ed134d37d 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -93,6 +93,7 @@ + @@ -565,7 +566,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs index f5b4dea87..7e534d7f0 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs @@ -14,7 +14,14 @@ namespace Tango.SharedUI.Converters { try { - return value.ToString().Ellipsis(System.Convert.ToInt32(parameter)); + if (value != null) + { + return value.ToString().Ellipsis(System.Convert.ToInt32(parameter)); + } + else + { + return value; + } } catch { diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs new file mode 100644 index 000000000..d130ebaaf --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.SharedUI.Converters +{ + public class StringToOneLineConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + string str = value.ToString(); + int newLineIndex = str.IndexOf(Environment.NewLine); + + if (newLineIndex == -1) + { + newLineIndex = str.IndexOf("\n"); + } + + string firstline = str; + + if (newLineIndex > 0) + { + firstline = str.Substring(0, newLineIndex); + } + + if (parameter != null) + { + firstline = firstline.Ellipsis(System.Convert.ToInt32(parameter)); + } + + return firstline; + } + else + { + return value; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index a65ac7322..3429bcb59 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -130,6 +130,7 @@ + -- cgit v1.3.1