Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 8b231964 authored by Harald Martini's avatar Harald Martini
Browse files

Added links to simulation output

parent 18238993
No related branches found
No related tags found
No related merge requests found
......@@ -445,7 +445,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
string.Join(", ", jobProgress.Select(x => string.Format("{0,4:P}", x.Value.Progress)))));
var justFinished = jobProgress.Where(x => x.Value.Done & !finishedRuns.Contains(x.Key))
.ToDictionary(x => x.Key, x => x.Value);
//PrintRuns(justFinished, fileWriters);
PrintRuns(justFinished, fileWriters, outputMessages);
finishedRuns.AddRange(justFinished.Select(x => x.Key));
await Task.Delay(100);
}
......@@ -453,7 +453,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
var remainingRuns = jobContainer.GetProgress().Where(x => x.Value.Done && !finishedRuns.Contains(x.Key))
.ToDictionary(x => x.Key, x => x.Value);
//PrintRuns(remainingRuns, fileWriters);
PrintRuns(remainingRuns, fileWriters, outputMessages);
finishedRuns.Clear();
fileWriters.Clear();
......@@ -494,6 +494,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
Message = string.Format(
"{2} for '{0}' written to {1}", Path.GetFileName(jobEntry.DataSource.SourceFile), entry.Key, entry.Value),
//Link = "<XML>" + entry.Key
Link = entry.Key
});
}
}
......@@ -505,6 +506,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
{
Type = MessageType.StatusMessage,
Message = string.Format("Sum file written to {0}", sumFileWriter.SumFileName),
Link = sumFileWriter.SumFileName,
//Link = "<CSV>" + sumFileWriter.SumFileName
});
}
......@@ -525,34 +527,36 @@ namespace VECTO3GUI2020.ViewModel.Implementation
.GetModDataFileName(p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix);
var runName = string.Format("{0} {1} {2}", p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix);
// if (p.Value.Error != null)
// {
// SimulationWorker.ReportProgress(0, new VectoSimulationProgress()
// {
// Type = VectoSimulationProgress.MsgType.StatusMessage,
// Message = string.Format("Finished Run {0} with ERROR: {1}", runName,
// p.Value.Error.Message),
// Link = "<CSV>" + modFilename
// });
// }
// else
// {
// SimulationWorker.ReportProgress(0, new VectoSimulationProgress()
// {
// Type = VectoSimulationProgress.MsgType.StatusMessage,
// Message = string.Format("Finished run {0} successfully.", runName)
// });
// }
// if (File.Exists(modFilename))
// {
// SimulationWorker.ReportProgress(0, new VectoSimulationProgress()
// {
// Type = VectoSimulationProgress.MsgType.StatusMessage,
// Message = string.Format("Run {0}: Modal results written to {1}", runName, modFilename),
// Link = "<CSV>" + modFilename
// });
// }
}
if (p.Value.Error != null)
{
outputMessages.Report(new MessageEntry()
{
Type = MessageType.StatusMessage,
Message = string.Format("Finished Run {0} with ERROR: {1}", runName,
p.Value.Error.Message),
Link = modFilename
//Link = "<CSV>" + modFilename
});
}
else
{
outputMessages.Report(new MessageEntry()
{
Type = MessageType.StatusMessage,
Message = string.Format("Finished run {0} successfully.", runName)
});
}
if (File.Exists(modFilename))
{
outputMessages.Report(new MessageEntry()
{
Type = MessageType.StatusMessage,
Message = string.Format("Run {0}: Modal results written to {1}", runName, modFilename),
Link = modFilename,
//Link = "<CSV>" + modFilename
});
}
}
}
......
......@@ -31,7 +31,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation
public string Link
{
get { return _link; }
set {}
set { SetProperty(ref _link, value); }
}
public MessageType Type
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Windows.Data;
using System.Windows.Input;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.WindowsAPICodePack.Shell.Interop;
using VECTO3GUI2020.ViewModel.Implementation;
using VECTO3GUI2020.ViewModel.Implementation.Common;
......@@ -13,22 +17,20 @@ namespace VECTO3GUI2020.ViewModel
public class OutputViewModel : ViewModelBase, IOutputViewModel
{
#region MembersAndProperties
private object _messageLock = new Object();
private ObservableCollection<MessageEntry> _messages = new ObservableCollection<MessageEntry>();
private int _progress;
private string _statusMessage;
private ICommand _openFolderCommand;
private ICommand _openFileCommand;
public ObservableCollection<MessageEntry> Messages
{
get { return _messages; }
}
public void AddMessage(MessageEntry messageEntry)
{
lock (_messageLock) {
Messages.Add(messageEntry);
}
}
public int Progress
{
......@@ -43,12 +45,74 @@ namespace VECTO3GUI2020.ViewModel
}
#endregion
public void AddMessage(MessageEntry messageEntry)
{
lock (_messageLock)
{
Messages.Add(messageEntry);
}
}
public OutputViewModel()
{
BindingOperations.EnableCollectionSynchronization(Messages, _messageLock);
}
#region Commands
public ICommand OpenFolderCommand =>
_openFolderCommand ?? (_openFolderCommand = new RelayCommand<string>(
OpenFolderExecute));
public ICommand OpenFileCommand =>
_openFileCommand ?? (_openFileCommand = new RelayCommand<string>(
OpenFileExecute));
private void OpenFolderExecute(string link)
{
if (link == null) {
return;
}
var directoryPath = Path.GetDirectoryName(link);
StartProcess(directoryPath);
}
private void OpenFileExecute(string link){
if (link == null) {
return;
}
StartProcess(link);
}
private void StartProcess(string command)
{
try
{
Process.Start(command);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
#endregion
}
public interface IOutputViewModel : IMainViewModel
{
//ObservableCollection<MessageEntry> Messages { get; }
......
......@@ -75,7 +75,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
_dialogHelper = multistageDependencies.DialogHelperLazy;
_inputDataReader = inputDataReader;
var exempted = true; //= PrimaryVehicle.Vehicle.ExemptedVehicle
var exempted = PrimaryVehicle.Vehicle.ExemptedVehicle;
_manufacturingStageViewModel =
vmFactory.GetManufacturingStageViewModel(_consolidateManufacturingStage, exempted);
......
......@@ -33,12 +33,24 @@
<DataGrid.Columns>
<DataGridTemplateColumn Header="Message" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DataTemplate DataType="impl:MessageEntry">
<StackPanel>
<TextBlock Text="{Binding Message}" Visibility="{Binding Message, Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"/>
<TextBlock Text="{Binding Link}" Visibility="{Binding Message, Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"/>
<TextBlock Visibility="{Binding Link, Converter={StaticResource NullToVisibilityConverter}}">
<Hyperlink Command="{Binding Path=DataContext.OpenFolderCommand,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
CommandParameter="{Binding Link}">
Open Folder
</Hyperlink>
<Hyperlink Command="{Binding Path=DataContext.OpenFileCommand,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
CommandParameter="{Binding Link}">
Open File
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment