This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using DTS.Common.Utils;
using System;
using System.Globalization;
using System.Xml;
namespace DTS.Common.XMLUtils
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S101:Types should be named in PascalCase", Justification = "Acronym")]
public static class DTSXMLFile
{
public static double GetItemsToCompleteCount(string fileName)
{
var node = FileUtils.GetImportXmlNode(fileName, null, out _);
double totalItems = 0;
try
{
totalItems = Convert.ToDouble(node.GetAttribute("TotalItems"), CultureInfo.InvariantCulture);
return totalItems;
}
catch
{
return totalItems;
}
}
public static string GetInnerXML(XmlReader reader)
{
if (null == reader) { throw new ArgumentException("GetInnerXML - XmlReader was null"); }
reader.ReadStartElement(reader.Name);
var s = reader.Value;
if (reader.NodeType == XmlNodeType.Text) { reader.Read(); }
reader.ReadEndElement();
return s;
}
}
}

View File

@@ -0,0 +1,76 @@
using System;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
//FB 24428 https://stackoverflow.com/questions/244953/how-to-serialize-a-nullable-int-without-xsinil-being-added-to-the-resulting-x
public class NullableElement<T>
{
public NullableElement(T value)
{
_value = value;
_hasValue = true;
}
public NullableElement()
{
_hasValue = false;
}
[XmlText]
public T Value
{
get
{
if (!HasValue)
throw new InvalidOperationException();
return _value;
}
set
{
_value = value;
_hasValue = true;
}
}
[XmlIgnore]
public bool HasValue
{ get { return _hasValue; } }
public T GetValueOrDefault()
{ return _value; }
public T GetValueOrDefault(T i_defaultValue)
{ return HasValue ? _value : i_defaultValue; }
public static explicit operator T(NullableElement<T> i_value)
{ return i_value.Value; }
public static implicit operator NullableElement<T>(T i_value)
{ return new NullableElement<T>(i_value); }
public override bool Equals(object i_other)
{
if (!HasValue)
return (i_other == null);
if (i_other == null)
return false;
return _value.Equals(i_other);
}
public override int GetHashCode()
{
if (!HasValue)
return 0;
return _value.GetHashCode();
}
public override string ToString()
{
if (!HasValue)
return "";
return _value.ToString();
}
bool _hasValue;
T _value;
}
}

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Linq;
using DTS.Common.Utilities.Logging;
using DTS.Common.Utils;
// ReSharper disable UnusedVariable
namespace DTS.Common.XMLUtils
{
public static class TestMetadataXml
{
/// <summary>
/// Return list of files
/// </summary>
/// <param name="path"></param>
/// <param name="file"></param>
/// <param name="pattern"></param>
/// <returns></returns>
public static XDocument GetTestMetadataXml(string path, string file = "", string pattern = "")
{
if (string.IsNullOrEmpty(pattern)) pattern = ".dts";
FileUtils.FileList = new List<string>();
if (!String.IsNullOrEmpty(file))
{ FileUtils.FileList.Add(file); }
else
{ FileUtils.FindFiles(path, pattern); }
return SetTestMetadataType(FileUtils.FileList);
}
/// <summary>
/// Read all DTS xml files
/// </summary>
/// <param name="fileList">DTS xml file list</param>
/// <returns></returns>
private static XDocument SetTestMetadataType(IEnumerable<string> fileList)
{
try
{
var count = 0;
var x = new XDocument();
x.Add(new XElement("Tests"));
foreach (var file in fileList)
{
try
{
var xTestMetadata = new XElement("TestMetadata");
xTestMetadata.SetAttributeValue("Id", count++.ToString());
using (var reader = new StreamReader(file))
{
var allText = reader.ReadToEnd();
var delimiter = "<?xml version=";
var delimiterArray = new string[] { delimiter };
var allTextArray = allText.Split(delimiterArray, StringSplitOptions.RemoveEmptyEntries);
var xmlCounter = 0;
foreach (var fullstring in allTextArray)
{
var fullString = delimiter + allTextArray[xmlCounter];
xmlCounter++;
var sr = new StringReader(fullString);
var xDoc = XDocument.Load(sr);
if (xDoc.Element("Test") != null)
{
//remove file name and check folder
xDoc.Element("Test")
?.SetAttributeValue("DataType", file.Contains("ALL") ? "ALL" : "ROI");
xDoc.Element("Test")?.SetAttributeValue("FilePath", file);
xDoc.Element("Test")?.SetAttributeValue("FileDate", File.GetCreationTime(file));
xTestMetadata.Add(xDoc.Element("Test"));
}
else
{
xTestMetadata.Add(xDoc.Element("TestSetup"));
}
}
}
x.Root?.Add(xTestMetadata);
}
catch (Exception ex)
{
APILogger.Log("failed to process file:", file, ex);
}
}
return x;
}
catch (Exception ex)
{
var error = ex.Message;
return new XDocument();
}
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
[XmlRootAttribute("ExportFile")]
public class ExportFileXMLClass
{
[XmlElement("TestSetups")]
public TestSetupsXMLClass[] TestSetupsOuter { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class DASHardwareXMLClass
{
public string SerialNumber { get; set; }
public string SamplesPerSecond { get; set; }
public string IsClockMaster { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class DASListXMLClass
{
[XmlElement("DASList")]
public List<DASHardwareXMLClass> DASList { get; set; }
}
}

View File

@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTS.Common.XMLUtils
{
public class FieldsXMLClass
{
public string SetupName { get; set; }
public string SetupDescription { get; set; }
public string AutomaticTestProgression { get; set; }
public string AutomaticProgressionDelayMS { get; set; }
public string InvertTrigger { get; set; }
public string InvertStart { get; set; }
public string IgnoreShortedStart { get; set; }
public string IgnoreShortedTrigger { get; set; }
public string ViewDiagnostics { get; set; }
public string VerifyChannels { get; set; }
public string AutoVerifyChannels { get; set; }
public string VerifyChannelsDelayMS { get; set; }
public string RecordingMode { get; set; }
public string SamplesPerSecond { get; set; }
public string PreTriggerSeconds { get; set; }
public string PostTriggerSeconds { get; set; }
public string NumberOfEvents { get; set; }
public string WakeUpMotionTimeout { get; set; }
public string ScheduledStartDateTime { get; set; }
public string IntervalBetweenEventStartsMinutes { get; set; }
public string StartWithEvent { get; set; }
public string WakeUpWithMotion { get; set; }
public string StrictDiagnostics { get; set; }
public string RequireConfirmationOnErrors { get; set; }
public string ROIDownload { get; set; }
public string ViewROIDownload { get; set; }
public string DownloadAll { get; set; }
public string ViewRealtime { get; set; }
public string RealtimePlotCount { get; set; }
//public RegionsOfInterestXMLClass RegionsOfInterest { get; set; }
public string ROIStart { get; set; }
public string ROIEnd { get; set; }
public string ViewDownloadAll { get; set; }
public string Export { get; set; }
public string ExportFormat { get; set; }
public string LabDetails { get; set; }
public string UseLabDetails { get; set; }
public string CustomerDetails { get; set; }
public string UseCustomerDetails { get; set; }
public string AllowMissingSensors { get; set; }
public string AllowSensorIdToBlankChannel { get; set; }
public string ExcitationWarmupTimeMS { get; set; }
public string LocalOnly { get; set; }
public string LastModified { get; set; }
public string LastModifiedBy { get; set; }
public string TurnOffExcitation { get; set; }
public string TriggerCheckRealtime { get; set; }
public string TriggerCheckStep { get; set; }
public string PostTestDiagnostics { get; set; }
public string ExportFolder { get; set; }
public string DownloadFolder { get; set; }
public string CommonStatusLine { get; set; }
public string SameAsDownloadFolder { get; set; }
public string UploadData { get; set; }
public string UploadDataFolder { get; set; }
public string UploadExportsOnly { get; set; }
public string Settings { get; set; }
public string WarnOnBatteryFail { get; set; }
public string Dirty { get; set; }
public string Complete { get; set; }
public string ErrorMessage { get; set; }
public string TestEngineerDetails { get; set; }
public string UseTestEngineerDetails { get; set; }
public string UserTags { get; set; }
public string DoAutoArm { get; set; }
public string DoEnableRepeat { get; set; }
public string DoStreaming { get; set; }
public string CheckoutMode { get; set; }
public string QuitTestWithoutWarning { get; set; }
public string SuppressMissingSensorsWarning { get; set; }
public string ISFFile { get; set; }
public string NotAllChannelsRealTime { get; set; }
public string NotAllChannelsViewer { get; set; }
public string CalibrationBehavior { get; set; }
public string ClockSyncProfileMaster { get; set; }
public string ClockSyncProfileSlave { get; set; }
public string ExtraProperties { get; set; }
public string MeasureSquibResistancesStep { get; set; }
public string TestSetupUniqueId { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class ChannelXMLClass
{
public ChannelXMLClass()
{
Settings = new SettingsXMLClass();
}
public string ISOChannelName { get; set; }
public string ISOCode { get; set; }
public string UserChannelName { get; set; }
public string UserCode { get; set; }
public string Disabled { get; set; }
[XmlElement("Settings")]
public SettingsXMLClass Settings { get; set; }
public string SensorId { get; set; }
public string DASId { get; set; }
public string DASChannelIdx { get; set; }
public string TestSetupOrder { get; set; }
public string GroupOrder { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTS.Common.XMLUtils
{
public class SettingsXMLClass
{
public string FilterClass { get; set; }
public string Polarity { get; set; }
public string Range { get; set; }
public string ZeroMethod { get; set; }
public string ZeroMethodStart { get; set; }
public string ZeroMethodEnd { get; set; }
public string InitialOffset { get; set; }
public string UserValue1 { get; set; }
public string UserValue2 { get; set; }
public string UserValue3 { get; set; }
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class GroupXMLClass
{
public GroupXMLClass()
{
HardwareList = new HardwareListXMLClass();
Channel = new List<ChannelXMLClass>();
}
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public string TestSetupName { get; set; }
public string DisplayOrder { get; set; }
public string Position { get; set; }
public string TestObjectType { get; set; }
public string Id { get; set; }
public string StaticGroupId { get; set; }
[XmlElement("HardwareList")]
public HardwareListXMLClass HardwareList { get; set; }
[XmlElement("Channel")]
public List<ChannelXMLClass> Channel { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTS.Common.XMLUtils
{
public class HardwareXMLClass
{
public string Hardware { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class HardwareListXMLClass
{
public HardwareListXMLClass()
{
Hardware = new List<string>();
}
[XmlElement("Hardware")]
public List<string> Hardware { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class GroupsXMLClass
{
[XmlElement("Group")]
public List<GroupXMLClass> Group { get; set; }
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class LevelTriggerXMLClass
{
[XmlAttribute]
public string GroupChannelId { get; set; }
[XmlAttribute]
public string HardwareChannelId { get; set; }
[XmlAttribute]
public string SensorSerialNumber { get; set; }
[XmlAttribute]
public string GreaterThanEnabled { get; set; }
[XmlAttribute]
public string GreaterThanValue { get; set; }
[XmlAttribute]
public string LessThanEnabled { get; set; }
[XmlAttribute]
public string LessThanValue { get; set; }
[XmlAttribute]
public string TriggerInside { get; set; }
[XmlAttribute]
public string TriggerOutside { get; set; }
[XmlAttribute]
public string InsideLowerEU { get; set; }
[XmlAttribute]
public string InsideUpperEU { get; set; }
[XmlAttribute]
public string OutsideLowerEU { get; set; }
[XmlAttribute]
public string OutsideUpperEU { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class LevelTriggersXMLClass
{
[XmlElement("LevelTrigger")]
public List<LevelTriggerXMLClass> LevelTriggers { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class MetaDataXMLClass
{
[XmlAttribute]
public string TestObject { get; set; }
[XmlAttribute]
public string SetupName { get; set; }
[XmlAttribute]
public string PropName { get; set; }
[XmlAttribute]
public string PropValue { get; set; }
[XmlAttribute]
public string Optional { get; set; }
[XmlAttribute]
public string Version { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class MetaDatasXMLClass
{
[XmlElement("MetaData")]
public List<MetaDataXMLClass> MetaDatas { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
public class TestSetupXMLClass
{
public string Id { get; set; }
[XmlElement("DASList")]
public List<DASListXMLClass> DASList { get; set; }
[XmlElement("Groups")]
public List<GroupsXMLClass> Groups { get; set; }
[XmlElement("Fields")]
public FieldsXMLClass Fields { get; set; }
public string HardwareIncludes { get; set; }
[XmlElement("LevelTriggers")]
public LevelTriggersXMLClass LevelTriggers { get; set; }
[XmlElement("MetaDatas")]
public MetaDatasXMLClass MetaDatas { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace DTS.Common.XMLUtils
{
[XmlRootAttribute("TestSetups")]
public class TestSetupsXMLClass
{
[XmlElement("TestSetup")]
public TestSetupXMLClass[] TestSetups { get; set; }
}
}