From 091a4bdeb2feadb4962c6be5deb367ab56d81707 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 30 Mar 2020 00:56:02 +0300 Subject: Implemented PPC Updates & Packages. Moved PPC/FSE interfaces to PPC.Shared. Changes Generic Serialization to json. --- .../Tango.FSE.PPCConsole.csproj | 12 ++ .../Tango.FSE.PPCConsole/ViewModelLocator.cs | 9 ++ .../Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs | 1 + .../ViewModels/MonitoringViewVM.cs | 2 +- .../ViewModels/UpdatesViewVM.cs | 138 +++++++++++++++++++++ .../Tango.FSE.PPCConsole/Views/MainView.xaml | 2 +- .../Tango.FSE.PPCConsole/Views/UpdatesView.xaml | 123 ++++++++++++++++++ .../Tango.FSE.PPCConsole/Views/UpdatesView.xaml.cs | 28 +++++ .../FSE/Tango.FSE.Common/FSEViewModel.cs | 7 ++ .../MachineUpdates/IMachineUpdatesProvider.cs | 13 ++ .../MachineUpdates/MachineUpdatesResult.cs | 22 ++++ .../Performance/PerformancePackageEventArgs.cs | 2 +- .../FSE/Tango.FSE.Common/Resources/Styles.xaml | 39 +++++- .../SystemInfo/ISystemInfoProvider.cs | 2 +- .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 6 + .../DefaultMachineUpdatesProvider.cs | 51 ++++++++ .../Performance/DefaultPerformanceProvider.cs | 2 +- .../SystemInfo/DefaultSystemInfoProvider.cs | 2 +- .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 5 + .../FSE/Tango.FSE.UI/ViewModelLocator.cs | 4 + .../Tango.PPC.Technician.csproj | 4 + .../ViewModels/PackagesViewVM.cs | 1 + .../MachineUpdate/MachineUpdateManager.cs | 43 ++++++- .../Performance/DefaultPerformanceService.cs | 2 +- .../SystemInfo/DefaultSystemInfoService.cs | 2 +- .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 9 +- .../UpdatePackages/DefaultPackageRunner.cs | 1 + .../UpdatePackages/IPackageRunner.cs | 1 + .../UpdatePackages/PPCPackageAttribute.cs | 1 + .../UpdatePackages/PackageInstallation.cs | 26 ---- .../UpdatePackages/PackageInstallationState.cs | 15 --- .../UpdatePackages/PackageStateChangedEventArgs.cs | 1 + .../Tango.PPC.Common/UpdatePackages/PackageType.cs | 14 --- .../UpdatePackages/PackagesFile.cs | 1 + .../Information/GetMachineInformationRequest.cs | 12 ++ .../Information/GetMachineInformationResponse.cs | 13 ++ .../Information/InformationPackage.cs | 19 +++ .../Performance/PerformancePackage.cs | 25 ++++ .../Performance/StartPerformanceUpdatesRequest.cs | 12 ++ .../Performance/StartPerformanceUpdatesResponse.cs | 13 ++ .../Tango.PPC.Shared/Properties/AssemblyInfo.cs | 23 ++++ .../Properties/Resources.Designer.cs | 62 +++++++++ .../PPC/Tango.PPC.Shared/Properties/Resources.resx | 117 +++++++++++++++++ .../Properties/Settings.Designer.cs | 30 +++++ .../Tango.PPC.Shared/Properties/Settings.settings | 7 ++ .../PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj | 104 ++++++++++++++++ .../PPC/Tango.PPC.Shared/Themes/Generic.xaml | 6 + .../Updates/GetUpdatesAndPackagesRequest.cs | 13 ++ .../Updates/GetUpdatesAndPackagesResponse.cs | 22 ++++ .../Updates/PackageInstallation.cs | 26 ++++ .../Updates/PackageInstallationState.cs | 15 +++ .../PPC/Tango.PPC.Shared/Updates/PackageType.cs | 14 +++ .../PPC/Tango.PPC.UI/Tango.PPC.UI.csproj | 6 +- .../ExtensionMethods/ObjectExtensions.cs | 6 +- .../Tango.FileSystem/FileExplorerControl.cs | 13 ++ .../ExternalBridge/ExternalBridgeService.cs | 2 +- .../Information/GetMachineInformationRequest.cs | 12 -- .../Information/GetMachineInformationResponse.cs | 13 -- .../Network/Information/InformationPackage.cs | 19 --- .../Network/Performance/PerformancePackage.cs | 25 ---- .../Performance/StartPerformanceUpdatesRequest.cs | 12 -- .../Performance/StartPerformanceUpdatesResponse.cs | 13 -- .../Tango.Integration/Tango.Integration.csproj | 8 +- .../Tango.SharedUI/Helpers/DataGridHelper.cs | 67 ++++++++++ .../Tango.SharedUI/Tango.SharedUI.csproj | 3 +- .../Tango.Transport/GenericMessageSerializer.cs | 137 ++++++++++++++++++++ .../Tango.Transport/ProtoSerializer.cs | 87 ------------- .../Tango.Transport/Tango.Transport.csproj | 4 +- .../Tango.Transport/TransporterBase.cs | 12 +- Software/Visual_Studio/Tango.sln | 35 +++++- 70 files changed, 1318 insertions(+), 280 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml create mode 100644 Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/IMachineUpdatesProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/MachineUpdatesResult.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/MachineUpdates/DefaultMachineUpdatesProvider.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallation.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallationState.cs delete mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageType.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/InformationPackage.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/PerformancePackage.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.resx create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.Designer.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.settings create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Themes/Generic.xaml create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesRequest.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesResponse.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallation.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallationState.cs create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageType.cs delete mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationRequest.cs delete mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs delete mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs delete mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/PerformancePackage.cs delete mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesRequest.cs delete mode 100644 Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesResponse.cs create mode 100644 Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs create mode 100644 Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs delete mode 100644 Software/Visual_Studio/Tango.Transport/ProtoSerializer.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj index be14e05f1..9484930e4 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Tango.FSE.PPCConsole.csproj @@ -112,6 +112,10 @@ + + + UpdatesView.xaml + ConsoleView.xaml @@ -158,6 +162,10 @@ + + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7} + Tango.PPC.Shared + {6b9774f7-960d-438e-ad81-c6b9be328d50} RealTimeGraphX.WPF @@ -236,6 +244,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs index 93317651c..4faa72e8e 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModelLocator.cs @@ -17,6 +17,7 @@ namespace Tango.FSE.PPCConsole TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); } public static MainViewVM MainViewVM @@ -58,5 +59,13 @@ namespace Tango.FSE.PPCConsole return TangoIOC.Default.GetInstance(); } } + + public static UpdatesViewVM UpdatesViewVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs index 5c73f70cc..e18a75ef6 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MainViewVM.cs @@ -19,6 +19,7 @@ namespace Tango.FSE.PPCConsole.ViewModels RemoteDesktopView, MonitoringView, FileSystemView, + UpdatesView, } private NavigationView _selectedView; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs index 890adcf54..64c8a124e 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs @@ -13,7 +13,7 @@ using Tango.Core.Helpers; using Tango.FSE.Common; using Tango.FSE.Common.Graphs; using Tango.FSE.Common.Performance; -using Tango.Integration.ExternalBridge.Network.Information; +using Tango.PPC.Shared.Information; using Tango.SystemInfo; using static Tango.SharedUI.Controls.NavigationControl; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs new file mode 100644 index 000000000..df29a6eeb --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.FSE.Common; +using Tango.PPC.Shared.Updates; +using static Tango.SharedUI.Controls.NavigationControl; + +namespace Tango.FSE.PPCConsole.ViewModels +{ + public class UpdatesViewVM : FSEViewModel, INavigationViewModel + { + private bool _loaded; + private ICollectionView _updatesView; + private ICollectionView _packagesView; + + private List _updates; + public List Updates + { + get { return _updates; } + set { _updates = value; RaisePropertyChangedAuto(); } + } + + private List _packages; + public List Packages + { + get { return _packages; } + set { _packages = value; RaisePropertyChangedAuto(); } + } + + private String _filter; + public String Filter + { + get { return _filter; } + set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + public RelayCommand RefreshCommand { get; set; } + public RelayCommand UpdateDetailsCommand { get; set; } + + public UpdatesViewVM() + { + UpdateDetailsCommand = new RelayCommand(DisplayUpdateDetails); + RefreshCommand = new RelayCommand(RefreshUpdates); + } + + private void RefreshUpdates() + { + _loaded = false; + LoadMachineUpdates(); + } + + private void DisplayUpdateDetails(TangoUpdate update) + { + Debug.WriteLine($"Update Details: {update.ApplicationVersion}"); + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + LoadMachineUpdates(); + } + + public override void OnApplicationStarted() + { + base.OnApplicationStarted(); + MachineProvider.MachineConnected += MachineProvider_MachineConnected; + } + + private void MachineProvider_MachineConnected(object sender, Common.Connection.MachineConnectedEventArgs e) + { + _loaded = false; + + if (IsVisible) + { + LoadMachineUpdates(); + } + } + + private void OnFilterChanged() + { + _updatesView?.Refresh(); + _packagesView?.Refresh(); + } + + private async void LoadMachineUpdates() + { + if (!_loaded) + { + try + { + IsFree = false; + await Task.Delay(1000); + var result = await MachineUpdatesProvider.GetUpdates(); + Updates = result.Updates.ToList(); + Packages = result.Packages.ToList(); + + _filter = null; + RaisePropertyChanged(nameof(Filter)); + + _updatesView = CollectionViewSource.GetDefaultView(Updates); + _updatesView.Filter = OnUpdatesFilter; + + _packagesView = CollectionViewSource.GetDefaultView(Packages); + _packagesView.Filter = OnPackagesFilter; + + _loaded = true; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error retrieving machine updates."); + } + finally + { + IsFree = true; + } + } + } + + private bool OnPackagesFilter(object obj) + { + PackageInstallation package = obj as PackageInstallation; + return String.IsNullOrWhiteSpace(Filter) || package.PackageName.ToLower().Contains(Filter.ToLower()); + } + + private bool OnUpdatesFilter(object obj) + { + TangoUpdate update = obj as TangoUpdate; + return String.IsNullOrWhiteSpace(Filter) || update.UpdateStatus.ToDescription().ToLower().Contains(Filter.ToLower()); + } + } +} diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml index e11014515..93e1355be 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/MainView.xaml @@ -34,7 +34,7 @@ - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml new file mode 100644 index 000000000..232d30893 --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Loading machine updates... + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml.cs new file mode 100644 index 000000000..959223f9b --- /dev/null +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.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.FSE.PPCConsole.Views +{ + /// + /// Interaction logic for ConsoleView.xaml + /// + public partial class UpdatesView : UserControl + { + public UpdatesView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs index ce61f30c6..bae284bfe 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs @@ -23,6 +23,7 @@ using Tango.FSE.Common.Logging; using Tango.FSE.Common.Navigation; using Tango.FSE.Common.Notifications; using Tango.FSE.Common.Performance; +using Tango.FSE.Common.MachineUpdates; using Tango.FSE.Common.RemoteDesktop; using Tango.FSE.Common.Resolution; using Tango.FSE.Common.Storage; @@ -125,6 +126,12 @@ namespace Tango.FSE.Common [TangoInject] public IStorageProvider StorageProvider { get; set; } + /// + /// Gets or sets the machine updates provider. + /// + [TangoInject] + public IMachineUpdatesProvider MachineUpdatesProvider { get; set; } + /// /// Gets or sets the FSE service. /// diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/IMachineUpdatesProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/IMachineUpdatesProvider.cs new file mode 100644 index 000000000..eff9e655b --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/IMachineUpdatesProvider.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.Common.MachineUpdates +{ + public interface IMachineUpdatesProvider + { + Task GetUpdates(); + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/MachineUpdatesResult.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/MachineUpdatesResult.cs new file mode 100644 index 000000000..870b4b618 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/MachineUpdates/MachineUpdatesResult.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.PPC.Shared.Updates; + +namespace Tango.FSE.Common.MachineUpdates +{ + public class MachineUpdatesResult + { + public List Updates { get; set; } + public List Packages { get; set; } + + public MachineUpdatesResult() + { + Updates = new List(); + Packages = new List(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Performance/PerformancePackageEventArgs.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Performance/PerformancePackageEventArgs.cs index 669890a29..c177ed5a6 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Performance/PerformancePackageEventArgs.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Performance/PerformancePackageEventArgs.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Tango.Integration.ExternalBridge.Network.Performance; +using Tango.PPC.Shared.Performance; namespace Tango.FSE.Common.Performance { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml index 5ff141bd7..8b549f98f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml @@ -467,19 +467,24 @@ + + + + + - - - + + + - - + + @@ -493,4 +498,28 @@ + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs index d21224c4d..b842d034f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/SystemInfo/ISystemInfoProvider.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Tango.Integration.ExternalBridge.Network.Information; +using Tango.PPC.Shared.Information; namespace Tango.FSE.Common.SystemInfo { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index ce56e7f69..f2bbcb71f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -135,6 +135,8 @@ + + @@ -272,6 +274,10 @@ + + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7} + Tango.PPC.Shared + {6b9774f7-960d-438e-ad81-c6b9be328d50} RealTimeGraphX.WPF diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/MachineUpdates/DefaultMachineUpdatesProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/MachineUpdates/DefaultMachineUpdatesProvider.cs new file mode 100644 index 000000000..4f2ee9b02 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/MachineUpdates/DefaultMachineUpdatesProvider.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.FSE.Common.Connection; +using Tango.FSE.Common.MachineUpdates; +using Tango.PPC.Shared.Updates; +using Tango.Transport; + +namespace Tango.FSE.UI.MachineUpdates +{ + public class DefaultMachineUpdatesProvider : IMachineUpdatesProvider + { + private MachineUpdatesResult _lastResult; + private IMachineProvider MachineProvider { get; set; } + + public DefaultMachineUpdatesProvider(IMachineProvider machineProvider) + { + MachineProvider = machineProvider; + MachineProvider.MachineDisconnected += MachineProvider_MachineDisconnected; + } + + private void MachineProvider_MachineDisconnected(object sender, MachineDisconnectedEventArgs e) + { + _lastResult = null; + } + + public async Task GetUpdates() + { + if (_lastResult != null) + { + return _lastResult; + } + + var response = await MachineProvider.MachineOperator.SendGenericRequest(new GetUpdatesAndPackagesRequest() { }, new TransportRequestConfig() + { + Timeout = TimeSpan.FromSeconds(30) + }); + + MachineUpdatesResult result = new MachineUpdatesResult(); + result.Updates = response.Updates.Select(x => x.ToObservable()).ToList(); + result.Packages = response.Packages; + + _lastResult = result; + + return result; + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs index 69184290a..8debcd73b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Performance/DefaultPerformanceProvider.cs @@ -7,7 +7,7 @@ using Tango.Core; using Tango.Core.DI; using Tango.FSE.Common.Connection; using Tango.FSE.Common.Performance; -using Tango.Integration.ExternalBridge.Network.Performance; +using Tango.PPC.Shared.Performance; namespace Tango.FSE.UI.Performance { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs index e691939f0..5fcc1809d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/SystemInfo/DefaultSystemInfoProvider.cs @@ -7,7 +7,7 @@ using Tango.Core; using Tango.Core.DI; using Tango.FSE.Common.Connection; using Tango.FSE.Common.SystemInfo; -using Tango.Integration.ExternalBridge.Network.Information; +using Tango.PPC.Shared.Information; namespace Tango.FSE.UI.SystemInfo { diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index b4854db5a..eb6810d48 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -170,6 +170,7 @@ + @@ -331,6 +332,10 @@ + + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7} + Tango.PPC.Shared + {bb2abb74-ba58-4812-83aa-ec8171f42df4} Tango.AutoComplete diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs index 1ffb0cbb7..d94e4ff9c 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs @@ -19,6 +19,7 @@ using Tango.FSE.Common.Modules; using Tango.FSE.Common.Navigation; using Tango.FSE.Common.Notifications; using Tango.FSE.Common.Performance; +using Tango.FSE.Common.MachineUpdates; using Tango.FSE.Common.RemoteDesktop; using Tango.FSE.Common.Resolution; using Tango.FSE.Common.Storage; @@ -36,6 +37,7 @@ using Tango.FSE.UI.Modules; using Tango.FSE.UI.Navigation; using Tango.FSE.UI.Notifications; using Tango.FSE.UI.Performance; +using Tango.FSE.UI.MachineUpdates; using Tango.FSE.UI.RemoteDesktop; using Tango.FSE.UI.Resolution; using Tango.FSE.UI.Storage; @@ -67,6 +69,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); TangoIOC.Default.Unregister(); + TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); //TangoIOC.Default.Unregister(); @@ -93,6 +96,7 @@ namespace Tango.FSE.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj index bdbc5992c..e8eec7b2f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/Tango.PPC.Technician.csproj @@ -181,6 +181,10 @@ {0BE74EEE-22CB-4DBA-B896-793B9E1A3AC0} Tango.PPC.Common + + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7} + Tango.PPC.Shared + {f02eaa84-ad59-465b-99a2-4422c13bfb72} Tango.PPC.Browser diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs index 3f3e44c4d..1d7e1780a 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Technician/ViewModels/PackagesViewVM.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Tango.Core.DI; using Tango.PPC.Common; using Tango.PPC.Common.UpdatePackages; +using Tango.PPC.Shared.Updates; namespace Tango.PPC.Technician.ViewModels { 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 1d010ecfb..733574f72 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -31,10 +31,14 @@ using Tango.SharedUI.Helpers; using Tango.SQLExaminer; using Tango.Transport.Web; using System.Data.Entity; +using Tango.PPC.Common.ExternalBridge; +using Tango.Integration.ExternalBridge; +using Tango.BL.DTO; +using Tango.PPC.Shared.Updates; namespace Tango.PPC.Common.MachineUpdate { - public class MachineUpdateManager : ExtendedObject, IMachineUpdateManager + public class MachineUpdateManager : ExtendedObject, IMachineUpdateManager, IExternalBridgeRequestHandler { private IPPCApplicationManager _app_manager; private IMachineProvider _machineProvider; @@ -95,7 +99,7 @@ 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) + public MachineUpdateManager(PPCWebClient ppcWebClient, IPPCApplicationManager applicationManager, IMachineProvider machineProvider, IPackageRunner packageRunner, IPPCExternalBridgeService externalBridge) { _client = ppcWebClient; _machineProvider = machineProvider; @@ -111,6 +115,8 @@ namespace Tango.PPC.Common.MachineUpdate _checkForUpdateTimer = new System.Timers.Timer(_settings.AutoUpdateCheckInterval.TotalMilliseconds); _checkForUpdateTimer.Elapsed += _checkForUpdateTimer_Elapsed; _checkForUpdateTimer.Start(); + + externalBridge.RegisterRequestHandler(this); } #endregion @@ -1676,5 +1682,38 @@ namespace Tango.PPC.Common.MachineUpdate } #endregion + + #region External Bridge + + public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) + { + + } + + [ExternalBridgeRequestHandlerMethod(typeof(GetUpdatesAndPackagesRequest))] + public async void OnGetUpdatesAndPackagesRequest(GetUpdatesAndPackagesRequest request, String token, ExternalBridgeReceiver receiver) + { + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var updates = await db.TangoUpdates.OrderByDescending(x => x.StartDate).ToListAsync(); + var updatesDTO = updates.Select(x => TangoUpdateDTO.FromObservable(x)).ToList(); + var packages = (await _packageRunner.GetPackagesFile()).PackageInstallations; + + var response = new GetUpdatesAndPackagesResponse(); + response.Updates.AddRange(updatesDTO); + response.Packages.AddRange(packages); + + await receiver.SendGenericResponse(response, token); + } + } + catch (Exception ex) + { + await receiver.SendErrorResponse(ex, token); + } + } + + #endregion } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs index 2279d204c..d327f6b00 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Performance/DefaultPerformanceService.cs @@ -10,8 +10,8 @@ using System.Threading.Tasks; using Tango.Core; using Tango.Core.DI; using Tango.Integration.ExternalBridge; -using Tango.Integration.ExternalBridge.Network.Performance; using Tango.PPC.Common.ExternalBridge; +using Tango.PPC.Shared.Performance; namespace Tango.PPC.Common.Performance { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs index a5e8516a4..ef8e31bce 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs @@ -8,10 +8,10 @@ using System.Threading.Tasks; using Tango.Core; using Tango.Core.DI; using Tango.Integration.ExternalBridge; -using Tango.Integration.ExternalBridge.Network.Information; using Tango.PPC.Common.Application; using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.ExternalBridge; +using Tango.PPC.Shared.Information; using Tango.Settings; using Tango.SystemInfo; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index ad197f47b..9575b7137 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -181,13 +181,10 @@ - - - @@ -429,6 +426,10 @@ {6aa425c9-ea6a-4b01-aaed-5ff122e8b663} Tango.WiFi + + {208c8bd8-72c6-4e3c-acaa-351091a2acc7} + Tango.PPC.Shared + @@ -455,7 +456,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs index c94aedeb0..68b31da4e 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/DefaultPackageRunner.cs @@ -15,6 +15,7 @@ using Tango.Core.Helpers; using Tango.PPC.Common.Application; using Tango.PPC.Common.Connection; using Tango.PPC.Common.Notifications; +using Tango.PPC.Shared.Updates; namespace Tango.PPC.Common.UpdatePackages { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs index b864100aa..cdffd1ddc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/IPackageRunner.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Shared.Updates; namespace Tango.PPC.Common.UpdatePackages { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PPCPackageAttribute.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PPCPackageAttribute.cs index 3186b57b1..6067b0c18 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PPCPackageAttribute.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PPCPackageAttribute.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Shared.Updates; namespace Tango.PPC.Common.UpdatePackages { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallation.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallation.cs deleted file mode 100644 index bf00915bd..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallation.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.PPC.Common.UpdatePackages -{ - public class PackageInstallation - { - public String PackageName { get; set; } - - public PackageType Type { get; set; } - - public DateTime InstallationDate { get; set; } - - public PackageInstallationState State { get; set; } - - public String FailedReason { get; set; } - - public PackageInstallation() - { - InstallationDate = DateTime.Now; - } - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallationState.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallationState.cs deleted file mode 100644 index 1300352fb..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageInstallationState.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.PPC.Common.UpdatePackages -{ - public enum PackageInstallationState - { - NotInstalled, - Installed, - Failed, - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageStateChangedEventArgs.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageStateChangedEventArgs.cs index 9c8cbe2c0..cadba4c72 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageStateChangedEventArgs.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageStateChangedEventArgs.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Shared.Updates; namespace Tango.PPC.Common.UpdatePackages { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageType.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageType.cs deleted file mode 100644 index 48a2140b1..000000000 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackageType.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.PPC.Common.UpdatePackages -{ - public enum PackageType - { - Pre, - Post - } -} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackagesFile.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackagesFile.cs index 2fbd30d9f..7af30d2ec 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackagesFile.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UpdatePackages/PackagesFile.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Shared.Updates; namespace Tango.PPC.Common.UpdatePackages { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationRequest.cs new file mode 100644 index 000000000..1464c15ac --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Information +{ + public class GetMachineInformationRequest + { + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationResponse.cs new file mode 100644 index 000000000..e88bfce05 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/GetMachineInformationResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Information +{ + public class GetMachineInformationResponse + { + public InformationPackage Package { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/InformationPackage.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/InformationPackage.cs new file mode 100644 index 000000000..e48413db6 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Information/InformationPackage.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SystemInfo; + +namespace Tango.PPC.Shared.Information +{ + public class InformationPackage + { + public List System { get; set; } + + public InformationPackage() + { + System = new List(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/PerformancePackage.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/PerformancePackage.cs new file mode 100644 index 000000000..855437bcc --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/PerformancePackage.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Performance +{ + public class PerformancePackage + { + public int CPU { get; set; } + public int ApplicationCPU { get; set; } + + public int RAM { get; set; } + public int ApplicationRAM { get; set; } + public int MaxRAM { get; set; } + + public int Temperature { get; set; } + + public int AvailableDiskSpace { get; set; } + public int DiskCapacity { get; set; } + + public DateTime DateTime { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesRequest.cs new file mode 100644 index 000000000..69fbaf631 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Performance +{ + public class StartPerformanceUpdatesRequest + { + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesResponse.cs new file mode 100644 index 000000000..196225572 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Performance/StartPerformanceUpdatesResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Performance +{ + public class StartPerformanceUpdatesResponse + { + public PerformancePackage Package { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..c9efeb790 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/AssemblyInfo.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango Panel PC Shared Library")] +[assembly: AssemblyVersion("1.0.0.0")] + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + +//Friends With +[assembly: InternalsVisibleTo("Tango.PPC.UI")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.Designer.cs new file mode 100644 index 000000000..416184c0f --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.PPC.Shared.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.PPC.Shared.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.resx b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.Designer.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.Designer.cs new file mode 100644 index 000000000..0b65472a5 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Tango.PPC.Shared.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.settings b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj new file mode 100644 index 000000000..2ae1c7575 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj @@ -0,0 +1,104 @@ + + + + + Debug + AnyCPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7} + library + Tango.PPC.Shared + Tango.PPC.Shared + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + true + full + false + ..\..\Build\PPC\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Build\PPC\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + GlobalVersionInfo.cs + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {997a961c-beda-4b56-aa0f-c39e532f7ffa} + Tango.SystemInfo + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Themes/Generic.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Themes/Generic.xaml new file mode 100644 index 000000000..1226f66d1 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Themes/Generic.xaml @@ -0,0 +1,6 @@ + + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesRequest.cs new file mode 100644 index 000000000..f8cadc49d --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Updates +{ + public class GetUpdatesAndPackagesRequest + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesResponse.cs new file mode 100644 index 000000000..d264739d7 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesResponse.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.DTO; + +namespace Tango.PPC.Shared.Updates +{ + public class GetUpdatesAndPackagesResponse + { + public List Updates { get; set; } + + public List Packages { get; set; } + + public GetUpdatesAndPackagesResponse() + { + Updates = new List(); + Packages = new List(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallation.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallation.cs new file mode 100644 index 000000000..639fd76bf --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallation.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Updates +{ + public class PackageInstallation + { + public String PackageName { get; set; } + + public PackageType Type { get; set; } + + public DateTime InstallationDate { get; set; } + + public PackageInstallationState State { get; set; } + + public String FailedReason { get; set; } + + public PackageInstallation() + { + InstallationDate = DateTime.Now; + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallationState.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallationState.cs new file mode 100644 index 000000000..51ae2abce --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageInstallationState.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Updates +{ + public enum PackageInstallationState + { + NotInstalled, + Installed, + Failed, + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageType.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageType.cs new file mode 100644 index 000000000..0e553ca21 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/PackageType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.Updates +{ + public enum PackageType + { + Pre, + Post + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 45eaa0e50..9a5824d81 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -558,6 +558,10 @@ {0be74eee-22cb-4dba-b896-793b9e1a3ac0} Tango.PPC.Common + + {208c8bd8-72c6-4e3c-acaa-351091a2acc7} + Tango.PPC.Shared + @@ -693,7 +697,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)" - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs index cee991507..3b344ce56 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs @@ -126,7 +126,11 @@ namespace Tango.Core.ExtensionMethods var desProp = destination.GetType().GetProperty(prop.Name, BindingFlags.Public | BindingFlags.Instance); - if (desProp != null && desProp.PropertyType == prop.PropertyType && desProp.SetMethod != null) + if (desProp != null && desProp.SetMethod != null && desProp.PropertyType.IsEnum && prop.PropertyType.IsEnum) + { + desProp.SetValue(destination, Enum.Parse(desProp.PropertyType, value.ToString())); + } + else if (desProp != null && desProp.PropertyType == prop.PropertyType && desProp.SetMethod != null) { desProp.SetValue(destination, value); } diff --git a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs index 0769b3576..0a7fe8ddc 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs @@ -415,6 +415,19 @@ namespace Tango.FileSystem UploadCommandInternal = new RelayCommand(() => { UploadCommand?.Execute(null); + },() => + { + if (CurrentItem == null) return false; + + if (CurrentItem is FolderItem) + { + if ((CurrentItem as FolderItem).IsRoot) + { + return false; + } + } + + return true; }); } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs index 58df06fd8..f981ce8bb 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs @@ -427,7 +427,7 @@ namespace Tango.Integration.ExternalBridge { if (_requestHandlers.ContainsKey(genericType.Name)) { - var innerMessage = ProtoSerializer.DeserializeFromByteString(genericType, (message as GenericRequest).Data); //JsonConvert.DeserializeObject(json, _genericMessageSettings); + var innerMessage = GenericMessageSerializer.DeserializeFromByteString(genericType, (message as GenericRequest).Data); //JsonConvert.DeserializeObject(json, _genericMessageSettings); var handler = _requestHandlers[genericType.Name]; handler.Method.Invoke(handler.Handler, new object[] diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationRequest.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationRequest.cs deleted file mode 100644 index 38c06b024..000000000 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Integration.ExternalBridge.Network.Information -{ - public class GetMachineInformationRequest - { - } -} diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs deleted file mode 100644 index 5ae1aa440..000000000 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/GetMachineInformationResponse.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Integration.ExternalBridge.Network.Information -{ - public class GetMachineInformationResponse - { - public InformationPackage Package { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs deleted file mode 100644 index afa23492e..000000000 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Information/InformationPackage.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.SystemInfo; - -namespace Tango.Integration.ExternalBridge.Network.Information -{ - public class InformationPackage - { - public List System { get; set; } - - public InformationPackage() - { - System = new List(); - } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/PerformancePackage.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/PerformancePackage.cs deleted file mode 100644 index 56921e0c5..000000000 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/PerformancePackage.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Integration.ExternalBridge.Network.Performance -{ - public class PerformancePackage - { - public int CPU { get; set; } - public int ApplicationCPU { get; set; } - - public int RAM { get; set; } - public int ApplicationRAM { get; set; } - public int MaxRAM { get; set; } - - public int Temperature { get; set; } - - public int AvailableDiskSpace { get; set; } - public int DiskCapacity { get; set; } - - public DateTime DateTime { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesRequest.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesRequest.cs deleted file mode 100644 index 2c036e937..000000000 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Integration.ExternalBridge.Network.Performance -{ - public class StartPerformanceUpdatesRequest - { - } -} diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesResponse.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesResponse.cs deleted file mode 100644 index 8eb22bdef..000000000 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Network/Performance/StartPerformanceUpdatesResponse.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Integration.ExternalBridge.Network.Performance -{ - public class StartPerformanceUpdatesResponse - { - public PerformancePackage Package { get; set; } - } -} diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 1356c115c..8ecbd3d09 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -106,12 +106,6 @@ - - - - - - @@ -221,7 +215,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs b/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs new file mode 100644 index 000000000..80c847a45 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Helpers/DataGridHelper.cs @@ -0,0 +1,67 @@ +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.Input; + +namespace Tango.SharedUI.Helpers +{ + public static class DataGridHelper + { + #region DoubleClickCommand + + /// + /// Determines whether an element is DoubleClickCommand by the drag and drop service. + /// + public static readonly DependencyProperty DoubleClickCommandProperty = + DependencyProperty.RegisterAttached("DoubleClickCommand", + typeof(ICommand), typeof(DataGridHelper), + new FrameworkPropertyMetadata(null, DoubleClickCommandChanged)); + + /// + /// DoubleClickCommand changed. + /// + /// The d. + /// The instance containing the event data. + private static void DoubleClickCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs xx) + { + if (xx.NewValue != null) + { + var dataGrid = d as DataGrid; + + dataGrid.MouseDoubleClick += (x, e) => + { + if (dataGrid.SelectedItem != null && (e.OriginalSource as UIElement != null) && (e.OriginalSource as FrameworkElement).DataContext == dataGrid.SelectedItem) + { + (xx.NewValue as ICommand)?.Execute(dataGrid.SelectedItem); + } + }; + } + } + + /// + /// Sets the DoubleClickCommand attached property. + /// + /// The element. + /// if set to true [value]. + public static void SetDoubleClickCommand(DataGrid dataGrid, ICommand value) + { + dataGrid.SetValue(DoubleClickCommandProperty, value); + } + + /// + /// Gets the DoubleClickCommand attached property. + /// + /// The element. + /// + public static ICommand GetDoubleClickCommand(DataGrid dataGrid) + { + return (ICommand)dataGrid.GetValue(DoubleClickCommandProperty); + } + + #endregion + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index 4764d0eac..000a4e5d7 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -156,6 +156,7 @@ + @@ -254,7 +255,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs b/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs new file mode 100644 index 000000000..aa3486dc3 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs @@ -0,0 +1,137 @@ +using Google.Protobuf; +using Newtonsoft.Json; +using ProtoBuf; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Common; +using Tango.PMR.Integration; + +namespace Tango.Transport +{ + public static class GenericMessageSerializer + { + public enum GenericMessageSerializerMode + { + Json, + Protobuf + } + + public static GenericMessageSerializerMode Mode { get; set; } + + static GenericMessageSerializer() + { + ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddMissingTypes = true; + ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddProtoContractTypesOnly = false; + ProtoBuf.Meta.RuntimeTypeModel.Default.InferTagFromNameDefault = true; + ProtoBuf.Meta.RuntimeTypeModel.Default.UseImplicitZeroDefaults = true; + } + + public static object Deserialize(Type type, byte[] array) + { + if (Mode == GenericMessageSerializerMode.Json) + { + return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(array), type); + } + else + { + AutoProtobuf.Build(type); + + using (MemoryStream ms = new MemoryStream(array)) + { + return Serializer.Deserialize(type, ms); + } + } + } + + public static object DeserializeFromByteString(Type type, ByteString byteString) + { + if (Mode == GenericMessageSerializerMode.Json) + { + return JsonConvert.DeserializeObject(byteString.ToStringUtf8(), type); + } + else + { + AutoProtobuf.Build(type); + return Deserialize(type, byteString.ToByteArray()); + } + } + + //--------------------------------------------------------------------- + + public static byte[] Serialize(T message) + { + if (Mode == GenericMessageSerializerMode.Json) + { + return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)); + } + else + { + AutoProtobuf.Build(); + + using (MemoryStream ms = new MemoryStream()) + { + Serializer.Serialize(ms, message); + return ms.ToArray(); + } + } + } + + public static T Deserialize(byte[] array) + { + if (Mode == GenericMessageSerializerMode.Json) + { + return (T)Deserialize(typeof(T), array); + } + else + { + AutoProtobuf.Build(); + + using (MemoryStream ms = new MemoryStream(array)) + { + return Serializer.Deserialize(ms); + } + } + } + + public static ByteString SerializeToByteString(T message) + { + if (Mode == GenericMessageSerializerMode.Json) + { + return ByteString.CopyFromUtf8(JsonConvert.SerializeObject(message)); + } + else + { + AutoProtobuf.Build(); + + return ByteString.CopyFrom(Serialize(message)); + } + } + + public static T DeserializeFromByteString(ByteString byteString) + { + if (Mode == GenericMessageSerializerMode.Json) + { + return JsonConvert.DeserializeObject(byteString.ToStringUtf8()); + } + else + { + AutoProtobuf.Build(); + + return Deserialize(byteString.ToByteArray()); + } + } + + public static T ExtractGenericRequestFromContainer(MessageContainer container) where T : class + { + var message = MessageFactory.ExtractMessageFromContainer(container); + var genericType = Type.GetType((message as GenericRequest).Type); + var innerMessage = DeserializeFromByteString(genericType, (message as GenericRequest).Data); + return innerMessage as T; + } + } +} diff --git a/Software/Visual_Studio/Tango.Transport/ProtoSerializer.cs b/Software/Visual_Studio/Tango.Transport/ProtoSerializer.cs deleted file mode 100644 index c974f2712..000000000 --- a/Software/Visual_Studio/Tango.Transport/ProtoSerializer.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Google.Protobuf; -using ProtoBuf; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.PMR; -using Tango.PMR.Common; -using Tango.PMR.Integration; - -namespace Tango.Transport -{ - public static class ProtoSerializer - { - static ProtoSerializer() - { - ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddMissingTypes = true; - ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddProtoContractTypesOnly = false; - ProtoBuf.Meta.RuntimeTypeModel.Default.InferTagFromNameDefault = true; - ProtoBuf.Meta.RuntimeTypeModel.Default.UseImplicitZeroDefaults = true; - } - - public static object Deserialize(Type type, byte[] array) - { - AutoProtobuf.Build(type); - - using (MemoryStream ms = new MemoryStream(array)) - { - return Serializer.Deserialize(type, ms); - } - } - - public static object DeserializeFromByteString(Type type, ByteString byteString) - { - AutoProtobuf.Build(type); - - return Deserialize(type, byteString.ToByteArray()); - } - - //--------------------------------------------------------------------- - - public static byte[] Serialize(T message) - { - AutoProtobuf.Build(); - - using (MemoryStream ms = new MemoryStream()) - { - Serializer.Serialize(ms, message); - return ms.ToArray(); - } - } - - public static T Deserialize(byte[] array) - { - AutoProtobuf.Build(); - - using (MemoryStream ms = new MemoryStream(array)) - { - return Serializer.Deserialize(ms); - } - } - - public static ByteString SerializeToByteString(T message) - { - AutoProtobuf.Build(); - - return ByteString.CopyFrom(Serialize(message)); - } - - public static T DeserializeFromByteString(ByteString byteString) - { - AutoProtobuf.Build(); - - return Deserialize(byteString.ToByteArray()); - } - - public static T ExtractGenericRequestFromContainer(MessageContainer container) where T : class - { - var message = MessageFactory.ExtractMessageFromContainer(container); - var genericType = Type.GetType((message as GenericRequest).Type); - var innerMessage = ProtoSerializer.DeserializeFromByteString(genericType, (message as GenericRequest).Data); - return innerMessage as T; - } - } -} diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 120584798..f83384097 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -125,7 +125,7 @@ - + @@ -186,7 +186,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index 5e076738c..0958e4d9f 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -334,7 +334,7 @@ namespace Tango.Transport if (handlers.Count > 0) { - var innerRequest = ProtoSerializer.DeserializeFromByteString(handlers[0].RequestType, genericRequest.Data); + var innerRequest = GenericMessageSerializer.DeserializeFromByteString(handlers[0].RequestType, genericRequest.Data); foreach (var handler in handlers) { @@ -930,10 +930,10 @@ namespace Tango.Transport { GenericRequest genericRequest = new GenericRequest(); genericRequest.Type = request.GetType().AssemblyQualifiedName; - genericRequest.Data = ProtoSerializer.SerializeToByteString(request); + genericRequest.Data = GenericMessageSerializer.SerializeToByteString(request); var response = await SendRequest(genericRequest, config); - var responseObject = ProtoSerializer.DeserializeFromByteString(response.Message.Data); + var responseObject = GenericMessageSerializer.DeserializeFromByteString(response.Message.Data); return responseObject; } @@ -949,7 +949,7 @@ namespace Tango.Transport { GenericResponse genericResponse = new GenericResponse(); - genericResponse.Data = ProtoSerializer.SerializeToByteString(response); + genericResponse.Data = GenericMessageSerializer.SerializeToByteString(response); await SendResponse(genericResponse, token, config); } @@ -966,7 +966,7 @@ namespace Tango.Transport GenericRequest genericRequest = new GenericRequest(); genericRequest.Type = request.GetType().AssemblyQualifiedName; - genericRequest.Data = ProtoSerializer.SerializeToByteString(request); + genericRequest.Data = GenericMessageSerializer.SerializeToByteString(request); Subject subject = new Subject(); @@ -975,7 +975,7 @@ namespace Tango.Transport try { - var responseObject = ProtoSerializer.DeserializeFromByteString(response.Message.Data); + var responseObject = GenericMessageSerializer.DeserializeFromByteString(response.Message.Data); subject.OnNext(responseObject); } catch (Exception ex) diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 6e79d8d13..96548aaac 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -369,6 +369,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.SystemInfo", "Tango.S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.FileSystem", "Tango.FileSystem\Tango.FileSystem.csproj", "{C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PPC.Shared", "PPC\Tango.PPC.Shared\Tango.PPC.Shared.csproj", "{208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -3422,6 +3424,26 @@ Global {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|x64.Build.0 = Release|Any CPU {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|x86.ActiveCfg = Release|Any CPU {C6EBBBBE-2123-44DC-AEF7-A0D47D736AC0}.Release|x86.Build.0 = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|ARM.ActiveCfg = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|ARM.Build.0 = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|ARM64.Build.0 = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|x64.ActiveCfg = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|x64.Build.0 = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|x86.ActiveCfg = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Debug|x86.Build.0 = Debug|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|Any CPU.Build.0 = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|ARM.ActiveCfg = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|ARM.Build.0 = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|ARM64.ActiveCfg = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|ARM64.Build.0 = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|x64.ActiveCfg = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|x64.Build.0 = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|x86.ActiveCfg = Release|Any CPU + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3544,14 +3566,15 @@ Global {834C81C3-09B5-45D7-BE12-E7D1E6655A7C} = {004337EB-0761-4D30-B9F5-AE6E1CFC6013} {866B916A-207C-43F0-B403-7C4A820C2E11} = {4EE6DBA1-71BC-49E2-8DC7-266487E61050} {A07E6CB4-0132-4EB1-9A38-C8C057884DC2} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} + {208C8BD8-72C6-4E3C-ACAA-351091A2ACC7} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_UpdateFileVersion = False - BuildVersion_StartDate = 2000/1/1 - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs BuildVersion_UseGlobalSettings = False + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_StartDate = 2000/1/1 + BuildVersion_UpdateFileVersion = False + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} EndGlobalSection EndGlobal -- cgit v1.3.1