diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-30 00:56:02 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-30 00:56:02 +0300 |
| commit | 091a4bdeb2feadb4962c6be5deb367ab56d81707 (patch) | |
| tree | 289a672287063108b851b2831d4c699dcddd26d9 /Software/Visual_Studio/PPC/Tango.PPC.Common | |
| parent | 3d6a882cf14f36297d8b379e0fdf65376064edf7 (diff) | |
| download | Tango-091a4bdeb2feadb4962c6be5deb367ab56d81707.tar.gz Tango-091a4bdeb2feadb4962c6be5deb367ab56d81707.zip | |
Implemented PPC Updates & Packages.
Moved PPC/FSE interfaces to PPC.Shared.
Changes Generic Serialization to json.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common')
12 files changed, 53 insertions, 63 deletions
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 <see cref="MachineUpdateManager"/> class. /// </summary> /// <param name="applicationManager">The application manager.</param> - 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 @@ <Compile Include="UpdatePackages\IPackageRunner.cs" /> <Compile Include="UpdatePackages\IPPCPackage.cs" /> <Compile Include="UpdatePackages\PackageContext.cs" /> - <Compile Include="UpdatePackages\PackageInstallation.cs" /> - <Compile Include="UpdatePackages\PackageInstallationState.cs" /> <Compile Include="UpdatePackages\PackageProgressEventArgs.cs" /> <Compile Include="UpdatePackages\PackageRunnerResult.cs" /> <Compile Include="UpdatePackages\PackageStateChangedEventArgs.cs" /> <Compile Include="UpdatePackages\PackagesFile.cs" /> - <Compile Include="UpdatePackages\PackageType.cs" /> <Compile Include="UpdatePackages\PPCPackageAttribute.cs" /> <Compile Include="Publish\PPCPublisher.cs" /> <Compile Include="Publish\PublishInfo.cs" /> @@ -429,6 +426,10 @@ <Project>{6aa425c9-ea6a-4b01-aaed-5ff122e8b663}</Project> <Name>Tango.WiFi</Name> </ProjectReference> + <ProjectReference Include="..\Tango.PPC.Shared\Tango.PPC.Shared.csproj"> + <Project>{208c8bd8-72c6-4e3c-acaa-351091a2acc7}</Project> + <Name>Tango.PPC.Shared</Name> + </ProjectReference> </ItemGroup> <ItemGroup> <BootstrapperPackage Include=".NETFramework,Version=v4.6"> @@ -455,7 +456,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ 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 { |
