-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-HTTP
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-HTTP
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-MQTT
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-MQTT
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-Common
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-Common
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-XML
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-XML
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-SHDR
Check warning on line 11 in src/MTConnect.NET-Common/Assets/Files/FileAsset.cs GitHub Actions / build-and-test-ubuntu-latest-MTConnect-NET-HTTP-AspNetCore
|
||
|
||
|
||
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<string>(); | ||
|
||
ids.Add(ObjectExtensions.GetHashPropertyString(asset).ToSHA1Hash()); | ||
|
||
// Need to include CuttingItems | ||
|
||
return StringFunctions.ToSHA1Hash(ids.ToArray()); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |