aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-12-05 19:51:45 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-12-05 19:51:45 +0200
commitcf5c35b14c3fe78874d28d3cb230adb123b1fd75 (patch)
tree82711fcb58d8a7a309c036daaeb245af77ca08d2 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance
parentd061840379f8dab9c5a47a1771ecc7e763eb8c0c (diff)
downloadTango-cf5c35b14c3fe78874d28d3cb230adb123b1fd75.tar.gz
Tango-cf5c35b14c3fe78874d28d3cb230adb123b1fd75.zip
Implemented "Export System Logs" on PPC maitenance.
Related Work Items: #1617
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj13
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs69
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml2
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/packages.config1
4 files changed, 82 insertions, 3 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
index ca7e1d1dc..a43fc2dc3 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Tango.PPC.Maintenance.csproj
@@ -45,6 +45,9 @@
<Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
+ <Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
+ <HintPath>..\..\..\packages\Ionic.Zip.1.9.1.8\lib\Ionic.Zip.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
@@ -164,6 +167,10 @@
<Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project>
<Name>Tango.DragAndDrop</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\..\Tango.Explorer\Tango.Explorer.csproj">
+ <Project>{4399af76-db52-4cfb-8020-6f85bdb29fd5}</Project>
+ <Name>Tango.Explorer</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\..\Tango.Integration\Tango.Integration.csproj">
<Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project>
<Name>Tango.Integration</Name>
@@ -196,6 +203,10 @@
<Project>{0be74eee-22cb-4dba-b896-793b9e1a3ac0}</Project>
<Name>Tango.PPC.Common</Name>
</ProjectReference>
+ <ProjectReference Include="..\Tango.PPC.Storage\Tango.PPC.Storage.csproj">
+ <Project>{04febb02-f782-4b96-b47d-f6902afa43be}</Project>
+ <Name>Tango.PPC.Storage</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\maintenance.png" />
@@ -247,7 +258,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
index 6622bc2f4..aeb349bdc 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
@@ -1,16 +1,20 @@
-using System;
+using Ionic.Zip;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
+using Tango.Explorer;
using Tango.Integration.Operation;
+using Tango.Logging;
using Tango.PMR.MachineStatus;
using Tango.PPC.Common;
using Tango.PPC.Maintenance.Helpers;
using Tango.PPC.Maintenance.Models;
using Tango.PPC.Maintenance.Views;
+using Tango.PPC.Storage;
namespace Tango.PPC.Maintenance.ViewModels
{
@@ -38,6 +42,8 @@ namespace Tango.PPC.Maintenance.ViewModels
public RelayCommand CloseDyeingHeadCommand { get; set; }
+ public RelayCommand ExportLogsCommand { get; set; }
+
public MaintenanceViewVM()
{
Guides = new ObservableCollection<GuideBase>(GuideHelper.CreateAllGuides());
@@ -47,6 +53,7 @@ namespace Tango.PPC.Maintenance.ViewModels
OpenDyeingHeadCommand = new RelayCommand(OpenDyeingHead);
CloseDyeingHeadCommand = new RelayCommand(CloseDyeingHead);
+ ExportLogsCommand = new RelayCommand(ExportLogsToStorage);
}
public override void OnApplicationStarted()
@@ -173,5 +180,65 @@ namespace Tango.PPC.Maintenance.ViewModels
IsFree = true;
}
}
+
+ private async void ExportLogsToStorage()
+ {
+ var result = await NavigationManager.
+ NavigateForResult<StorageModule,
+ Storage.Views.MainView, ExplorerFileItem,
+ Storage.Models.StorageNavigationRequest>(
+ new Storage.Models.StorageNavigationRequest()
+ {
+ Intent = Storage.Models.StorageNavigationIntent.SaveFile,
+ DefaultFileName = $"Tango-Logs-{DateTime.Now.ToFileName()}",
+ Filter = "do not display anything",
+ Title = "Export System Logs",
+ });
+
+ if (result != null)
+ {
+ String file = result.Path + ".zip";
+
+ IsFree = false;
+
+ try
+ {
+ NotificationProvider.SetGlobalBusyMessage("Exporting system logs...");
+
+ var appFileLogger = LogManager.RegisteredLoggers.FirstOrDefault(x => x is FileLogger) as FileLogger;
+
+ await Task.Factory.StartNew(() =>
+ {
+ using (ZipFile zip = new ZipFile(file))
+ {
+ zip.Password = "1Creativity";
+
+ if (appFileLogger != null)
+ {
+ zip.AddDirectory(appFileLogger.Folder);
+ }
+
+ zip.ParallelDeflateThreshold = -1;
+ zip.Save();
+ }
+ });
+
+ NotificationProvider.ReleaseGlobalBusyMessage();
+
+ await NotificationProvider.ShowSuccess("System logs exported successfully.");
+ }
+ catch (Exception ex)
+ {
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ LogManager.Log(ex, "Error exporting system logs.");
+ await NotificationProvider.ShowError($"An error occurred while trying to export the system logs.\n{ex.FlattenMessage()}");
+ }
+ finally
+ {
+ NotificationProvider.ReleaseGlobalBusyMessage();
+ IsFree = true;
+ }
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
index 03d059999..c843daffc 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/Views/MaintenanceView.xaml
@@ -171,7 +171,7 @@
<touch:TouchButton Command="{Binding CloseDyeingHeadCommand}" Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}">CLOSE DYEING HEAD LEAD</touch:TouchButton>
- <touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}">RUN HEAD CLEANING</touch:TouchButton>
+ <touch:TouchButton Margin="20" CornerRadius="25" Height="50" FontSize="18" Style="{StaticResource TangoHollowButton}" Command="{Binding ExportLogsCommand}" >EXPORT SYSTEM LOGS</touch:TouchButton>
</UniformGrid>
</StackPanel>
</StackPanel>
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/packages.config b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/packages.config
index 7dea9c43f..d6bb93fd4 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/packages.config
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/packages.config
@@ -4,6 +4,7 @@
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net46" />
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net46" />
<package id="Google.Protobuf" version="3.4.1" targetFramework="net46" />
+ <package id="Ionic.Zip" version="1.9.1.8" targetFramework="net461" />
<package id="System.Reactive.Core" version="3.1.1" targetFramework="net461" />
<package id="System.Reactive.Interfaces" version="3.1.1" targetFramework="net461" />
<package id="System.Reactive.Linq" version="3.1.1" targetFramework="net461" />