aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-24 06:48:05 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-24 06:48:05 +0300
commita749f032ba876742415c75a001894422f19cf146 (patch)
treeb8f8922f2c121e95705da42f55bfd79a77e53c87 /Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI
parent637f1c02f2dcfce2d9ec201369af1f81e336443d (diff)
downloadTango-a749f032ba876742415c75a001894422f19cf146.tar.gz
Tango-a749f032ba876742415c75a001894422f19cf146.zip
Added installer FSE log viewer file association.
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Tango.FSE.LogViewer.UI.csproj9
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/ViewModels/LayoutViewVM.cs105
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Views/LogFileTabView.xaml20
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/log_viewer_icon.icobin0 -> 119603 bytes
4 files changed, 106 insertions, 28 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Tango.FSE.LogViewer.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Tango.FSE.LogViewer.UI.csproj
index 0e68f5d58..5f72b9307 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Tango.FSE.LogViewer.UI.csproj
+++ b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Tango.FSE.LogViewer.UI.csproj
@@ -34,6 +34,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+ <PropertyGroup>
+ <ApplicationIcon>log_viewer_icon.ico</ApplicationIcon>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
@@ -166,5 +169,11 @@
<Name>Tango.FSE.UI</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="log_viewer_icon.ico" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PostBuildEvent>copy /Y "$(TargetPath)" "$(SolutionDir)Build\FSE\$(ConfigurationName)"</PostBuildEvent>
+ </PropertyGroup>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/ViewModels/LayoutViewVM.cs
index cf1c2d810..6513fa2d2 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/ViewModels/LayoutViewVM.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/ViewModels/LayoutViewVM.cs
@@ -6,8 +6,10 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Data;
using Tango.Core.Commands;
+using Tango.FSE.Common.Helpers;
using Tango.Integration.Logging;
using Tango.Logging;
@@ -35,16 +37,53 @@ namespace Tango.FSE.LogViewer.UI.ViewModels
public RelayCommand OpenLogFileCommand { get; set; }
public RelayCommand<LogFileTabViewVM> CloseLogFileCommand { get; set; }
+ public RelayCommand SaveAsLogFileCommand { get; set; }
+ public RelayCommand ExitCommand { get; set; }
public LayoutViewVM()
{
LogFiles = new ObservableCollection<LogFileTabViewVM>();
OpenLogFileCommand = new RelayCommand(OpenLogFile);
CloseLogFileCommand = new RelayCommand<LogFileTabViewVM>(CloseLogFile);
+ SaveAsLogFileCommand = new RelayCommand(SaveAsLogFile);
+ ExitCommand = new RelayCommand(ExitApplication);
- LogFiles.Add(new LogFileTabViewVM() { Name = "Log File 1.log" });
- LogFiles.Add(new LogFileTabViewVM() { Name = "Log File With Long File Name 2.log" });
- LogFiles.Add(new LogFileTabViewVM() { Name = "Log File 3.log" });
+ Application.Current.MainWindow.ContentRendered += MainWindow_ContentRendered;
+ }
+
+ private void MainWindow_ContentRendered(object sender, EventArgs e)
+ {
+ var startupArgs = StartupArgsHelper.CleanArgsFromWeb(Environment.GetCommandLineArgs().Skip(1).ToArray()).ToList();
+ OnApplicationReady(startupArgs);
+ }
+
+ private void ExitApplication()
+ {
+ Environment.Exit(0);
+ }
+
+ private async void SaveAsLogFile()
+ {
+ if (SelectedLogFile != null)
+ {
+ var result = await StorageProvider.SaveFile("Save Log File As...", "Twine Log Files|*.log", SelectedLogFile.Name, ".log");
+ if (result.Confirmed)
+ {
+ try
+ {
+ await Task.Factory.StartNew(() =>
+ {
+ File.Copy(SelectedLogFile.File, result.SelectedItem, true);
+ });
+
+ await NotificationProvider.ShowSuccess("Log file saved successfully.");
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError($"Error saving log file.\n{ex.FlattenMessage()}");
+ }
+ }
+ }
}
private async void OpenLogFile()
@@ -64,36 +103,43 @@ namespace Tango.FSE.LogViewer.UI.ViewModels
List<LogItemBase> logs = new List<LogItemBase>();
LogFileTabViewVM logFile = new LogFileTabViewVM();
- using (NotificationProvider.PushTaskItem($"Loading '{Path.GetFileName(file)}'..."))
+ try
{
- DateTime createdTime = File.GetCreationTime(file);
+ using (NotificationProvider.PushTaskItem($"Loading '{Path.GetFileName(file)}'..."))
+ {
+ DateTime createdTime = File.GetCreationTime(file);
- await Task.Delay(1500);
+ await Task.Delay(1500);
- await Task.Factory.StartNew(() =>
- {
- if (!file.StartsWith("Embedded"))
- {
- ApplicationLogFileParser parser = new ApplicationLogFileParser();
- logs = parser.Parse(file, createdTime);
- }
- else
+ await Task.Factory.StartNew(() =>
{
- EmbeddedLogFileParser parser = new EmbeddedLogFileParser();
- logs = parser.Parse(file, createdTime).Cast<LogItemBase>().ToList();
- logFile.IsEmbedded = true;
- }
+ if (!Path.GetFileName(file).StartsWith("Embedded"))
+ {
+ ApplicationLogFileParser parser = new ApplicationLogFileParser();
+ logs = parser.Parse(file, createdTime);
+ }
+ else
+ {
+ EmbeddedLogFileParser parser = new EmbeddedLogFileParser();
+ logs = parser.Parse(file, createdTime).Cast<LogItemBase>().ToList();
+ logFile.IsEmbedded = true;
+ }
- logFile.Name = Path.GetFileName(file);
- logFile.File = file;
- logFile.Size = Core.Helpers.FileHelper.GetFriendlyFileSize(new FileInfo(file).Length);
- logFile.StartTime = createdTime;
- logFile.EndTime = logs.Last().TimeStamp;
- });
+ logFile.Name = Path.GetFileName(file);
+ logFile.File = file;
+ logFile.Size = Core.Helpers.FileHelper.GetFriendlyFileSize(new FileInfo(file).Length);
+ logFile.StartTime = createdTime;
+ logFile.EndTime = logs.Last().TimeStamp;
+ });
- logFile.Logs = new ObservableCollection<LogItemBase>(logs);
- LogFiles.Add(logFile);
- SelectedLogFile = logFile;
+ logFile.Logs = new ObservableCollection<LogItemBase>(logs);
+ LogFiles.Add(logFile);
+ SelectedLogFile = logFile;
+ }
+ }
+ catch (Exception ex)
+ {
+ await NotificationProvider.ShowError($"Error loading log file '{Path.GetFileName(file)}'.\n{ex.FlattenMessage()}");
}
}
@@ -174,5 +220,10 @@ namespace Tango.FSE.LogViewer.UI.ViewModels
return false;
}
+
+ private void OnApplicationReady(List<string> args)
+ {
+
+ }
}
}
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Views/LogFileTabView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Views/LogFileTabView.xaml
index a2f99bfe3..8f06dac0d 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Views/LogFileTabView.xaml
+++ b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/Views/LogFileTabView.xaml
@@ -16,7 +16,25 @@
Background="{StaticResource FSE_PrimaryBackgroundDarkBrush}"
Foreground="{StaticResource FSE_PrimaryForegroundBrush}">
<Grid>
- <DataGrid x:Name="dataGridLogs" Margin="0 5 0 0" Style="{StaticResource FSE_LogsGridStyle}" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedLog}" CellStyle="{StaticResource FSE_LogsGridCellStyle}" CanUserSortColumns="True">
+ <DataGrid Visibility="{Binding IsEmbedded,Converter={StaticResource BooleanToVisibilityInverseConverter}}" Margin="0 5 0 0" Style="{StaticResource FSE_LogsGridStyle}" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedLog}" CellStyle="{StaticResource FSE_LogsGridCellStyle}" CanUserSortColumns="True">
+ <DataGrid.Resources>
+ <components:BindingProxy x:Key="proxy" Data="{Binding}" />
+ </DataGrid.Resources>
+ <DataGrid.Columns>
+ <DataGridTemplateColumn Header="#" Width="40" CellTemplate="{StaticResource FSE_LogIcon_Cell}"/>
+ <DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,StringFormat='HH:mm:ss.ff'}" Width="100" />
+ <DataGridTextColumn Header="SERVICE" Binding="{Binding ClassName}" Width="200" />
+ <DataGridTemplateColumn Header="MESSAGE" Width="1*" >
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock TextWrapping="NoWrap" Text="{Binding Message,Converter={StaticResource StringToOneLineConverter},ConverterParameter='120'}"></TextBlock>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+ </DataGrid.Columns>
+ </DataGrid>
+
+ <DataGrid Visibility="{Binding IsEmbedded,Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0 5 0 0" Style="{StaticResource FSE_LogsGridStyle}" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedLog}" CellStyle="{StaticResource FSE_LogsGridCellStyle}" CanUserSortColumns="True">
<DataGrid.Resources>
<components:BindingProxy x:Key="proxy" Data="{Binding}" />
</DataGrid.Resources>
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/log_viewer_icon.ico b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/log_viewer_icon.ico
new file mode 100644
index 000000000..974172d32
--- /dev/null
+++ b/Software/Visual_Studio/FSE/Tango.FSE.LogViewer.UI/log_viewer_icon.ico
Binary files differ