diff --git a/src/MTConnect.NET-Common/Assets/CuttingTools/ICuttingToolArchetype.g.cs b/src/MTConnect.NET-Common/Assets/CuttingTools/ICuttingToolArchetype.g.cs deleted file mode 100644 index 430ece5f..00000000 --- a/src/MTConnect.NET-Common/Assets/CuttingTools/ICuttingToolArchetype.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. -// TrakHound Inc. licenses this file to you under the MIT license. - -namespace MTConnect.Assets.CuttingTools -{ - /// - /// Asset that describes the static cutting tool geometries and nominal values as one would expect from a tool catalog. - /// - public interface ICuttingToolArchetype : IAsset - { - /// - /// Detailed structure of the cutting tool which is static during its lifecycle. ISO 13399. - /// - MTConnect.Assets.CuttingTools.ICuttingToolDefinition CuttingToolDefinition { get; } - - /// - /// Data regarding the application or use of the tool.This data is provided by various pieces of equipment (i.e. machine tool, presetter) and statistical process control applications. Life cycle data will not remain static, but will change periodically when a tool is used or measured. - /// - MTConnect.Assets.CuttingTools.ICuttingToolLifeCycle CuttingToolLifeCycle { get; } - - /// - /// Manufacturers of the cutting tool.This will reference the tool item and adaptive items specifically. The cutting itemsmanufacturers’ will be a property of CuttingItem.> Note: In XML, the representation will be a comma(,) delimited list of manufacturer names. See CuttingTool Schema Diagrams. - /// - System.Collections.Generic.IEnumerable Manufacturers { get; } - - /// - /// Unique identifier for this assembly. - /// - string SerialNumber { get; } - - /// - /// Identifier for a class of cutting tools. - /// - string ToolId { get; } - } -} \ No newline at end of file diff --git a/src/MTConnect.NET-Common/Assets/Files/AbstractFileAsset.cs b/src/MTConnect.NET-Common/Assets/Files/AbstractFileAsset.cs new file mode 100644 index 00000000..df17c34e --- /dev/null +++ b/src/MTConnect.NET-Common/Assets/Files/AbstractFileAsset.cs @@ -0,0 +1,16 @@ +// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. +// TrakHound Inc. licenses this file to you under the MIT license. + +namespace MTConnect.Assets.Files +{ + public partial class AbstractFileAsset + { + public const string TypeId = "File"; + + + public AbstractFileAsset() + { + Type = TypeId; + } + } +} diff --git a/src/MTConnect.NET-Common/Assets/Files/FileAsset.cs b/src/MTConnect.NET-Common/Assets/Files/FileAsset.cs new file mode 100644 index 00000000..6fa0377e --- /dev/null +++ b/src/MTConnect.NET-Common/Assets/Files/FileAsset.cs @@ -0,0 +1,90 @@ +// Copyright (c) 2023 TrakHound Inc., All Rights Reserved. +// TrakHound Inc. licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +namespace MTConnect.Assets.Files +{ + public partial class FileAsset + { + public const string TypeId = "File"; + + + public FileAsset() + { + Type = TypeId; + } + + + protected override IAsset OnProcess(Version mtconnectVersion) + { + if (Size <= 0) return null; + if (string.IsNullOrEmpty(VersionId)) return null; + + return base.OnProcess(mtconnectVersion); + } + + public override AssetValidationResult IsValid(Version mtconnectVersion) + { + var baseResult = base.IsValid(mtconnectVersion); + var message = baseResult.Message; + var result = baseResult.IsValid; + + if (baseResult.IsValid) + { + if (Size <= 0) + { + message = "Size property is Required and must be greater than 0"; + result = false; + } + else if (string.IsNullOrEmpty(VersionId)) + { + message = "VersionId property is Required"; + result = false; + } + else if (CreationTime <= DateTime.MinValue) + { + message = "CreationTime property is Required"; + result = false; + } + else if (Location == null) + { + message = "FileLocation is Required"; + result = false; + } + else + { + if (string.IsNullOrEmpty(Location.Href)) + { + message = "FileLocation Href property is Required"; + result = false; + } + } + } + + return new AssetValidationResult(result, message); + } + + public override string GenerateHash() + { + return GenerateHash(this); + } + + public static string GenerateHash(FileAsset asset) + { + if (asset != null) + { + var ids = new List(); + + ids.Add(ObjectExtensions.GetHashPropertyString(asset).ToSHA1Hash()); + + // Need to include CuttingItems + + return StringFunctions.ToSHA1Hash(ids.ToArray()); + } + + return null; + } + } +} diff --git a/src/MTConnect.NET-JSON-cppagent/Assets/CuttingTools/JsonCuttingToolArchetype.cs b/src/MTConnect.NET-JSON-cppagent/Assets/CuttingTools/JsonCuttingToolArchetype.cs index dd5a2f42..b77ff70b 100644 --- a/src/MTConnect.NET-JSON-cppagent/Assets/CuttingTools/JsonCuttingToolArchetype.cs +++ b/src/MTConnect.NET-JSON-cppagent/Assets/CuttingTools/JsonCuttingToolArchetype.cs @@ -14,7 +14,7 @@ public class JsonCuttingToolArchetype public JsonCuttingToolArchetype() { } - public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype) + public JsonCuttingToolArchetype(ICuttingToolArchetypeAsset cuttingToolArchetype) { if (cuttingToolArchetype != null) { @@ -23,9 +23,9 @@ public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype) } - public CuttingToolArchetype ToCuttingToolArchetype() + public ICuttingToolArchetypeAsset ToCuttingToolArchetype() { - var cuttingToolArchetype = new CuttingToolArchetype(); + var cuttingToolArchetype = new CuttingToolArchetypeAsset(); if (CuttingToolDefinition != null) cuttingToolArchetype.CuttingToolDefinition = CuttingToolDefinition.ToCuttingToolDefinition(); return cuttingToolArchetype; } diff --git a/src/MTConnect.NET-JSON-cppagent/Assets/Files/JsonFileAsset.cs b/src/MTConnect.NET-JSON-cppagent/Assets/Files/JsonFileAsset.cs index 42213a93..92da0c99 100644 --- a/src/MTConnect.NET-JSON-cppagent/Assets/Files/JsonFileAsset.cs +++ b/src/MTConnect.NET-JSON-cppagent/Assets/Files/JsonFileAsset.cs @@ -77,12 +77,12 @@ public class JsonFileAsset public DateTime CreationTime { get; set; } [JsonPropertyName("modificationTime")] - public DateTime ModificationTime { get; set; } + public DateTime? ModificationTime { get; set; } public JsonFileAsset() { } - public JsonFileAsset(IFile asset) + public JsonFileAsset(IFileAsset asset) { if (asset != null) { @@ -134,9 +134,9 @@ public JsonFileAsset(IFile asset) } - public IFile ToFileAsset() + public IFileAsset ToFileAsset() { - var asset = new File(); + var asset = new FileAsset(); asset.AssetId = AssetId; asset.Type = Type; diff --git a/src/MTConnect.NET-JSON-cppagent/Assets/JsonAssetsDocument.cs b/src/MTConnect.NET-JSON-cppagent/Assets/JsonAssetsDocument.cs index e2f115a5..0362b6bf 100644 --- a/src/MTConnect.NET-JSON-cppagent/Assets/JsonAssetsDocument.cs +++ b/src/MTConnect.NET-JSON-cppagent/Assets/JsonAssetsDocument.cs @@ -48,7 +48,7 @@ public JsonAssetsDocument(IAssetsResponseDocument assetsDocument) switch (asset.Type) { case "CuttingTool": jsonAsset = new JsonCuttingToolAsset(asset as CuttingToolAsset); break; - case "File": jsonAsset = new JsonFileAsset(asset as File); break; + case "File": jsonAsset = new JsonFileAsset(asset as FileAsset); break; case "QIFDocumentWrapper": jsonAsset = new JsonQIFDocumentWrapperAsset(asset as QIFDocumentWrapperAsset); break; case "RawMaterial": jsonAsset = new JsonRawMaterialAsset(asset as RawMaterialAsset); break; } diff --git a/src/MTConnect.NET-JSON-cppagent/Assets/QIF/JsonQIFDocumentWrapperAsset.cs b/src/MTConnect.NET-JSON-cppagent/Assets/QIF/JsonQIFDocumentWrapperAsset.cs index e93a0bbf..9b7d0389 100644 --- a/src/MTConnect.NET-JSON-cppagent/Assets/QIF/JsonQIFDocumentWrapperAsset.cs +++ b/src/MTConnect.NET-JSON-cppagent/Assets/QIF/JsonQIFDocumentWrapperAsset.cs @@ -33,10 +33,10 @@ public class JsonQIFDocumentWrapperAsset [JsonPropertyName("qifDocumentType")] - public string QifDocumentType { get; set; } + public string QIFDocumentType { get; set; } [JsonPropertyName("qifDocument")] - public string QifDocument { get; set; } + public string QIFDocument { get; set; } public JsonQIFDocumentWrapperAsset() { } @@ -54,8 +54,8 @@ public JsonQIFDocumentWrapperAsset(QIFDocumentWrapperAsset asset) if (asset.Description != null) Description = new JsonDescription(asset.Description); - QifDocumentType = asset.QifDocumentType; - QifDocument = asset.QifDocument; + QIFDocumentType = asset.QifDocumentType.ToString(); + //QifDocument = asset.QifDocument; } } @@ -72,8 +72,8 @@ public QIFDocumentWrapperAsset ToQIFDocumentWrapperAsset() if (Description != null) asset.Description = Description.ToDescription(); - asset.QifDocumentType = QifDocumentType; - asset.QifDocument = QifDocument; + asset.QifDocumentType = QIFDocumentType.ConvertEnum(); + //asset.QifDocument = QifDocument; return asset; } } diff --git a/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonMaterial.cs b/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonMaterial.cs index cd6872c5..6f0c2eac 100644 --- a/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonMaterial.cs +++ b/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonMaterial.cs @@ -36,7 +36,7 @@ public class JsonMaterial public JsonMaterial() { } - public JsonMaterial(Material material) + public JsonMaterial(IMaterial material) { if (material != null) { @@ -52,7 +52,7 @@ public JsonMaterial(Material material) } - public Material ToMaterial() + public IMaterial ToMaterial() { var material = new Material(); material.Id = Id; diff --git a/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonRawMaterialAsset.cs b/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonRawMaterialAsset.cs index 6e426e04..0e2baadd 100644 --- a/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonRawMaterialAsset.cs +++ b/src/MTConnect.NET-JSON-cppagent/Assets/RawMaterials/JsonRawMaterialAsset.cs @@ -83,7 +83,7 @@ public class JsonRawMaterialAsset public JsonRawMaterialAsset() { } - public JsonRawMaterialAsset(RawMaterialAsset asset) + public JsonRawMaterialAsset(IRawMaterialAsset asset) { if (asset != null) { @@ -100,16 +100,16 @@ public JsonRawMaterialAsset(RawMaterialAsset asset) ContainerType = asset.ContainerType; ProcessKind = asset.ProcessKind; SerialNumber = asset.SerialNumber; - Form = asset.Form; + //Form = asset.Form; HasMaterial = asset.HasMaterial; ManufacturingDate = asset.ManufacturingDate; FirstUseDate = asset.FirstUseDate; LastUseDate = asset.LastUseDate; - InitialVolume = asset.InitialVolume; - InitialDimension = asset.InitialDimension; - InitialQuantity = asset.InitialQuantity; - CurrentVolume = asset.CurrentVolume; - CurrentDimension = asset.CurrentDimension; + //InitialVolume = asset.InitialVolume; + //InitialDimension = asset.InitialDimension; + //InitialQuantity = asset.InitialQuantity; + //CurrentVolume = asset.CurrentVolume; + //CurrentDimension = asset.CurrentDimension; CurrentQuantity = asset.CurrentQuantity; if (asset != null) Material = new JsonMaterial(asset.Material); @@ -117,7 +117,7 @@ public JsonRawMaterialAsset(RawMaterialAsset asset) } - public RawMaterialAsset ToRawMaterialAsset() + public IRawMaterialAsset ToRawMaterialAsset() { var asset = new RawMaterialAsset(); @@ -133,16 +133,16 @@ public RawMaterialAsset ToRawMaterialAsset() asset.ContainerType = ContainerType; asset.ProcessKind = ProcessKind; asset.SerialNumber = SerialNumber; - asset.Form = Form; + //asset.Form = Form; asset.HasMaterial = HasMaterial; asset.ManufacturingDate = ManufacturingDate; asset.FirstUseDate = FirstUseDate; asset.LastUseDate = LastUseDate; - asset.InitialVolume = InitialVolume; - asset.InitialDimension = InitialDimension; - asset.InitialQuantity = InitialQuantity; - asset.CurrentVolume = CurrentVolume; - asset.CurrentDimension = CurrentDimension; + //asset.InitialVolume = InitialVolume; + //asset.InitialDimension = InitialDimension; + //asset.InitialQuantity = InitialQuantity; + //asset.CurrentVolume = CurrentVolume; + //asset.CurrentDimension = CurrentDimension; asset.CurrentQuantity = CurrentQuantity; if (Material != null) diff --git a/src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingToolArchetype.cs b/src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingToolArchetype.cs index dd5a2f42..b77ff70b 100644 --- a/src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingToolArchetype.cs +++ b/src/MTConnect.NET-JSON/Assets/CuttingTools/JsonCuttingToolArchetype.cs @@ -14,7 +14,7 @@ public class JsonCuttingToolArchetype public JsonCuttingToolArchetype() { } - public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype) + public JsonCuttingToolArchetype(ICuttingToolArchetypeAsset cuttingToolArchetype) { if (cuttingToolArchetype != null) { @@ -23,9 +23,9 @@ public JsonCuttingToolArchetype(CuttingToolArchetype cuttingToolArchetype) } - public CuttingToolArchetype ToCuttingToolArchetype() + public ICuttingToolArchetypeAsset ToCuttingToolArchetype() { - var cuttingToolArchetype = new CuttingToolArchetype(); + var cuttingToolArchetype = new CuttingToolArchetypeAsset(); if (CuttingToolDefinition != null) cuttingToolArchetype.CuttingToolDefinition = CuttingToolDefinition.ToCuttingToolDefinition(); return cuttingToolArchetype; } diff --git a/src/MTConnect.NET-JSON/Assets/Files/JsonFileAsset.cs b/src/MTConnect.NET-JSON/Assets/Files/JsonFileAsset.cs index 42213a93..92da0c99 100644 --- a/src/MTConnect.NET-JSON/Assets/Files/JsonFileAsset.cs +++ b/src/MTConnect.NET-JSON/Assets/Files/JsonFileAsset.cs @@ -77,12 +77,12 @@ public class JsonFileAsset public DateTime CreationTime { get; set; } [JsonPropertyName("modificationTime")] - public DateTime ModificationTime { get; set; } + public DateTime? ModificationTime { get; set; } public JsonFileAsset() { } - public JsonFileAsset(IFile asset) + public JsonFileAsset(IFileAsset asset) { if (asset != null) { @@ -134,9 +134,9 @@ public JsonFileAsset(IFile asset) } - public IFile ToFileAsset() + public IFileAsset ToFileAsset() { - var asset = new File(); + var asset = new FileAsset(); asset.AssetId = AssetId; asset.Type = Type; diff --git a/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs b/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs index e2f115a5..0362b6bf 100644 --- a/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs +++ b/src/MTConnect.NET-JSON/Assets/JsonAssetsDocument.cs @@ -48,7 +48,7 @@ public JsonAssetsDocument(IAssetsResponseDocument assetsDocument) switch (asset.Type) { case "CuttingTool": jsonAsset = new JsonCuttingToolAsset(asset as CuttingToolAsset); break; - case "File": jsonAsset = new JsonFileAsset(asset as File); break; + case "File": jsonAsset = new JsonFileAsset(asset as FileAsset); break; case "QIFDocumentWrapper": jsonAsset = new JsonQIFDocumentWrapperAsset(asset as QIFDocumentWrapperAsset); break; case "RawMaterial": jsonAsset = new JsonRawMaterialAsset(asset as RawMaterialAsset); break; } diff --git a/src/MTConnect.NET-JSON/Assets/QIF/JsonQIFDocumentWrapperAsset.cs b/src/MTConnect.NET-JSON/Assets/QIF/JsonQIFDocumentWrapperAsset.cs index e93a0bbf..7e4d8fdd 100644 --- a/src/MTConnect.NET-JSON/Assets/QIF/JsonQIFDocumentWrapperAsset.cs +++ b/src/MTConnect.NET-JSON/Assets/QIF/JsonQIFDocumentWrapperAsset.cs @@ -41,7 +41,7 @@ public class JsonQIFDocumentWrapperAsset public JsonQIFDocumentWrapperAsset() { } - public JsonQIFDocumentWrapperAsset(QIFDocumentWrapperAsset asset) + public JsonQIFDocumentWrapperAsset(IQIFDocumentWrapperAsset asset) { if (asset != null) { @@ -54,13 +54,13 @@ public JsonQIFDocumentWrapperAsset(QIFDocumentWrapperAsset asset) if (asset.Description != null) Description = new JsonDescription(asset.Description); - QifDocumentType = asset.QifDocumentType; - QifDocument = asset.QifDocument; + QifDocumentType = asset.QifDocumentType.ToString(); + //QifDocument = asset.QIFDocument; ?? } } - public QIFDocumentWrapperAsset ToQIFDocumentWrapperAsset() + public IQIFDocumentWrapperAsset ToQIFDocumentWrapperAsset() { var asset = new QIFDocumentWrapperAsset(); @@ -72,8 +72,8 @@ public QIFDocumentWrapperAsset ToQIFDocumentWrapperAsset() if (Description != null) asset.Description = Description.ToDescription(); - asset.QifDocumentType = QifDocumentType; - asset.QifDocument = QifDocument; + asset.QifDocumentType = QifDocumentType.ConvertEnum(); + //asset.QifDocument = QifDocument; ?? return asset; } } diff --git a/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonMaterial.cs b/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonMaterial.cs index cd6872c5..6f0c2eac 100644 --- a/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonMaterial.cs +++ b/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonMaterial.cs @@ -36,7 +36,7 @@ public class JsonMaterial public JsonMaterial() { } - public JsonMaterial(Material material) + public JsonMaterial(IMaterial material) { if (material != null) { @@ -52,7 +52,7 @@ public JsonMaterial(Material material) } - public Material ToMaterial() + public IMaterial ToMaterial() { var material = new Material(); material.Id = Id; diff --git a/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonRawMaterialAsset.cs b/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonRawMaterialAsset.cs index 6e426e04..0e2baadd 100644 --- a/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonRawMaterialAsset.cs +++ b/src/MTConnect.NET-JSON/Assets/RawMaterials/JsonRawMaterialAsset.cs @@ -83,7 +83,7 @@ public class JsonRawMaterialAsset public JsonRawMaterialAsset() { } - public JsonRawMaterialAsset(RawMaterialAsset asset) + public JsonRawMaterialAsset(IRawMaterialAsset asset) { if (asset != null) { @@ -100,16 +100,16 @@ public JsonRawMaterialAsset(RawMaterialAsset asset) ContainerType = asset.ContainerType; ProcessKind = asset.ProcessKind; SerialNumber = asset.SerialNumber; - Form = asset.Form; + //Form = asset.Form; HasMaterial = asset.HasMaterial; ManufacturingDate = asset.ManufacturingDate; FirstUseDate = asset.FirstUseDate; LastUseDate = asset.LastUseDate; - InitialVolume = asset.InitialVolume; - InitialDimension = asset.InitialDimension; - InitialQuantity = asset.InitialQuantity; - CurrentVolume = asset.CurrentVolume; - CurrentDimension = asset.CurrentDimension; + //InitialVolume = asset.InitialVolume; + //InitialDimension = asset.InitialDimension; + //InitialQuantity = asset.InitialQuantity; + //CurrentVolume = asset.CurrentVolume; + //CurrentDimension = asset.CurrentDimension; CurrentQuantity = asset.CurrentQuantity; if (asset != null) Material = new JsonMaterial(asset.Material); @@ -117,7 +117,7 @@ public JsonRawMaterialAsset(RawMaterialAsset asset) } - public RawMaterialAsset ToRawMaterialAsset() + public IRawMaterialAsset ToRawMaterialAsset() { var asset = new RawMaterialAsset(); @@ -133,16 +133,16 @@ public RawMaterialAsset ToRawMaterialAsset() asset.ContainerType = ContainerType; asset.ProcessKind = ProcessKind; asset.SerialNumber = SerialNumber; - asset.Form = Form; + //asset.Form = Form; asset.HasMaterial = HasMaterial; asset.ManufacturingDate = ManufacturingDate; asset.FirstUseDate = FirstUseDate; asset.LastUseDate = LastUseDate; - asset.InitialVolume = InitialVolume; - asset.InitialDimension = InitialDimension; - asset.InitialQuantity = InitialQuantity; - asset.CurrentVolume = CurrentVolume; - asset.CurrentDimension = CurrentDimension; + //asset.InitialVolume = InitialVolume; + //asset.InitialDimension = InitialDimension; + //asset.InitialQuantity = InitialQuantity; + //asset.CurrentVolume = CurrentVolume; + //asset.CurrentDimension = CurrentDimension; asset.CurrentQuantity = CurrentQuantity; if (Material != null) diff --git a/src/MTConnect.NET-JSON/Formatters/JsonEntityFormatter.cs b/src/MTConnect.NET-JSON/Formatters/JsonEntityFormatter.cs index 26d8b5ee..a3a1f60b 100644 --- a/src/MTConnect.NET-JSON/Formatters/JsonEntityFormatter.cs +++ b/src/MTConnect.NET-JSON/Formatters/JsonEntityFormatter.cs @@ -176,7 +176,7 @@ public string Format(IAsset asset, IEnumerable> opt switch (asset.Type) { case "CuttingTool": return JsonFunctions.Convert(new JsonCuttingToolAsset(asset as CuttingToolAsset)); - case "File": return JsonFunctions.Convert(new JsonFileAsset(asset as File)); + case "File": return JsonFunctions.Convert(new JsonFileAsset(asset as FileAsset)); case "QIFDocumentWrapper": return JsonFunctions.Convert(new JsonQIFDocumentWrapperAsset(asset as QIFDocumentWrapperAsset)); case "RawMaterial": return JsonFunctions.Convert(new JsonRawMaterialAsset(asset as RawMaterialAsset)); diff --git a/src/MTConnect.NET-XML/Assets/CuttingTools/XmlCuttingToolAsset.cs b/src/MTConnect.NET-XML/Assets/CuttingTools/XmlCuttingToolAsset.cs index f4442673..82703b4f 100644 --- a/src/MTConnect.NET-XML/Assets/CuttingTools/XmlCuttingToolAsset.cs +++ b/src/MTConnect.NET-XML/Assets/CuttingTools/XmlCuttingToolAsset.cs @@ -33,7 +33,6 @@ public override ICuttingToolAsset ToAsset() { var asset = new CuttingToolAsset(); asset.AssetId = AssetId; - asset.Type = CuttingToolAsset.TypeId; asset.Timestamp = Timestamp; asset.DeviceUuid = DeviceUuid; asset.Removed = Removed; diff --git a/src/MTConnect.NET-XML/Assets/Files/XmlFileAsset.cs b/src/MTConnect.NET-XML/Assets/Files/XmlFileAsset.cs index 2901c41a..214dec67 100644 --- a/src/MTConnect.NET-XML/Assets/Files/XmlFileAsset.cs +++ b/src/MTConnect.NET-XML/Assets/Files/XmlFileAsset.cs @@ -8,6 +8,7 @@ namespace MTConnect.Assets.Xml.Files { + [XmlRoot("File")] public class XmlFileAsset : XmlAsset { [XmlAttribute("name")] @@ -22,10 +23,12 @@ public class XmlFileAsset : XmlAsset [XmlAttribute("applicationType")] public string ApplicationType { get; set; } - [XmlAttribute("FileProperties")] + [XmlArray("FileProperties")] + [XmlArrayItem("FileProperty")] public List FileProperties { get; set; } - [XmlAttribute("FileComments")] + [XmlArray("FileComments")] + [XmlArrayItem("FileComment")] public List FileComments { get; set; } @@ -47,7 +50,8 @@ public class XmlFileAsset : XmlAsset [XmlElement("PublicKey")] public string PublicKey { get; set; } - [XmlElement("Destinations")] + [XmlArray("Destinations")] + [XmlArrayItem("Destination")] public List Destinations { get; set; } [XmlElement("CreationTime")] @@ -57,12 +61,11 @@ public class XmlFileAsset : XmlAsset public string ModificationTime { get; set; } - public IFileAsset ToFileAsset() + public override IFileAsset ToAsset() { var asset = new FileAsset(); asset.AssetId = AssetId; - asset.Type = Type; asset.Timestamp = Timestamp; asset.DeviceUuid = DeviceUuid; asset.Removed = Removed; @@ -75,7 +78,7 @@ public IFileAsset ToFileAsset() asset.Signature = Signature; asset.PublicKey = PublicKey; asset.CreationTime = CreationTime.ToDateTime(); - asset.ModificationTime = ModificationTime.ToDateTime(); + if (!string.IsNullOrEmpty(ModificationTime)) asset.ModificationTime = ModificationTime.ToDateTime(); asset.Name = Name; asset.MediaType = MediaType; asset.ApplicationCategory = ApplicationCategory.ConvertEnum();