Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

Added JSONJob Class,

Added JSONInputDataV10_PrimaryAndInterimBus
parent 509c2fe4
No related branches found
No related tags found
No related merge requests found
using System;
using Newtonsoft.Json;
using VECTO3GUI2020.ViewModel.Implementation.Common;
namespace VECTO3GUI2020.Model.Multistage
{
public class JSONJob : ObservableObject
{
private JSONJobHeader _jobHeader;
public JSONJobHeader JobHeader
{
get => _jobHeader;
set => SetProperty(ref _jobHeader, value);
}
private JSONJobBody _jobBody;
private JSONJobBody JobBody
{
get => _jobBody;
set => SetProperty(ref _jobBody, value);
}
}
public class JSONJobHeader : ObservableObject
{
public class JobHeader : ObservableObject
{
public const int PrimaryAndInterimVersion = 10;
//public const int CompletedBusFileVersion = 7;
private string _createdBy;
private DateTime _dateTime;
private string _appVersion;
private int _fileVersion;
public string CreatedBy
{
get { return _createdBy; }
set { SetProperty(ref _createdBy, value); }
}
public DateTime Date
{
get { return _dateTime; }
set { SetProperty(ref _dateTime, value); }
}
public string AppVersion
{
get { return _appVersion; }
set { SetProperty(ref _appVersion, value); }
}
public int FileVersion
{
get { return _fileVersion; }
set
{
SetProperty(ref _fileVersion, value);
//JobType = JobTypeHelper.GetJobTypeByFileVersion(_fileVersion);
}
}
}
}
public class JSONJobBody : ObservableObject
{
private string _interimVehicle;
private string _primaryVehicle;
public string InterimVehicle
{
get { return _interimVehicle; }
set { SetProperty(ref _interimVehicle, value); }
}
public string PrimaryVehicle
{
get { return _primaryVehicle; }
set { SetProperty(ref _primaryVehicle, value); }
}
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ using Ninject.Modules;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider;
using TUGraz.VectoCore.Models.SimulationComponent;
using VECTO3GUI2020.Model.Multistage;
using VECTO3GUI2020.Ninject.Util;
using VECTO3GUI2020.ViewModel.Implementation;
using VECTO3GUI2020.ViewModel.Implementation.Common;
......@@ -59,6 +60,8 @@ namespace VECTO3GUI2020.Ninject
Bind<IAdditionalJobInfoViewModel>().To<AdditionalJobInfoViewModelNewVif>()
.WhenInjectedInto(typeof(ICreateVifViewModel));
Bind<JSONJob>().ToSelf();
}
}
}
namespace VECTO3GUI2020.Util.JSON
{
public interface IJsonWriterFactory
{
}
}
\ No newline at end of file
......@@ -183,6 +183,7 @@
<Compile Include="Helper\ProcessHelper.cs" />
<Compile Include="Helper\VisualTreeHelperExtensions.cs" />
<Compile Include="Helper\TemplateSelector\MultistageParameterDataTemplateSelector.cs" />
<Compile Include="Model\Multistage\JSONJob.cs" />
<Compile Include="Properties\GUILabels.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
......@@ -217,7 +218,6 @@
<DependentUpon>Test.xaml</DependentUpon>
</Compile>
<Compile Include="TestViewModel.cs" />
<Compile Include="Util\JSON\IJsonWriterFactory.cs" />
<Compile Include="Util\XML\Implementation\ComponentWriter\XMLBusAuxiliariesWriter.cs" />
<Compile Include="Util\XML\Implementation\ComponentWriter\XMLPTOWriter.cs" />
<Compile Include="ViewModel\Implementation\AboutViewModel.cs" />
......@@ -879,11 +879,7 @@
<ItemGroup>
<Resource Include="Resources\Icons\folderpicker.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="Model\Multistage\" />
<Folder Include="Util\JSON\Implementation\" />
<Folder Include="Util\JSON\Interfaces\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="Resources\Icons\Trash_16x.ico" />
</ItemGroup>
......
......@@ -99,7 +99,7 @@ namespace VECTO3GUI2020.ViewModel.Implementation.Common
_parent = parent as CreateVifViewModel;
Debug.Assert(_parent != null);
if()
//if()
}
......
......@@ -11,6 +11,7 @@ using TUGraz.VectoCore.InputData.FileIO.XML.Declaration;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider;
using TUGraz.VectoCore.Utils;
using VECTO3GUI2020.Helper;
using VECTO3GUI2020.Model.Multistage;
using VECTO3GUI2020.ViewModel.Implementation.Common;
using VECTO3GUI2020.ViewModel.Interfaces;
using VECTO3GUI2020.ViewModel.Interfaces.Document;
......@@ -33,6 +34,7 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
private readonly IDialogHelper _dialogHelper;
private readonly IXMLInputDataReader _inputDataReader;
private static uint _newVifCounter = 0;
private readonly JSONJob _jsonJob;
private bool? _exemptedPrimary;
......@@ -50,8 +52,9 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
set => SetProperty(ref _stageInputExempted, value);
}
public CreateVifViewModel(IDialogHelper dialogHelper, IXMLInputDataReader inputDataReader)
public CreateVifViewModel(IDialogHelper dialogHelper, IXMLInputDataReader inputDataReader, IAdditionalJobInfoViewModel additionalJobInfo, JSONJob jsonJob)
{
_jsonJob = jsonJob;
_dialogHelper = dialogHelper;
_inputDataReader = inputDataReader;
Title = "Create VIF";
......@@ -83,6 +86,10 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
}
}
#region Commands
private ICommand _selectPrimaryInputFileCommand;
private ICommand _selectCompletedInputFileCommand;
public ICommand SelectCompletedInputFileCommand
{
get => _selectCompletedInputFileCommand ?? (_selectCompletedInputFileCommand = new RelayCommand(() => {
......@@ -95,29 +102,36 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
public bool LoadStageInput(string fileName)
{
if (fileName == null) {
if (fileName == null)
{
return false;
}
var valid = true;
IVehicleDeclarationInputData vehicleInputData = null;
try {
try
{
var inputData = _inputDataReader.Create(fileName) as IDeclarationInputDataProvider;
vehicleInputData = inputData.JobInputData.Vehicle;
var type = vehicleInputData.GetType();
valid = (inputData != null) && (vehicleInputData is XMLDeclarationInterimStageBusDataProviderV28) || (vehicleInputData is XMLDeclarationExemptedInterimStageBusDataProviderV28);
} catch (Exception e) {
}
catch (Exception e)
{
valid = false;
}
valid = valid && SetStageInputExempted(vehicleInputData.ExemptedVehicle);
if (valid) {
if (valid)
{
StageInputPath = fileName;
} else {
}
else
{
_dialogHelper.ShowMessageBox("Invalid File", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
......@@ -135,16 +149,20 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
public bool LoadPrimaryInput(string fileName)
{
if (fileName == null) {
if (fileName == null)
{
return false;
}
var valid = true;
IDeclarationInputDataProvider inputData = null;
try {
try
{
inputData = _inputDataReader.Create(fileName) as IDeclarationInputDataProvider;
valid = inputData != null && inputData.JobInputData.Vehicle.VehicleCategory.IsBus();
} catch (Exception ex) {
}
catch (Exception ex)
{
valid = false;
}
......@@ -152,9 +170,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
if (valid) {
if (valid)
{
PrimaryInputPath = fileName;
} else {
}
else
{
_dialogHelper.ShowMessageBox("Invalid File", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
......@@ -166,16 +187,19 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
{
var valid = StageInputExempted == null || StageInputExempted == primaryExempted;
if (valid) {
if (valid)
{
ExemptedPrimary = primaryExempted;
} else {
}
else
{
_dialogHelper.ShowMessageBox(
caption: "Error",
button: MessageBoxButton.OK,
icon: MessageBoxImage.Error,
messageBoxText: (primaryExempted
? "Exempted primary vehicle not allowed for non-exempted interim/completed input"
: "Only exempted input allowed for selected interim/completed input"));
: "Only exempted input allowed for exempted interim/completed input"));
}
return valid;
}
......@@ -184,9 +208,12 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
{
var valid = ExemptedPrimary == null || ExemptedPrimary == stageInputExempted;
if (valid) {
if (valid)
{
StageInputExempted = stageInputExempted;
} else {
}
else
{
_dialogHelper.ShowMessageBox(
caption: "Error",
button: MessageBoxButton.OK,
......@@ -199,17 +226,16 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
}
#region Commands
private ICommand _selectPrimaryInputFileCommand;
private ICommand _selectCompletedInputFileCommand;
private bool _selected;
private string _documentName;
#endregion
#endregion
#region Implementation of IDocumentViewModel
private bool _selected;
private string _documentName;
public string DocumentName
{
get => _documentName;
......
......@@ -88,6 +88,8 @@ namespace TUGraz.VectoCommon.InputData
IVehicleDeclarationInputData CompletedVehicle { get; }
}
public interface IMultistageBusInputDataProvider : IDeclarationInputDataProvider
{
......
......@@ -1122,4 +1122,37 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
? null
: JSONInputDataFactory.ReadShiftParameters(Path.Combine(BasePath, Body.GetEx<string>("TCU")), false);
}
public class JSONInputDataV10_PrimaryAndInterimBus : JSONFile, IInputDataProvider
{
private readonly IXMLInputDataReader _xmlInputReader;
private string _primaryVehicleInputDataPath;
private IVehicleDeclarationInputData _primaryVehicleInputData;
public IVehicleDeclarationInputData PrimaryVehicle =>
_primaryVehicleInputData ?? (_primaryVehicleInputData =
_xmlInputReader.CreateDeclaration(_primaryVehicleInputDataPath).JobInputData.Vehicle);
private string _stageInputDataPath;
private IVehicleDeclarationInputData _stageInputData;
public IVehicleDeclarationInputData StageInputData =>
_stageInputData ?? (_stageInputData =
_xmlInputReader.CreateDeclaration(_stageInputDataPath).JobInputData.Vehicle);
public JSONInputDataV10_PrimaryAndInterimBus(JObject data, string filename, bool tolerateMissing = false) :
base(data, filename, tolerateMissing)
{
var kernel = new StandardKernel(new VectoNinjectModule());
_xmlInputReader = kernel.Get<IXMLInputDataReader>();
_primaryVehicleInputDataPath = default(string);
_stageInputDataPath = default(string);
}
}
}
......@@ -101,6 +101,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
return new JSONInputDataV8_Hybrid(json, filename, tolerateMissing);
case 9:
return new JSONInputDataV9_BEV(json, filename, tolerateMissing);
case 10:
return new JSONInputDataV10_PrimaryAndInterimBus(json, filename, tolerateMissing);
default:
throw new VectoException("Job-File: Unsupported FileVersion. Got: {0} ", version);
}
......
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