Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 63f0d770 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

add certification number and digest values output and check to verify results...

add certification number and digest values output and check to verify results view, splitting up into multiple files
parent d9dcb974
No related branches found
No related tags found
No related merge requests found
Showing
with 1416 additions and 255 deletions
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Helper\CollectionConverter.cs" /> <Compile Include="Helper\CollectionConverter.cs" />
<Compile Include="Helper\CultureAwareBinding.cs" />
<Compile Include="Helper\HashingHelper.cs" /> <Compile Include="Helper\HashingHelper.cs" />
<Compile Include="Helper\IOService.cs" /> <Compile Include="Helper\IOService.cs" />
<Compile Include="Properties\Annotations.cs" /> <Compile Include="Properties\Annotations.cs" />
...@@ -76,16 +77,20 @@ ...@@ -76,16 +77,20 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
</Compile> </Compile>
<Compile Include="ViewModel\ComponentEntry.cs" /> <Compile Include="ViewModel\ComponentEntry.cs" />
<Compile Include="ViewModel\HashedXMLFile.cs" />
<Compile Include="ViewModel\HomeViewModel.cs" /> <Compile Include="ViewModel\HomeViewModel.cs" />
<Compile Include="ViewModel\IMainView.cs" /> <Compile Include="ViewModel\IMainView.cs" />
<Compile Include="ViewModel\ApplicationViewModel.cs" /> <Compile Include="ViewModel\ApplicationViewModel.cs" />
<Compile Include="ViewModel\ObservableObject.cs" /> <Compile Include="ViewModel\ObservableObject.cs" />
<Compile Include="ViewModel\RelayCommand.cs" /> <Compile Include="ViewModel\RelayCommand.cs" />
<Compile Include="ViewModel\HashComponentDataViewModel.cs" /> <Compile Include="ViewModel\HashComponentDataViewModel.cs" />
<Compile Include="ViewModel\UserControl\HashedXMLFile.cs" />
<Compile Include="ViewModel\UserControl\ManufacturerReportXMLFile.cs" />
<Compile Include="ViewModel\UserControl\ReportXMLFile.cs" />
<Compile Include="ViewModel\UserControl\VectoJobFile.cs" />
<Compile Include="ViewModel\UserControl\VectoXMLFile.cs" />
<Compile Include="ViewModel\VerifyJobInputDataViewModel.cs" /> <Compile Include="ViewModel\VerifyJobInputDataViewModel.cs" />
<Compile Include="ViewModel\VerifyComponentInputDataViewModel.cs" /> <Compile Include="ViewModel\VerifyComponentInputDataViewModel.cs" />
<Compile Include="ViewModel\UserControl\XMLFile.cs" /> <Compile Include="ViewModel\UserControl\XMLFileSelector.cs" />
<Compile Include="Util\XMLValidator.cs" /> <Compile Include="Util\XMLValidator.cs" />
<Compile Include="ViewModel\VerifyResultDataViewModel.cs" /> <Compile Include="ViewModel\VerifyResultDataViewModel.cs" />
<Compile Include="Views\AboutDialog.xaml.cs"> <Compile Include="Views\AboutDialog.xaml.cs">
......
...@@ -3,6 +3,7 @@ using System.Collections.ObjectModel; ...@@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using HashingTool.ViewModel; using HashingTool.ViewModel;
using HashingTool.ViewModel.UserControl;
using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Resources;
using TUGraz.VectoHashing; using TUGraz.VectoHashing;
......
using System;
namespace HashingTool.ViewModel namespace HashingTool.ViewModel
{ {
public class ComponentEntry public class ComponentEntry
...@@ -8,5 +10,7 @@ namespace HashingTool.ViewModel ...@@ -8,5 +10,7 @@ namespace HashingTool.ViewModel
public string[] CanonicalizationMethod { get; set; } public string[] CanonicalizationMethod { get; set; }
public string DigestMethod { get; set; } public string DigestMethod { get; set; }
public bool Valid { get; set; } public bool Valid { get; set; }
public string CertificationNumber { get; set; }
public DateTime CertificationDate { get; set; }
} }
} }
...@@ -62,7 +62,7 @@ namespace HashingTool.ViewModel ...@@ -62,7 +62,7 @@ namespace HashingTool.ViewModel
private void SourceChanged(object sender, PropertyChangedEventArgs e) private void SourceChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "Document" || e.PropertyName == "IsValid") { if (e.PropertyName == "UPDATED") {
DoComputeHash(); DoComputeHash();
} }
} }
......
using System;
using System.Collections.ObjectModel;
using System.Xml;
namespace HashingTool.ViewModel.UserControl
{
public class HashedXMLFile : VectoXMLFile
{
protected string _digestValueRead;
public HashedXMLFile(string name, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(name, true, contentCheck, hashValidation) {}
public string DigestValueRead
{
get { return _digestValueRead; }
internal set {
if (_digestValueRead == value) {
return;
}
_digestValueRead = value;
RaisePropertyChanged("DigestValueRead");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Xml;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoHashing;
namespace HashingTool.ViewModel.UserControl
{
public class ManufacturerReportXMLFile : ReportXMLFile
{
private ViewModel.ComponentEntry[] _jobComponents;
public ManufacturerReportXMLFile(string name, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(name, contentCheck, hashValidation)
{
_xmlFile.PropertyChanged += UpdateComponents;
}
public ViewModel.ComponentEntry[] JobComponents
{
set {
if (_jobComponents == value) {
return;
}
_jobComponents = value;
DoUpdateComponents();
RaisePropertyChanged("JobComponents");
RaisePropertyChanged("ManufacturerReportValid");
}
private get { return _jobComponents; }
}
private void UpdateComponents(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "UPDATED") {
return;
}
DoUpdateComponents();
RaisePropertyChanged("ManufacturerReportValid");
RaisePropertyChanged("UPDATED");
}
private void DoUpdateComponents()
{
if (_xmlFile.Document == null || _xmlFile.Document.DocumentElement == null) {
Components = new ComponentEntry[] { };
VehicleIdentificationNumber = "";
RaisePropertyChanged("Components");
RaisePropertyChanged("VehicleIdentificationNumber");
return;
}
var components = GetContainigComponents().GroupBy(s => s)
.Select(g => new { Entry = g.Key, Count = g.Count() });
var componentData = new List<ComponentEntry>();
foreach (var component in components) {
if (component.Entry == XMLNames.Component_Vehicle) {
continue;
}
for (var i = 0; i < component.Count; i++) {
var node = GetNodes(component.Entry, i);
var entry = new ComponentEntry {
Component = component.Count == 1
? component.Entry
: string.Format("{0} ({1})", component.Entry, i + 1),
DigestValue = ReadElementValue(node, XMLNames.DI_Signature_Reference_DigestValue),
CertificationMethod = ReadElementValue(node, XMLNames.Report_Component_CertificationMethod),
};
if (entry.Component.StartsWith("Axle ")) {
entry.Component = entry.Component.Replace("Axle", "Tyre");
entry.CertificationNumber = ReadElementValue(node, XMLNames.Report_Tyre_TyreCertificationNumber);
entry.DigestValue = "Not Available";
} else {
entry.CertificationNumber = ReadElementValue(node, XMLNames.Report_Component_CertificationNumber) ??
ReadElementValue(node, XMLNames.Report_Component_CertificationMethod);
}
if (JobComponents != null) {
var jobComponent = JobComponents.Where(
x => x.Component == entry.Component).ToArray();
if (jobComponent.Any()) {
entry.DigestValueMatchesJobComponent = entry.Component.StartsWith("Tyre ")
? (bool?)null
: (jobComponent.First().DigestValueRead == entry.DigestValue);
entry.DigestValueExpected = jobComponent.First().DigestValueRead;
if (entry.CertificationMethod != CertificationMethod.StandardValues.ToXMLFormat()) {
entry.CertificationNumberMatchesJobComponent = jobComponent.First().CertificationNumber ==
entry.CertificationNumber;
entry.CertificationNumberExpected = jobComponent.First().CertificationNumber;
}
}
}
componentData.Add(entry);
}
}
Components = componentData.ToArray();
VehicleIdentificationNumber = GetVehicleIdentificationNumber();
RaisePropertyChanged("Components");
RaisePropertyChanged("VehicleIdentificationNumber");
}
private string GetVehicleIdentificationNumber()
{
if (_xmlFile.Document == null || _xmlFile.IsValid != XmlFileStatus.ValidXML || _xmlFile.ContentValid == null ||
!_xmlFile.ContentValid.Value) {
return "";
}
var node = _xmlFile.Document.SelectSingleNode(string.Format("//*[local-name()='{0}']", XMLNames.Vehicle_VIN));
if (node == null) {
return "";
}
return node.InnerText;
}
public bool ManufacturerReportValid
{
get {
var componentsValid = JobComponents != null && JobComponents.Length > 0;
if (Components == null || JobComponents == null || JobComponents.Length == 0) {
return false;
}
foreach (var entry in Components) {
// certification number is optional (iff standard values are used)
var entryCertificationNbr = entry.CertificationNumberMatchesJobComponent == null ||
entry.CertificationNumberMatchesJobComponent.Value;
if (!entryCertificationNbr) {
var msg = string.Format("Certification number for component {0} does not match! Job-File: {1}, Report: {2}",
entry.Component, entry.CertificationNumberExpected, entry.CertificationNumber);
if (!_xmlFile.XMLValidationErrors.Contains(msg)) {
_xmlFile.XMLValidationErrors.Add(msg);
}
}
componentsValid &= entryCertificationNbr;
// digest value is mandatory (except for tires)
if (entry.Component.StartsWith("Tyre ")) {
continue;
}
var entryDigest = entry.DigestValueMatchesJobComponent != null && entry.DigestValueMatchesJobComponent.Value;
if (!entryDigest) {
var msg = string.Format("Digest value for component {0} does not match! Job-File: {1}, Report: {2}",
entry.Component, entry.DigestValueExpected, entry.DigestValue);
if (!_xmlFile.XMLValidationErrors.Contains(msg)) {
_xmlFile.XMLValidationErrors.Add(msg);
}
}
componentsValid &= entryDigest;
}
return JobDigestValid && componentsValid;
}
}
private string ReadElementValue(XmlNode xmlNode, string elementName)
{
var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName));
if (node == null) {
return null;
}
return node.InnerText;
}
protected XmlNode GetNodes(string component, int index)
{
var nodes = _xmlFile.Document.SelectNodes(GetComponentQueryString(component));
if (nodes == null || nodes.Count == 0) {
throw new Exception(component == null
? "No component found"
: string.Format("Component {0} not found", component));
}
if (index >= nodes.Count) {
throw new Exception(string.Format("index exceeds number of components found! index: {0}, #components: {1}", index,
nodes.Count));
}
return nodes[index];
}
protected static string GetComponentQueryString(string component = null)
{
if (component == null) {
return "(//*[@id])[1]";
}
return string.Format("//*[local-name()='{0}']", component);
}
protected IList<string> GetContainigComponents()
{
var retVal = new List<string>();
foreach (var component in EnumHelper.GetValues<VectoComponents>()) {
var nodes = _xmlFile.Document.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']",
XMLNames.VectoManufacturerReport, component.XMLElementName()));
var count = nodes == null ? 0 : nodes.Count;
for (var i = 0; i < count; i++) {
retVal.Add(component.XMLElementName());
}
}
foreach (var component in new[] { XMLNames.AxleWheels_Axles_Axle }) {
var nodes = _xmlFile.Document.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']",
XMLNames.VectoManufacturerReport, component));
var count = nodes == null ? 0 : nodes.Count;
for (var i = 0; i < count; i++) {
retVal.Add(component);
}
}
return retVal;
}
public string VehicleIdentificationNumber { get; private set; }
public ComponentEntry[] Components { get; private set; }
public class ComponentEntry
{
public string Component { get; set; }
public string CertificationNumber { get; set; }
public string DigestValue { get; set; }
public string CertificationMethod { get; set; }
public bool? DigestValueMatchesJobComponent { get; set; }
public bool? CertificationNumberMatchesJobComponent { get; set; }
public string DigestValueExpected { get; set; }
public string CertificationNumberExpected { get; set; }
}
}
}
\ No newline at end of file
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Xml;
namespace HashingTool.ViewModel.UserControl
{
public class ReportXMLFile : HashedXMLFile
{
private string _jobDigestValueReadRead;
private string _jobDigestMethodRead;
private string[] _jobCanonicalizationMethodRead;
private string _jobDigestComputed;
private bool _jobDigestValid;
private DateTime? _creationDate;
public ReportXMLFile(string name, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null)
: base(name, contentCheck, hashValidation)
{
_xmlFile.PropertyChanged += ReadJobDigest;
}
private void ReadJobDigest(object sender, PropertyChangedEventArgs e)
{
var jobDigest = "";
var jobDigestMethod = "";
var jobc14NMethod = new string[] { };
DateTime? creationDate = null;
if (e.PropertyName != "UPDATED") {
return;
}
if (_xmlFile.Document != null && _xmlFile.Document.DocumentElement != null) {
var digestValueNode =
_xmlFile.Document.SelectSingleNode("//*[local-name()='InputDataSignature']//*[local-name()='DigestValue']");
if (digestValueNode != null) {
jobDigest = digestValueNode.InnerText;
}
var digestMethodNode =
_xmlFile.Document.SelectSingleNode(
"//*[local-name()='InputDataSignature']//*[local-name()='DigestMethod']/@Algorithm");
if (digestMethodNode != null) {
jobDigestMethod = digestMethodNode.InnerText;
}
var c14NtMethodNodes =
_xmlFile.Document.SelectNodes("//*[local-name()='InputDataSignature']//*[local-name()='Transform']/@Algorithm");
if (c14NtMethodNodes != null) {
jobc14NMethod = (from XmlNode node in c14NtMethodNodes select node.InnerText).ToArray();
}
var dateNode =
_xmlFile.Document.SelectSingleNode("//*[local-name()='ApplicationInformation']/*[local-name()='Date']");
creationDate = dateNode != null
? XmlConvert.ToDateTime(dateNode.InnerText, XmlDateTimeSerializationMode.RoundtripKind)
: (DateTime?)null;
}
JobCanonicalizationMethodRead = jobc14NMethod;
JobDigestMethodRead = jobDigestMethod;
JobDigestValueRead = jobDigest;
CreationDate = creationDate;
RaisePropertyChanged("UPDATED");
}
public string JobDigestMethodRead
{
get { return _jobDigestMethodRead; }
set {
if (_jobDigestMethodRead == value) {
return;
}
_jobDigestMethodRead = value;
RaisePropertyChanged("JobDigestMethodRead");
}
}
public string[] JobCanonicalizationMethodRead
{
get { return _jobCanonicalizationMethodRead; }
set {
if (_jobCanonicalizationMethodRead == value) {
return;
}
_jobCanonicalizationMethodRead = value;
RaisePropertyChanged("JobCanonicalizationMethodRead");
}
}
public string JobDigestValueRead
{
get { return _jobDigestValueReadRead; }
internal set {
if (_jobDigestValueReadRead == value) {
return;
}
_jobDigestValueReadRead = value;
RaisePropertyChanged("JobDigestValueRead");
}
}
public string JobDigestValueComputed
{
get { return _jobDigestComputed; }
set {
if (_jobDigestComputed == value) {
JobDigestValid = _jobDigestComputed == JobDigestValueRead;
return;
}
_jobDigestComputed = value;
RaisePropertyChanged("JobDigestValueComputed");
JobDigestValid = _jobDigestComputed == JobDigestValueRead;
}
}
public bool JobDigestValid
{
get { return _jobDigestValid; }
set {
if (_jobDigestValid == value) {
return;
}
_jobDigestValid = value;
RaisePropertyChanged("JobDigestValid");
}
}
public DateTime? CreationDate
{
get { return _creationDate; }
set {
if (_creationDate == value) {
return;
}
_creationDate = value;
RaisePropertyChanged("CreationDate");
}
}
}
}
\ No newline at end of file
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using HashingTool.Helper; using HashingTool.Helper;
using HashingTool.ViewModel.UserControl; using TUGraz.VectoCommon.Resources;
using TUGraz.VectoHashing; using TUGraz.VectoHashing;
namespace HashingTool.ViewModel namespace HashingTool.ViewModel.UserControl
{ {
public class VectoXMLFile : ObservableObject public class VectoJobFile : VectoXMLFile
{
protected readonly XMLFile _xmlFile;
protected string _digestValueComputed;
protected bool? _valid;
protected string _name;
protected string _tooltip;
protected string _componentType;
protected readonly Action<XmlDocument, VectoXMLFile> _validateHashes;
private string _digestMethod;
public VectoXMLFile(string name, bool validate, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null)
{
_validateHashes = hashValidation;
_xmlFile = new XMLFile(IoService, validate, contentCheck);
_xmlFile.PropertyChanged += FileChanged;
Name = name;
CanonicalizationMethods = new ObservableCollection<string>();
Valid = null;
ValidTooltip = HashingHelper.ToolTipNone;
}
protected virtual void FileChanged(object sender, PropertyChangedEventArgs e)
{
if (_xmlFile.IsValid == XmlFileStatus.ValidXML) {
if (_xmlFile.HasContentValidation) {
Valid = _xmlFile.ContentValid;
if (Valid != null && Valid.Value) {
ValidTooltip = HashingHelper.ToolTipOk;
} else {
ValidTooltip = HashingHelper.ToolTipInvalidFileType;
}
} else {
ValidTooltip = HashingHelper.ToolTipOk;
}
} else {
Valid = false;
ValidTooltip = HashingHelper.ToolTipXMLValidationFailed;
}
if (Valid != null && Valid.Value && _validateHashes != null) {
_validateHashes(_xmlFile.Document, this);
}
}
public XMLFile XMLFile
{
get { return _xmlFile; }
}
public string Name
{
get { return _name; }
private set {
if (_name == value) {
return;
}
_name = value;
RaisePropertyChanged("Name");
}
}
public ObservableCollection<string> CanonicalizationMethods { get; private set; }
public void SetCanonicalizationMethod(IEnumerable<string> c14NMethods)
{
CanonicalizationMethods.Clear();
foreach (var c14N in c14NMethods) {
CanonicalizationMethods.Add(c14N);
}
RaisePropertyChanged("CanonicalizationMethods");
}
public string DigestMethod
{
get { return _digestMethod; }
set {
if (_digestMethod == value) {
return;
}
_digestMethod = value;
RaisePropertyChanged("DigestMethod");
}
}
public string DigestValueComputed
{ {
get { return _digestValueComputed; } private bool _componentDataValid;
internal set { private string _jobValidToolTip;
if (_digestValueComputed == value) { private string _vin;
return; private DateTime? _jobDate;
}
_digestValueComputed = value;
RaisePropertyChanged("DigestValueComputed");
}
}
public bool? Valid public VectoJobFile(string name, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(name, true, contentCheck, hashValidation)
{ {
get { return _valid; } _xmlFile.PropertyChanged += JobFilechanged;
internal set { Components = new ObservableCollection<ComponentEntry>();
if (_valid == value) {
return;
}
_valid = value;
RaisePropertyChanged("Valid");
}
} }
public string ValidTooltip public ObservableCollection<ComponentEntry> Components { get; private set; }
{
get { return _tooltip; }
set {
if (_tooltip == value) {
return;
}
_tooltip = value;
RaisePropertyChanged("ValidTooltip");
}
}
public string Component public bool JobDataValid
{ {
get { return _componentType; } get { return _componentDataValid; }
set { set {
if (_componentType == value) { if (_componentDataValid == value) {
return;
}
_componentType = value;
RaisePropertyChanged("Component");
}
}
}
public class HashedXMLFile : VectoXMLFile
{
protected string _digestValueRead;
public HashedXMLFile(string name, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(name, true, contentCheck, hashValidation) {}
public string DigestValueRead
{
get { return _digestValueRead; }
internal set {
if (_digestValueRead == value) {
return;
}
_digestValueRead = value;
RaisePropertyChanged("DigestValueRead");
}
}
}
public class ReportXMLFile : HashedXMLFile
{
private string _jobDigestValueReadRead;
private string _jobDigestMethodRead;
private string[] _jobCanonicalizationMethodRead;
private string _jobDigestComputed;
private bool _jobDigestValid;
public ReportXMLFile(string name, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null)
: base(name, contentCheck, hashValidation)
{
_xmlFile.PropertyChanged += ReadJobDigest;
}
private void ReadJobDigest(object sender, PropertyChangedEventArgs e)
{
var jobDigest = "";
var jobDigestMethod = "";
var jobc14NMethod = new string[] { };
if (e.PropertyName != "Document") {
return; return;
} }
if (_xmlFile.Document != null && _xmlFile.Document.DocumentElement != null) { _componentDataValid = value;
var digestValueNode = JobValidToolTip = value ? HashingHelper.ToolTipComponentHashInvalid : HashingHelper.ToolTipOk;
_xmlFile.Document.SelectSingleNode("//*[local-name()='InputDataSignature']//*[local-name()='DigestValue']"); RaisePropertyChanged("JobDataValid");
if (digestValueNode != null) {
jobDigest = digestValueNode.InnerText;
}
var digestMethodNode =
_xmlFile.Document.SelectSingleNode(
"//*[local-name()='InputDataSignature']//*[local-name()='DigestMethod']/@Algorithm");
if (digestMethodNode != null) {
jobDigestMethod = digestMethodNode.InnerText;
}
var c14NtMethodNodes =
_xmlFile.Document.SelectNodes("//*[local-name()='InputDataSignature']//*[local-name()='Transform']/@Algorithm");
if (c14NtMethodNodes != null) {
jobc14NMethod = (from XmlNode node in c14NtMethodNodes select node.InnerText).ToArray();
}
} }
JobCanonicalizationMethodRead = jobc14NMethod;
JobDigestMethodRead = jobDigestMethod;
JobDigestValueRead = jobDigest;
} }
public string JobDigestMethodRead public string JobValidToolTip
{ {
get { return _jobDigestMethodRead; } get { return _jobValidToolTip; }
set { set {
if (_jobDigestMethodRead == value) { if (_jobValidToolTip == value) {
return; return;
} }
_jobDigestMethodRead = value; _jobValidToolTip = value;
RaisePropertyChanged("JobDigestMethodRead"); RaisePropertyChanged("JobValidToolTip");
} }
} }
public string[] JobCanonicalizationMethodRead public string VehicleIdentificationNumber
{ {
get { return _jobCanonicalizationMethodRead; } get { return _vin; }
set { set {
if (_jobCanonicalizationMethodRead == value) { if (_vin == value) {
return;
}
_jobCanonicalizationMethodRead = value;
RaisePropertyChanged("JobCanonicalizationMethodRead");
}
}
public string JobDigestValueRead
{
get { return _jobDigestValueReadRead; }
internal set {
if (_jobDigestValueReadRead == value) {
return; return;
} }
_jobDigestValueReadRead = value; _vin = value;
RaisePropertyChanged("JobDigestValueRead"); RaisePropertyChanged("VehicleIdentificationNumber");
} }
} }
public string JobDigestValueComputed public DateTime? JobCreationDate
{ {
get { return _jobDigestComputed; } get { return _jobDate; }
set { set {
if (_jobDigestComputed == value) { if (_jobDate == value) {
return; return;
} }
_jobDigestComputed = value; _jobDate = value;
RaisePropertyChanged("JobDigestValueComputed"); RaisePropertyChanged("JobCreationDate");
JobDigestValid = JobDigestValueComputed == JobDigestValueRead;
} }
} }
public bool JobDigestValid private void JobFilechanged(object sender, PropertyChangedEventArgs e)
{ {
get { return _jobDigestValid; } if (e.PropertyName != "UPDATED") {
set {
if (_jobDigestValid == value) {
return; return;
} }
_jobDigestValid = value; DoValidateHash();
RaisePropertyChanged("JobDigestValid"); VehicleIdentificationNumber = DoReadVIN();
} JobCreationDate = DoReadJobDate();
}
}
public class VectoJobFile : VectoXMLFile
{
private bool _componentDataValid;
private string _jobValidToolTip;
public VectoJobFile(string name, Func<XmlDocument, Collection<string>, bool?> contentCheck, RaisePropertyChanged("UPDATED");
Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(name, true, contentCheck, hashValidation)
{
_xmlFile.PropertyChanged += JobFilechanged;
Components = new ObservableCollection<ComponentEntry>();
} }
public ObservableCollection<ComponentEntry> Components { get; private set; } private DateTime? DoReadJobDate()
public bool JobDataValid
{ {
get { return _componentDataValid; } if (_xmlFile.Document == null || _xmlFile.IsValid != XmlFileStatus.ValidXML || _xmlFile.ContentValid == null ||
set { !_xmlFile.ContentValid.Value) {
if (_componentDataValid == value) { return null;
return;
} }
_componentDataValid = value; var nodes = _xmlFile.Document.SelectNodes(string.Format("//*[local-name()='{0}']", XMLNames.Component_Date));
JobValidToolTip = value ? HashingHelper.ToolTipComponentHashInvalid : HashingHelper.ToolTipOk; if (nodes == null || nodes.Count == 0) {
RaisePropertyChanged("JobDataValid"); return null;
} }
return XmlConvert.ToDateTime(nodes[0].InnerText, XmlDateTimeSerializationMode.RoundtripKind);
} }
public string JobValidToolTip private string DoReadVIN()
{ {
get { return _jobValidToolTip; } if (_xmlFile.Document == null || _xmlFile.IsValid != XmlFileStatus.ValidXML || _xmlFile.ContentValid == null ||
set { !_xmlFile.ContentValid.Value) {
if (_jobValidToolTip == value) { return "";
return;
}
_jobValidToolTip = value;
RaisePropertyChanged("JobValidToolTip");
} }
var node = _xmlFile.Document.SelectSingleNode(string.Format("//*[local-name()='{0}']", XMLNames.Vehicle_VIN));
if (node == null) {
return "";
} }
return node.InnerText;
private void JobFilechanged(object sender, PropertyChangedEventArgs e)
{
DoValidateHash();
} }
private void DoValidateHash() private void DoValidateHash()
...@@ -358,6 +145,8 @@ namespace HashingTool.ViewModel ...@@ -358,6 +145,8 @@ namespace HashingTool.ViewModel
entry.DigestMethod = h.GetDigestMethod(component.Entry, i); entry.DigestMethod = h.GetDigestMethod(component.Entry, i);
entry.DigestValueRead = h.ReadHash(component.Entry, i); entry.DigestValueRead = h.ReadHash(component.Entry, i);
entry.DigestValueComputed = h.ComputeHash(component.Entry, i); entry.DigestValueComputed = h.ComputeHash(component.Entry, i);
entry.CertificationNumber = h.GetCertificationNumber(component.Entry, i);
entry.CertificationDate = h.GetCertificationDate(component.Entry, i);
if (!entry.Valid) { if (!entry.Valid) {
_xmlFile.XMLValidationErrors.Add( _xmlFile.XMLValidationErrors.Add(
string.Format( string.Format(
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml;
using HashingTool.Helper;
namespace HashingTool.ViewModel.UserControl
{
public class VectoXMLFile : ObservableObject
{
protected readonly XMLFileSelector _xmlFile;
protected string _digestValueComputed;
protected bool? _valid;
protected string _name;
protected string _tooltip;
protected string _componentType;
protected readonly Action<XmlDocument, VectoXMLFile> _validateHashes;
private string _digestMethod;
public VectoXMLFile(string name, bool validate, Func<XmlDocument, Collection<string>, bool?> contentCheck,
Action<XmlDocument, VectoXMLFile> hashValidation = null)
{
_validateHashes = hashValidation;
_xmlFile = new XMLFileSelector(IoService, validate, contentCheck);
_xmlFile.PropertyChanged += FileChanged;
Name = name;
CanonicalizationMethods = new ObservableCollection<string>();
Valid = null;
ValidTooltip = HashingHelper.ToolTipNone;
}
protected virtual void FileChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "UPDATED") {
return;
}
if (_xmlFile.IsValid == XmlFileStatus.ValidXML) {
if (_xmlFile.HasContentValidation) {
Valid = _xmlFile.ContentValid;
if (Valid != null && Valid.Value) {
ValidTooltip = HashingHelper.ToolTipOk;
} else {
ValidTooltip = HashingHelper.ToolTipInvalidFileType;
}
} else {
ValidTooltip = HashingHelper.ToolTipOk;
}
} else {
Valid = false;
ValidTooltip = HashingHelper.ToolTipXMLValidationFailed;
}
if (Valid != null && Valid.Value && _validateHashes != null) {
_validateHashes(_xmlFile.Document, this);
}
RaisePropertyChanged("UPDATED");
}
public XMLFileSelector XMLFile
{
get { return _xmlFile; }
}
public string Name
{
get { return _name; }
private set {
if (_name == value) {
return;
}
_name = value;
RaisePropertyChanged("Name");
}
}
public ObservableCollection<string> CanonicalizationMethods { get; private set; }
public void SetCanonicalizationMethod(IEnumerable<string> c14NMethods)
{
CanonicalizationMethods.Clear();
foreach (var c14N in c14NMethods) {
CanonicalizationMethods.Add(c14N);
}
RaisePropertyChanged("CanonicalizationMethods");
}
public string DigestMethod
{
get { return _digestMethod; }
set {
if (_digestMethod == value) {
return;
}
_digestMethod = value;
RaisePropertyChanged("DigestMethod");
}
}
public string DigestValueComputed
{
get { return _digestValueComputed; }
internal set {
if (_digestValueComputed == value) {
return;
}
_digestValueComputed = value;
RaisePropertyChanged("DigestValueComputed");
}
}
public bool? Valid
{
get { return _valid; }
internal set {
if (_valid == value) {
return;
}
_valid = value;
RaisePropertyChanged("Valid");
}
}
public string ValidTooltip
{
get { return _tooltip; }
set {
if (_tooltip == value) {
return;
}
_tooltip = value;
RaisePropertyChanged("ValidTooltip");
}
}
public string Component
{
get { return _componentType; }
set {
if (_componentType == value) {
return;
}
_componentType = value;
RaisePropertyChanged("Component");
}
}
}
}
\ No newline at end of file
...@@ -21,7 +21,7 @@ namespace HashingTool.ViewModel.UserControl ...@@ -21,7 +21,7 @@ namespace HashingTool.ViewModel.UserControl
ValidXML // green ValidXML // green
} }
public class XMLFile : ObservableObject public class XMLFileSelector : ObservableObject
{ {
private string _source; private string _source;
private XmlFileStatus _isValid; private XmlFileStatus _isValid;
...@@ -34,7 +34,7 @@ namespace HashingTool.ViewModel.UserControl ...@@ -34,7 +34,7 @@ namespace HashingTool.ViewModel.UserControl
private bool? _contentValid; private bool? _contentValid;
private RelayCommand _browseFileCommand; private RelayCommand _browseFileCommand;
public XMLFile(IOService ioservice, bool validate = false, public XMLFileSelector(IOService ioservice, bool validate = false,
Func<XmlDocument, Collection<string>, bool?> contentCheck = null) Func<XmlDocument, Collection<string>, bool?> contentCheck = null)
{ {
IoService = ioservice; IoService = ioservice;
...@@ -199,11 +199,12 @@ namespace HashingTool.ViewModel.UserControl ...@@ -199,11 +199,12 @@ namespace HashingTool.ViewModel.UserControl
XMLValidationErrors.Add(e.Message); XMLValidationErrors.Add(e.Message);
fileValid = XmlFileStatus.Invalid; fileValid = XmlFileStatus.Invalid;
} finally { } finally {
IsValid = fileValid; IsValid = fileValid;
ContentValid = contentValid; ContentValid = contentValid;
_busy = false; _busy = false;
_browseFileCommand.RaiseCanExecuteChanged(); _browseFileCommand.RaiseCanExecuteChanged();
RaisePropertyChanged("UPDATED");
} }
} }
......
...@@ -6,6 +6,7 @@ using System.Linq; ...@@ -6,6 +6,7 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using HashingTool.Helper; using HashingTool.Helper;
using HashingTool.ViewModel.UserControl;
using TUGraz.VectoHashing; using TUGraz.VectoHashing;
namespace HashingTool.ViewModel namespace HashingTool.ViewModel
...@@ -40,7 +41,7 @@ namespace HashingTool.ViewModel ...@@ -40,7 +41,7 @@ namespace HashingTool.ViewModel
private void ComponentFilechanged(object sender, PropertyChangedEventArgs e) private void ComponentFilechanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "Document" || e.PropertyName == "ContentValid") { if (e.PropertyName == "UPDATED") {
DoValidateHash(); DoValidateHash();
} }
} }
......
...@@ -14,7 +14,7 @@ namespace HashingTool.ViewModel ...@@ -14,7 +14,7 @@ namespace HashingTool.ViewModel
get { return ApplicationViewModel.HomeView; } get { return ApplicationViewModel.HomeView; }
} }
public XMLFile JobFile public XMLFileSelector JobFile
{ {
get { return _xmlFile; } get { return _xmlFile; }
} }
......
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.Windows.Input; using System.Windows.Input;
using System.Xml;
using HashingTool.Helper; using HashingTool.Helper;
using HashingTool.ViewModel.UserControl;
using TUGraz.VectoHashing; using TUGraz.VectoHashing;
namespace HashingTool.ViewModel namespace HashingTool.ViewModel
...@@ -12,13 +13,13 @@ namespace HashingTool.ViewModel ...@@ -12,13 +13,13 @@ namespace HashingTool.ViewModel
{ {
private readonly VectoJobFile _jobFile; private readonly VectoJobFile _jobFile;
private readonly ReportXMLFile _customerReport; private readonly ReportXMLFile _customerReport;
private readonly ReportXMLFile _manufacturerReport; private readonly ManufacturerReportXMLFile _manufacturerReport;
public VerifyResultDataViewModel() public VerifyResultDataViewModel()
{ {
_jobFile = new VectoJobFile("Job File", HashingHelper.IsJobFile, HashingHelper.HashJobFile); _jobFile = new VectoJobFile("Job File", HashingHelper.IsJobFile, HashingHelper.HashJobFile);
_manufacturerReport = new ReportXMLFile("Manufacturer Report", HashingHelper.IsManufacturerReport, _manufacturerReport = new ManufacturerReportXMLFile("Manufacturer Report", HashingHelper.IsManufacturerReport,
HashingHelper.ValidateDocumentHash); HashingHelper.ValidateDocumentHash);
_customerReport = new ReportXMLFile("Customer Report", HashingHelper.IsCustomerReport, _customerReport = new ReportXMLFile("Customer Report", HashingHelper.IsCustomerReport,
HashingHelper.ValidateDocumentHash); HashingHelper.ValidateDocumentHash);
...@@ -32,10 +33,12 @@ namespace HashingTool.ViewModel ...@@ -32,10 +33,12 @@ namespace HashingTool.ViewModel
private void Update(object sender, PropertyChangedEventArgs e) private void Update(object sender, PropertyChangedEventArgs e)
{ {
//RaisePropertyChanged("ManufacturerReportValid"); if (e.PropertyName != "UPDATED")
//RaisePropertyChanged("CustomerReportReportValid"); return;
UpdateReportJobDigest(_manufacturerReport); UpdateReportJobDigest(_manufacturerReport);
UpdateReportJobDigest(_customerReport); UpdateReportJobDigest(_customerReport);
_manufacturerReport.JobComponents = _jobFile.Components.ToArray();
} }
...@@ -60,16 +63,14 @@ namespace HashingTool.ViewModel ...@@ -60,16 +63,14 @@ namespace HashingTool.ViewModel
get { return _customerReport; } get { return _customerReport; }
} }
public ReportXMLFile ManufacturerReport public ManufacturerReportXMLFile ManufacturerReport
{ {
get { return _manufacturerReport; } get { return _manufacturerReport; }
} }
public ObservableCollection<VectoXMLFile> Files { get; private set; } public ObservableCollection<VectoXMLFile> Files { get; private set; }
//public bool ManufacturerReportValid
//{
// get {
private void UpdateReportJobDigest(ReportXMLFile reportXML) private void UpdateReportJobDigest(ReportXMLFile reportXML)
{ {
if (reportXML.Valid == null || !reportXML.Valid.Value || _jobFile.XMLFile.Document == null) { if (reportXML.Valid == null || !reportXML.Valid.Value || _jobFile.XMLFile.Document == null) {
...@@ -81,29 +82,9 @@ namespace HashingTool.ViewModel ...@@ -81,29 +82,9 @@ namespace HashingTool.ViewModel
var jobDigest = h.ComputeHash(reportXML.JobCanonicalizationMethodRead, var jobDigest = h.ComputeHash(reportXML.JobCanonicalizationMethodRead,
reportXML.JobDigestMethodRead); reportXML.JobDigestMethodRead);
reportXML.JobDigestValueComputed = jobDigest; reportXML.JobDigestValueComputed = jobDigest;
} catch (Exception e) { } catch (Exception ) {
reportXML.JobDigestValueComputed = ""; reportXML.JobDigestValueComputed = "";
} }
} }
// }
//}
//public bool CustomerReportReportValid
//{
// get {
// if (_customerReport.Valid == null || !_customerReport.Valid.Value) {
// return false;
// }
// try {
// var h = VectoHash.Load(_jobFile.XMLFile.Document);
// var jobDigest = h.ComputeHash(_customerReport.JobCanonicalizationMethodRead, _customerReport.JobDigestMethodRead);
// _customerReport.JobDigestValueComputed = jobDigest;
// return _customerReport.JobDigestValueRead == jobDigest;
// } catch (Exception e) {
// return false;
// }
// }
//}
} }
} }
...@@ -9,7 +9,8 @@ namespace HashingTool.Views ...@@ -9,7 +9,8 @@ namespace HashingTool.Views
/// </summary> /// </summary>
public partial class VectoXMLFileSelector public partial class VectoXMLFileSelector
{ {
public static readonly DependencyProperty XMLFileProperty = DependencyProperty.Register("XMLFile", typeof(XMLFile), public static readonly DependencyProperty XMLFileProperty = DependencyProperty.Register("XMLFile",
typeof(XMLFileSelector),
typeof(VectoXMLFileSelector)); typeof(VectoXMLFileSelector));
...@@ -19,9 +20,9 @@ namespace HashingTool.Views ...@@ -19,9 +20,9 @@ namespace HashingTool.Views
(Content as FrameworkElement).DataContext = this; (Content as FrameworkElement).DataContext = this;
} }
public XMLFile XMLFile public XMLFileSelector XMLFile
{ {
get { return (XMLFile)GetValue(XMLFileProperty); } get { return (XMLFileSelector)GetValue(XMLFileProperty); }
set { SetValue(XMLFileProperty, value); } set { SetValue(XMLFileProperty, value); }
} }
...@@ -32,6 +33,5 @@ namespace HashingTool.Views ...@@ -32,6 +33,5 @@ namespace HashingTool.Views
dialog.ShowDialog(); dialog.ShowDialog();
} }
} }
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
xmlns:viewModel="clr-namespace:HashingTool.ViewModel" xmlns:viewModel="clr-namespace:HashingTool.ViewModel"
xmlns:views="clr-namespace:HashingTool.Views" xmlns:views="clr-namespace:HashingTool.Views"
xmlns:helper="clr-namespace:HashingTool.Helper" xmlns:helper="clr-namespace:HashingTool.Helper"
xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib"
x:Class="HashingTool.Views.VerifyJobInputData" x:Class="HashingTool.Views.VerifyJobInputData"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="657" d:DesignWidth="534"> d:DesignHeight="657" d:DesignWidth="534">
...@@ -28,8 +29,32 @@ ...@@ -28,8 +29,32 @@
<DockPanel> <DockPanel>
<Label x:Name="lblFileSelect" DockPanel.Dock="Top" Content="Job data:" HorizontalAlignment="Left" Margin="10,0,0,0" <Label x:Name="lblFileSelect" DockPanel.Dock="Top" Content="Job data:" HorizontalAlignment="Left" Margin="10,0,0,0"
VerticalAlignment="Top" /> VerticalAlignment="Top" />
<views:VectoXMLFileSelector Margin="10,0,10,0" DockPanel.Dock="Top" VerticalAlignment="Top" XMLFile="{Binding JobFile}" <views:VectoXMLFileSelector Margin="10,0,10,0" DockPanel.Dock="Top" VerticalAlignment="Top"
XMLFile="{Binding JobFile}"
Height="80" /> Height="80" />
<Grid DockPanel.Dock="Top" Margin="10,10,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="100" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Vehicle" FontWeight="Bold" Margin="0,0,10,0" />
<Label Grid.Row="0" Grid.Column="1" Content="VIN:" />
<TextBox Grid.Row="0" Grid.Column="2" Text="{Binding VehicleIdentificationNumber, Mode=OneWay}"
Margin="10,2" IsReadOnly="True" />
<Label Grid.Row="0" Grid.Column="3" Content="Date:" />
<TextBox Grid.Row="0" Grid.Column="4"
Text="{helper:CultureAwareBinding Path=JobCreationDate, Mode=OneWay, StringFormat='g'}"
Margin="10,2" IsReadOnly="True" />
</Grid>
<Grid DockPanel.Dock="Top" Margin="0,0,0,0"> <Grid DockPanel.Dock="Top" Margin="0,0,0,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
...@@ -53,7 +78,8 @@ ...@@ -53,7 +78,8 @@
Text="{Binding DigestMethod, Mode=OneWay}" Text="{Binding DigestMethod, Mode=OneWay}"
Margin="10,2" IsReadOnly="True" /> Margin="10,2" IsReadOnly="True" />
<Label Grid.Row="3" Grid.Column="0" Content="Digest Value computed:" Style="{StaticResource DigestValueLabelStyle}" /> <Label Grid.Row="3" Grid.Column="0" Content="Digest Value computed:"
Style="{StaticResource DigestValueLabelStyle}" />
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding DigestValueComputed}" Margin="10,2" <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding DigestValueComputed}" Margin="10,2"
IsReadOnly="True" Style="{StaticResource DigestValueTextboxStyle}" /> IsReadOnly="True" Style="{StaticResource DigestValueTextboxStyle}" />
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="0,10,0,0" <ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="0,10,0,0"
...@@ -125,22 +151,36 @@ ...@@ -125,22 +151,36 @@
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
<RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Canonicalization methods:" /> <Label Grid.Row="0" Grid.Column="0" Content="Certification Number:" />
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding CanonicalizationMethod , Converter={StaticResource CollectionConverter}}" <TextBox Grid.Row="0" Grid.Column="1"
Text="{Binding CertificationNumber}"
Margin="10,2" IsReadOnly="True" />
<Label Grid.Row="0" Grid.Column="2" Content="Date:" />
<TextBox Grid.Row="0" Grid.Column="3"
Text="{helper:CultureAwareBinding Path=CertificationDate, StringFormat='g'}"
Margin="10,2" IsReadOnly="True" /> Margin="10,2" IsReadOnly="True" />
<Label Grid.Row="1" Grid.Column="0" Content="Digest method:" /> <Label Grid.Row="1" Grid.Column="0" Content="Canonicalization methods:" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding DigestMethod}" <TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3"
Text="{Binding CanonicalizationMethod , Converter={StaticResource CollectionConverter}}"
Margin="10,2" IsReadOnly="True" />
<Label Grid.Row="2" Grid.Column="0" Content="Digest method:" />
<TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" Text="{Binding DigestMethod}"
Margin="10,2" IsReadOnly="True" /> Margin="10,2" IsReadOnly="True" />
<Label Grid.Row="2" Grid.Column="0" Content="Digest Value read:" Style="{StaticResource DigestValueLabelStyle}" /> <Label Grid.Row="3" Grid.Column="0" Content="Digest Value read:"
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding DigestValueRead}" Style="{StaticResource DigestValueLabelStyle}" />
<TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Text="{Binding DigestValueRead}"
Margin="10,2" IsReadOnly="True"> Margin="10,2" IsReadOnly="True">
<TextBox.Style> <TextBox.Style>
<Style TargetType="TextBox" BasedOn="{StaticResource DigestValueTextboxStyle}"> <Style TargetType="TextBox" BasedOn="{StaticResource DigestValueTextboxStyle}">
...@@ -156,8 +196,9 @@ ...@@ -156,8 +196,9 @@
</TextBox.Style> </TextBox.Style>
</TextBox> </TextBox>
<Label Grid.Row="3" Grid.Column="0" Content="Digest Value computed:" Style="{StaticResource DigestValueLabelStyle}" /> <Label Grid.Row="4" Grid.Column="0" Content="Digest Value computed:"
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding DigestValueComputed}" Style="{StaticResource DigestValueLabelStyle}" />
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Text="{Binding DigestValueComputed}"
Margin="10,2" IsReadOnly="True"> Margin="10,2" IsReadOnly="True">
<TextBox.Style> <TextBox.Style>
<Style TargetType="TextBox" BasedOn="{StaticResource DigestValueTextboxStyle}"> <Style TargetType="TextBox" BasedOn="{StaticResource DigestValueTextboxStyle}">
......
This diff is collapsed.
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using HashingTool.ViewModel; using HashingTool.ViewModel;
using HashingTool.ViewModel.UserControl;
namespace HashingTool.Views namespace HashingTool.Views
{ {
......
...@@ -34,6 +34,7 @@ using System.Collections; ...@@ -34,6 +34,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Xml; using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Resources;
...@@ -89,9 +90,9 @@ namespace TUGraz.VectoHashing ...@@ -89,9 +90,9 @@ namespace TUGraz.VectoHashing
{ {
var retVal = new List<VectoComponents>(); var retVal = new List<VectoComponents>();
foreach (var component in EnumHelper.GetValues<VectoComponents>()) { foreach (var component in EnumHelper.GetValues<VectoComponents>()) {
var count = var nodes = Document.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']",
Document.SelectNodes(string.Format("//*[local-name()='{0}']//*[local-name()='{1}']", XMLNames.VectoInputDeclaration, component.XMLElementName()));
XMLNames.VectoInputDeclaration, component.XMLElementName())).Count; var count = nodes == null ? 0 : nodes.Count;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
retVal.Add(component); retVal.Add(component);
} }
...@@ -318,6 +319,27 @@ namespace TUGraz.VectoHashing ...@@ -318,6 +319,27 @@ namespace TUGraz.VectoHashing
return DoReadHash(component, index); return DoReadHash(component, index);
} }
public string GetCertificationNumber(VectoComponents component, int idx)
{
var nodes = GetNodes(component, idx);
return ReadElementValue(nodes[idx], XMLNames.Component_CertificationNumber);
}
public DateTime GetCertificationDate(VectoComponents component, int idx)
{
var nodes = GetNodes(component, idx);
return XmlConvert.ToDateTime(ReadElementValue(nodes[idx], XMLNames.Component_Date), XmlDateTimeSerializationMode.RoundtripKind);
}
private string ReadElementValue(XmlNode xmlNode, string elementName)
{
var node = xmlNode.SelectSingleNode(string.Format("./*[local-name()='{0}']", elementName));
if (node == null) {
throw new Exception(string.Format("Node '{0}' not found!", elementName));
}
return node.InnerText;
}
private string DoReadHash(VectoComponents? component, int index) private string DoReadHash(VectoComponents? component, int index)
{ {
var nodes = GetNodes(component, index); var nodes = GetNodes(component, index);
...@@ -352,7 +374,7 @@ namespace TUGraz.VectoHashing ...@@ -352,7 +374,7 @@ namespace TUGraz.VectoHashing
} }
private static string GetComponentQueryString(VectoComponents? component = null) protected static string GetComponentQueryString(VectoComponents? component = null)
{ {
if (component == null) { if (component == null) {
return "(//*[@id])[1]"; return "(//*[@id])[1]";
...@@ -390,5 +412,7 @@ namespace TUGraz.VectoHashing ...@@ -390,5 +412,7 @@ namespace TUGraz.VectoHashing
} }
return nodes[0].InnerText; return nodes[0].InnerText;
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment