init
This commit is contained in:
1
Common/DTS.Common.ISO/.svn/entries
Normal file
1
Common/DTS.Common.ISO/.svn/entries
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
1
Common/DTS.Common.ISO/.svn/format
Normal file
1
Common/DTS.Common.ISO/.svn/format
Normal file
@@ -0,0 +1 @@
|
||||
12
|
||||
Binary file not shown.
@@ -0,0 +1,366 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using DTS.Common.XMLUtils;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S101:Types should be named in PascalCase", Justification = "Acronym")]
|
||||
public class MMETestObjectWrapper : IXmlSerializable
|
||||
{
|
||||
/// <summary>
|
||||
/// part of IXmlSerializable - from MS documentation this should return null
|
||||
/// when implementing IXmlSerializable
|
||||
/// https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.ixmlserializable.getschema?view=net-9.0
|
||||
/// </summary>
|
||||
public XmlSchema GetSchema()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// writes an element with a text value into xml
|
||||
/// this is used for adding properties into the xml body for the class
|
||||
/// </summary>
|
||||
private void WriteField(XmlWriter writer, string field, string value)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("MMETestObjectWrapper::WriteField - writer was null"); }
|
||||
if (string.IsNullOrEmpty(field)) { return; } //nothing to add
|
||||
writer.WriteStartElement(field);
|
||||
writer.WriteString(value);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
/// <summary>
|
||||
/// serializes class to xml
|
||||
/// </summary>
|
||||
public void WriteXml(XmlWriter writer)
|
||||
{
|
||||
if (null == writer)
|
||||
{
|
||||
throw new ArgumentException("MMETestObjectWrapper::WriteXml - XmlWriter was null");
|
||||
}
|
||||
writer.WriteStartElement("TestObject");
|
||||
WriteField(writer, "BarrierHeightOfTestObject", BarrierHeightOfTestObject);
|
||||
WriteField(writer, "BarrierWidthOfTestObject", BarrierWidthOfTestObject);
|
||||
WriteField(writer, "ClassOfTestObject", ClassOfTestObject);
|
||||
WriteField(writer, "CodeOfTestObject", CodeOfTestObject);
|
||||
WriteField(writer, "DriverPosition", DriverPosition);
|
||||
WriteField(writer, "File", File);
|
||||
WriteField(writer, "ImpactSide", ImpactSide);
|
||||
WriteField(writer, "MMETestObjectGUID", MMETestObjectGUID);
|
||||
WriteField(writer, "MassOfTestObject", MassOfTestObject);
|
||||
WriteField(writer, "Name", Name);
|
||||
WriteField(writer, "NumberOfLoadcellsOfTestObject", NumberOfLoadcellsOfTestObject);
|
||||
WriteField(writer, "OffsetOfTestObject", OffsetOfTestObject);
|
||||
WriteField(writer, "OriginXOfTestObject", OriginXOfTestObject);
|
||||
WriteField(writer, "OriginYOfTestObject", OriginYOfTestObject);
|
||||
WriteField(writer, "OriginZOfTestObject", OriginZOfTestObject);
|
||||
WriteField(writer, "ReferenceNumberOfTestObject", ReferenceNumberOfTestObject);
|
||||
WriteField(writer, "ReferenceSystemOfTestObject", ReferenceSystemOfTestObject);
|
||||
WriteField(writer, "TypeOfTestObject", TypeOfTestObject);
|
||||
WriteField(writer, "Velocity", Velocity);
|
||||
WriteField(writer, "VelocityMeasurementUnit", VelocityMeasurementUnit);
|
||||
WriteField(writer, "YawAngleOfTestObject", YawAngleOfTestObject);
|
||||
|
||||
WriteComments(writer);
|
||||
WriteISOTestObjectChannels(writer);
|
||||
|
||||
WriteExtraProperties(writer);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
private void WriteISOTestObjectChannels(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("MMETestObjectWrapper::WriteISOTestObjectChannels - writer was null"); }
|
||||
writer.WriteStartElement("Channels");
|
||||
|
||||
if (null != ISOTestObjectChannels)
|
||||
{
|
||||
foreach (var channel in ISOTestObjectChannels)
|
||||
{
|
||||
writer.WriteStartElement("Channel");
|
||||
writer.WriteString(channel);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
private void ReadISOTestObjectChannels(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("MMETestObjectWrapper::ReadISOTestObjectChannels - reader was null"); }
|
||||
var channels = new List<string>();
|
||||
//if the element tag is empty there's nothing else to process, move to next node
|
||||
if (reader.Name == "Channels" && reader.IsEmptyElement) { reader.Read(); }
|
||||
else
|
||||
{
|
||||
reader.ReadStartElement("Channels");
|
||||
|
||||
while (reader.IsStartElement() && reader.Name == "Channel")
|
||||
{
|
||||
channels.Add(DTSXMLFile.GetInnerXML(reader));
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
ISOTestObjectChannels = channels.ToArray();
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
}
|
||||
private void ReadComments(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("MMETestObjectWrapper::ReadComments - XmlReader was null"); }
|
||||
var comments = new List<string>();
|
||||
//if top level element is empty, nothing to process, just move to next node
|
||||
if (reader.IsEmptyElement && reader.Name == "Comments") { reader.Read(); }
|
||||
else
|
||||
{
|
||||
reader.ReadStartElement("Comments");
|
||||
|
||||
while( reader.IsStartElement() && reader.Name == "Comment")
|
||||
{
|
||||
comments.Add(DTSXMLFile.GetInnerXML(reader));
|
||||
}
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
Comments = comments.ToArray();
|
||||
}
|
||||
private void WriteComments(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("MMETestObjectWrapper::WriteComments - XmlWriter was null"); }
|
||||
writer.WriteStartElement("Comments");
|
||||
foreach( var comment in Comments)
|
||||
{
|
||||
writer.WriteStartElement("Comment");
|
||||
writer.WriteString(comment);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
private void ReadExtraProperties(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("MMETestObjectWrapper::ReadExtraProperties - XmlReader was null"); }
|
||||
var list = new List<KeyValuePair<string, string>>();
|
||||
if (reader.Name == "ExtraProperties" && reader.IsEmptyElement) { reader.Read(); }
|
||||
else
|
||||
{
|
||||
reader.ReadStartElement("ExtraProperties");
|
||||
|
||||
while (reader.IsStartElement() && reader.Name == "ExtraProperty")
|
||||
{
|
||||
var key = reader.GetAttribute("Key");
|
||||
var value = reader.GetAttribute("Value");
|
||||
list.Add(new KeyValuePair<string, string>(key, value));
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
ExtraProperties = list.ToArray();
|
||||
}
|
||||
private void WriteExtraProperties(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("MMETestObjectWrapper::WriteExtraProperties - XmlWriter was null"); }
|
||||
writer.WriteStartElement("ExtraProperties");
|
||||
|
||||
if (null != ExtraProperties)
|
||||
{
|
||||
foreach( var kvp in ExtraProperties)
|
||||
{
|
||||
writer.WriteStartElement("ExtraProperty");
|
||||
|
||||
writer.WriteAttributeString("Key", kvp.Key);
|
||||
writer.WriteAttributeString("Value", kvp.Value);
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public void ReadXml(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("MMETestObjectWrapper::ReadXml - XmlReader was null"); }
|
||||
reader.ReadStartElement("TestObject");
|
||||
while (reader.IsStartElement())
|
||||
{
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "BarrierHeightOfTestObject":
|
||||
BarrierHeightOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "BarrierWidthOfTestObject":
|
||||
BarrierWidthOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "ClassOfTestObject":
|
||||
ClassOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "CodeOfTestObject":
|
||||
CodeOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "DriverPosition":
|
||||
DriverPosition = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "File":
|
||||
File = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "ImpactSide":
|
||||
ImpactSide = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "MMETestObjectGUID":
|
||||
MMETestObjectGUID = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "MassOfTestObject":
|
||||
MassOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "Name":
|
||||
Name = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "NumberOfLoadcellsOfTestObject":
|
||||
NumberOfLoadcellsOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "OffsetOfTestObject":
|
||||
OffsetOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "OriginXOfTestObject":
|
||||
OriginXOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "OriginYOfTestObject":
|
||||
OriginYOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "OriginZOfTestObject":
|
||||
OriginZOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "ReferenceNumberOfTestObject":
|
||||
ReferenceNumberOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "ReferenceSystemOfTestObject":
|
||||
ReferenceSystemOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "TypeOfTestObject":
|
||||
TypeOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "Velocity":
|
||||
Velocity = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "VelocityMeasurementUnit":
|
||||
VelocityMeasurementUnit = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "YawAngleOfTestObject":
|
||||
YawAngleOfTestObject = DTSXMLFile.GetInnerXML(reader); break;
|
||||
case "Comments":
|
||||
ReadComments(reader);
|
||||
break;
|
||||
case "Channels":
|
||||
ReadISOTestObjectChannels(reader);
|
||||
break;
|
||||
case "ExtraProperties":
|
||||
ReadExtraProperties(reader);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException($"MMETestObjectWrapper::ReadXml - invalid node - {reader.Name}");
|
||||
}
|
||||
}
|
||||
//end of TestObject element
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
public string GetDirectory() { return "Test Objects"; }
|
||||
|
||||
public string BarrierHeightOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string BarrierWidthOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string ClassOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string CodeOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string[] Comments { get; set; } = new string[0];
|
||||
|
||||
public string DriverPosition { get; set; } = "NOVALUE";
|
||||
|
||||
public string File { get; set; } = "Not Saved Yet";
|
||||
|
||||
public string ImpactSide { get; set; } = "NOVALUE";
|
||||
|
||||
public string[] ISOTestObjectChannels { get; set; }
|
||||
|
||||
public string MMETestObjectGUID { get; set; } = "";
|
||||
|
||||
public string MassOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string Name { get; set; } = "NOVALUE";
|
||||
|
||||
public string NumberOfLoadcellsOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string OffsetOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string OriginXOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string OriginYOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string OriginZOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string ReferenceNumberOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string ReferenceSystemOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string TypeOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
public string Velocity { get; set; } = "NOVALUE";
|
||||
|
||||
public string VelocityMeterPerSecond => ConvertVelocityToMeterPerSecond(Velocity, VelocityMeasurementUnit);
|
||||
|
||||
public string VelocityMeasurementUnit { get; set; } = "NOVALUE";
|
||||
|
||||
public string YawAngleOfTestObject { get; set; } = "NOVALUE";
|
||||
|
||||
/// <summary>
|
||||
/// Convert Velocity to m/sec unit
|
||||
/// </summary>
|
||||
/// <param name="velocity"></param>
|
||||
/// <param name="velocityUnit">VelocityUnit enum index</param>
|
||||
/// <returns>Velocity in m/sec</returns>
|
||||
private string ConvertVelocityToMeterPerSecond(string velocity, string velocityUnit)
|
||||
{
|
||||
if (velocity == "NOVALUE" || velocityUnit == "NOVALUE")
|
||||
{
|
||||
return velocity;
|
||||
}
|
||||
|
||||
if ((DTS.Common.Enums.VelocityUnit)Convert.ToInt32(velocityUnit) == Enums.VelocityUnit.KilometerPerHour)
|
||||
{
|
||||
return (Convert.ToDouble(velocity) / 3.6).ToString();
|
||||
}
|
||||
return velocity;
|
||||
}
|
||||
|
||||
public KeyValuePair<string, string>[] ExtraProperties { get; set; } = new KeyValuePair<string, string>[0];
|
||||
|
||||
|
||||
public MMETestObjectWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
public MMETestObjectWrapper(string location)
|
||||
{
|
||||
if (!location.Contains(Path.DirectorySeparatorChar) && !location.Contains(Path.AltDirectorySeparatorChar))
|
||||
{
|
||||
var dir = Path.Combine(Environment.CurrentDirectory, GetDirectory());
|
||||
location = Path.Combine(dir, location);
|
||||
}
|
||||
File = location;
|
||||
var serializer = new XmlSerializer(typeof(MMETestObjectWrapper));
|
||||
using (TextReader tr = new StreamReader(location))
|
||||
{
|
||||
var cd = (MMETestObjectWrapper)serializer.Deserialize(tr);
|
||||
ClassOfTestObject = cd.ClassOfTestObject;
|
||||
CodeOfTestObject = cd.CodeOfTestObject;
|
||||
Comments = cd.Comments;
|
||||
DriverPosition = cd.DriverPosition;
|
||||
ExtraProperties = cd.ExtraProperties;
|
||||
File = cd.File;
|
||||
ImpactSide = cd.ImpactSide;
|
||||
MassOfTestObject = cd.MassOfTestObject;
|
||||
MMETestObjectGUID = cd.MMETestObjectGUID;
|
||||
Name = cd.Name;
|
||||
ReferenceNumberOfTestObject = cd.ReferenceNumberOfTestObject;
|
||||
Velocity = cd.Velocity;
|
||||
VelocityMeasurementUnit = cd.VelocityMeasurementUnit;
|
||||
OffsetOfTestObject = cd.OffsetOfTestObject;
|
||||
BarrierWidthOfTestObject = cd.BarrierWidthOfTestObject;
|
||||
BarrierHeightOfTestObject = cd.BarrierHeightOfTestObject;
|
||||
YawAngleOfTestObject = cd.YawAngleOfTestObject;
|
||||
ReferenceSystemOfTestObject = cd.ReferenceSystemOfTestObject;
|
||||
OriginXOfTestObject = cd.OriginXOfTestObject;
|
||||
OriginYOfTestObject = cd.OriginYOfTestObject;
|
||||
OriginZOfTestObject = cd.OriginZOfTestObject;
|
||||
NumberOfLoadcellsOfTestObject = cd.NumberOfLoadcellsOfTestObject;
|
||||
|
||||
tr.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMEFineLocations2 : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string FINE_LOC_2 { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
/// <summary>
|
||||
/// imports a singular fine location 2
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
/// <param name="page"></param>
|
||||
public static MMEFineLocations2 ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(CustomFinLoc2Fields)).Cast<CustomFinLoc2Fields>().ToArray();
|
||||
|
||||
string sGuid = "", fineLoc2 = "", textL1 = "", textL2 = "", remarks = "", sortKey = "", lastChangeText = "", history = "";
|
||||
var expired = false;
|
||||
long version = 0;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case CustomFinLoc2Fields.Date:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFinLoc2Fields.Expired:
|
||||
expired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case CustomFinLoc2Fields.Fine_Loc_2:
|
||||
fineLoc2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFinLoc2Fields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.S_GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.SortKey:
|
||||
sortKey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc2Fields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomFineLoc2 unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
return new MMEFineLocations2(sGuid, fineLoc2, textL1, textL2, version, date, remarks, expired, sortKey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
|
||||
public MMEFineLocations2(string sGuid, string fineLoc2, string textL1, string textL2, long version, DateTime date,
|
||||
string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
FINE_LOC_2 = fineLoc2;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
|
||||
public static MMEFineLocations2[] GetFineLocations2()
|
||||
{
|
||||
var fineLocations2 = new List<MMEFineLocations2>();
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEFineLocations2";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string sFineLoc2 = ISOReader["FINE_LOC_2"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
fineLocations2.Add(new MMEFineLocations2(sGuid, sFineLoc2, textL1, textL2, version,
|
||||
date,
|
||||
remarks, expired, sortkey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process fine loc 2", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return fineLocations2.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,513 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ISO.Strings {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class StringResources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal StringResources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ISO.Strings.StringResources", typeof(StringResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO DIM serial numbers should start with 'SPD'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_DIMShouldStartWithSPD {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_DIMShouldStartWithSPD", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to DIR serial numbers should start with 'DI'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_DIRShouldStartWithDI {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_DIRShouldStartWithDI", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to DKR serial numbers should start with 'DK'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_DKRShouldStartWithDK {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_DKRShouldStartWithDK", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TDAS G5 serial numbers should start with '5M'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_G5ShouldStartWith5M {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_G5ShouldStartWith5M", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to IP address required.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_IPAddressRequired {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_IPAddressRequired", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE MICRO Base+ serial numbers should start with 'BA0'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_MICROBasePlusShouldStartWithBA0 {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_MICROBasePlusShouldStartWithBA0", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE MICRO serial numbers should start with 'BA0'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_MicroSerialNumberShouldStartWithBA0 {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_MicroSerialNumberShouldStartWithBA0", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE NANO Base+ serial numbers should start with 'BA5'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_NANOBasePlusShouldStartWithBA5 {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_NANOBasePlusShouldStartWithBA5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to PowerPRO serial numbers should start with 'PPRO'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_PowerProShouldStartWithPPRO {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_PowerProShouldStartWithPPRO", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a TDAS G5.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SerialNumberBelongsToAG5 {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SerialNumberBelongsToAG5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE MICRO.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SerialNumberBelongsToAMicro {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SerialNumberBelongsToAMicro", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE NANO.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SerialNumberBelongsToANano {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SerialNumberBelongsToANano", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a PowerPRO Battery.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SerialNumberBelongsToAPowerPRO {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SerialNumberBelongsToAPowerPRO", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE G5.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SerialNumberBelongsToASLICEG5 {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SerialNumberBelongsToASLICEG5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE PRO Lab SIM.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SerialNumberBelongsToASLICEPROLabSIM {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SerialNumberBelongsToASLICEPROLabSIM", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE Lab Ethernet.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SerialNumberBelongsToASlicePROLabSLE {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SerialNumberBelongsToASlicePROLabSLE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE PRO SIM.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SerialNumberBelongsToASLICEProSim {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SerialNumberBelongsToASLICEProSim", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a TDAS PRO Lab rack.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SerialNumberBelongsToATDASLabRack {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SerialNumberBelongsToATDASLabRack", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a TDAS PRO rack.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SerialNumberBelongsToATDASRack {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SerialNumberBelongsToATDASRack", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number required.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SerialNumberRequired {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SerialNumberRequired", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO SIM serial numbers should start with 'SPS'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SIMShouldStartWithSPS {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SIMShouldStartWithSPS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO Lab DIM serial numbers should start with 'SLD'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SLDShouldStartWithSLD {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SLDShouldStartWithSLD", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE PRO Lab DIM.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABDIM {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABDIM", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE PRO Lab TOM.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABTOM {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABTOM", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Serial number belongs to a SLICE PRO DIM.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SLICE_SerialNumberBelongsToASLICEProDIM {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SLICE_SerialNumberBelongsToASLICEProDIM", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE 6 AIR-BR serial numbers should start with 'S6BR'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SLICE6AIRBRShouldStartWith {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SLICE6AIRBRShouldStartWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE 6 AIR serial numbers should start with 'S6A'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SLICE6AIRShouldStartWith {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SLICE6AIRShouldStartWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE 6 distributor 3 serial numbers should start with S6DB3.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SLICE6DB3ShouldStartWith {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SLICE6DB3ShouldStartWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE 6 distributor serial numbers should start with 'S6DB'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_Slice6DBShouldStartWithS6DB {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_Slice6DBShouldStartWithS6DB", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE 6 serial numbers should start with 'SL6'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SLICE6ShouldStartWith {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SLICE6ShouldStartWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE distributor serial numbers should start with 'SD'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SliceDBShouldStartWithSDB {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SliceDBShouldStartWithSDB", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO Ethernet Control Module serial numbers should start with 'SPE'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SliceECM {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SliceECM", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE G5 serial numbers should start with 'SG5'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SliceG5ShouldStartWithSG5 {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SliceG5ShouldStartWithSG5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE Lab Ethernet serial numbers should start with 'SLE'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SliceLabEthernetShouldStartWithSLE {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SliceLabEthernetShouldStartWithSLE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE NANO serial numbers should start with 'BA5'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SLICENanoShouldStartWithBA5 {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SLICENanoShouldStartWithBA5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO Distributor serial numbers should start with 'SPDB'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SLICEPRODBShouldStartWithSPDB {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SLICEPRODBShouldStartWithSPDB", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE Mini Distributor serial numbers should start with 'SPM'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_SliceSPM {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_SliceSPM", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO Lab SIM serial numbers should start with 'SLS'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SLSShouldStartWithSLS {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SLSShouldStartWithSLS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO Lab TOM serial numbers should start with 'SLT'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_SLTShouldStartWithSLT {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_SLTShouldStartWithSLT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TDAS PRO lab rack serial numbers should start with 'LR'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDAS_TDASLabRackShouldStartWith {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDAS_TDASLabRackShouldStartWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TDAS PRO rack serial numbers should start with 'DR'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_TDASRackShouldStartWith {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_TDASRackShouldStartWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to SLICE PRO TOM serial numbers should start with 'SPT'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_TOMShouldStartWithSPT {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_TOMShouldStartWithSPT", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TSR AIR serial numbers should start with 'TA'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_TSRAIRShouldStartWithTA {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_TSRAIRShouldStartWithTA", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} serial numbers should start with '{1}'.
|
||||
/// </summary>
|
||||
internal static string AutoDetectDas_TypeShouldStartWithPrepend {
|
||||
get {
|
||||
return ResourceManager.GetString("AutoDetectDas_TypeShouldStartWithPrepend", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to commit CustomerDetails.
|
||||
/// </summary>
|
||||
internal static string CustomerDetails_FailedToCommit {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomerDetails_FailedToCommit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to CustomerDetail: Required name is null.
|
||||
/// </summary>
|
||||
internal static string CustomerDetails_NullReferenceName {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomerDetails_NullReferenceName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to commit LabDetails.
|
||||
/// </summary>
|
||||
internal static string LabDetails_FailedToCommit {
|
||||
get {
|
||||
return ResourceManager.GetString("LabDetails_FailedToCommit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to LabDetail: Required name is null.
|
||||
/// </summary>
|
||||
internal static string LabDetails_NullReferenceName {
|
||||
get {
|
||||
return ResourceManager.GetString("LabDetails_NullReferenceName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Failed to commit TestEngineerDetails.
|
||||
/// </summary>
|
||||
internal static string TestEngineerDetails_FailedToCommit {
|
||||
get {
|
||||
return ResourceManager.GetString("TestEngineerDetails_FailedToCommit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to TestEngineerDetail: Required name is null.
|
||||
/// </summary>
|
||||
internal static string TestEngineerDetails_NullReferenceName {
|
||||
get {
|
||||
return ResourceManager.GetString("TestEngineerDetails_NullReferenceName", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,347 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMETransducerMainLocation : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Type { get; }
|
||||
|
||||
public string Trans_Main_Loc { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public string Picture_ShortName { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// imports a singular transducer main location
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
/// <param name="page"></param>
|
||||
public static MMETransducerMainLocation ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(MainLocationFields)).Cast<MainLocationFields>().ToArray();
|
||||
|
||||
string sGuid = "",
|
||||
type = "",
|
||||
transMainLoc = "",
|
||||
textL1 = "",
|
||||
textL2 = "",
|
||||
remarks = "",
|
||||
sortkey = "",
|
||||
pictureShortName = "",
|
||||
lastChangeText = "",
|
||||
history = "";
|
||||
long version = 0;
|
||||
var expired = false;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case MainLocationFields.Date:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()),
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case MainLocationFields.Expired:
|
||||
expired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case MainLocationFields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()),
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case MainLocationFields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Picture_ShortName:
|
||||
pictureShortName = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.S_GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.SortKey:
|
||||
sortkey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Trans_Main_Loc:
|
||||
transMainLoc = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Type:
|
||||
type = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case MainLocationFields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()),
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomMainLoc unsupported field: " +
|
||||
field.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return new MMETransducerMainLocation(sGuid, type, transMainLoc, textL1, textL2, version, date, remarks,
|
||||
expired, sortkey, pictureShortName, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
public static void WriteXML(ref XmlWriter writer, MMETransducerMainLocation[] locs)
|
||||
{
|
||||
writer.WriteStartElement(TopLevelFields.CustomMainLocs.ToString());
|
||||
|
||||
foreach (var main in locs)
|
||||
{
|
||||
writer.Flush();
|
||||
main.WriteXML(ref writer);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
/// <summary>
|
||||
/// writes an ISODll.MMETransducerMainLocation to xml
|
||||
/// </summary>
|
||||
/// <param name="m"></param>
|
||||
/// <param name="writer"></param>
|
||||
public void WriteXML(ref XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("TransducerMainLocation");
|
||||
|
||||
var fields = Enum.GetValues(typeof(MainLocationFields)).Cast<MainLocationFields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var sVal = "";
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case MainLocationFields.Date: sVal = Date.ToString(System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case MainLocationFields.Expired: sVal = Expired.ToString(); break;
|
||||
case MainLocationFields.History: sVal = History; break;
|
||||
case MainLocationFields.Last_Change: sVal = Last_Change.ToString(System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case MainLocationFields.Last_Change_Text: sVal = Last_Change_Text; break;
|
||||
case MainLocationFields.Picture_ShortName: sVal = Picture_ShortName; break;
|
||||
case MainLocationFields.Remarks: sVal = Remarks; break;
|
||||
case MainLocationFields.S_GUID: sVal = S_GUID; break;
|
||||
case MainLocationFields.SortKey: sVal = SortKey; break;
|
||||
case MainLocationFields.Text_L1: sVal = Text_L1; break;
|
||||
case MainLocationFields.Text_L2: sVal = Text_L2; break;
|
||||
case MainLocationFields.Trans_Main_Loc: sVal = Trans_Main_Loc; break;
|
||||
case MainLocationFields.Type: sVal = Type; break;
|
||||
case MainLocationFields.Version: sVal = Version.ToString(System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
default: throw new NotSupportedException("ExportTestSetup::WriteMainLoc unsupported field: " + field.ToString());
|
||||
}
|
||||
|
||||
writer.WriteAttributeString(field.ToString(), sVal);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public MMETransducerMainLocation(string textL1)
|
||||
{
|
||||
Text_L1 = textL1;
|
||||
}
|
||||
|
||||
public MMETransducerMainLocation(string sGuid, string type, string transMainLoc, string textL1, string textL2,
|
||||
long version, DateTime date, string remarks, bool expired, string sortkey, string pictureShortName,
|
||||
DateTime lastChange, string lastChangeText, string history, MMEPossibleChannels.MMEChannelTypes recordType)
|
||||
{
|
||||
RecordType = recordType;
|
||||
S_GUID = sGuid;
|
||||
Type = type;
|
||||
Trans_Main_Loc = transMainLoc;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortkey;
|
||||
Picture_ShortName = pictureShortName;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public static void DeleteTransducerMainLocations()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("failed to delete main locations, ", ex); }
|
||||
}
|
||||
public static MMETransducerMainLocation[] GetTransducerMainLocations()
|
||||
{
|
||||
var transducerMainLocations = new List<MMETransducerMainLocation>();
|
||||
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEMainLocations";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string type = ISOReader["TYPE"].ToString();
|
||||
string transMainLoc = ISOReader["TRANS_MAIN_LOC"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = GetDate(ISOReader, "DATE");
|
||||
string remarks = ISOReader["REAMRKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
string pictureShortName = ISOReader["PICTURE_SHORTNAME"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
transducerMainLocations.Add(new MMETransducerMainLocation(sGuid, type, transMainLoc,
|
||||
textL1, textL2, version,
|
||||
date, remarks, expired, sortkey, pictureShortName, lastChange, lastChangeText,
|
||||
history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process main location", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return transducerMainLocations.ToArray();
|
||||
}
|
||||
public void Commit()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(S_GUID) });
|
||||
cmd.Parameters.Add(new SqlParameter("@TYPE", SqlDbType.NVarChar, 50) { Value = Type });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TRANS_MAIN_LOC", SqlDbType.NVarChar, 50) { Value = Trans_Main_Loc });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 50) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 50) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = Date });
|
||||
cmd.Parameters.Add(new SqlParameter("@REMARKS", SqlDbType.NVarChar, 50) { Value = Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = Expired });
|
||||
cmd.Parameters.Add(new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = SortKey });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PICTURE_SHORTNAME", SqlDbType.NVarChar, 50) { Value = Picture_ShortName });
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = Last_Change });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 50) { Value = Last_Change_Text });
|
||||
cmd.Parameters.Add(new SqlParameter("@HISTORY", SqlDbType.NVarChar, 50) { Value = History });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using ISO.Strings;
|
||||
using DTS.Common.Classes.LabratoryDetails;
|
||||
using DTS.Common.Interface.TestMetaData;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
[Serializable()]
|
||||
public class LabratoryDetails : LabratoryDetailsDbRecord //: ISerializableFile
|
||||
{
|
||||
#region enums
|
||||
|
||||
private enum Fields
|
||||
{
|
||||
Name,
|
||||
LaboratoryName,
|
||||
LaboratoryContactName,
|
||||
LaboratoryContactPhone,
|
||||
LaboratoryContactFax,
|
||||
LaboratoryContactEmail,
|
||||
LaboratoryTestRefNumber,
|
||||
LaboratoryProjectRefNumber,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
LocalOnly,
|
||||
Version
|
||||
};
|
||||
|
||||
#endregion enums
|
||||
|
||||
#region Properties
|
||||
|
||||
public new string LabratoryContactPhone
|
||||
{
|
||||
get => base.LabratoryContactPhone;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.LabratoryContactPhone = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new string LabratoryContactFax
|
||||
{
|
||||
get => base.LabratoryContactFax;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.LabratoryContactFax = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new string LabratoryContactEmail
|
||||
{
|
||||
get => base.LabratoryContactEmail;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.LabratoryContactEmail = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region XML
|
||||
|
||||
public void WriteXML(ref System.Xml.XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("LabDetail");
|
||||
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
writer.WriteStartElement(field.ToString());
|
||||
switch (field)
|
||||
{
|
||||
case Fields.LaboratoryContactEmail:
|
||||
writer.WriteString(LabratoryContactEmail);
|
||||
break;
|
||||
case Fields.LaboratoryContactFax:
|
||||
writer.WriteString(LabratoryContactFax);
|
||||
break;
|
||||
case Fields.LaboratoryContactName:
|
||||
writer.WriteString(LabratoryContactName);
|
||||
break;
|
||||
case Fields.LaboratoryContactPhone:
|
||||
writer.WriteString(LabratoryContactPhone);
|
||||
break;
|
||||
case Fields.LaboratoryName:
|
||||
writer.WriteString(LabratoryName);
|
||||
break;
|
||||
case Fields.LaboratoryTestRefNumber:
|
||||
writer.WriteString(LabratoryTestRefNumber);
|
||||
break;
|
||||
case Fields.LaboratoryProjectRefNumber:
|
||||
writer.WriteString(LabratoryProjectRefNumber);
|
||||
break;
|
||||
case Fields.LastModified:
|
||||
writer.WriteString(LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
case Fields.LastModifiedBy:
|
||||
writer.WriteString(LastModifiedBy);
|
||||
break;
|
||||
case Fields.LocalOnly:
|
||||
writer.WriteString(LocalOnly.ToString());
|
||||
break;
|
||||
case Fields.Name:
|
||||
writer.WriteString(Name);
|
||||
break;
|
||||
case Fields.Version:
|
||||
writer.WriteString(Version.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("LabratoryDetails::WriteXML unsupported field: " +
|
||||
field.ToString());
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public static LabratoryDetails ReadXML(System.Xml.XmlElement root)
|
||||
{
|
||||
var l = new LabratoryDetails();
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement)
|
||||
{
|
||||
ProcessXMLElement(node as System.Xml.XmlElement, ref l);
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
private static void ProcessXMLElement(System.Xml.XmlElement node, ref LabratoryDetails lab)
|
||||
{
|
||||
if (Enum.TryParse(node.Name, out Fields field))
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.Version:
|
||||
lab.Version = int.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case Fields.Name:
|
||||
lab.Name = node.InnerText;
|
||||
break;
|
||||
case Fields.LocalOnly:
|
||||
lab.LocalOnly = Convert.ToBoolean(node.InnerText);
|
||||
break;
|
||||
case Fields.LastModifiedBy:
|
||||
lab.LastModifiedBy = node.InnerText;
|
||||
break;
|
||||
case Fields.LastModified:
|
||||
lab.LastModified = DateTime.Parse(node.InnerText,
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case Fields.LaboratoryTestRefNumber:
|
||||
lab.LabratoryTestRefNumber = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryProjectRefNumber:
|
||||
lab.LabratoryProjectRefNumber = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryName:
|
||||
lab.LabratoryName = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactPhone:
|
||||
lab.LabratoryContactPhone = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactName:
|
||||
lab.LabratoryContactName = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactFax:
|
||||
lab.LabratoryContactFax = node.InnerText;
|
||||
break;
|
||||
case Fields.LaboratoryContactEmail:
|
||||
lab.LabratoryContactEmail = node.InnerText;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("LabratoryDetails::ProcessXMLElement unsupported field: " +
|
||||
field.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion XML
|
||||
|
||||
public static LabratoryDetails GetLabratoryDetails(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.LabratoryDetailsGet(name, out ILabratoryDetailsDbRecord[] labratoryDetailsDbRecords);
|
||||
|
||||
if (0 == errorNumber && null != labratoryDetailsDbRecords && labratoryDetailsDbRecords.Any())
|
||||
{
|
||||
return new LabratoryDetails(labratoryDetailsDbRecords[0]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to retrieve lab details", name, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void DeleteLabratoryDetails()
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.LabratoryDetailsDelete(null, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
APILogger.Log("Failed to delete labratory details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to delete laboratory details", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LabratoryDetails()
|
||||
{
|
||||
}
|
||||
|
||||
public LabratoryDetails(LabratoryDetails copy)
|
||||
{
|
||||
Name = copy.Name;
|
||||
LabratoryName = copy.LabratoryName;
|
||||
LabratoryContactName = copy.LabratoryContactName;
|
||||
LabratoryContactPhone = copy.LabratoryContactPhone;
|
||||
LabratoryContactFax = copy.LabratoryContactFax;
|
||||
LabratoryContactEmail = copy.LabratoryContactEmail;
|
||||
LabratoryTestRefNumber = copy.LabratoryTestRefNumber;
|
||||
LabratoryProjectRefNumber = copy.LabratoryProjectRefNumber;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
Version = copy.Version;
|
||||
}
|
||||
|
||||
public LabratoryDetails(ILabratoryDetailsDbRecord labratoryDetailsDbRecord)
|
||||
: base(labratoryDetailsDbRecord)
|
||||
{
|
||||
}
|
||||
|
||||
public static LabratoryDetails[] GetAllLabratoryDetails()
|
||||
{
|
||||
var labs = new List<LabratoryDetails>();
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.LabratoryDetailsGet(null, out ILabratoryDetailsDbRecord[] labratoryDetailsDbRecords);
|
||||
|
||||
if (errorNumber == 0)
|
||||
{
|
||||
foreach (var labratoryDetailDbRecord in labratoryDetailsDbRecords)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cd = new LabratoryDetails(labratoryDetailDbRecord);
|
||||
if (!cd.IsInvalidBlank())
|
||||
{
|
||||
labs.Add(cd);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failed to get labratory details", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to retreive laboratory details", ex);
|
||||
}
|
||||
return labs.ToArray();
|
||||
}
|
||||
|
||||
public void Delete(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.LabratoryDetailsDelete(Name, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
APILogger.Log("Failed to delete labratory details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failed to update laboratory", Name, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void Commit(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsInvalidBlank())
|
||||
{
|
||||
throw new NullReferenceException(StringResources.LabDetails_NullReferenceName);
|
||||
}
|
||||
var labratoryDetailsDbRecord = new LabratoryDetailsDbRecord(this);
|
||||
labratoryDetailsDbRecord.LastModified = DateTime.Now;
|
||||
labratoryDetailsDbRecord.LastModifiedBy = user;
|
||||
var errorNumber = DbOperations.LabratoryDetailsUpdateInsert(labratoryDetailsDbRecord, out string errorMessage);
|
||||
|
||||
|
||||
if (errorNumber == 0) return;
|
||||
APILogger.Log("failed to commit laboratory", Name, errorMessage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(StringResources.LabDetails_FailedToCommit, Name, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMEPositions : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Position { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
|
||||
public MMEPositions(string sGuid, string position, string textL1, string textL2, long version,
|
||||
DateTime date, string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText,
|
||||
string history, MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Position = position;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
|
||||
public static MMEPositions[] GetPositions()
|
||||
{
|
||||
var positions = new List<MMEPositions>();
|
||||
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEPositions";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string position = ISOReader["POSITION"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
positions.Add(new MMEPositions(sGuid, position, textL1, textL2, version, date, remarks,
|
||||
expired, sortkey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process position", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return positions.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// imports a singular position
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
/// <param name="page"></param>
|
||||
public static MMEPositions ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(PositionFields)).Cast<PositionFields>().ToArray();
|
||||
|
||||
string sGuid = "", position = "", textL1 = "", textL2 = "", remarks = "", sortKey = "", lastChangeText = "", history = "";
|
||||
long version = 0;
|
||||
var expired = false;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case PositionFields.Date:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PositionFields.Expired:
|
||||
expired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case PositionFields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PositionFields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.Position:
|
||||
position = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.RecordType:
|
||||
break;
|
||||
case PositionFields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.S_GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.SortKey:
|
||||
sortKey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PositionFields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomPosition unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return new MMEPositions(sGuid, position, textL1, textL2, version, date, remarks, expired, sortKey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMEFilterClasses : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Filter_Class { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public static MMEFilterClasses ReadXML(XmlElement node)
|
||||
{
|
||||
string sGuid = "", filterClass = "", textL1 = "", textL2 = "", remarks = "", sortKey = "", lastChangeText = "", history = "";
|
||||
long version = 0;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
var bExpired = false;
|
||||
|
||||
var fields = Enum.GetValues(typeof(CustomFilterFields)).Cast<CustomFilterFields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case CustomFilterFields.Date:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFilterFields.Expired:
|
||||
bExpired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case CustomFilterFields.Filter_Class:
|
||||
filterClass = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFilterFields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.S_GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.SortKey:
|
||||
sortKey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFilterFields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomFilterClasses unknown field: " + field);
|
||||
}
|
||||
}
|
||||
return new MMEFilterClasses(sGuid, filterClass, textL1, textL2, version, date, remarks, bExpired, sortKey,
|
||||
lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
public MMEFilterClasses(string sGuid, string filterClass, string textL1, string textL2, long version,
|
||||
DateTime date, string remarks, bool bExpired, string sortKey, DateTime lastChange, string lastChangeText, string history,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Filter_Class = filterClass;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = bExpired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
|
||||
public static MMEFilterClasses[] GetFilterClasses()
|
||||
{
|
||||
var filterClasses = new List<MMEFilterClasses>();
|
||||
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEFilterClasses";
|
||||
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string filterClass = ISOReader["FILTER_CLASS"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
filterClasses.Add(new MMEFilterClasses(sGuid, filterClass, textL1, textL2, version,
|
||||
date, remarks, expired,
|
||||
sortkey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process filter classes ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
return filterClasses.ToArray();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Text_L1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,327 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Interface.Groups;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.GroupTemplate;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class TestObject : IComparable, ITestObject
|
||||
{
|
||||
private List<TestObjectChannel> _allChannels = new List<TestObjectChannel>();
|
||||
public TestObjectChannel[] AllChannels
|
||||
{
|
||||
get => _allChannels.ToArray();
|
||||
set
|
||||
{
|
||||
_allChannels = new List<TestObjectChannel>(value);
|
||||
SortChannels();
|
||||
}
|
||||
}
|
||||
|
||||
public void SortChannels()
|
||||
{
|
||||
_allChannels.Sort();
|
||||
}
|
||||
|
||||
public TestObjectChannel GetChannel(string channelid)
|
||||
{
|
||||
return Array.Find(AllChannels, ch => ch.GetId() == channelid || ch.Name == channelid);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Embedded)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(DisplaySerialNumber))
|
||||
{
|
||||
var index = SerialNumber.LastIndexOf('_');
|
||||
var displaySerialNumber = SerialNumber;
|
||||
if (index >= 0)
|
||||
{
|
||||
displaySerialNumber = SerialNumber.Substring(index + 1);
|
||||
}
|
||||
return displaySerialNumber;
|
||||
}
|
||||
return DisplaySerialNumber;
|
||||
}
|
||||
return SerialNumber;
|
||||
//return Embedded ?
|
||||
// DisplaySerialNumber : SerialNumber;
|
||||
}
|
||||
|
||||
public string DisplaySerialNumber => SysBuilt ? SerialNumberConverted : OriginalSerialNumber;
|
||||
|
||||
public string SerialNumberConverted { get; set; }
|
||||
|
||||
public string SerialNumber { get; set; }
|
||||
|
||||
public string SerialNumberOrOriginalSerialNumber => Embedded ? OriginalSerialNumber : SerialNumber;
|
||||
|
||||
public string TestObjectType { get; set; }
|
||||
|
||||
public string ParentObject { get; set; }
|
||||
|
||||
public bool SysBuilt { get; set; }
|
||||
|
||||
public string TextL1 { get; set; }
|
||||
|
||||
private List<string> _hardwareIds = new List<string>();
|
||||
public string[] HardwareIds
|
||||
{
|
||||
get => _hardwareIds.ToArray();
|
||||
set { _hardwareIds.Clear(); _hardwareIds.AddRange(value); }
|
||||
}
|
||||
|
||||
public string Template { get; set; }
|
||||
|
||||
public void SetTemplateOnly(string value) { Template = value; }
|
||||
public void SetTemplate(string value, ref ISO13499FileDb db)
|
||||
{
|
||||
Template = value;
|
||||
var template = TestObjectTemplate.GetTemplate(ref db, Template);
|
||||
SetTemplate(template);
|
||||
}
|
||||
public void SetTemplate(TestObjectTemplate template)
|
||||
{
|
||||
_allChannels.Clear();
|
||||
if (null == template) return;
|
||||
Template = template.TemplateName;
|
||||
AllChannels = template.Channels.Select(c => new TestObjectChannel(c, this, template)).ToArray();
|
||||
}
|
||||
|
||||
public bool LocalOnly { get; set; }
|
||||
|
||||
public string LastModifiedBy { get; set; }
|
||||
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
public TestObject(TestObject copy, TestObjectTemplate template, ISO13499FileDb db)
|
||||
{
|
||||
SerialNumberConverted = string.Empty;
|
||||
_allChannels = new List<TestObjectChannel>();
|
||||
foreach (var ch in copy.AllChannels) { _allChannels.Add(new TestObjectChannel(ch, this, template)); }
|
||||
Embedded = copy.Embedded;
|
||||
_hardwareIds = new List<string>();
|
||||
_hardwareIds.AddRange(copy.HardwareIds.ToArray());
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
OriginalSerialNumber = copy.OriginalSerialNumber;
|
||||
OriginalTemplate = copy.OriginalTemplate;
|
||||
ParentObject = copy.ParentObject;
|
||||
_sensorSettings = new Dictionary<string, Dictionary<string, Dictionary<SensorConstants.SensorSettings, SensorSetting>>>();
|
||||
using (var e1 = copy._sensorSettings.GetEnumerator())
|
||||
{
|
||||
while (e1.MoveNext())
|
||||
{
|
||||
using (var e2 = e1.Current.Value.GetEnumerator())
|
||||
{
|
||||
while (e2.MoveNext())
|
||||
{
|
||||
using (var e3 = e2.Current.Value.GetEnumerator())
|
||||
{
|
||||
while (e3.MoveNext())
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(e1.Current.Key))
|
||||
{
|
||||
_sensorSettings.Add(e1.Current.Key,
|
||||
new Dictionary<string, Dictionary<SensorConstants.SensorSettings, SensorSetting>>());
|
||||
}
|
||||
if (!_sensorSettings[e1.Current.Key].ContainsKey(e2.Current.Key))
|
||||
{
|
||||
_sensorSettings[e1.Current.Key].Add(e2.Current.Key,
|
||||
new Dictionary<SensorConstants.SensorSettings, SensorSetting>());
|
||||
}
|
||||
if (!_sensorSettings[e1.Current.Key][e2.Current.Key].ContainsKey(e3.Current.Key))
|
||||
{
|
||||
_sensorSettings[e1.Current.Key][e2.Current.Key].Add(e3.Current.Key,
|
||||
new SensorSetting(e3.Current.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SerialNumber = copy.SerialNumber;
|
||||
SysBuilt = copy.SysBuilt;
|
||||
Template = copy.Template;
|
||||
TestObjectType = copy.TestObjectType;
|
||||
TextL1 = copy.TextL1;
|
||||
}
|
||||
|
||||
public bool Embedded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// original serial number of this group (the serial number will be changed once it's embedded in a test setup)
|
||||
/// </summary>
|
||||
public string OriginalSerialNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the original template for this group (the template is also changed once it's embedded in a test setup)
|
||||
/// </summary>
|
||||
public string OriginalTemplate { get; set; }
|
||||
|
||||
|
||||
public static SensorSetting[] GetSettingsFromString(string s, string sensor, string channelid)
|
||||
{
|
||||
var tokens = s.Split(',');
|
||||
|
||||
return (from token in tokens select token.Split('=') into subtokens let setting = (SensorConstants.SensorSettings)Convert.ToInt32(subtokens[0]) select new SensorSetting(setting, subtokens[1], channelid, sensor)).ToArray();
|
||||
}
|
||||
public TestObject()
|
||||
{
|
||||
OriginalTemplate = "";
|
||||
OriginalSerialNumber = "";
|
||||
SerialNumberConverted = string.Empty;
|
||||
_allChannels = new List<TestObjectChannel>();
|
||||
_hardwareIds = new List<string>();
|
||||
LastModified = DateTime.MinValue;
|
||||
LastModifiedBy = "N/A";
|
||||
LocalOnly = false;
|
||||
SerialNumber = "";
|
||||
Template = "";
|
||||
ParentObject = "";
|
||||
}
|
||||
public class SensorSetting
|
||||
{
|
||||
public string ChannelId { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
public SensorConstants.SensorSettings Setting { get; set; }
|
||||
public string Value { get; set; }
|
||||
public SensorSetting(SensorConstants.SensorSettings setting, string value, string channelId, string serialNumber)
|
||||
{
|
||||
ChannelId = channelId;
|
||||
Value = value;
|
||||
Setting = setting;
|
||||
SerialNumber = serialNumber;
|
||||
}
|
||||
public SensorSetting(SensorSetting copy)
|
||||
{
|
||||
ChannelId = copy.ChannelId;
|
||||
Value = copy.Value;
|
||||
Setting = copy.Setting;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
}
|
||||
}
|
||||
private readonly Dictionary<string, Dictionary<string, Dictionary<SensorConstants.SensorSettings, SensorSetting>>> _sensorSettings =
|
||||
new Dictionary<string, Dictionary<string, Dictionary<SensorConstants.SensorSettings, SensorSetting>>>();
|
||||
|
||||
public SensorSetting[] GetSensorSettings(string channelId, string serialNumber)
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(channelId)) return new SensorSetting[0];
|
||||
return _sensorSettings[channelId].ContainsKey(serialNumber) ? _sensorSettings[channelId][serialNumber].Values.ToArray() : new SensorSetting[0];
|
||||
}
|
||||
public void SetSensorSetting(string channelId, string serialNumber, SensorSetting setting)
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(channelId)) { _sensorSettings[channelId] = new Dictionary<string, Dictionary<SensorConstants.SensorSettings, SensorSetting>>(); }
|
||||
if (!_sensorSettings[channelId].ContainsKey(serialNumber)) { _sensorSettings[channelId][serialNumber] = new Dictionary<SensorConstants.SensorSettings, SensorSetting>(); }
|
||||
_sensorSettings[channelId][serialNumber][setting.Setting] = setting;
|
||||
}
|
||||
private void RemoveSensorSetting(string channelId, string serialNumber)
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(channelId)) return;
|
||||
if (_sensorSettings[channelId].ContainsKey(serialNumber)) { _sensorSettings[channelId].Remove(serialNumber); }
|
||||
}
|
||||
|
||||
public TestObject(TestObject copy, ref ISO13499FileDb db)
|
||||
{
|
||||
SerialNumberConverted = string.Empty;
|
||||
OriginalSerialNumber = copy.OriginalSerialNumber;
|
||||
OriginalTemplate = copy.OriginalTemplate;
|
||||
Embedded = copy.Embedded;
|
||||
|
||||
_allChannels = new List<TestObjectChannel>();
|
||||
|
||||
var t = TestObjectTemplate.GetTemplate(ref db, Template);
|
||||
|
||||
copy.SortChannels();
|
||||
foreach (var c in copy.AllChannels) { _allChannels.Add(new TestObjectChannel(c, this, t)); }
|
||||
|
||||
for (var i = 0; i < copy.AllChannels.Length && i < _allChannels.Count; i++)
|
||||
{
|
||||
_allChannels[i].ChannelIdx = i;
|
||||
}
|
||||
|
||||
_hardwareIds = new List<string>(copy.HardwareIds);
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
Template = copy.Template;
|
||||
ParentObject = copy.ParentObject;
|
||||
SysBuilt = copy.SysBuilt;
|
||||
using (var e = copy._sensorSettings.GetEnumerator())
|
||||
{
|
||||
_sensorSettings =
|
||||
new Dictionary<string, Dictionary<string, Dictionary<SensorConstants.SensorSettings, SensorSetting>>>();
|
||||
while (e.MoveNext())
|
||||
{
|
||||
if (!_sensorSettings.ContainsKey(e.Current.Key))
|
||||
{
|
||||
_sensorSettings[e.Current.Key] =
|
||||
new Dictionary<string, Dictionary<SensorConstants.SensorSettings, SensorSetting>>();
|
||||
}
|
||||
using (var e2 = copy._sensorSettings[e.Current.Key].GetEnumerator())
|
||||
{
|
||||
while (e2.MoveNext())
|
||||
{
|
||||
if (!_sensorSettings[e.Current.Key].ContainsKey(e2.Current.Key))
|
||||
{
|
||||
_sensorSettings[e.Current.Key][e2.Current.Key] =
|
||||
new Dictionary<SensorConstants.SensorSettings, SensorSetting>();
|
||||
}
|
||||
using (var e3 = copy._sensorSettings[e.Current.Key][e2.Current.Key].GetEnumerator())
|
||||
{
|
||||
while (e3.MoveNext())
|
||||
{
|
||||
_sensorSettings[e.Current.Key][e2.Current.Key][e3.Current.Key] =
|
||||
new SensorSetting(e3.Current.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string GetSerializedSetting(SensorSetting[] settings)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var bNeedComma = false;
|
||||
foreach (var setting in settings)
|
||||
{
|
||||
if (bNeedComma) { sb.Append(","); }
|
||||
bNeedComma = true;
|
||||
|
||||
sb.AppendFormat("{0}={1}", (int)setting.Setting, setting.Value);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static int CompareTestObject(TestObject left, TestObject right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
return null == right ? 1 : string.Compare(left.SerialNumber, right.SerialNumber, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int CompareTo(object o)
|
||||
{
|
||||
if (o is TestObject testObject)
|
||||
{
|
||||
return CompareTestObject(this, testObject);
|
||||
}
|
||||
throw new ArgumentException($"object {o} is not the same type as this instance (TestObject)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public abstract class AbstractOLEDbWrapper
|
||||
{
|
||||
protected static long GetLong(IDataReader reader, string field)
|
||||
{
|
||||
return DBNull.Value == reader[field] ? long.MinValue : Convert.ToInt64(reader[field]);
|
||||
}
|
||||
|
||||
protected static DateTime GetDate(IDataReader reader, string field)
|
||||
{
|
||||
if (DBNull.Value != reader[field]) { return (DateTime)reader[field]; }
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{27D0C63B-9095-42DA-95FD-F64444C80558}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ISO</RootNamespace>
|
||||
<AssemblyName>ISO</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AbstractOLEDbWrapper.cs" />
|
||||
<Compile Include="CalculatedValueClass.cs" />
|
||||
<Compile Include="LevelTriggerChannel.cs" />
|
||||
<Compile Include="Strings\StringResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>StringResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TestEngineerDetails.cs" />
|
||||
<Compile Include="CustomerDetails.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="HardwareChannel.cs" />
|
||||
<Compile Include="Hardware.cs" />
|
||||
<Compile Include="ISerializableFile.cs" />
|
||||
<Compile Include="ISO13499FileDb.cs" />
|
||||
<Compile Include="IsoCode.cs" />
|
||||
<Compile Include="LabratoryDetails.cs" />
|
||||
<Compile Include="MMEDirections.cs" />
|
||||
<Compile Include="IsoMDBFile.cs" />
|
||||
<Compile Include="MMEFilterClasses.cs" />
|
||||
<Compile Include="MMEFineLocations1.cs" />
|
||||
<Compile Include="MMEFineLocations2.cs" />
|
||||
<Compile Include="MMEFineLocations3.cs" />
|
||||
<Compile Include="MMEPhysicalDimensions.cs" />
|
||||
<Compile Include="MMEPositions.cs" />
|
||||
<Compile Include="MMEPossibleChannels.cs" />
|
||||
<Compile Include="MMETestObjects.cs" />
|
||||
<Compile Include="MMETestObjectWrapper.cs" />
|
||||
<Compile Include="MMETransducerMainLocation.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<CustomToolNamespace>DTS.Common.ISO</CustomToolNamespace>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TestObject.cs" />
|
||||
<Compile Include="TestObjectChannel.cs" />
|
||||
<Compile Include="TestObjectMetaData.cs" />
|
||||
<Compile Include="TestObjectTemplateChannel.cs" />
|
||||
<Compile Include="TestObjectTemplate.cs" />
|
||||
<Compile Include="TestPlan.cs" />
|
||||
<Compile Include="TestSetting.cs" />
|
||||
<Compile Include="TestTypesFile.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
<CustomToolNamespace>DTS.Common.ISO</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Strings\StringResources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>StringResources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Design\DTS.Common.ISOClassDiagram.cd" />
|
||||
<None Include="Resources\DTS_2C_Logo.png">
|
||||
<CustomToolNamespace>DTS.Common.ISO</CustomToolNamespace>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\DTS_2C_web_small.png">
|
||||
<CustomToolNamespace>DTS.Common.ISO</CustomToolNamespace>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DTS.Common.DAS.Concepts\DTS.Common.DAS.Concepts.csproj">
|
||||
<Project>{ae3987f7-c4c6-40fb-a353-1a2dadef7a9a}</Project>
|
||||
<Name>DTS.Common.DAS.Concepts</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.Storage\DTS.Common.Storage.csproj">
|
||||
<Project>{e3be457c-0ac7-4a9c-bc81-eafeb3217878}</Project>
|
||||
<Name>DTS.Common.Storage</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common.Utilities\DTS.Common.Utilities.csproj">
|
||||
<Project>{d6da1b74-c711-43c2-91b1-1908a8d04dbf}</Project>
|
||||
<Name>DTS.Common.Utilities</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DTS.Common\DTS.Common.csproj">
|
||||
<Project>{f7a0804f-61a4-40ae-83d0-f1137622b592}</Project>
|
||||
<Name>DTS.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,668 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a "possible" channel, once we know what iso object we are dealing with there can be a number of channels
|
||||
/// defined for the object. We might not care about all of them ...
|
||||
/// this is also a template channel, in that some fields will not be known yet (direction, dimension maybe, position, etc)
|
||||
/// TestObjectChannel will consume this channel and then allow setting the locations as needed
|
||||
/// </summary>
|
||||
public class MMEPossibleChannels : AbstractOLEDbWrapper
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public void ClearId() { Id = -1; }
|
||||
public void SetId(long id) { Id = id; }
|
||||
|
||||
public string Type { get; private set; }
|
||||
public void SetType(string type) { Type = type; }
|
||||
|
||||
public string Test_Object { get; private set; }
|
||||
|
||||
public void Set_Test_Object(string val)
|
||||
{
|
||||
Test_Object = val;
|
||||
}
|
||||
|
||||
public string Position { get; private set; }
|
||||
|
||||
public void Set_Position(string val)
|
||||
{
|
||||
Position = val;
|
||||
}
|
||||
|
||||
public string Trans_Main_Loc { get; private set; }
|
||||
|
||||
public void Set_Main_Loc(string val)
|
||||
{
|
||||
Trans_Main_Loc = val;
|
||||
}
|
||||
|
||||
public string Fine_Loc_1 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the fine location 1
|
||||
/// the property doesn't seem to have a set
|
||||
/// so not sure if it was omitted or on purpose
|
||||
/// See all othe "Set_*" functions
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
public void Set_Fine_Loc_1(string val)
|
||||
{
|
||||
Fine_Loc_1 = val;
|
||||
}
|
||||
|
||||
|
||||
public string Fine_Loc_2 { get; private set; }
|
||||
|
||||
public void Set_Fine_Loc_2(string val)
|
||||
{
|
||||
Fine_Loc_2 = val;
|
||||
}
|
||||
|
||||
public string Fine_Loc_3 { get; private set; }
|
||||
|
||||
public void Set_Fine_Loc_3(string val)
|
||||
{
|
||||
Fine_Loc_3 = val;
|
||||
}
|
||||
|
||||
public string Physical_Dimension { get; private set; }
|
||||
|
||||
public void Set_Physical_Dimension(string val)
|
||||
{
|
||||
Physical_Dimension = val;
|
||||
}
|
||||
|
||||
public string Direction { get; private set; }
|
||||
|
||||
public void Set_Direction(string val)
|
||||
{
|
||||
Direction = val;
|
||||
}
|
||||
|
||||
public string Default_Filter_Class { get; private set; }
|
||||
|
||||
public void Set_Default_Filter_Class(string val)
|
||||
{
|
||||
Default_Filter_Class = val;
|
||||
}
|
||||
|
||||
public string Text_L1 { get; private set; }
|
||||
public void SetText1(string text1) { Text_L1 = text1; }
|
||||
|
||||
public string Text_L2 { get; private set; }
|
||||
public void SetText2(string text2) { Text_L2 = text2; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; private set; }
|
||||
public void SetRemarks(string remarks) { Remarks = remarks; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public string Picture_ShortName { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public int MMEChannelType { get; }
|
||||
|
||||
public MMEPossibleChannels(MMEPossibleChannels copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
Type = copy.Type;
|
||||
Test_Object = copy.Test_Object;
|
||||
Position = copy.Position;
|
||||
Trans_Main_Loc = copy.Trans_Main_Loc;
|
||||
Fine_Loc_1 = copy.Fine_Loc_1;
|
||||
Fine_Loc_2 = copy.Fine_Loc_2;
|
||||
Fine_Loc_3 = copy.Fine_Loc_3;
|
||||
Physical_Dimension = copy.Physical_Dimension;
|
||||
Direction = copy.Direction;
|
||||
Default_Filter_Class = copy.Default_Filter_Class;
|
||||
Text_L1 = copy.Text_L1;
|
||||
Text_L2 = copy.Text_L2;
|
||||
Version = copy.Version;
|
||||
Date = copy.Date;
|
||||
Remarks = copy.Remarks;
|
||||
Expired = copy.Expired;
|
||||
SortKey = copy.SortKey;
|
||||
Picture_ShortName = copy.Picture_ShortName;
|
||||
Last_Change = copy.Last_Change;
|
||||
Last_Change_Text = copy.Last_Change_Text;
|
||||
History = copy.History;
|
||||
MMEChannelType = copy.MMEChannelType;
|
||||
}
|
||||
public MMEPossibleChannels(long id, string type, string textObject, string position, string transMainLoc,
|
||||
string fineLoc1, string fineLoc2, string fineLoc3, string physicalDimension, string direction, string defaultFilterClass,
|
||||
string textL1, string textL2, long version, DateTime date, string remarks, bool expired, string sortkey,
|
||||
string pictureShortName, DateTime lastChange, string lastChangeText, string history, int mmeChannelType)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
Test_Object = textObject;
|
||||
Position = position;
|
||||
Trans_Main_Loc = transMainLoc;
|
||||
Fine_Loc_1 = fineLoc1;
|
||||
Fine_Loc_2 = fineLoc2;
|
||||
Fine_Loc_3 = fineLoc3;
|
||||
Physical_Dimension = physicalDimension;
|
||||
Direction = direction;
|
||||
Default_Filter_Class = defaultFilterClass;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortkey;
|
||||
Picture_ShortName = pictureShortName;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
MMEChannelType = mmeChannelType;
|
||||
}
|
||||
public enum MMEChannelTypes
|
||||
{
|
||||
ISO13499_106,
|
||||
SQL
|
||||
}
|
||||
|
||||
public static MMEPossibleChannels[] GetPossibleChannels()
|
||||
{
|
||||
var possibleChannels = new List<MMEPossibleChannels>();
|
||||
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEPossibleChannels";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
long id = GetLong(ISOReader, "ID");
|
||||
string type = ISOReader["TYPE"].ToString();
|
||||
string testObject = ISOReader["TEST_OBJECT"].ToString();
|
||||
string position = ISOReader["POSITION"].ToString();
|
||||
string transMainLoc = ISOReader["TRANS_MAIN_LOC"].ToString();
|
||||
string fineLoc1 = ISOReader["FINE_LOC_1"].ToString();
|
||||
string fineLoc2 = ISOReader["FINE_LOC_2"].ToString();
|
||||
string fineLoc3 = ISOReader["FINE_LOC_3"].ToString();
|
||||
string physicalDimension = ISOReader["PHYSICAL_DIMENSION"].ToString();
|
||||
string direction = ISOReader["DIRECTION"].ToString();
|
||||
string defaultFilterClass = ISOReader["DEFAULT_FILTER_CLASS"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = GetDate(ISOReader, "DATE");
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
string pictureShortName = ISOReader["PICTURE_SHORTNAME"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
|
||||
possibleChannels.Add(new MMEPossibleChannels(id, type, testObject, position,
|
||||
transMainLoc, fineLoc1, fineLoc2,
|
||||
fineLoc3, physicalDimension, direction, defaultFilterClass, textL1, textL2,
|
||||
version, date, remarks, expired, sortkey, pictureShortName, lastChange,
|
||||
lastChangeText, history, (int)MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process possible channels", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return possibleChannels.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reads/parses out a CustomChannel from XML
|
||||
/// </summary>
|
||||
/// <param name="root"></param>
|
||||
/// <returns></returns>
|
||||
public static MMEPossibleChannels ReadXML(XmlElement root)
|
||||
{
|
||||
long id = -1;
|
||||
var type = "";
|
||||
var testobject = "";
|
||||
var position = "";
|
||||
var date = DateTime.Now;
|
||||
var filterclass = "";
|
||||
var expired = false;
|
||||
var direction = "";
|
||||
var fineloc1 = "";
|
||||
var fineloc2 = "";
|
||||
var fineloc3 = "";
|
||||
var history = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var lastChangeText = "";
|
||||
var dimension = "";
|
||||
var pictureShortName = "";
|
||||
var remarks = "";
|
||||
var sortkey = "";
|
||||
var text1 = "";
|
||||
var text2 = "";
|
||||
var transMainLoc = "";
|
||||
var version = 0;
|
||||
|
||||
foreach (var child in root.ChildNodes)
|
||||
{
|
||||
if (!(child is XmlElement)) continue;
|
||||
var element = child as XmlElement;
|
||||
|
||||
if (Enum.TryParse(element.Name, out DbOperations.MMETables.MMEPossibleChannelsFields field))
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.ID:
|
||||
id = long.Parse(element.InnerText, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.DATE:
|
||||
date = DateTime.Parse(element.InnerText, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.DEFAULT_FILTER_CLASS:
|
||||
filterclass = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.DIRECTION:
|
||||
direction = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(element.InnerText);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.FINE_LOC_1:
|
||||
fineloc1 = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.FINE_LOC_2:
|
||||
fineloc2 = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.FINE_LOC_3:
|
||||
fineloc3 = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.HISTORY:
|
||||
history = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.LAST_CHANGE:
|
||||
lastChange = DateTime.Parse(element.InnerText, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.TYPE:
|
||||
type = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.PHYSICAL_DIMENSION:
|
||||
dimension = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.PICTURE_SHORTNAME:
|
||||
pictureShortName = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.POSITION:
|
||||
position = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.REMARKS:
|
||||
remarks = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.SORTKEY:
|
||||
sortkey = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.TEST_OBJECT:
|
||||
testobject = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.TEXT_L1:
|
||||
text1 = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.TEXT_L2:
|
||||
text2 = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.TRANS_MAIN_LOC:
|
||||
transMainLoc = element.InnerText;
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPossibleChannelsFields.VERSION:
|
||||
version = Convert.ToInt32(element.InnerText, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(
|
||||
"CustomChannel::ProcessXMLElement field in enum not handled: " + field);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//This is a field that was exported in an earlier version of DataPRO, so stay backward compatible
|
||||
switch (element.Name)
|
||||
{
|
||||
//These have been replaced by TYPE
|
||||
case DbOperations.MMETables.MyType: //This was exported in all versions up to 1.3.496
|
||||
case DbOperations.MMETables.CustomChannelType
|
||||
: //This was exported in versions from 1.3.498 - 1.3.515
|
||||
type = element.InnerText;
|
||||
break;
|
||||
//This has been replaced by ID
|
||||
case DbOperations.MMETables.Id: //This was exported in all versions up to 1.3.515
|
||||
id = long.Parse(element.InnerText, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException(
|
||||
"CustomChannel::ProcessXMLElement field not in enum and unknown: " + field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new MMEPossibleChannels(id, type, testobject, position, transMainLoc, fineloc1, fineloc2,
|
||||
fineloc3, dimension, direction, filterclass, text1, text2, version, date, remarks, expired, sortkey,
|
||||
pictureShortName, lastChange, lastChangeText, history, (int)MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
if (-1 == Id) { CreateNewMMEChannel(); }
|
||||
else
|
||||
{
|
||||
UpdateAll();
|
||||
}
|
||||
}
|
||||
public static void Commit(MMEPossibleChannels[] channels)
|
||||
{
|
||||
foreach (var channel in channels)
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText =
|
||||
DbOperationsEnum.StoredProcedure.sp_MMEPossibleChannelsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.BigInt) { Value = 0 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TYPE", SqlDbType.NVarChar, 50) { Value = channel.Type });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TEST_OBJECT", SqlDbType.NVarChar, 50) { Value = channel.Test_Object });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@POSITION", SqlDbType.NVarChar, 50) { Value = channel.Position });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TRANS_MAIN_LOC", SqlDbType.NVarChar, 50)
|
||||
{
|
||||
Value = channel.Trans_Main_Loc
|
||||
});
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@FINE_LOC_1", SqlDbType.NVarChar, 50) { Value = channel.Fine_Loc_1 });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@FINE_LOC_2", SqlDbType.NVarChar, 50) { Value = channel.Fine_Loc_2 });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@FINE_LOC_3", SqlDbType.NVarChar, 50) { Value = channel.Fine_Loc_3 });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PHYSICAL_DIMENSION", SqlDbType.NVarChar, 50)
|
||||
{
|
||||
Value = channel.Physical_Dimension
|
||||
});
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@DIRECTION", SqlDbType.NVarChar, 50) { Value = channel.Direction });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@DEFAULT_FILTER_CLASS", SqlDbType.NVarChar, 50)
|
||||
{
|
||||
Value = channel.Default_Filter_Class
|
||||
});
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 100) { Value = channel.Text_L1 });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 100) { Value = channel.Text_L2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = channel.Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = channel.Date });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@REMARKS", SqlDbType.NVarChar, 50) { Value = channel.Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = channel.Expired });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = channel.SortKey });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PICTURE_SHORTNAME", SqlDbType.NVarChar, 50)
|
||||
{
|
||||
Value = channel.Picture_ShortName
|
||||
});
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = DateTime.Now });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 50) { Value = "Created" });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@HISTORY", SqlDbType.NVarChar, 50) { Value = channel.History });
|
||||
var newIdParam =
|
||||
new SqlParameter("@new_id", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(newIdParam);
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
var id = int.Parse(newIdParam.Value.ToString());
|
||||
channel.Id = id == 0 ? channel.Id : id;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public void Insert()
|
||||
{
|
||||
CreateNewMMEChannel();
|
||||
}
|
||||
public void Delete()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPossibleChannelsDelete.ToString();
|
||||
cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.BigInt) { Value = Id });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void UpdateAll()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPossibleChannelsUpdate.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.BigInt) { Value = Id });
|
||||
cmd.Parameters.Add(new SqlParameter("@TYPE", SqlDbType.NVarChar, 50) { Value = Type });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEST_OBJECT", SqlDbType.NVarChar, 50) { Value = Test_Object });
|
||||
cmd.Parameters.Add(new SqlParameter("@POSITION", SqlDbType.NVarChar, 50) { Value = Position });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TRANS_MAIN_LOC", SqlDbType.NVarChar, 50) { Value = Trans_Main_Loc });
|
||||
cmd.Parameters.Add(new SqlParameter("@FINE_LOC_1", SqlDbType.NVarChar, 50) { Value = Fine_Loc_1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@FINE_LOC_2", SqlDbType.NVarChar, 50) { Value = Fine_Loc_2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@FINE_LOC_3", SqlDbType.NVarChar, 50) { Value = Fine_Loc_3 });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PHYSICAL_DIMENSION", SqlDbType.NVarChar, 50) { Value = Physical_Dimension });
|
||||
cmd.Parameters.Add(new SqlParameter("@DIRECTION", SqlDbType.NVarChar, 50) { Value = Direction });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@DEFAULT_FILTER_CLASS", SqlDbType.NVarChar, 50)
|
||||
{
|
||||
Value = Default_Filter_Class
|
||||
});
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 100) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 100) { Value = Text_L2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = Date });
|
||||
cmd.Parameters.Add(new SqlParameter("@REMARKS", SqlDbType.NVarChar, 50) { Value = Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = Expired });
|
||||
cmd.Parameters.Add(new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = SortKey });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PICTURE_SHORTNAME", SqlDbType.NVarChar, 50) { Value = Picture_ShortName });
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = DateTime.Now });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 50) { Value = "Created" });
|
||||
cmd.Parameters.Add(new SqlParameter("@HISTORY", SqlDbType.NVarChar, 50) { Value = History });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateNewMMEChannel()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPossibleChannelsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.BigInt) { Value = Id });
|
||||
cmd.Parameters.Add(new SqlParameter("@TYPE", SqlDbType.NVarChar, 50) { Value = Type });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEST_OBJECT", SqlDbType.NVarChar, 50) { Value = Test_Object });
|
||||
cmd.Parameters.Add(new SqlParameter("@POSITION", SqlDbType.NVarChar, 50) { Value = Position });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@TRANS_MAIN_LOC", SqlDbType.NVarChar, 50) { Value = Trans_Main_Loc });
|
||||
cmd.Parameters.Add(new SqlParameter("@FINE_LOC_1", SqlDbType.NVarChar, 50) { Value = Fine_Loc_1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@FINE_LOC_2", SqlDbType.NVarChar, 50) { Value = Fine_Loc_2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@FINE_LOC_3", SqlDbType.NVarChar, 50) { Value = Fine_Loc_3 });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PHYSICAL_DIMENSION", SqlDbType.NVarChar, 50) { Value = Physical_Dimension });
|
||||
cmd.Parameters.Add(new SqlParameter("@DIRECTION", SqlDbType.NVarChar, 50) { Value = Direction });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@DEFAULT_FILTER_CLASS", SqlDbType.NVarChar, 50)
|
||||
{
|
||||
Value = Default_Filter_Class
|
||||
});
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 100) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 100) { Value = Text_L2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = Date });
|
||||
cmd.Parameters.Add(new SqlParameter("@REMARKS", SqlDbType.NVarChar, 50) { Value = Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = Expired });
|
||||
cmd.Parameters.Add(new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = SortKey });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PICTURE_SHORTNAME", SqlDbType.NVarChar, 50) { Value = Picture_ShortName });
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = DateTime.Now });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 50) { Value = "Created" });
|
||||
cmd.Parameters.Add(new SqlParameter("@HISTORY", SqlDbType.NVarChar, 50) { Value = History });
|
||||
var newIdParam = new SqlParameter("@new_id", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(newIdParam);
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
var id = int.Parse(newIdParam.Value.ToString());
|
||||
Id = id == 0 ? Id : id;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.LogException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="DTS_2C_Logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\DTS_2C_Logo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="DTS_2C_web_small" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\DTS_2C_web_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMEDirections : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Direction { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// imports a singular custom direction
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
public static MMEDirections ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(CustomDirectionFields)).Cast<CustomDirectionFields>().ToArray();
|
||||
|
||||
string sGuid = "", direction = "", textL1 = "", textL2 = "", remarks = "", lastChangeText = "", history = "", sortkey = "";
|
||||
var date = DateTime.Now;
|
||||
long version = 0;
|
||||
var bExpired = false;
|
||||
var lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case CustomDirectionFields.Direction:
|
||||
direction = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.Expired:
|
||||
bExpired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case CustomDirectionFields.GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomDirectionFields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.SortKey:
|
||||
sortkey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomDirectionFields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomDirection unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return new MMEDirections(sGuid, direction, textL1, textL2, date, version, bExpired, remarks, lastChange, lastChangeText, history, sortkey, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
public MMEDirections(string sGuid, string direction, string textL1, string textL2, DateTime date, long version,
|
||||
bool bExpired, string remarks, DateTime lastChange, string lastChangeText, string history, string sortkey,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Direction = direction;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Date = date;
|
||||
Version = version;
|
||||
Expired = bExpired;
|
||||
Remarks = remarks;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
SortKey = sortkey;
|
||||
}
|
||||
|
||||
public static MMEDirections[] GetDirections()
|
||||
{
|
||||
var directions = new List<MMEDirections>();
|
||||
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEDirections";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
var version =
|
||||
Convert.ToInt32(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.VERSION.ToString()]);
|
||||
var text2 = Convert.ToString(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L2.ToString()]);
|
||||
var text1 = Convert.ToString(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.TEXT_L1.ToString()]);
|
||||
var sortKey =
|
||||
Convert.ToString(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.SORTKEY.ToString()]);
|
||||
var sGuid = Convert.ToString(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.s_GUID.ToString()]);
|
||||
var remarks =
|
||||
Convert.ToString(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.REMARKS.ToString()]);
|
||||
var lastChangeText =
|
||||
Convert.ToString(
|
||||
ISOReader[
|
||||
DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE_TEXT.ToString()]);
|
||||
var lastChange = GetDate(ISOReader,
|
||||
DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE.ToString());
|
||||
var history =
|
||||
Convert.ToString(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.HISTORY.ToString()]);
|
||||
var expired =
|
||||
Convert.ToBoolean(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.EXPIRED.ToString()]);
|
||||
var direction =
|
||||
Convert.ToString(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.DIRECTION.ToString()]);
|
||||
var date = Convert.ToDateTime(
|
||||
ISOReader[DbOperations.MMETables.MMEDirectionsFields.DATE.ToString()]);
|
||||
var mmedirection = new MMEDirections(sGuid, direction, text1, text2, date,
|
||||
Convert.ToInt64(version), expired, remarks, lastChange, lastChangeText,
|
||||
history, sortKey, MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
||||
directions.Add(mmedirection);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failed to load direction", ex);
|
||||
}
|
||||
}
|
||||
|
||||
ISOReader.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
return directions.ToArray();
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEDirectionsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(S_GUID) });
|
||||
cmd.Parameters.Add(new SqlParameter("@DIRECTION", SqlDbType.NVarChar, 50) { Value = Direction });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 255) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 255) { Value = Text_L2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = Date });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = Expired });
|
||||
cmd.Parameters.Add(new SqlParameter("@REMARKS", SqlDbType.NVarChar) { Value = Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = Last_Change });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 255) { Value = Last_Change_Text });
|
||||
cmd.Parameters.Add(new SqlParameter("@HISTORY", SqlDbType.NVarChar) { Value = History });
|
||||
cmd.Parameters.Add(new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = SortKey });
|
||||
var newIdParam = new SqlParameter("@new_id", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(newIdParam);
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,263 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using ISO.Strings;
|
||||
using DTS.Common.Classes.TestEngineerDetails;
|
||||
using DTS.Common.Interface.TestMetaData;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
[Serializable()]
|
||||
public class TestEngineerDetails : TestEngineerDetailsDbRecord //: ISerializableFile
|
||||
{
|
||||
private enum Fields
|
||||
{
|
||||
Name,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
TestEngineerFax,
|
||||
TestEngineerEmail,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version
|
||||
}
|
||||
public static TestEngineerDetails ReadXML(System.Xml.XmlElement root)
|
||||
{
|
||||
var t = new TestEngineerDetails();
|
||||
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement)
|
||||
{
|
||||
ProcessXMLElement(node as System.Xml.XmlElement, ref t);
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
private static void ProcessXMLElement(System.Xml.XmlElement node, ref TestEngineerDetails t)
|
||||
{
|
||||
if (!Enum.TryParse(node.Name, out Fields field)) return;
|
||||
switch (field)
|
||||
{
|
||||
case Fields.TestEngineerEmail: t.TestEngineerEmail = node.InnerText; break;
|
||||
case Fields.TestEngineerFax: t.TestEngineerFax = node.InnerText; break;
|
||||
case Fields.TestEngineerName: t.TestEngineerName = node.InnerText; break;
|
||||
case Fields.TestEngineerPhone: t.TestEngineerPhone = node.InnerText; break;
|
||||
case Fields.LastModified: t.LastModified = DateTime.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case Fields.LastModifiedBy: t.LastModifiedBy = node.InnerText; break;
|
||||
case Fields.LocalOnly: t.LocalOnly = bool.Parse(node.InnerText); break;
|
||||
case Fields.Name: t.Name = node.InnerText; break;
|
||||
case Fields.Version: t.Version = int.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
default: throw new NotSupportedException("ISODll.TestEngineerDetails::ProcessXMLElement unsupported field: " + field);
|
||||
}
|
||||
}
|
||||
public void WriteXML(ref System.Xml.XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("TestEngineerDetail");
|
||||
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
writer.WriteStartElement(field.ToString());
|
||||
|
||||
switch (field)
|
||||
{
|
||||
|
||||
case Fields.TestEngineerEmail: writer.WriteString(TestEngineerEmail); break;
|
||||
case Fields.TestEngineerFax: writer.WriteString(TestEngineerFax); break;
|
||||
case Fields.TestEngineerName: writer.WriteString(TestEngineerName); break;
|
||||
case Fields.TestEngineerPhone: writer.WriteString(TestEngineerPhone); break;
|
||||
case Fields.LastModified: writer.WriteString(LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
case Fields.LastModifiedBy: writer.WriteString(LastModifiedBy); break;
|
||||
case Fields.LocalOnly: writer.WriteString(LocalOnly.ToString()); break;
|
||||
case Fields.Name: writer.WriteString(Name); break;
|
||||
case Fields.Version: writer.WriteString(Version.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
default: throw new NotSupportedException("TestEngineerDetails::WriteXML unsupported field " + field);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public new string TestEngineerName
|
||||
{
|
||||
get => base.TestEngineerName;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.TestEngineerName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new string TestEngineerPhone
|
||||
{
|
||||
get => base.TestEngineerPhone;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.TestEngineerPhone = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new string TestEngineerFax
|
||||
{
|
||||
get => base.TestEngineerFax;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.TestEngineerFax = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new string TestEngineerEmail
|
||||
{
|
||||
get => base.TestEngineerEmail;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.TestEngineerEmail = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TestEngineerDetails()
|
||||
{
|
||||
}
|
||||
|
||||
public TestEngineerDetails(TestEngineerDetails copy)
|
||||
{
|
||||
Name = copy.Name;
|
||||
TestEngineerName = copy.TestEngineerName;
|
||||
TestEngineerPhone = copy.TestEngineerPhone;
|
||||
TestEngineerFax = copy.TestEngineerFax;
|
||||
TestEngineerEmail = copy.TestEngineerEmail;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
Version = copy.Version;
|
||||
}
|
||||
public TestEngineerDetails(ITestEngineerDetailsDbRecord testEngineerDetailsDbRecord)
|
||||
: base(testEngineerDetailsDbRecord)
|
||||
{
|
||||
}
|
||||
public static TestEngineerDetails GetTestEngineerDetails(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.TestEngineerDetailsGet(name, out ITestEngineerDetailsDbRecord[] testEngineerDetailsDbRecords);
|
||||
|
||||
if (errorNumber == 0)
|
||||
{
|
||||
return new TestEngineerDetails(testEngineerDetailsDbRecords[0]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("failed to get test engineer details", name, ex); }
|
||||
return null;
|
||||
}
|
||||
public static void DeleteAllTestEngineerDetails()
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.TestEngineerDetailsDelete(null, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
APILogger.Log("Failed to delete test engineer details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("Failed to delete test engineer details", ex); }
|
||||
}
|
||||
public static TestEngineerDetails[] GetAllTestEngineerDetails()
|
||||
{
|
||||
var list = new List<TestEngineerDetails>();
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.TestEngineerDetailsGet(null, out ITestEngineerDetailsDbRecord[] testEngineerDetailsDbRecords);
|
||||
|
||||
if (errorNumber == 0)
|
||||
{
|
||||
foreach (var testEngineerDetailsDbRecord in testEngineerDetailsDbRecords)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ted = new TestEngineerDetails(testEngineerDetailsDbRecord);
|
||||
if (!ted.IsInvalidBlank())
|
||||
{
|
||||
list.Add(ted);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failed to get test engineer details", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("Failed to retrieve test engineer details", ex); }
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private void Update(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var testEngineerDetailsDbRecord = new TestEngineerDetailsDbRecord(this);
|
||||
testEngineerDetailsDbRecord.LastModified = DateTime.Now;
|
||||
testEngineerDetailsDbRecord.LastModifiedBy = user;
|
||||
var errorNumber = DbOperations.TestEngineerDetailsUpdateInsert(testEngineerDetailsDbRecord, out string errorMessage);
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
APILogger.Log("Failed to update test engineer details", TestEngineerName, errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to update test engineer details", TestEngineerName, ex);
|
||||
throw; //TODO: handle exception properly
|
||||
}
|
||||
}
|
||||
public void Commit(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsInvalidBlank())
|
||||
{
|
||||
throw new NullReferenceException(StringResources.TestEngineerDetails_NullReferenceName);
|
||||
}
|
||||
Update(user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(StringResources.TestEngineerDetails_FailedToCommit, Name, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
public void Delete(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.CustomerDetailsDelete(Name, out string errorMessage);
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
APILogger.Log("Failed to delete test engineer details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("Failed to update test engineer details", Name, ex); throw; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Interface.Groups;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <inheritdoc cref="TestObjectTemplateChannel" />
|
||||
/// <summary>
|
||||
/// this class represents a more simpilized version of the group/test object channel
|
||||
/// this is closer tied to what's in the database
|
||||
/// It extends a template channel adds more meta data
|
||||
/// </summary>
|
||||
public class TestObjectChannel : TestObjectTemplateChannel, IComparable<TestObjectChannel>, IGroupChannel
|
||||
{
|
||||
#region properties
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// controls whether channel should be used when collecting data or not
|
||||
/// Disabled channels are not used in run test
|
||||
/// </summary>
|
||||
public bool Disabled { get; set; }
|
||||
public int ChannelIdx { get; set; } = CHANNEL_IDX_UNKNOWN;
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// the serial number of the sensor associated with this channel (if any)
|
||||
/// </summary>
|
||||
public string SensorSerialNumber
|
||||
{
|
||||
get => GetProperty("SensorSerialNumber", "") as string;
|
||||
set => SetProperty("SensorSerialNumber", value);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// the physical hardware channel associated with this channel (if any)
|
||||
/// </summary>
|
||||
public string HardwareId
|
||||
{
|
||||
get => GetProperty("HardwareId", "") as string;
|
||||
set
|
||||
{
|
||||
var tokens = value?.Split('_');
|
||||
if (3 == tokens?.Length)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("{0}_{1}", tokens[0], tokens[1]);
|
||||
var index = tokens[2].IndexOf(CHANNEL_SEPARATOR);
|
||||
if (index >= 0) { sb.Append(tokens[2].Substring(index)); }
|
||||
value = sb.ToString();
|
||||
}
|
||||
SetProperty("HardwareId", value);
|
||||
}
|
||||
}
|
||||
public SquibChannelTypes SquibChannelType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// the test object this channel belongs to
|
||||
/// </summary>
|
||||
public TestObject TestObject { get; }
|
||||
#endregion
|
||||
|
||||
#region constants and enums
|
||||
private const char CHANNEL_SEPARATOR = 'x';
|
||||
public const int CHANNEL_IDX_UNKNOWN = -1;
|
||||
public enum SquibChannelTypes
|
||||
{
|
||||
None, //Non-squib channels
|
||||
Voltage,
|
||||
Current
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// compares one channel to another, used for sorting
|
||||
/// order is determined by 1) display order, 2) name of the channels, 3) test object serial number (or original serial number)
|
||||
/// </summary>
|
||||
/// <param name="right"></param>
|
||||
/// <returns></returns>
|
||||
public int CompareTo(TestObjectChannel right)
|
||||
{
|
||||
if (null == right) { return 1; }
|
||||
if (this == right) { return 0; }
|
||||
var comp = DisplayOrder.CompareTo(right.DisplayOrder);
|
||||
if (0 != comp) { return comp; }
|
||||
|
||||
comp = string.Compare(Name, right.Name, StringComparison.Ordinal);
|
||||
if (0 != comp) { return comp; }
|
||||
|
||||
if (null == TestObject || null == right.TestObject) return 0;
|
||||
comp = string.Compare(TestObject.SerialNumberOrOriginalSerialNumber, right.TestObject.SerialNumberOrOriginalSerialNumber, StringComparison.Ordinal);
|
||||
return 0 != comp ? comp : 0;
|
||||
}
|
||||
|
||||
public string GetGraphId()
|
||||
{
|
||||
return SquibChannelType == SquibChannelTypes.Current ? GetId() + Constants.CURRENT_SUFFIX : GetId();
|
||||
}
|
||||
public string GetId()
|
||||
{
|
||||
return GetIdWithSpecificChannelId(Channel.Id);
|
||||
}
|
||||
public string GetIdWithSpecificChannelId(long id)
|
||||
{
|
||||
return $"{TestObject.SerialNumber}_{Channel.MMEChannelType}_{id}";
|
||||
}
|
||||
public string GetDASId()
|
||||
{
|
||||
var result = string.Empty;
|
||||
|
||||
if (HardwareId.Contains('_'))
|
||||
{
|
||||
result = HardwareId.Substring(0, HardwareId.IndexOf('_'));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region constructors and initializers
|
||||
public TestObjectChannel(TestObjectTemplateChannel copy, TestObject testObject, TestObjectTemplate template)
|
||||
: base(copy, template)
|
||||
{
|
||||
TestObject = testObject;
|
||||
if (copy is TestObjectChannel channel)
|
||||
{
|
||||
Disabled = channel.Disabled;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public int CompareTo(IGroupChannel other)
|
||||
{
|
||||
return CompareTo((TestObjectChannel)other);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Classes.Hardware;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
// ReSharper disable ConvertToAutoProperty
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class HardwareChannel : DASChannelDBRecord, INotifyPropertyChanged
|
||||
{
|
||||
private Hardware _parentHardware;
|
||||
public Hardware ParentDAS
|
||||
{
|
||||
get => _parentHardware;
|
||||
set => SetProperty(ref _parentHardware, value, "ParentDAS");
|
||||
}
|
||||
|
||||
public HardwareChannel() { }
|
||||
public HardwareChannel(IDASChannelDBRecord record, Hardware h) : base(record)
|
||||
{
|
||||
ParentDAS = h;
|
||||
}
|
||||
public HardwareChannel(HardwareChannel copy, Hardware h)
|
||||
{
|
||||
SupportedSquibFireModes = copy.SupportedSquibFireModes;
|
||||
SupportedExcitations = copy.SupportedExcitations;
|
||||
SupportedDigitalOutputModes = copy.SupportedDigitalOutputModes;
|
||||
SupportedDigitalInputModes = copy.SupportedDigitalInputModes;
|
||||
SupportedBridges = copy.SupportedBridges;
|
||||
ParentDAS = h;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
DASDisplayOrder = copy.DASDisplayOrder;
|
||||
ChannelIdx = copy.ChannelIdx;
|
||||
ModuleArrayIndex = copy.ModuleArrayIndex;
|
||||
_moduleSerialNumber = copy.ModuleSerialNumber;
|
||||
}
|
||||
|
||||
public static int PhysicalCompare(HardwareChannel left, HardwareChannel right)
|
||||
{
|
||||
if (left == right) { return 0; }
|
||||
if (null == left) { return -1; }
|
||||
return null == right ? 1 : left.ChannelIdx.CompareTo(right.ChannelIdx);
|
||||
}
|
||||
public void Insert()
|
||||
{
|
||||
_ = DbOperations.DASChannelsInsert(this, ParentDAS.GetId());
|
||||
}
|
||||
public bool IsSupported(SensorConstants.BridgeType bridge)
|
||||
{
|
||||
return (SupportedBridges & (int)bridge) == (int)bridge;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AutoDetectDas_DIMShouldStartWithSPD" xml:space="preserve">
|
||||
<value>SLICE PRO DIM serial numbers should start with 'SPD'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_G5ShouldStartWith5M" xml:space="preserve">
|
||||
<value>TDAS G5 serial numbers should start with '5M'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_IPAddressRequired" xml:space="preserve">
|
||||
<value>IP address required</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_MICROBasePlusShouldStartWithBA0" xml:space="preserve">
|
||||
<value>SLICE MICRO Base+ serial numbers should start with 'BA0'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_MicroSerialNumberShouldStartWithBA0" xml:space="preserve">
|
||||
<value>SLICE MICRO serial numbers should start with 'BA0'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_NANOBasePlusShouldStartWithBA5" xml:space="preserve">
|
||||
<value>SLICE NANO Base+ serial numbers should start with 'BA5'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_PowerProShouldStartWithPPRO" xml:space="preserve">
|
||||
<value>PowerPRO serial numbers should start with 'PPRO'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SerialNumberBelongsToAG5" xml:space="preserve">
|
||||
<value>Serial number belongs to a TDAS G5</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SerialNumberBelongsToAMicro" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE MICRO</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SerialNumberBelongsToANano" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE NANO</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SerialNumberBelongsToASLICEG5" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE G5</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SerialNumberBelongsToASLICEPROLabSIM" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE PRO Lab SIM</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SerialNumberBelongsToASlicePROLabSLE" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE Lab Ethernet</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SerialNumberBelongsToASLICEProSim" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE PRO SIM</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SerialNumberBelongsToATDASLabRack" xml:space="preserve">
|
||||
<value>Serial number belongs to a TDAS PRO Lab rack</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SerialNumberBelongsToATDASRack" xml:space="preserve">
|
||||
<value>Serial number belongs to a TDAS PRO rack</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SerialNumberRequired" xml:space="preserve">
|
||||
<value>Serial number required</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SIMShouldStartWithSPS" xml:space="preserve">
|
||||
<value>SLICE PRO SIM serial numbers should start with 'SPS'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SLDShouldStartWithSLD" xml:space="preserve">
|
||||
<value>SLICE PRO Lab DIM serial numbers should start with 'SLD'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SLICE6AIRShouldStartWith" xml:space="preserve">
|
||||
<value>SLICE 6 AIR serial numbers should start with 'S6A'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_Slice6DBShouldStartWithS6DB" xml:space="preserve">
|
||||
<value>SLICE 6 distributor serial numbers should start with 'S6DB'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SLICE6ShouldStartWith" xml:space="preserve">
|
||||
<value>SLICE 6 serial numbers should start with 'SL6'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SliceDBShouldStartWithSDB" xml:space="preserve">
|
||||
<value>SLICE distributor serial numbers should start with 'SD'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SliceECM" xml:space="preserve">
|
||||
<value>SLICE PRO Ethernet Control Module serial numbers should start with 'SPE'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SliceSPM" xml:space="preserve">
|
||||
<value>SLICE Mini Distributor serial numbers should start with 'SPM'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SliceG5ShouldStartWithSG5" xml:space="preserve">
|
||||
<value>SLICE G5 serial numbers should start with 'SG5'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SliceLabEthernetShouldStartWithSLE" xml:space="preserve">
|
||||
<value>SLICE Lab Ethernet serial numbers should start with 'SLE'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SLICENanoShouldStartWithBA5" xml:space="preserve">
|
||||
<value>SLICE NANO serial numbers should start with 'BA5'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABDIM" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE PRO Lab DIM</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABTOM" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE PRO Lab TOM</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SLICE_SerialNumberBelongsToASLICEProDIM" xml:space="preserve">
|
||||
<value>Serial number belongs to a SLICE PRO DIM</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SLSShouldStartWithSLS" xml:space="preserve">
|
||||
<value>SLICE PRO Lab SIM serial numbers should start with 'SLS'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SLTShouldStartWithSLT" xml:space="preserve">
|
||||
<value>SLICE PRO Lab TOM serial numbers should start with 'SLT'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_TDASLabRackShouldStartWith" xml:space="preserve">
|
||||
<value>TDAS PRO lab rack serial numbers should start with 'LR'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_TDASRackShouldStartWith" xml:space="preserve">
|
||||
<value>TDAS PRO rack serial numbers should start with 'DR'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_TOMShouldStartWithSPT" xml:space="preserve">
|
||||
<value>SLICE PRO TOM serial numbers should start with 'SPT'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SerialNumberBelongsToAPowerPRO" xml:space="preserve">
|
||||
<value>Serial number belongs to a PowerPRO Battery</value>
|
||||
</data>
|
||||
<data name="CustomerDetails_FailedToCommit" xml:space="preserve">
|
||||
<value>Failed to commit CustomerDetails</value>
|
||||
</data>
|
||||
<data name="CustomerDetails_NullReferenceName" xml:space="preserve">
|
||||
<value>CustomerDetail: Required name is null</value>
|
||||
</data>
|
||||
<data name="LabDetails_FailedToCommit" xml:space="preserve">
|
||||
<value>Failed to commit LabDetails</value>
|
||||
</data>
|
||||
<data name="LabDetails_NullReferenceName" xml:space="preserve">
|
||||
<value>LabDetail: Required name is null</value>
|
||||
</data>
|
||||
<data name="TestEngineerDetails_FailedToCommit" xml:space="preserve">
|
||||
<value>Failed to commit TestEngineerDetails</value>
|
||||
</data>
|
||||
<data name="TestEngineerDetails_NullReferenceName" xml:space="preserve">
|
||||
<value>TestEngineerDetail: Required name is null</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_TSRAIRShouldStartWithTA" xml:space="preserve">
|
||||
<value>TSR AIR serial numbers should start with 'TA'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SLICE6DB3ShouldStartWith" xml:space="preserve">
|
||||
<value>SLICE 6 distributor 3 serial numbers should start with S6DB3</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_DIRShouldStartWithDI" xml:space="preserve">
|
||||
<value>DIR serial numbers should start with 'DI'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_DKRShouldStartWithDK" xml:space="preserve">
|
||||
<value>DKR serial numbers should start with 'DK'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDAS_SLICEPRODBShouldStartWithSPDB" xml:space="preserve">
|
||||
<value>SLICE PRO Distributor serial numbers should start with 'SPDB'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_SLICE6AIRBRShouldStartWith" xml:space="preserve">
|
||||
<value>SLICE 6 AIR-BR serial numbers should start with 'S6BR'</value>
|
||||
</data>
|
||||
<data name="AutoDetectDas_TypeShouldStartWithPrepend" xml:space="preserve">
|
||||
<value>{0} serial numbers should start with '{1}'</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMEFineLocations3 : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string FINE_LOC_3 { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public string Picture_ShortName { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// imports a singular fine location 3
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
/// <param name="page"></param>
|
||||
public static MMEFineLocations3 ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(CustomFinLoc3Fields)).Cast<CustomFinLoc3Fields>().ToArray();
|
||||
|
||||
string sGuid = "", fineLoc3 = "", textL1 = "", textL2 = "", remarks = "", sortKey = "", lastChangeText = "", history = "", picturesShortName = "";
|
||||
var expired = false;
|
||||
long version = 0;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case CustomFinLoc3Fields.Date:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFinLoc3Fields.Expired:
|
||||
expired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case CustomFinLoc3Fields.Fine_Loc_3:
|
||||
fineLoc3 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFinLoc3Fields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.S_GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.SortKey:
|
||||
sortKey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc3Fields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomFineLoc3 unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return new MMEFineLocations3(sGuid, fineLoc3, textL1, textL2, version, date, remarks, expired, sortKey, lastChange, lastChangeText, history, picturesShortName, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
public MMEFineLocations3(string textL1)
|
||||
{
|
||||
Text_L1 = textL1;
|
||||
}
|
||||
|
||||
public MMEFineLocations3(string sGuid, string fineLoc3, string textL1, string textL2, long version, DateTime date,
|
||||
string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history, string picturesShortName,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
FINE_LOC_3 = fineLoc3;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
Picture_ShortName = picturesShortName;
|
||||
}
|
||||
|
||||
public static MMEFineLocations3[] GetFineLocations3()
|
||||
{
|
||||
var fineLocations3 = new List<MMEFineLocations3>();
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEFineLocations3";
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string sFineLoc3 = ISOReader["FINE_LOC_3"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
string pictureShortName = ISOReader["PICTURE_SHORTNAME"].ToString();
|
||||
fineLocations3.Add(new MMEFineLocations3(sGuid, sFineLoc3, textL1, textL2, version,
|
||||
date,
|
||||
remarks, expired, sortkey, lastChange, lastChangeText, history, pictureShortName,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process fine loc 3", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return fineLocations3.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// a simple setting in a test
|
||||
/// can have a default value, a value, and an id
|
||||
/// default value is used by TestSettingsDictionary for when
|
||||
/// the setting doesn't currently exist or have a value
|
||||
/// </summary>
|
||||
public class TestSetting
|
||||
{
|
||||
//public string Id { get; }
|
||||
public int Id { get; }
|
||||
public string Value { get; set; }
|
||||
|
||||
public string DefaultValue { get; }
|
||||
private const string SEPARATOR = "_x_";
|
||||
public TestSetting(TestSetting copy, string value)
|
||||
{
|
||||
Id = copy.Id;
|
||||
DefaultValue = copy.DefaultValue;
|
||||
Value = value;
|
||||
}
|
||||
public TestSetting(TestSetting copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
DefaultValue = copy.DefaultValue;
|
||||
Value = copy.Value;
|
||||
}
|
||||
public TestSetting(int id, string value, string defaultValue)
|
||||
{
|
||||
Id = id;
|
||||
Value = value;
|
||||
DefaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public TestSetting(TestSettingsEnum id, string value, string defaultValue)
|
||||
{
|
||||
Id = (int)id;
|
||||
Value = value;
|
||||
DefaultValue = defaultValue;
|
||||
}
|
||||
public string ToSerializeString()
|
||||
{
|
||||
return $"{Id}={Value.Replace("=", SEPARATOR)}";
|
||||
}
|
||||
|
||||
public static bool TryParse(string s, out TestSetting ts)
|
||||
{
|
||||
ts = null;
|
||||
|
||||
var tokens = s.Split(new[] { "=" }, StringSplitOptions.None);
|
||||
if (tokens.Length < 2) { return false; }
|
||||
var id = tokens[0].Replace(SEPARATOR, "=");
|
||||
var val = tokens[1].Replace(SEPARATOR, "=");
|
||||
if (Enum.TryParse(id, out TestSettingsEnum enumValue))
|
||||
{
|
||||
ts = new TestSetting(enumValue, val, val);
|
||||
return true;
|
||||
}
|
||||
if (int.TryParse(id, out var iTemp))
|
||||
{
|
||||
ts = new TestSetting(iTemp, val, val);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// list of all non columned test settings
|
||||
/// </summary>
|
||||
public enum TestSettingsEnum
|
||||
{
|
||||
ArmCheckListStep,
|
||||
CheckListInputVoltageCheck,
|
||||
CheckListBatteryVoltageCheck,
|
||||
CheckListSquibResistanceCheck,
|
||||
CheckListSensorIDCheck,
|
||||
CheckListTriggerStartCheck,
|
||||
CheckListTiltSensorCheck,
|
||||
CheckListTemperatureCheck,
|
||||
CheckListClockSyncCheck,
|
||||
EW,//ExcitationWarmup
|
||||
CheckListMustPass
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// holds all possible settings for a test
|
||||
/// </summary>
|
||||
public class TestSettingDictionary
|
||||
{
|
||||
public TestSettingDictionary()
|
||||
{
|
||||
}
|
||||
public TestSettingDictionary(TestSettingDictionary copy)
|
||||
{
|
||||
using (var e = copy._lookup.GetEnumerator())
|
||||
{
|
||||
while (e.MoveNext())
|
||||
{
|
||||
_lookup[e.Current.Key] = new TestSetting(e.Current.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
private const string SEPARATOR = "_X_";
|
||||
private readonly Dictionary<int, TestSetting> _lookup = new Dictionary<int, TestSetting>();
|
||||
public string GetValue(int id, string defaultValue)
|
||||
{
|
||||
if (!_lookup.ContainsKey(id)) { return defaultValue; }
|
||||
return _lookup[id].Value ?? _lookup[id].DefaultValue;
|
||||
}
|
||||
|
||||
public string GetValue(TestSettingsEnum id, string defaultValue)
|
||||
{
|
||||
return GetValue((int)id, defaultValue);
|
||||
}
|
||||
public void UnLoad()
|
||||
{
|
||||
_lookup.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// used to change the value in the dictionary (just the value, leave everything else the same)
|
||||
/// </summary>
|
||||
/// <param name="setting"></param>
|
||||
/// <param name="value"></param>
|
||||
public void SetValue(TestSetting setting, string value)
|
||||
{
|
||||
//we do it this way to avoid Add() and also to avoid accidentally reusing the input setting inappropriately
|
||||
_lookup[setting.Id] = new TestSetting(setting, value);
|
||||
}
|
||||
/// <summary>
|
||||
/// used to initialize a value in the dictionary
|
||||
/// </summary>
|
||||
/// <param name="setting"></param>
|
||||
public void SetValue(TestSetting setting)
|
||||
{
|
||||
_lookup[setting.Id] = setting;
|
||||
}
|
||||
|
||||
public void SetValue(TestSettingsEnum id, string value)
|
||||
{
|
||||
SetValue((int)id, value);
|
||||
}
|
||||
public void SetValue(int id, string value)
|
||||
{
|
||||
if (!_lookup.ContainsKey(id))
|
||||
{
|
||||
_lookup[id] = new TestSetting(id, value, value);
|
||||
}
|
||||
else { _lookup[id].Value = value; }
|
||||
}
|
||||
public string ToSerializeString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var s in _lookup.Values)
|
||||
{
|
||||
var sVal = s.ToSerializeString();
|
||||
// ReSharper disable once StringIndexOfIsCultureSpecific.1
|
||||
System.Diagnostics.Trace.Assert(sVal.IndexOf(SEPARATOR) < 0);
|
||||
sVal = sVal.Replace(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator, SEPARATOR);
|
||||
if (sb.Length > 0) { sb.Append(System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator); }
|
||||
sb.Append(sVal);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
public void LoadSettings(string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s)) { return; } //nothing to deserialize
|
||||
var tokens = s.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
var tok = token.Replace(SEPARATOR, System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator);
|
||||
//we prefer the default settings from the application
|
||||
//if for some reason this key is no longer used, we can still stick it in the storage and use it as is
|
||||
if (!TestSetting.TryParse(tok, out var ts)) continue;
|
||||
if (!_lookup.ContainsKey(ts.Id))//no longer has a default setting, just use as is
|
||||
{
|
||||
_lookup[ts.Id] = ts;
|
||||
}
|
||||
else { _lookup[ts.Id].Value = ts.Value; }//default setting exists, just set the value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
using DTS.Common.Interface.GroupTemplate;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class TestObjectTemplateChannel : INotifyPropertyChanged, IGroupTemplateChannel, IComparable<TestObjectTemplateChannel>
|
||||
{
|
||||
#region INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected bool SetProperty<T>(ref T storage, T value, string propertyName = null)
|
||||
{
|
||||
if (Equals(storage, value)) return false;
|
||||
|
||||
storage = value;
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
protected void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region constants and enums
|
||||
public const string NONISOCHANNELTYPE = "NONISO";
|
||||
public const string SEPARATOR = "_X_";
|
||||
public const string TEST_SPECIFIC_DOUT = "TSD_";
|
||||
public enum ReferenceChannelTypes { IMPLICIT, EXPLICIT, NOVALUE };
|
||||
public enum DataSourceTypes
|
||||
{
|
||||
Transducer,
|
||||
Calculation,
|
||||
Camera,
|
||||
Simulation,
|
||||
Parameter
|
||||
};
|
||||
|
||||
public enum DataStatusTypes
|
||||
{
|
||||
OK,
|
||||
ChannelFailed,
|
||||
MeaninglessData,
|
||||
NoData,
|
||||
QuestionableData,
|
||||
ScalingFactorApplied,
|
||||
SystemFailed,
|
||||
LinearisedData,
|
||||
NOVALUE
|
||||
}
|
||||
|
||||
public enum StandardChannelProperties
|
||||
{
|
||||
NameOfTheChannel,
|
||||
DisplayOrder
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region properties
|
||||
public bool Custom => null == Channel || Channel.MMEChannelType == (int)MMEPossibleChannels.MMEChannelTypes.SQL;
|
||||
public int DisplayOrder
|
||||
{
|
||||
get => Convert.ToInt32(_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
set
|
||||
{
|
||||
_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = value.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
OnPropertyChanged("DisplayOrder");
|
||||
}
|
||||
}
|
||||
public int TemplateChannelId { get; set; }
|
||||
public string NameOfTheChannel
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = _channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value as string;
|
||||
if (!string.IsNullOrWhiteSpace(s) && s != DataStatusTypes.NOVALUE.ToString()) return s;
|
||||
if (Name.StartsWith(TEST_SPECIFIC_DOUT))
|
||||
{
|
||||
return $"(Digital Output Setting){Name}";
|
||||
}
|
||||
return Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
_channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value = value;
|
||||
OnPropertyChanged("NameOfTheChannel");
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
var tokens = Channel.Text_L1.Split(new[] { SEPARATOR }, StringSplitOptions.None);
|
||||
return tokens.Last();
|
||||
}
|
||||
}
|
||||
public TestObjectTemplate Template { get; private set; }
|
||||
private readonly List<string> _channelPropertyNames = new List<string>();
|
||||
private Dictionary<string, ChannelProperty> _channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
public MMEPossibleChannels Channel { get; private set; }
|
||||
public bool LocalOnly { get; set; }
|
||||
|
||||
public string ISOCode => null != Channel ? IsoCodeStatics.GetString(Channel, false) : "????????????????";
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
public bool Filter(string term)
|
||||
{
|
||||
if (Name.ToLower().Contains(term.ToLower()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (NameOfTheChannel.ToLower().Contains(term.ToLower()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected object GetProperty(string name, object defaultValue)
|
||||
{
|
||||
if (!_channelProperties.ContainsKey(name)) { _channelProperties[name] = new ChannelProperty(name, defaultValue); }
|
||||
return _channelProperties[name].Value;
|
||||
}
|
||||
protected void SetProperty(string name, object value)
|
||||
{
|
||||
if (!_channelProperties.ContainsKey(name)) { _channelProperties[name] = new ChannelProperty(name, value); }
|
||||
else { _channelProperties[name].Value = value; }
|
||||
OnPropertyChanged("name"); // ? variable name instead of "name"
|
||||
}
|
||||
public void SetChannel(MMEPossibleChannels channel)
|
||||
{
|
||||
Channel = channel;
|
||||
}
|
||||
public void SetDisplayText(string objectSerial, string channelNumber, string text)
|
||||
{
|
||||
var name = text;
|
||||
|
||||
// In either case we will eventually split this display text to parse out "text", so dont allow separator
|
||||
System.Diagnostics.Trace.Assert(!(name.Contains(SEPARATOR) || objectSerial.Contains(SEPARATOR) || channelNumber.Contains(SEPARATOR)), "SetDisplayText fed invalid characters");
|
||||
|
||||
if (string.IsNullOrEmpty(objectSerial) && string.IsNullOrEmpty(channelNumber))
|
||||
{
|
||||
// custom ISO channel name creation. no need for special sparator
|
||||
Channel.SetText1($"{name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (name?.Length > Constants.MAX_USER_CHANNEL_NAME_LENGTH)
|
||||
{
|
||||
name = name.Substring(0, Constants.MAX_USER_CHANNEL_NAME_LENGTH);
|
||||
}
|
||||
// Non ISO custom channel name creation
|
||||
Channel.SetText1(string.Format("{0}{1}{2}{1}{3}", objectSerial, SEPARATOR, channelNumber, name));
|
||||
}
|
||||
}
|
||||
public void SetID(long id)
|
||||
{
|
||||
Channel = new MMEPossibleChannels(Channel);
|
||||
Channel.SetId(id);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return null != Channel ? $"{Name}({Channel.Id})" : Name;
|
||||
}
|
||||
private void AddStandardProperties()
|
||||
{
|
||||
if (null != _channelProperties) { _channelProperties.Clear(); _channelProperties = null; }
|
||||
_channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
var scp = Enum.GetValues(typeof(StandardChannelProperties)).Cast<StandardChannelProperties>().ToArray();
|
||||
foreach (var p in scp)
|
||||
{
|
||||
ChannelProperty cp;
|
||||
switch (p)
|
||||
{
|
||||
case StandardChannelProperties.DisplayOrder: cp = new ChannelProperty(p.ToString(), "-1"); break;
|
||||
case StandardChannelProperties.NameOfTheChannel: cp = new ChannelProperty("Name of the channel", "NOVALUE"); break;
|
||||
default: cp = new ChannelProperty(p.ToString(), "NOVALUE"); break;
|
||||
}
|
||||
_channelProperties.Add(p.ToString(), cp);
|
||||
}
|
||||
}
|
||||
public void SetTemplate(TestObjectTemplate template) { Template = template; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Required
|
||||
private bool _bRequired;
|
||||
|
||||
/// <summary>
|
||||
/// Required channel property raises the OnRequiredChanged event
|
||||
/// </summary>
|
||||
public bool Required
|
||||
{
|
||||
get => _bRequired;
|
||||
set
|
||||
{
|
||||
_bRequired = value;
|
||||
OnRequiredChanged(new RequiredChangedEventArgs { NewValue = value });
|
||||
SetProperty(ref _bRequired, value, "Required");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Event and event handler provide "client" side functionality
|
||||
/// to add required channels to the list
|
||||
/// See also RequiredChangedEventArgs class
|
||||
/// </summary>
|
||||
public event EventHandler<RequiredChangedEventArgs> RequiredChanged;
|
||||
public virtual void OnRequiredChanged(RequiredChangedEventArgs e)
|
||||
{
|
||||
RequiredChanged?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public int CompareTo(TestObjectTemplateChannel other)
|
||||
{
|
||||
if (null == other)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (Equals(other))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var displayOrder = DisplayOrder.CompareTo(other.DisplayOrder);
|
||||
|
||||
if (0 == displayOrder)
|
||||
{
|
||||
var channelId = Channel.Id.CompareTo(other.Channel.Id);
|
||||
return 0 == channelId ? string.Compare(Name, other.Name, StringComparison.Ordinal) : channelId;
|
||||
}
|
||||
return displayOrder;
|
||||
}
|
||||
#endregion Required
|
||||
|
||||
#region constructors and initializers
|
||||
public TestObjectTemplateChannel(DataRow dr, TestObjectTemplate template, ref ISO13499FileDb db)
|
||||
{
|
||||
Template = template;
|
||||
AddStandardProperties();
|
||||
TemplateChannelId = Convert.ToInt32(dr["TemplateChannelId"]);
|
||||
|
||||
_channelProperties[StandardChannelProperties.NameOfTheChannel.ToString()].Value = (string)dr["NameOfTheChannel"];
|
||||
|
||||
_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = -1;
|
||||
if (!DBNull.Value.Equals(dr["DisplayOrder"]))
|
||||
{
|
||||
_channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = Convert
|
||||
.ToInt32(dr["DisplayOrder"]).ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayOrder = -1;
|
||||
}
|
||||
_bRequired = Convert.ToBoolean(dr["Required"]);
|
||||
LocalOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
var channelId = Convert.ToInt64(dr["MMEChannelId"]);
|
||||
var channelType = Convert.ToInt32(dr["MMEChannelType"]);
|
||||
Channel = db.GetPossibleChannel(channelId, channelType);
|
||||
}
|
||||
public TestObjectTemplateChannel(TestObjectTemplateChannel copy, TestObjectTemplate template)
|
||||
{
|
||||
TemplateChannelId = copy.TemplateChannelId;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
_bRequired = copy.Required;
|
||||
Channel = new MMEPossibleChannels(copy.Channel);
|
||||
_channelProperties = new Dictionary<string, ChannelProperty>();
|
||||
using (var e = copy._channelProperties.GetEnumerator())
|
||||
{
|
||||
while (e.MoveNext())
|
||||
{
|
||||
_channelProperties[e.Current.Key] = new ChannelProperty(e.Current.Value);
|
||||
}
|
||||
}
|
||||
_channelPropertyNames = new List<string>(copy._channelPropertyNames.ToArray());
|
||||
Template = template;
|
||||
}
|
||||
public TestObjectTemplateChannel(MMEPossibleChannels channel)
|
||||
{
|
||||
Channel = channel;
|
||||
AddStandardProperties();
|
||||
DisplayOrder = -1;
|
||||
var scp = Enum.GetValues(typeof(StandardChannelProperties)).Cast<StandardChannelProperties>().ToArray();
|
||||
foreach (var p in scp)
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
//case StandardChannelProperties.DisplayOrder: _channelProperties[StandardChannelProperties.DisplayOrder.ToString()].Value = Convert.ToInt32(Channel.Id).ToString(System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case StandardChannelProperties.NameOfTheChannel: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Unused Properties/meta data
|
||||
public string LaboratoryCode
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string CustomerChannelCode
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string ChannelCode
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string Comments1
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string Location
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string Dimension
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string Direction
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string ChannelFrequencyClass
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string Unit
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string ReferenceSystem
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TestObjectNumber
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TransducerType
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TransducerId
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string PreFilterType
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string CutOffFrequency
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string ChannelAmplitudeClass
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public ReferenceChannelTypes ReferenceChannel
|
||||
{
|
||||
get => ReferenceChannelTypes.NOVALUE;
|
||||
set { }
|
||||
}
|
||||
public string ReferenceChannelName
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public DataSourceTypes DataSource
|
||||
{
|
||||
get => DataSourceTypes.Parameter;
|
||||
set { }
|
||||
}
|
||||
public DataStatusTypes DataStatus
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE;
|
||||
set { }
|
||||
}
|
||||
public string SamplingInterval
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string BitResolution
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TimeOfFirstSample
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string NumberOfSamples
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string OffsetPostTest
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TransducerNaturalFrequency
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TransducerDampingRatio
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string Comments2
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string FirstGlobalMaximumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TimeOfMaximumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string FirstGlobalMinimumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string TimeOfMinimumValue
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string StartOffsetInterval
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
public string EndOffsetInterval
|
||||
{
|
||||
get => DataStatusTypes.NOVALUE.ToString();
|
||||
set { }
|
||||
}
|
||||
#endregion
|
||||
|
||||
//TODO: move to separate class
|
||||
public class ChannelProperty : ISerializable
|
||||
{
|
||||
public string Name { get; }
|
||||
public object Value { get; set; } = "NOVALUE";
|
||||
|
||||
public ChannelProperty(ChannelProperty copy)
|
||||
{
|
||||
Name = copy.Name;
|
||||
Value = copy.Value;
|
||||
}
|
||||
public ChannelProperty(string name, object value)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("PropertyName", Name);
|
||||
info.AddValue("PropertyValue", Value, Value.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
public class RequiredChangedEventArgs : EventArgs
|
||||
{
|
||||
public bool NewValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,645 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text;
|
||||
using DTS.Common.DAS.Concepts;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using ISO.Strings;
|
||||
using DTS.Common.Classes.Hardware;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable CheckNamespace
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
// ReSharper disable ConvertToAutoProperty
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class Hardware : DASDBRecord, INotifyPropertyChanged, IISOHardware
|
||||
{
|
||||
|
||||
public enum ChannelType
|
||||
{
|
||||
Analog,
|
||||
IEPE,
|
||||
Squib,
|
||||
DigitalOutput,
|
||||
RTC,
|
||||
UART,
|
||||
StreamOutput,
|
||||
StreamInput,
|
||||
Thermocoupler,
|
||||
CAN
|
||||
}
|
||||
#region Properties
|
||||
|
||||
public bool IsInvalidDate(DateTime input)
|
||||
{
|
||||
return input.Date.Equals(DASDBRecord.INVALID_DATE.Date);
|
||||
}
|
||||
|
||||
private int _calInterval = 365;
|
||||
|
||||
public int CalInterval
|
||||
{
|
||||
get => _calInterval;
|
||||
set => _calInterval = value;
|
||||
}
|
||||
|
||||
public void GetChannelsString(out int analog, out int digitalIn, out int digitalOut, out int squib, out int uart, out int streamOut, out int streamIn, out int can)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
analog = 0;
|
||||
digitalIn = 0;
|
||||
digitalOut = 0;
|
||||
squib = 0;
|
||||
uart = 0;
|
||||
streamOut = 0;
|
||||
streamIn = 0;
|
||||
can = 0;
|
||||
//was returning "1" for ethernet controllers which don't have a channel ...
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
return;
|
||||
}
|
||||
if (null != ISOChannels && ISOChannels.Any())
|
||||
{
|
||||
foreach (var ch in ISOChannels)
|
||||
{
|
||||
if (ch.IsSupported(SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
squib++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
digitalIn++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.TOMDigital))
|
||||
{
|
||||
digitalOut++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.UART))
|
||||
{
|
||||
uart++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.StreamOut))
|
||||
{
|
||||
streamOut++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.StreamIn))
|
||||
{
|
||||
streamIn++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.CAN))
|
||||
{
|
||||
can++;
|
||||
}
|
||||
else analog++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public string IPAddress
|
||||
{
|
||||
get => Connection;
|
||||
set
|
||||
{
|
||||
Connection = value;
|
||||
OnPropertyChanged("IPAddress");
|
||||
}
|
||||
}
|
||||
#endregion Properties
|
||||
|
||||
public Hardware()
|
||||
{
|
||||
|
||||
}
|
||||
public Hardware(Hardware copy)
|
||||
{
|
||||
DASId = copy.DASId;
|
||||
Version = copy.Version;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
ProtocolVersion = copy.ProtocolVersion;
|
||||
Position = copy.Position;
|
||||
MinSampleRate = copy.MinSampleRate;
|
||||
MaxSampleRate = copy.MaxSampleRate;
|
||||
MaxAAFRate = copy.MaxAAFRate;
|
||||
MaxModules = copy.MaxModules;
|
||||
MaxMemory = copy.MaxMemory;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
LastUsedBy = copy.LastUsedBy;
|
||||
LastUsed = copy.LastUsed;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LastModified = copy.LastModified;
|
||||
IsReconfigurable = copy.IsReconfigurable;
|
||||
IsProgrammable = copy.IsProgrammable;
|
||||
ISOChannels = copy.ISOChannels.Select(c => new HardwareChannel(c, this)).ToArray();
|
||||
IPAddress = copy.IPAddress;
|
||||
FirmwareVersion = copy.FirmwareVersion;
|
||||
DASType = copy.DASType;
|
||||
var channeltypes = new int[copy?.ChannelTypes.Length??0];
|
||||
Array.Copy(copy.ChannelTypes, channeltypes, copy.ChannelTypes.Length);
|
||||
ChannelTypes = channeltypes;
|
||||
Channels = copy.Channels;
|
||||
CalInterval = copy.CalInterval;
|
||||
CalDate = copy.CalDate;
|
||||
IsModule = copy.IsModule;
|
||||
ParentDAS = copy.ParentDAS;
|
||||
PositionOnChain = copy.PositionOnChain;
|
||||
PositionOnDistributor = copy.PositionOnDistributor;
|
||||
Port = copy.Port;
|
||||
IsFirstUseValid = copy.IsFirstUseValid;
|
||||
FirstUseDate = copy.FirstUseDate;
|
||||
StandIn = copy.StandIn;
|
||||
TestId = copy.TestId;
|
||||
GroupId = copy.GroupId;
|
||||
}
|
||||
public HardwareTypes DASTypeEnum
|
||||
{
|
||||
get => (HardwareTypes)DASType;
|
||||
set
|
||||
{
|
||||
DASType = (int)value;
|
||||
OnPropertyChanged("DASTypeEnum");
|
||||
}
|
||||
}
|
||||
public bool IsPseudoRackModule()
|
||||
{
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public bool IsTSRAIR()
|
||||
{
|
||||
return IsTSRAIR(DASTypeEnum);
|
||||
}
|
||||
|
||||
public static bool IsTSRAIR(HardwareTypes dasType)
|
||||
{
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
case HardwareTypes.DKR:
|
||||
case HardwareTypes.DIR:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public bool IsTSRAIRModule()
|
||||
{
|
||||
return IsTSRAIRModule(DASTypeEnum);
|
||||
}
|
||||
public static bool IsTSRAIRModule(HardwareTypes dasType)
|
||||
{
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.EMB_ANG_ACC:
|
||||
case HardwareTypes.EMB_ANG_ARS:
|
||||
case HardwareTypes.EMB_ATM:
|
||||
case HardwareTypes.EMB_LIN_ACC_HI:
|
||||
case HardwareTypes.EMB_LIN_ACC_LO:
|
||||
case HardwareTypes.EMB_MAG:
|
||||
case HardwareTypes.EMB_MAG_SWITCH:
|
||||
case HardwareTypes.EMB_MIC:
|
||||
case HardwareTypes.EMB_OPT:
|
||||
case HardwareTypes.EMB_RTC_S_MARK:
|
||||
case HardwareTypes.EMB_RTC_NS_PAD:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public Hardware(IDASDBRecord copy) : base(copy)
|
||||
{
|
||||
}
|
||||
public Hardware(IDataReader reader) : base(reader)
|
||||
{
|
||||
}
|
||||
|
||||
public static List<HardwareChannel> GetDASISOChannels(string hardwareId, Hardware das)
|
||||
{
|
||||
var channelList = new List<HardwareChannel>();
|
||||
|
||||
var hResult = DbOperations.DASChannelsGet(hardwareId, out var dbChannels);
|
||||
|
||||
if (0 == hResult && null != dbChannels && dbChannels.Any())
|
||||
{
|
||||
foreach (var dbChannel in dbChannels)
|
||||
{
|
||||
channelList.Add(new HardwareChannel(dbChannel, das));
|
||||
}
|
||||
}
|
||||
channelList.Sort(HardwareChannel.PhysicalCompare);
|
||||
return channelList;
|
||||
}
|
||||
private static void GetAllDASISOChannels(Dictionary<string, Hardware> serialNumberToHardware)
|
||||
{
|
||||
var channelsByDASKey = new Dictionary<string, List<HardwareChannel>>();
|
||||
|
||||
var hResult = DbOperations.DASChannelsGet(null, out var dbChannels);
|
||||
|
||||
foreach (var dbChannel in dbChannels)
|
||||
{
|
||||
if (!serialNumberToHardware.ContainsKey(dbChannel.HardwareId)) { continue; }
|
||||
var hardware = serialNumberToHardware[dbChannel.HardwareId];
|
||||
var hc = new HardwareChannel(dbChannel, hardware);
|
||||
if (!channelsByDASKey.ContainsKey(dbChannel.HardwareId))
|
||||
{
|
||||
channelsByDASKey[dbChannel.HardwareId] = new List<HardwareChannel>();
|
||||
}
|
||||
channelsByDASKey[dbChannel.HardwareId].Add(hc);
|
||||
}
|
||||
using (var enumHardware = serialNumberToHardware.GetEnumerator())
|
||||
{
|
||||
while (enumHardware.MoveNext())
|
||||
{
|
||||
var hardware = enumHardware.Current.Value;
|
||||
if (!channelsByDASKey.ContainsKey(enumHardware.Current.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var list = channelsByDASKey[enumHardware.Current.Key];
|
||||
list.Sort(HardwareChannel.PhysicalCompare);
|
||||
hardware.ISOChannels = list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<HardwareChannel> _isoChannels = new List<HardwareChannel>();
|
||||
public HardwareChannel[] ISOChannels
|
||||
{
|
||||
get => _isoChannels.ToArray();
|
||||
set => SetProperty(ref _isoChannels, new List<HardwareChannel>(value), "ISOChannels");
|
||||
}
|
||||
|
||||
public static Hardware[] GetAllDAS()
|
||||
{
|
||||
return GetAllDAS(null, null);
|
||||
}
|
||||
public static Hardware[] GetSingleDAS(string serialNumber, string position)
|
||||
{
|
||||
var list = new List<Hardware>();
|
||||
try
|
||||
{
|
||||
var hResult = DbOperations.DASGet(serialNumber, position, out var dbDAS);
|
||||
if (0 == hResult)
|
||||
{
|
||||
foreach (var curDas in dbDAS)
|
||||
{
|
||||
list.Add(new Hardware(curDas));
|
||||
}
|
||||
}
|
||||
foreach (var das in list)
|
||||
{
|
||||
var channels = GetDASISOChannels(das.SerialNumber, das);
|
||||
channels.Sort(HardwareChannel.PhysicalCompare);
|
||||
das.ISOChannels = channels.ToArray();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("failed to retrieve all das, ", ex); }
|
||||
list.Sort(new HardwareCompare());
|
||||
return list.ToArray();
|
||||
}
|
||||
public static Hardware[] GetAllDAS(string serialNumber, string position)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(serialNumber))
|
||||
{
|
||||
return GetSingleDAS(serialNumber, position);
|
||||
}
|
||||
var list = new List<Hardware>();
|
||||
try
|
||||
{
|
||||
var hResult = DbOperations.DASGet(serialNumber, position, out var dbDAS);
|
||||
if (0 == hResult && null != dbDAS)
|
||||
{
|
||||
foreach (var curDas in dbDAS)
|
||||
{
|
||||
list.Add(new Hardware(curDas));
|
||||
}
|
||||
}
|
||||
var serialNumberToDAS = new Dictionary<string, Hardware>();
|
||||
foreach (var das in list)
|
||||
{
|
||||
serialNumberToDAS[$"{das.SerialNumber}_{das.DASType}"] = das;
|
||||
}
|
||||
GetAllDASISOChannels(serialNumberToDAS);
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("failed to retrieve all das, ", ex); }
|
||||
list.Sort(new HardwareCompare());
|
||||
return list.ToArray();
|
||||
}
|
||||
public class HardwareCompare : Comparer<Hardware>
|
||||
{
|
||||
public override int Compare(Hardware x, Hardware y)
|
||||
{
|
||||
var ret = string.Compare(x.SerialNumber, y.SerialNumber, StringComparison.Ordinal);
|
||||
if (0 == ret) { ret = string.Compare(x.IPAddress, y.IPAddress, StringComparison.Ordinal); }
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
var embedded = HardwareConstants.HasEmbeddedSensors(DASTypeEnum);
|
||||
_ = DbOperations.DASDelete(DASId, null, embedded);
|
||||
}
|
||||
private void DeleteChannels()
|
||||
{
|
||||
_ = DbOperations.DASChannelsDelete(GetId());
|
||||
}
|
||||
|
||||
public void Insert()
|
||||
{
|
||||
var result = DbOperations.DASInsert(this);
|
||||
//ErrorCodes.ERROR_SUCCESS = 0
|
||||
//We only want to insert the DAS Channels if the DAS was inserted successfully.
|
||||
//It could be unsuccessful, for example, if an older database is in use.
|
||||
if (result == 0)
|
||||
{
|
||||
InsertChannels();
|
||||
}
|
||||
}
|
||||
private void InsertChannels()
|
||||
{
|
||||
foreach (var channel in ISOChannels)
|
||||
{
|
||||
channel.Insert();
|
||||
}
|
||||
}
|
||||
public bool IsDummyObject => SerialNumber.Contains("Dummy");
|
||||
|
||||
public void Update()
|
||||
{
|
||||
DbOperations.DASUpdate(this);
|
||||
|
||||
DeleteChannels();
|
||||
InsertChannels();
|
||||
}
|
||||
|
||||
public string GetId()
|
||||
{
|
||||
return GetId(SerialNumber, DASType.ToString(), IPAddress);
|
||||
}
|
||||
public string GetIdOld()
|
||||
{
|
||||
return $"{SerialNumber}_{DASType}_{IPAddress}";
|
||||
}
|
||||
public static string GetId(string sn, string dastype, string ip)
|
||||
{
|
||||
return $"{sn}_{dastype}";
|
||||
}
|
||||
public void SetChannel(HardwareChannel channel)
|
||||
{
|
||||
for (var i = 0; i < _isoChannels.Count; i++)
|
||||
{
|
||||
if (ISOChannels[i].ChannelIdx != channel.ChannelIdx) continue;
|
||||
_isoChannels[i] = channel; return;
|
||||
}
|
||||
_isoChannels.Add(channel);
|
||||
}
|
||||
|
||||
private const string TDAS_RACK_PREPEND = "DR";
|
||||
private const string TDAS_LABRACK_PREPEND = "LR";
|
||||
private const string SLICE6_PREPEND = "SL6";
|
||||
private const string SLICE6AIR_PREPEND = "S6A";
|
||||
private const string SLICE6AIRBR_PREPEND = "S6BR";
|
||||
private const string SLICE6AIRBR_PREPEND2 = "S6ABR";
|
||||
private const string SLICE2SIM_PREPEND = "SPS";
|
||||
private const string SLICE2LABSIM_PREPEND = "SLS";
|
||||
private const string SLICE2TOM_PREPEND = "SPT";
|
||||
private const string SLICE2LABTOM_PREPEND = "SLT";
|
||||
private const string SLICE2DIM_PREPEND = "SPD";
|
||||
private const string SLICE2LABDIM_PREPEND = "SLD";
|
||||
private const string SLICENANO_PREPEND = "BA5";
|
||||
private const string SLICEMICRO_PREPEND = "BA0";
|
||||
private const string SLICE15NANO_PREPEND = "BA5";
|
||||
private const string SLICE15MICRO_PREPEND = "BA0";
|
||||
private const string SLICELABETHERNET_PREPEND = "SLE";
|
||||
private const string SLICE_PRO_DB_PREPEND = "SPDB";
|
||||
private const string SLICE6DB_PREPEND = "S6DB";
|
||||
private const string SLICE6DB3_PREPEND = "S6DB3";
|
||||
private const string SLICEG5_PREPEND = "SG5";
|
||||
private const string G5_PREPEND = "5M";
|
||||
private const string SLICEPROETHERNET_PREPEND = "SPE";
|
||||
private const string SLICEDB_PREPEND = "SD";
|
||||
private const string POWERPRO_PREPEND = "PPR";
|
||||
private const string SLICEMINIDB_PREPEND = "SPM";
|
||||
private const string DIR_PREPEND = "DI";
|
||||
private const string DKR_PREPEND = "DK";
|
||||
private const string SLICETC_PREPEND = "STC";
|
||||
private const string SLICE_PRO_CAN_FD_PREPEND = "SPFD";
|
||||
|
||||
private void ValidateSN(ref List<string> errors, ref bool bValid, string prepend, string error, string alternativePrepend = null)
|
||||
{
|
||||
if (SerialNumber.Contains(DFConstantsAndEnums.SERIAL_SEPARATOR) && !StandIn)
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add($"{Strings.Strings.InvalidCharacterInSerialNumber} '{DFConstantsAndEnums.SERIAL_SEPARATOR}'");
|
||||
}
|
||||
if (SerialNumber.Contains(DFConstantsAndEnums.CHANNEL_SEPARATOR) && !StandIn)
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add($"{Strings.Strings.InvalidCharacterInSerialNumber} '{DFConstantsAndEnums.CHANNEL_SEPARATOR}'");
|
||||
}
|
||||
if (!SerialNumber.StartsWith(prepend)
|
||||
&& (string.IsNullOrEmpty(alternativePrepend) || !SerialNumber.StartsWith(alternativePrepend)))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add(error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateNotSN(ref List<string> errors, ref bool bValid, string prepend, string error)
|
||||
{
|
||||
if (SerialNumber.StartsWith(prepend))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add($"{error} ({DASTypeEnum.ToString()})");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateIPAddress(ref List<string> errors)
|
||||
{
|
||||
var bValid = true;
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
case HardwareTypes.SLICE6DB:
|
||||
case HardwareTypes.SLICE6DB3:
|
||||
case HardwareTypes.SLICE_Pro_Distributor:
|
||||
//case HardwareTypes.SLICE6DB_AIR:
|
||||
case HardwareTypes.SLICE6DB_InDummy:
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
case HardwareTypes.G5VDS:
|
||||
//case ISODll.Hardware.HardwareTypes.G5IPORT:
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(IPAddress))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add(StringResources.AutoDetectDAS_IPAddressRequired);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return bValid;
|
||||
}
|
||||
public bool ValidateSerialNumber(ref List<string> errors)
|
||||
{
|
||||
var bValid = true;
|
||||
if (string.IsNullOrWhiteSpace(SerialNumber))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add(StringResources.AutoDetectDAS_SerialNumberRequired);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
ValidateSN(ref errors, ref bValid, TDAS_RACK_PREPEND, StringResources.AutoDetectDas_TDASRackShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
ValidateSN(ref errors, ref bValid, TDAS_LABRACK_PREPEND, StringResources.AutoDetectDAS_TDASLabRackShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6_PREPEND, StringResources.AutoDetectDas_SLICE6ShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6AIR_PREPEND, StringResources.AutoDetectDas_SLICE6AIRShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6AIRBR_PREPEND, StringResources.AutoDetectDas_SLICE6AIRBRShouldStartWith, SLICE6AIRBR_PREPEND2);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2SIM_PREPEND, StringResources.AutoDetectDas_SIMShouldStartWithSPS);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2LABSIM_PREPEND, StringResources.AutoDetectDAS_SLSShouldStartWithSLS);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2TOM_PREPEND, StringResources.AutoDetectDas_TOMShouldStartWithSPT);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2LABTOM_PREPEND, StringResources.AutoDetectDAS_SLTShouldStartWithSLT);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2DIM_PREPEND, StringResources.AutoDetectDas_DIMShouldStartWithSPD);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2LABDIM_PREPEND, StringResources.AutoDetectDAS_SLDShouldStartWithSLD);
|
||||
break;
|
||||
case HardwareTypes.SLICE_NANO_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICENANO_PREPEND, StringResources.AutoDetectDas_SLICENanoShouldStartWithBA5);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Micro_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICEMICRO_PREPEND, StringResources.AutoDetectDas_MicroSerialNumberShouldStartWithBA0);
|
||||
break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICE15NANO_PREPEND, StringResources.AutoDetectDAS_NANOBasePlusShouldStartWithBA5);
|
||||
break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICE15MICRO_PREPEND, StringResources.AutoDetectDAS_MICROBasePlusShouldStartWithBA0);
|
||||
break;
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
ValidateSN(ref errors, ref bValid, SLICELABETHERNET_PREPEND, StringResources.AutoDetectDAS_SliceLabEthernetShouldStartWithSLE);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor:
|
||||
ValidateSN(ref errors, ref bValid, SLICE_PRO_DB_PREPEND, StringResources.AutoDetectDAS_SLICEPRODBShouldStartWithSPDB);
|
||||
break;
|
||||
case HardwareTypes.SLICE6DB3:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6DB3_PREPEND, StringResources.AutoDetectDas_SLICE6DB3ShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6DB:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6DB_PREPEND, StringResources.AutoDetectDas_Slice6DBShouldStartWithS6DB);
|
||||
break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
ValidateSN(ref errors, ref bValid, SLICEG5_PREPEND, StringResources.AutoDetectDas_SliceG5ShouldStartWithSG5);
|
||||
break;
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
case HardwareTypes.G5VDS:
|
||||
ValidateSN(ref errors, ref bValid, G5_PREPEND, StringResources.AutoDetectDas_G5ShouldStartWith5M);
|
||||
break;
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
ValidateSN(ref errors, ref bValid, SLICEPROETHERNET_PREPEND, StringResources.AutoDetectDas_SliceECM);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
ValidateSN(ref errors, ref bValid, SLICEMINIDB_PREPEND, StringResources.AutoDetectDas_SliceSPM);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
ValidateSN(ref errors, ref bValid, SLICEDB_PREPEND, StringResources.AutoDetectDas_SliceDBShouldStartWithSDB);
|
||||
break;
|
||||
case HardwareTypes.PowerPro:
|
||||
ValidateSN(ref errors, ref bValid, POWERPRO_PREPEND, StringResources.AutoDetectDas_PowerProShouldStartWithPPRO);
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
ValidateSN(ref errors, ref bValid, HardwareConstants.TSR_AIR_PREPEND, StringResources.AutoDetectDas_TSRAIRShouldStartWithTA);
|
||||
break;
|
||||
case HardwareTypes.DKR:
|
||||
ValidateSN(ref errors, ref bValid, DKR_PREPEND, StringResources.AutoDetectDas_DKRShouldStartWithDK);
|
||||
break;
|
||||
case HardwareTypes.DIR:
|
||||
ValidateSN(ref errors, ref bValid, DIR_PREPEND, StringResources.AutoDetectDas_DIRShouldStartWithDI);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
ValidateSN(ref errors, ref bValid, SLICETC_PREPEND, string.Format(StringResources.AutoDetectDas_TypeShouldStartWithPrepend, Strings.Strings.SLICE_TC_Description, SLICETC_PREPEND));
|
||||
break;
|
||||
case HardwareTypes.SLICE_PRO_CAN_FD:
|
||||
ValidateSN(ref errors, ref bValid, SLICE_PRO_CAN_FD_PREPEND, string.Format(StringResources.AutoDetectDas_TypeShouldStartWithPrepend, Strings.Strings.SLICE_PRO_CAN_FD_Description, SLICE_PRO_CAN_FD_PREPEND));
|
||||
break;
|
||||
default:
|
||||
|
||||
ValidateNotSN(ref errors, ref bValid, G5_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToAG5);
|
||||
ValidateNotSN(ref errors, ref bValid, TDAS_RACK_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToATDASRack);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICENANO_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToANano);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICEMICRO_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToAMicro);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2SIM_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToASLICEProSim);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2LABSIM_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToASLICEPROLabSIM);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICEG5_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToASLICEG5);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICELABETHERNET_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToASlicePROLabSLE);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2DIM_PREPEND, StringResources.AutoDetectDas_SLICE_SerialNumberBelongsToASLICEProDIM);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2LABTOM_PREPEND, StringResources.AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABTOM);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2LABDIM_PREPEND, StringResources.AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABDIM);
|
||||
ValidateNotSN(ref errors, ref bValid, TDAS_LABRACK_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToATDASLabRack);
|
||||
ValidateNotSN(ref errors, ref bValid, POWERPRO_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToAPowerPRO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bValid;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,189 @@
|
||||
/* Copyright 2017 Diversified Technical Systems
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Classes.TestSetups;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// this class will probably become an abstract base class in the future but for now since we only have
|
||||
/// summed realtime channels, we can be a little less formal
|
||||
/// </summary>
|
||||
public class CalculatedValueClass : CalculatedChannelRecord
|
||||
{
|
||||
public CalculatedValueClass() { }
|
||||
public CalculatedValueClass(CalculatedValueClass copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
Operation = copy.Operation;
|
||||
TestSetupName = copy.TestSetupName;
|
||||
Name = copy.Name;
|
||||
foreach (var a in copy.Attributes)
|
||||
{
|
||||
_attributes.Add(a.Copy());
|
||||
}
|
||||
CalculatedValueCode = copy.CalculatedValueCode;
|
||||
CFCForInputChannels = copy.CFCForInputChannels;
|
||||
ChannelFilterClassForOutput = copy.ChannelFilterClassForOutput;
|
||||
var ids = new List<string>(copy.InputChannelIds);
|
||||
_inputChannelIds = ids.ToArray();
|
||||
}
|
||||
public CalculatedValueClass(ICalculatedChannelRecord record)
|
||||
: base(record)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if the calculation channel supports realtime
|
||||
/// </summary>
|
||||
public bool SupportsRealtime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!ViewInRealtime) { return false; }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool IsValid(Dictionary<string, bool> channelIdLookup)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name)) { return false; }
|
||||
if (InputChannelIds.Length < 1) { return false; }
|
||||
foreach (var id in _inputChannelIds) { if (!channelIdLookup.ContainsKey(id)) { return false; } }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public new Operations Operation
|
||||
{
|
||||
get => base.Operation;
|
||||
set
|
||||
{
|
||||
base.Operation = value;
|
||||
OnPropertyChanged("ViewInRealtime");
|
||||
OnPropertyChanged("CanChangeViewInRealtime");
|
||||
}
|
||||
}
|
||||
|
||||
public new bool ViewInRealtime
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Operation)
|
||||
{
|
||||
case Operations.IRTRACC3D:
|
||||
case Operations.IRTRACC3D_ABDOMEN:
|
||||
case Operations.IRTRACC3D_LOWERTHORAX:
|
||||
case Operations.HIC:
|
||||
return false;
|
||||
}
|
||||
return base.ViewInRealtime;
|
||||
}
|
||||
set => base.ViewInRealtime = value;
|
||||
}
|
||||
|
||||
public bool CanChangeViewInRealtime
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Operation)
|
||||
{
|
||||
case Operations.IRTRACC3D:
|
||||
case Operations.IRTRACC3D_ABDOMEN:
|
||||
case Operations.IRTRACC3D_LOWERTHORAX:
|
||||
case Operations.HIC:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public new string[] InputChannelIds
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_channels.Any())
|
||||
{
|
||||
var ids = new List<string>();
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
if (null == ch)
|
||||
{
|
||||
ids.Add("-1");
|
||||
}
|
||||
else
|
||||
{
|
||||
ids.Add(ch.Id.ToString());
|
||||
}
|
||||
}
|
||||
_inputChannelIds = ids.ToArray();
|
||||
}
|
||||
|
||||
return base.InputChannelIds;
|
||||
}
|
||||
set => base.InputChannelIds = value;
|
||||
}
|
||||
|
||||
private List<IGroupChannel> _channels = new List<IGroupChannel>();
|
||||
|
||||
public List<TestObjectChannel> TestObjectChannels { get; set; } = new List<TestObjectChannel>();
|
||||
|
||||
public void SetChannels(IGroupChannel[] groupChannels)
|
||||
{
|
||||
_channels = new List<IGroupChannel>(groupChannels);
|
||||
}
|
||||
|
||||
public void SetTestObjectChannels(TestObjectChannel[] testObjectChannels)
|
||||
{
|
||||
TestObjectChannels = new List<TestObjectChannel>(testObjectChannels);
|
||||
}
|
||||
public byte[] InputChannelIdsBlob
|
||||
{
|
||||
get
|
||||
{
|
||||
var text = string.Join(CultureInfo.InvariantCulture.TextInfo.ListSeparator, InputChannelIds);
|
||||
return Encoding.UTF8.GetBytes(text);
|
||||
}
|
||||
set
|
||||
{
|
||||
var text = Encoding.UTF8.GetString(value);
|
||||
var ids = new List<string>(text.Split(
|
||||
new[] { CultureInfo.InvariantCulture.TextInfo.ListSeparator },
|
||||
StringSplitOptions.None));
|
||||
_inputChannelIds = ids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<CCAttributeBase> _attributes = new List<CCAttributeBase>();
|
||||
public CCAttributeBase[] Attributes
|
||||
{
|
||||
get => _attributes.ToArray();
|
||||
set { _attributes.Clear(); _attributes.AddRange(value); }
|
||||
}
|
||||
public void ReplaceInputChannelIdAtIndex(int index, string newId)
|
||||
{
|
||||
_inputChannelIds[index] = newId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the design here is so that we can attach attributes to calculated channels that need them (HIC, Head Contact Duration), but let them be a bit variable and dynamic
|
||||
/// </summary>
|
||||
public abstract class CCAttributeBase
|
||||
{
|
||||
protected int _attributeId;
|
||||
public int AttributeId => _attributeId;
|
||||
|
||||
protected object _attributeValue;
|
||||
public abstract string GetSerializedValue();
|
||||
|
||||
public abstract string GetDefaultValue();
|
||||
|
||||
public abstract string GetNameResourceId { get; }
|
||||
public abstract CCAttributeBase Copy();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a class for storing directly in and out of the db
|
||||
/// it's simplified and doesn't know about sensors and is just a wrapper for a row in the db
|
||||
/// </summary>
|
||||
public class LevelTriggerChannel
|
||||
{
|
||||
public IGroupChannel GroupChannel { get; set; } = null;
|
||||
|
||||
public string GroupChannelId { get; set; } = "-1";
|
||||
|
||||
public string HardwareChannelId { get; set; } = "";
|
||||
|
||||
public string SensorSerialNumber { get; set; } = "";
|
||||
|
||||
public bool GreaterThanEnabled { get; set; } = true;
|
||||
|
||||
public double GreaterThanThresholdEU { get; set; }
|
||||
|
||||
public bool LessThanEnabled { get; set; }
|
||||
|
||||
public bool TriggerBetweenBounds { get; set; }
|
||||
|
||||
public bool TriggerOutsideBounds { get; set; }
|
||||
|
||||
public double InsideUpperLevelEU { get; set; }
|
||||
|
||||
public double InsideLowerLevelEU { get; set; }
|
||||
|
||||
public double OutsideUpperLevelEU { get; set; }
|
||||
|
||||
public double OutsideLowerLevelEU { get; set; }
|
||||
|
||||
public double LessThanThresholdEU { get; set; }
|
||||
|
||||
public LevelTriggerChannel(LevelTriggerChannel copy)
|
||||
{
|
||||
GroupChannel = copy.GroupChannel;
|
||||
GroupChannelId = copy.GroupChannelId;
|
||||
HardwareChannelId = copy.HardwareChannelId;
|
||||
SensorSerialNumber = copy.SensorSerialNumber;
|
||||
GreaterThanEnabled = copy.GreaterThanEnabled;
|
||||
GreaterThanThresholdEU = copy.GreaterThanThresholdEU;
|
||||
LessThanEnabled = copy.LessThanEnabled;
|
||||
LessThanThresholdEU = copy.LessThanThresholdEU;
|
||||
InsideUpperLevelEU = copy.InsideUpperLevelEU;
|
||||
InsideLowerLevelEU = copy.InsideLowerLevelEU;
|
||||
OutsideUpperLevelEU = copy.OutsideUpperLevelEU;
|
||||
OutsideLowerLevelEU = copy.OutsideLowerLevelEU;
|
||||
TriggerBetweenBounds = copy.TriggerBetweenBounds;
|
||||
TriggerOutsideBounds = copy.TriggerOutsideBounds;
|
||||
}
|
||||
public LevelTriggerChannel(
|
||||
string groupChannelId,
|
||||
string hardwareChannelId,
|
||||
string sensorSerialNumber,
|
||||
bool greaterThanEnabled,
|
||||
double greaterThanEU,
|
||||
bool lessThanEnabled,
|
||||
double lessThanEU,
|
||||
double insideLowerLevelEU,
|
||||
double insideUpperLevelEU,
|
||||
double outsideLowerLevelEU,
|
||||
double outsideUpperLevelEU,
|
||||
bool triggerOutsideBounds,
|
||||
bool triggerInsideBounds)
|
||||
{
|
||||
GroupChannelId = groupChannelId;
|
||||
HardwareChannelId = hardwareChannelId;
|
||||
SensorSerialNumber = sensorSerialNumber;
|
||||
GreaterThanEnabled = greaterThanEnabled;
|
||||
GreaterThanThresholdEU = greaterThanEU;
|
||||
LessThanEnabled = lessThanEnabled;
|
||||
LessThanThresholdEU = lessThanEU;
|
||||
InsideLowerLevelEU = insideLowerLevelEU;
|
||||
InsideUpperLevelEU = insideUpperLevelEU;
|
||||
OutsideLowerLevelEU = outsideLowerLevelEU;
|
||||
OutsideUpperLevelEU = outsideUpperLevelEU;
|
||||
TriggerOutsideBounds = triggerOutsideBounds;
|
||||
TriggerBetweenBounds = triggerInsideBounds;
|
||||
}
|
||||
public LevelTriggerChannel(System.Data.DataRow dr)
|
||||
{
|
||||
try
|
||||
{
|
||||
GreaterThanEnabled = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.GreaterThanEnabled.ToString()]);
|
||||
GreaterThanThresholdEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.GreaterThanEU.ToString()]);
|
||||
HardwareChannelId = Convert.ToString(dr[DbOperations.LevelTriggers.Fields.HardwareChannelId.ToString()]);
|
||||
LessThanEnabled = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.LessThanEnabled.ToString()]);
|
||||
LessThanThresholdEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.LessThanEU.ToString()]);
|
||||
SensorSerialNumber = Convert.ToString(dr[DbOperations.LevelTriggers.Fields.SensorSerialNumber.ToString()]);
|
||||
GroupChannelId = Convert.ToInt64(dr[DbOperations.LevelTriggers.Fields.ChannelId.ToString()]).ToString();
|
||||
TriggerBetweenBounds = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.InsideEnabled.ToString()]);
|
||||
TriggerOutsideBounds = Convert.ToBoolean(dr[DbOperations.LevelTriggers.Fields.OutsideEnabled.ToString()]);
|
||||
OutsideUpperLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.OutsideUpperEU.ToString()]);
|
||||
OutsideLowerLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.OutsideLowerEU.ToString()]);
|
||||
InsideUpperLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.InsideUpperEU.ToString()]);
|
||||
InsideLowerLevelEU = Convert.ToDouble(dr[DbOperations.LevelTriggers.Fields.InsideLowerEU.ToString()]);
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log(ex); }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{GroupChannel.HardwareChannel} - {LevelTriggerText}";
|
||||
}
|
||||
|
||||
public string LevelTriggerText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (LessThanEnabled && GreaterThanEnabled)
|
||||
{
|
||||
return $"{Strings.Strings.LevelTrigger_LessThan} {LessThanThresholdEU:N2} or {Strings.Strings.LevelTrigger_GreaterThan} {GreaterThanThresholdEU:N2} ({GroupChannel.Units})";
|
||||
}
|
||||
if (LessThanEnabled)
|
||||
{
|
||||
return $"{Strings.Strings.LevelTrigger_LessThan} {LessThanThresholdEU:N2}({GroupChannel.Units})";
|
||||
}
|
||||
if (GreaterThanEnabled)
|
||||
{
|
||||
return $"{Strings.Strings.LevelTrigger_GreaterThan} {GreaterThanThresholdEU:N2}({GroupChannel.Units})";
|
||||
}
|
||||
if (TriggerBetweenBounds)
|
||||
{
|
||||
return string.Format(Strings.Strings.LevelTrigger_TriggerInside, $"{InsideLowerLevelEU:N2}", $"{InsideUpperLevelEU:N2}", GroupChannel.Units);
|
||||
}
|
||||
return TriggerOutsideBounds ? string.Format(Strings.Strings.LevelTrigger_TriggerOutside, $"{OutsideLowerLevelEU:N2}", $"{OutsideUpperLevelEU:N2}", GroupChannel.Units) : Strings.Strings.Table_NA;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public abstract class TestTypesFile
|
||||
{
|
||||
private static readonly string[] DefaultTestTypes = {
|
||||
"Bumper Test",
|
||||
"Car to Car",
|
||||
"Euro NCAP Oblique Pole Impact",
|
||||
"FMVSS 280 50K MAMA 2B",
|
||||
"Frontal",
|
||||
"Frontal Offset",
|
||||
"Frontal Perpendicular",
|
||||
"Full Width Frontal Impact 50km/h",
|
||||
"GROUP RATING 40% OFFSET",
|
||||
"Hybrid III 5th percentile female dummy",
|
||||
"Interior Head Impact",
|
||||
"Low Speed Repairability",
|
||||
"Pedestrian",
|
||||
"Pedestrian Protection",
|
||||
"Pole Side Impact",
|
||||
"Rear Impact",
|
||||
"Side",
|
||||
"Seat Test",
|
||||
"Side Impact",
|
||||
"Static Roof Crush",
|
||||
"Static Side Door Strength",
|
||||
"Steering System",
|
||||
"Whiplash",
|
||||
};
|
||||
private const string TEST_TYPES_KEY = "#test types#";
|
||||
private const string SUB_TYPES_KEY = "#test subtypes#";
|
||||
private static readonly string[] DEFAULT_SUBTYPES = {
|
||||
"NOVALUE",
|
||||
"ODB",
|
||||
"FW",
|
||||
"MDB",
|
||||
"Pole",
|
||||
"Low",
|
||||
"Medium",
|
||||
"High",
|
||||
"Headform",
|
||||
"Upper Legform",
|
||||
"Lower Legform",
|
||||
"Barrier Test",
|
||||
"Pendulum Test",
|
||||
"Centerline Europe",
|
||||
"Centerline NA",
|
||||
"Impact",
|
||||
"Oblique pole 32km/h",
|
||||
"FMVSS 280 50K MAMA 2B",
|
||||
"30 Deg. ECE 94",
|
||||
"30 Deg. FMVSS LHS",
|
||||
"30 Deg. FMVSS RHS",
|
||||
"50km/h",
|
||||
"64km/h",
|
||||
"Def. Barrier",
|
||||
"Rigid Barrier",
|
||||
"30mph Belted",
|
||||
"30mph Chassis",
|
||||
"30mph Unbelted",
|
||||
"35mph Belted",
|
||||
"35mph Belted NA",
|
||||
"ECE 12",
|
||||
"FMVSS 204",
|
||||
"50km/h",
|
||||
"FRONT",
|
||||
"REAR",
|
||||
"Hybrid III 5th percentile female dummy",
|
||||
"FMVSS 201",
|
||||
"Frontal Offset",
|
||||
"Rear Offset",
|
||||
"Headform to Hoodtop",
|
||||
"Lower Leg to Bumper",
|
||||
"Thigh to Hood Leading Edge",
|
||||
"Euro NCAP 29 Km/h",
|
||||
"35mph Europe",
|
||||
"35mph NA",
|
||||
"ECE 32",
|
||||
"FMVSS 301",
|
||||
"Anchorage Test",
|
||||
"Seat Back Torque Test",
|
||||
"Static Seat Belt Anchorage Test",
|
||||
"38mph",
|
||||
"AEMDB 50KM/H",
|
||||
"EEVC Step 1",
|
||||
"EEVC Step 2",
|
||||
"EEVC Step 2 - 2EUSID",
|
||||
"Euro NCAP 50 Km/h",
|
||||
"FMVSS 214",
|
||||
"FMVSS 301",
|
||||
"FMVSS 216",
|
||||
"Default",
|
||||
"Impact-Headform",
|
||||
"Impact-Torso",
|
||||
"Linear Guided Sled",
|
||||
"Euro Ncap/ SRA 24km/h",
|
||||
"Euro Ncap/IIWPG 16 km/h",
|
||||
"Euro Ncap/SRA 16 km/h",
|
||||
"L6e",
|
||||
"L7e"
|
||||
};
|
||||
|
||||
private static readonly object FILE_LOCK = new object();
|
||||
|
||||
private const string FILENAME = @"ISOTypesAndSubTypes.txt";
|
||||
public static string[] GetTestTypes()
|
||||
{
|
||||
var types = new List<string>();
|
||||
lock (FILE_LOCK)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!System.IO.File.Exists(FILENAME))
|
||||
{
|
||||
CreateFile();
|
||||
}
|
||||
var lines = System.IO.File.ReadAllLines(FILENAME, Encoding.UTF8);
|
||||
var bHaveSeenStart = false;
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var sTrimAndLower = line.Trim().ToLower();
|
||||
switch (sTrimAndLower)
|
||||
{
|
||||
case TEST_TYPES_KEY: bHaveSeenStart = true; break;
|
||||
case SUB_TYPES_KEY: bHaveSeenStart = false; break;
|
||||
default:
|
||||
if (bHaveSeenStart)
|
||||
{
|
||||
if (line.StartsWith("#")) { continue; }
|
||||
types.Add(line);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
return DefaultTestTypes;
|
||||
}
|
||||
}
|
||||
return types.ToArray();
|
||||
}
|
||||
public static string[] GetTestSubtypes()
|
||||
{
|
||||
var subtypes = new List<string>();
|
||||
lock (FILE_LOCK)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!System.IO.File.Exists(FILENAME))
|
||||
{
|
||||
CreateFile();
|
||||
}
|
||||
var lines = System.IO.File.ReadAllLines(FILENAME, Encoding.UTF8);
|
||||
var bHaveSeenStart = false;
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var sTrimAndLower = line.Trim().ToLower();
|
||||
switch (sTrimAndLower)
|
||||
{
|
||||
case TEST_TYPES_KEY: bHaveSeenStart = false; break;
|
||||
case SUB_TYPES_KEY: bHaveSeenStart = true; break;
|
||||
default:
|
||||
if (bHaveSeenStart)
|
||||
{
|
||||
if (line.StartsWith("#")) { continue; }
|
||||
subtypes.Add(line);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
return DefaultTestTypes;
|
||||
}
|
||||
}
|
||||
return subtypes.ToArray();
|
||||
}
|
||||
private static void CreateFile()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(TEST_TYPES_KEY);
|
||||
foreach (var type in DefaultTestTypes)
|
||||
{
|
||||
sb.AppendLine(type);
|
||||
}
|
||||
sb.AppendLine(SUB_TYPES_KEY);
|
||||
foreach (var subtype in DEFAULT_SUBTYPES)
|
||||
{
|
||||
sb.AppendLine(subtype);
|
||||
}
|
||||
System.IO.File.WriteAllText(FILENAME, sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
public static void AddType(string type)
|
||||
{
|
||||
lock (FILE_LOCK)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!System.IO.File.Exists(FILENAME))
|
||||
{
|
||||
CreateFile();
|
||||
}
|
||||
var lines = new List<string>(System.IO.File.ReadAllLines(FILENAME, Encoding.UTF8));
|
||||
var bFound = false;
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
var line = lines[i].Trim().ToLower();
|
||||
if (line != TEST_TYPES_KEY) continue;
|
||||
lines.Insert(i + 1, type);
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
if (!bFound)
|
||||
{
|
||||
lines.Add(TEST_TYPES_KEY);
|
||||
lines.Add(type);
|
||||
}
|
||||
System.IO.File.WriteAllLines(FILENAME, lines.ToArray(), Encoding.UTF8);
|
||||
}
|
||||
catch (System.Exception ex) { APILogger.Log(ex); }
|
||||
}
|
||||
}
|
||||
public static void AddSubtype(string type)
|
||||
{
|
||||
lock (FILE_LOCK)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!System.IO.File.Exists(FILENAME))
|
||||
{
|
||||
CreateFile();
|
||||
}
|
||||
var lines = new List<string>(System.IO.File.ReadAllLines(FILENAME, Encoding.UTF8));
|
||||
var bFound = false;
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
var line = lines[i].Trim().ToLower();
|
||||
if (line != SUB_TYPES_KEY) continue;
|
||||
lines.Insert(i + 1, type);
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
if (!bFound)
|
||||
{
|
||||
lines.Add(SUB_TYPES_KEY);
|
||||
lines.Add(type);
|
||||
}
|
||||
System.IO.File.WriteAllLines(FILENAME, lines.ToArray(), Encoding.UTF8);
|
||||
}
|
||||
catch (System.Exception ex) { APILogger.Log(ex); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using ISO.Strings;
|
||||
using DTS.Common.Classes.CustomerDetails;
|
||||
using DTS.Common.Interface.TestMetaData;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
[Serializable]
|
||||
public class CustomerDetails : CustomerDetailsDbRecord //: ISerializableFile
|
||||
{
|
||||
#region properties
|
||||
public new string ProjectRefNumber
|
||||
{
|
||||
get => base.ProjectRefNumber;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.ProjectRefNumber = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new string CustomerOrderNumber
|
||||
{
|
||||
get => base.CustomerOrderNumber;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.CustomerOrderNumber = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new string CustomerCostUnit
|
||||
{
|
||||
get => base.CustomerCostUnit;
|
||||
set
|
||||
{
|
||||
if (value != string.Empty)
|
||||
{
|
||||
base.CustomerCostUnit = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion properties
|
||||
#region constructor
|
||||
public CustomerDetails()
|
||||
{
|
||||
}
|
||||
|
||||
//public CustomerDetails(string name, bool localOnly) { Name = name; LocalOnly = localOnly; }
|
||||
|
||||
public CustomerDetails(ICustomerDetailsDbRecord customerDetailsDbRecord)
|
||||
: base(customerDetailsDbRecord)
|
||||
{
|
||||
}
|
||||
#endregion constructor
|
||||
private enum Fields
|
||||
{
|
||||
Name,
|
||||
CustomerName,
|
||||
CustomerTestRefNumber,
|
||||
ProjectRefNumber,
|
||||
CustomerOrderNumber,
|
||||
CustomerCostUnit,
|
||||
LocalOnly,
|
||||
LastModified,
|
||||
LastModifiedBy,
|
||||
Version
|
||||
}
|
||||
public static CustomerDetails ReadXML(System.Xml.XmlElement root)
|
||||
{
|
||||
var c = new CustomerDetails();
|
||||
|
||||
foreach (var node in root.ChildNodes)
|
||||
{
|
||||
if (node is System.Xml.XmlElement)
|
||||
{
|
||||
ProcessXMLElement(node as System.Xml.XmlElement, ref c);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
private static void ProcessXMLElement(System.Xml.XmlElement node, ref CustomerDetails c)
|
||||
{
|
||||
if (!Enum.TryParse(node.Name, out Fields field)) return;
|
||||
switch (field)
|
||||
{
|
||||
case Fields.CustomerCostUnit: c.CustomerCostUnit = node.InnerText; break;
|
||||
case Fields.CustomerName: c.CustomerName = node.InnerText; break;
|
||||
case Fields.CustomerOrderNumber: c.CustomerOrderNumber = node.InnerText; break;
|
||||
case Fields.CustomerTestRefNumber: c.CustomerTestRefNumber = node.InnerText; break;
|
||||
case Fields.LastModified: c.LastModified = DateTime.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case Fields.LastModifiedBy: c.LastModifiedBy = node.InnerText; break;
|
||||
case Fields.LocalOnly: c.LocalOnly = bool.Parse(node.InnerText); break;
|
||||
case Fields.Name: c.Name = node.InnerText; break;
|
||||
case Fields.ProjectRefNumber: c.ProjectRefNumber = node.InnerText; break;
|
||||
case Fields.Version: c.Version = int.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
default: throw new NotSupportedException("ISODll.CustomerDetails::ProcessXMLElement unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
public void WriteXML(ref System.Xml.XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("CustomerDetail");
|
||||
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
writer.WriteStartElement(field.ToString());
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case Fields.CustomerCostUnit: writer.WriteString(CustomerCostUnit); break;
|
||||
case Fields.CustomerName: writer.WriteString(CustomerName); break;
|
||||
case Fields.CustomerOrderNumber: writer.WriteString(CustomerOrderNumber); break;
|
||||
case Fields.CustomerTestRefNumber: writer.WriteString(CustomerTestRefNumber); break;
|
||||
case Fields.LastModified: writer.WriteString(LastModified.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
case Fields.LastModifiedBy: writer.WriteString(LastModifiedBy); break;
|
||||
case Fields.LocalOnly: writer.WriteString(LocalOnly.ToString()); break;
|
||||
case Fields.Name: writer.WriteString(Name); break;
|
||||
case Fields.ProjectRefNumber: writer.WriteString(ProjectRefNumber); break;
|
||||
case Fields.Version: writer.WriteString(Version.ToString(System.Globalization.CultureInfo.InvariantCulture)); break;
|
||||
default: throw new NotSupportedException("CustomerDetails::WriteXML unsupported field " + field.ToString());
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public static CustomerDetails GetCustomerDetails(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.CustomerDetailsGet(name, out ICustomerDetailsDbRecord[] customerDetailsDbRecords);
|
||||
|
||||
if (errorNumber == 0 && null != customerDetailsDbRecords && customerDetailsDbRecords.Any())
|
||||
{
|
||||
return new CustomerDetails(customerDetailsDbRecords[0]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failed to get customer details", name, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void DeleteCustomerDetails(string name = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.CustomerDetailsDelete(name, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
APILogger.Log("Failed to delete customer details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to delete customer details", ex);
|
||||
}
|
||||
}
|
||||
public static CustomerDetails[] GetAllCustomerDetails()
|
||||
{
|
||||
var list = new List<CustomerDetails>();
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.CustomerDetailsGet(null, out ICustomerDetailsDbRecord[] customerDetailsDbRecords);
|
||||
|
||||
if (errorNumber == 0)
|
||||
{
|
||||
foreach (var customerDetailDbRecord in customerDetailsDbRecords)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cd = new CustomerDetails(customerDetailDbRecord);
|
||||
if (!cd.IsInvalidBlank())
|
||||
{
|
||||
list.Add(cd);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failed to get customer details", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to retrieve customer details", ex);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
private void Insert(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var customerDetailsDbRecord = new CustomerDetailsDbRecord(this);
|
||||
customerDetailsDbRecord.LastModified = DateTime.Now;
|
||||
customerDetailsDbRecord.LastModifiedBy = user;
|
||||
customerDetailsDbRecord.Version = Version;
|
||||
var errorNumber = DbOperations.CustomerDetailsInsert(customerDetailsDbRecord, out int newId, out string errorMessage);
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
if (newId != -1)
|
||||
{
|
||||
customerDetailsDbRecord.CustomerId = newId;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to insert new customer details", Name, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
private void UpdateAll(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var customerDetailsDbRecord = new CustomerDetailsDbRecord(this);
|
||||
customerDetailsDbRecord.LastModified = DateTime.Now;
|
||||
customerDetailsDbRecord.LastModifiedBy = user;
|
||||
var errorNumber = DbOperations.CustomerDetailsUpdate(customerDetailsDbRecord, out string errorMessage);
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to update customer details", Name, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void Commit(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsInvalidBlank())
|
||||
{
|
||||
throw new NullReferenceException(StringResources.CustomerDetails_NullReferenceName);
|
||||
}
|
||||
|
||||
if (null == GetCustomerDetails(Name))
|
||||
{
|
||||
Insert(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateAll(user);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(StringResources.CustomerDetails_FailedToCommit, Name, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
public void Delete(string user)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorNumber = DbOperations.CustomerDetailsDelete(Name, out string errorMessage);
|
||||
|
||||
if (errorNumber != 0)
|
||||
{
|
||||
APILogger.Log("Failed to delete customer details", errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to update customer details", Name, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="DTS.Common.ISO.AbstractOLEDbWrapper" Collapsed="true">
|
||||
<Position X="12.75" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAEAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>AbstractOLEDbWrapper.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.CalculatedValueClass" Collapsed="true">
|
||||
<Position X="26.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>QEACBAEBAAAECAACAAiEAAQQAAAAAAAACAEAAAgAQAA=</HashCode>
|
||||
<FileName>CalculatedValueClass.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.CCAttributeBase" Collapsed="true">
|
||||
<Position X="28.25" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAEAAJAAEAAAAAgkAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>CalculatedValueClass.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.CustomerDetails" Collapsed="true">
|
||||
<Position X="30" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAAAAEQQAAAAAAAAAgIAoEQCQAEAggEAAEEAAABAgAA=</HashCode>
|
||||
<FileName>CustomerDetails.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.Hardware" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="31.75" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IlwSTlRASAAAZCAiZEBAAUJSiBGQSIKBAAECgA+DkJA=</HashCode>
|
||||
<FileName>Hardware.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.HardwareChannel" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="33.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AiAGJEBAAgAAAIAKoAAECAAAgCkAGAAAAAkAEAEAABE=</HashCode>
|
||||
<FileName>HardwareChannel.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.ISO13499FileDb" Collapsed="true">
|
||||
<Position X="26.5" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>gGAAQEAAKWBIKQIgBGEGAAhBBQcASIAARIEBLiCCW6A=</HashCode>
|
||||
<FileName>ISO13499FileDb.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.IsoCodeStatics" Collapsed="true">
|
||||
<Position X="28.25" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>IsoCode.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.IsoMDBFile" Collapsed="true">
|
||||
<Position X="30" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>IsoMDBFile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.LabratoryDetails" Collapsed="true">
|
||||
<Position X="31.75" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IhAwIHQAAAAAJAAAAgCACIQCAAEgAgkAIAEAAIQgAEA=</HashCode>
|
||||
<FileName>LabratoryDetails.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.LevelTriggerChannel" Collapsed="true">
|
||||
<Position X="33.5" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAgAEAAAAAAAIAAAQAIAAAMAgAAAEAQGAAAAQEAAA=</HashCode>
|
||||
<FileName>LevelTriggerChannel.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEDirections" Collapsed="true">
|
||||
<Position X="17.25" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IFQAAEAAAIAAAAAAAiAAAAAAAAAAEghBAAACAAGABAA=</HashCode>
|
||||
<FileName>MMEDirections.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEFigures" Collapsed="true">
|
||||
<Position X="21.75" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ABBAAAAAiAAIgAAAAAAAAAICAgAAECgAwCACAAAIIAA=</HashCode>
|
||||
<FileName>MMEFigures.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEFilterClasses" Collapsed="true">
|
||||
<Position X="1.5" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBAAAEAAAIAAAAAEAgAAAAAAAABAQghBAAACAAGABAA=</HashCode>
|
||||
<FileName>MMEFilterClasses.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEFineLocations1" Collapsed="true">
|
||||
<Position X="6" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBAAAEAAAIAAAAAAAgAAAAAAAAQAAghBAEACAAGBBBA=</HashCode>
|
||||
<FileName>MMEFineLocations1.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEFineLocations2" Collapsed="true">
|
||||
<Position X="8.25" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBAAAEAAIIAAAAAAAgAAAAAAAIAACghBAEACAAGABAA=</HashCode>
|
||||
<FileName>MMEFineLocations2.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEFineLocations3" Collapsed="true">
|
||||
<Position X="12.75" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBAAAEAAAYQAAAAAAgAAAAAAAAAABghBAEACgAGABAA=</HashCode>
|
||||
<FileName>MMEFineLocations3.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEPhysicalDimensions" Collapsed="true">
|
||||
<Position X="15" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>oBgAAEACgoAAgAAAQgAACCAAAAAABghBAAACEAGABAA=</HashCode>
|
||||
<FileName>MMEPhysicalDimensions.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEPositions" Collapsed="true">
|
||||
<Position X="19.5" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBAAAEAAAKAAAgAgAgAAAAAAAAAAAgjBAAACAAGABAA=</HashCode>
|
||||
<FileName>MMEPositions.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMEPossibleChannels" Collapsed="true">
|
||||
<Position X="24" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBACAEBAgIAipgIgCiMQAAACACFAgwkRAQADgGGNJIA=</HashCode>
|
||||
<FileName>MMEPossibleChannels.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMETestObjects" Collapsed="true">
|
||||
<Position X="3.75" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBAAAEAAAIAEAgAAAgAAAAABAAAAAghBAAACAAGABAA=</HashCode>
|
||||
<FileName>MMETestObjects.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMETestObjectWrapper" Collapsed="true">
|
||||
<Position X="28.25" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>ABAAwABAIAARIAADgRBACkRAAAAGJAAJEgACAAAEIAA=</HashCode>
|
||||
<FileName>MMETestObjectWrapper.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MMETransducerMainLocation" Collapsed="true">
|
||||
<Position X="10.5" Y="1.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IRAAAEAAAIAAAAAAAgAAgAAAAAAAAghBAQADgCGABAA=</HashCode>
|
||||
<FileName>MMETransducerMainLocation.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.Resources" Collapsed="true">
|
||||
<Position X="31.75" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAABEAAAAQAAAAAAQAAAAAAAEIA=</HashCode>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TemplateRegion" Collapsed="true">
|
||||
<Position X="33.5" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>QAAAOEAACAgIAACgACQxAQAQAAAAAAAAAAkIAIAAgAA=</HashCode>
|
||||
<FileName>TemplateRegion.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TemplateZone" Collapsed="true">
|
||||
<Position X="26.5" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAgEAAAAAiAAAAAAAAAQAAAAAAAAAAAAAAABAYAAA=</HashCode>
|
||||
<FileName>TemplateZone.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestEngineerDetails" Collapsed="true">
|
||||
<Position X="28.25" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAQAAESCAAAAAAAAAgAAAAQCCAEAAhkAAIHEAQAgAAA=</HashCode>
|
||||
<FileName>TestEngineerDetails.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestObject" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="30" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAYAAEQCAFAUAAYFIAQAIRiLAAECEgYAApkIAwAIAgQ=</HashCode>
|
||||
<FileName>TestObject.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestObjectChannel" Collapsed="true">
|
||||
<Position X="0.5" Y="4.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AUIEgAAAAAAAAAQAAACAAAAAAAAAAAAAQCAIBQIAAAA=</HashCode>
|
||||
<FileName>TestObjectChannel.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestObjectMetaData" Collapsed="true">
|
||||
<Position X="31.75" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>MAAAAAAAABAAMAAAAAAAAAAAAAEAAAEAAAAIAAACAAA=</HashCode>
|
||||
<FileName>TestObjectMetaData.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.MetaData" Collapsed="true">
|
||||
<Position X="26.5" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAIAAgAAAAAAA=</HashCode>
|
||||
<FileName>TestObjectMetaData.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestSetupMetaData" Collapsed="true">
|
||||
<Position X="31.75" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>MAAAAAAAABAAMQAAAAAAAAAAAAEAAAEAAAAIAABCAAA=</HashCode>
|
||||
<FileName>TestObjectMetaData.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestObjectTemplate" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="33.5" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAAAEkSCABAgACgFAgBAAQACAAEAAAQAAEEIAAFAEAg=</HashCode>
|
||||
<FileName>TestObjectTemplate.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestObjectTemplateChannel" Collapsed="true">
|
||||
<Position X="0.5" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>EARIQEEoAEEEQqUUMHIAQpQIwBcgVCACICFAQABaMIo=</HashCode>
|
||||
<FileName>TestObjectTemplateChannel.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.RequiredChangedEventArgs" Collapsed="true">
|
||||
<Position X="30" Y="2.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>TestObjectTemplateChannel.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestPlan" Collapsed="true">
|
||||
<Position X="26.5" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAAAASgEwJCxAMAIAAAAAASAAAAAAEAAAAAgABABABA=</HashCode>
|
||||
<FileName>TestPlan.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="DTS.Common.ISO.TestTypesFile" Collapsed="true">
|
||||
<Position X="33.5" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAgAAAAAgAggAQABACAAACAAAgAAAAAAABEAAA=</HashCode>
|
||||
<FileName>TestTypesFile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="ISO.TestSetting" Collapsed="true">
|
||||
<Position X="28.25" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AIACAAAAAAAAAAAAAAAAAAACAABAAAAAAAAgAAAQAAA=</HashCode>
|
||||
<FileName>TestSetting.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="ISO.TestSettingDictionary" Collapsed="true">
|
||||
<Position X="30" Y="4.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAACAIgAAAoAAAAAAAAACAAAAAAAAAAAAAAAQAAA=</HashCode>
|
||||
<FileName>TestSetting.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Interface Name="DTS.Common.ISO.ISerializableFile" Collapsed="true">
|
||||
<Position X="26.5" Y="5.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAQAAAAAAAAAAAABAAAAAAAAAAAAABEAAAAAAAAAA=</HashCode>
|
||||
<FileName>ISerializableFile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Enum Name="ISO.TestSettingsEnum" Collapsed="true">
|
||||
<Position X="26.5" Y="6.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAgAAgQAAAAAAAAAAgAAAAQCBAIACAAAAAAAAAABA=</HashCode>
|
||||
<FileName>TestSetting.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Enum>
|
||||
<Font Name="Segoe UI" Size="9" />
|
||||
</ClassDiagram>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,698 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// this is a helper class wrapping access to the iso13499 access db
|
||||
/// it also now makes use of datapro database tables which mimic the access db
|
||||
/// </summary>
|
||||
public class ISO13499FileDb
|
||||
{
|
||||
public class ExpiredISOFieldException : Exception
|
||||
{
|
||||
public ExpiredISOFieldException(string remark) : base(remark) { }
|
||||
}
|
||||
#region dictionaries
|
||||
/// <summary>
|
||||
/// list of directions, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEDirections> _directionsDictionary = new Dictionary<string, MMEDirections>();
|
||||
/// <summary>
|
||||
/// list of filter classes, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFilterClasses> _filterClassesDictionary = new Dictionary<string, MMEFilterClasses>();
|
||||
/// <summary>
|
||||
/// list of all known fine 1 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFineLocations1> _fineLoc1Dictionary = new Dictionary<string, MMEFineLocations1>();
|
||||
/// <summary>
|
||||
/// list of all known fine 2 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFineLocations2> _fineLoc2Dictionary = new Dictionary<string, MMEFineLocations2>();
|
||||
/// <summary>
|
||||
/// list of all known fine 3 locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEFineLocations3> _fineLoc3Dictionary = new Dictionary<string, MMEFineLocations3>();
|
||||
/// <summary>
|
||||
/// list of all known physical dimensions, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEPhysicalDimensions> _physicalDimensionsDictionary = new Dictionary<string, MMEPhysicalDimensions>();
|
||||
/// <summary>
|
||||
/// list of all known positions, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMEPositions> _positionsDictionary = new Dictionary<string, MMEPositions>();
|
||||
/// <summary>
|
||||
/// list of all known possible channels, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly List<MMEPossibleChannels> _possibleChannels = new List<MMEPossibleChannels>();
|
||||
|
||||
private readonly Dictionary<string, List<MMEPossibleChannels>> _possibleChannelsByType =
|
||||
new Dictionary<string, List<MMEPossibleChannels>>();
|
||||
/// <summary>
|
||||
/// list of possible test objects, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMETestObjects> _testObjectsDictionary = new Dictionary<string, MMETestObjects>();
|
||||
/// <summary>
|
||||
/// list of all possible transducer locations, populated when first loaded
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, MMETransducerMainLocation> _transducerMainLoc = new Dictionary<string, MMETransducerMainLocation>();
|
||||
#endregion
|
||||
/*
|
||||
public string GetLocalConnectionString()
|
||||
{
|
||||
lock (dbLock)
|
||||
{
|
||||
if (null != _localConnection) return _localConnection;
|
||||
if (null == Server && !_bCS3) { throw new Exception("db connection not initialized"); }
|
||||
if (_bCS3)
|
||||
{
|
||||
_localConnection = CS3UsingNTLMAuthentication ? $"Server={CS3Host};Database={CS3Name};Trusted_Connection=TRUE;"
|
||||
: $"Server={CS3Host};Database={CS3Name};User Id={CS3User};Password={CS3Password}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_localConnection = _usingNTLMAuthentication
|
||||
? $"Server={Server};Database={DBName};Trusted_Connection=TRUE;"
|
||||
: $"Server={Server};Database={DBName};User Id={Username};Password={Password};";
|
||||
}
|
||||
}
|
||||
return _localConnection;
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// constructs an iso13499file db
|
||||
/// </summary>
|
||||
public ISO13499FileDb()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scans all possible channels for unique types, returns the list of unique types
|
||||
/// </summary>
|
||||
private List<string> _uniquePossibleChannelTypes = null;
|
||||
public string[] GetUniquePossibleChannelTypes()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
if (null != _uniquePossibleChannelTypes) return _uniquePossibleChannelTypes.ToArray();
|
||||
_uniquePossibleChannelTypes = new List<string>();
|
||||
var uniquetypes = (from pc in _possibleChannels where !pc.Expired orderby pc.Text_L1 select pc.Type)
|
||||
.Distinct().ToArray();
|
||||
if (uniquetypes.Length > 0)
|
||||
{
|
||||
_uniquePossibleChannelTypes.AddRange(uniquetypes);
|
||||
_uniquePossibleChannelTypes.Sort();
|
||||
}
|
||||
return _uniquePossibleChannelTypes.ToArray();
|
||||
}
|
||||
}
|
||||
public string[] GetUniquePossibleChannelTypes(string typeToRemove)
|
||||
{
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return GetUniquePossibleChannelTypes()
|
||||
.Where(uniquePossibleChannelType => !uniquePossibleChannelType.StartsWith(typeToRemove)).ToArray();
|
||||
}
|
||||
}
|
||||
private void RefreshIfNeeded()
|
||||
{
|
||||
lock (RefreshLock)
|
||||
{
|
||||
if (!_bLoaded) { RefreshAllData(); }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets a list of all possible channels given a type
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public MMEPossibleChannels[] GetPossibleChannelsForType(string type)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
if (!_possibleChannelsByType.ContainsKey(type))
|
||||
{
|
||||
return new MMEPossibleChannels[0];
|
||||
}
|
||||
return _possibleChannelsByType[type].ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets the possible channels just from DataPRO exclusive (so excluding ISO13499 origined channels)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEPossibleChannels[] GetSQLPossibleChannels()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
var list = (from pc in _possibleChannels.AsParallel()
|
||||
where pc.MMEChannelType == (int)MMEPossibleChannels.MMEChannelTypes.SQL
|
||||
select pc).ToArray();
|
||||
|
||||
if (null != list && list.Any())
|
||||
{
|
||||
return list.Select(li => new MMEPossibleChannels(li)).ToArray();
|
||||
}
|
||||
return new MMEPossibleChannels[0];
|
||||
}
|
||||
}
|
||||
|
||||
public MMEPossibleChannels[] GetAllPossibleChannels()
|
||||
{
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _possibleChannels.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets the "type" field from all possible channels where the channel test object matchines the input string in to
|
||||
/// </summary>
|
||||
/// <param name="to"></param>
|
||||
/// <returns></returns>
|
||||
public string[] GetTestObjectTypeForTestObject(string to)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return (from pc in _possibleChannels.AsParallel()
|
||||
where pc.Test_Object == to
|
||||
orderby pc.Type
|
||||
select pc.Type).Distinct().ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dictionary of possible channels keyed by id, there's a separate dictionary for iso13499 origined channels
|
||||
/// and DataPRO origined channels
|
||||
/// </summary>
|
||||
private Dictionary<long, MMEPossibleChannels> _mmePossibleChannelsDict = null;
|
||||
private Dictionary<long, MMEPossibleChannels> _mmePossibleChannelsDictOurs = null;
|
||||
public MMEPossibleChannels GetPossibleChannel(long id, int channelType)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
if (1 == channelType)
|
||||
{
|
||||
if (null == _mmePossibleChannelsDictOurs)
|
||||
{
|
||||
_mmePossibleChannelsDictOurs = new Dictionary<long, MMEPossibleChannels>();
|
||||
foreach (var channel in _possibleChannels)
|
||||
{
|
||||
if (channel.MMEChannelType != channelType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!_mmePossibleChannelsDictOurs.ContainsKey(channel.Id))
|
||||
{
|
||||
_mmePossibleChannelsDictOurs.Add(channel.Id, channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _mmePossibleChannelsDictOurs.ContainsKey(id) ? _mmePossibleChannelsDictOurs[id] : null;
|
||||
}
|
||||
if (null == _mmePossibleChannelsDict)
|
||||
{
|
||||
_mmePossibleChannelsDict = new Dictionary<long, MMEPossibleChannels>();
|
||||
foreach (var channel in _possibleChannels)
|
||||
{
|
||||
if (channel.MMEChannelType != channelType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!_mmePossibleChannelsDict.ContainsKey(channel.Id))
|
||||
{
|
||||
_mmePossibleChannelsDict.Add(channel.Id, channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _mmePossibleChannelsDict.ContainsKey(id) ? _mmePossibleChannelsDict[id] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// checks for an isocode in either ISO or our db
|
||||
/// </summary>
|
||||
/// <param name="isocode"></param>
|
||||
/// <returns></returns>
|
||||
public bool ContainsPossibleChannelWithISOCode(string isocode)
|
||||
{
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _mmePossibleChannelsDict.Any(ch => IsoCodeStatics.GetString(ch.Value, false) == isocode)
|
||||
|| _mmePossibleChannelsDictOurs.Any(ch => IsoCodeStatics.GetString(ch.Value, false) == isocode);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets all possible test objects from test object tables
|
||||
/// </summary>
|
||||
/// <param name="bIncludeExpired"></param>
|
||||
/// <returns></returns>
|
||||
public MMETestObjects[] GetTestObjects(bool bIncludeExpired)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return bIncludeExpired
|
||||
? _testObjectsDictionary.Values.ToArray()
|
||||
: (from to in _testObjectsDictionary.Values.ToArray().AsParallel() where !to.Expired select to)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns any test objects which match test object test object iso code.
|
||||
/// returns null if not found
|
||||
/// </summary>
|
||||
/// <param name="iso"></param>
|
||||
/// <param name="bIncludeExpired"></param>
|
||||
/// <returns></returns>
|
||||
public MMETestObjects GetTestObjectByIso(string iso, bool bIncludeExpired = true)
|
||||
{
|
||||
MMETestObjects testObjectType = null;
|
||||
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
if (bIncludeExpired)
|
||||
{
|
||||
if (_testObjectsDictionary.ContainsKey(iso))
|
||||
{
|
||||
testObjectType = _testObjectsDictionary[iso];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var nonExpiredTestObjects = _testObjectsDictionary.Values.Where(testObject => !testObject.Expired).ToList();
|
||||
var firstMatch = nonExpiredTestObjects.Find(obj => obj.Test_Object == iso);
|
||||
if (null != firstMatch) { testObjectType = firstMatch; }
|
||||
}
|
||||
}
|
||||
return testObjectType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns a position if any that has a matching iso code position field
|
||||
/// returns null if not found
|
||||
/// </summary>
|
||||
/// <param name="key">position code to look for</param>
|
||||
/// <returns></returns>
|
||||
public MMEPositions GetPositionByISO(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _positionsDictionary.ContainsKey(key) ? _positionsDictionary[key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the first position with a guid which matches the requested guid
|
||||
/// returns null if not found
|
||||
/// </summary>
|
||||
/// <param name="GUID">guid to look for</param>
|
||||
/// <returns></returns>
|
||||
public MMEPositions GetPosition(string GUID)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
var positions = (from p in _positionsDictionary.Values.ToArray().AsParallel()
|
||||
where p.S_GUID == GUID
|
||||
select p);
|
||||
if (positions.Any())
|
||||
{
|
||||
return positions.First();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets all possible filter classes
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEFilterClasses[] GetFilterClasses()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _filterClassesDictionary.Values.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns filter class matching the iso code filter class field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFilterClasses GetFilterClassByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _filterClassesDictionary.ContainsKey(key) ? _filterClassesDictionary[key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets all possible directions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEDirections[] GetDirections()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _directionsDictionary.Values.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// returns a direction given the isocode direction field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEDirections GetDirectionByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _directionsDictionary.ContainsKey(key) ? _directionsDictionary[key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns a fine location 1, given a matching iso fine location field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations1 GetFineLocation1ByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _fineLoc1Dictionary.ContainsKey(key) ? _fineLoc1Dictionary[key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns a fine location 2 based on fine location 2 iso code field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations2 GetFineLocation2ByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _fineLoc2Dictionary.ContainsKey(key) ? _fineLoc2Dictionary[key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets fine location 3 based on fine location 3 isocode field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEFineLocations3 GetFineLocation3ByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _fineLoc3Dictionary.ContainsKey(key) ? _fineLoc3Dictionary[key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets all possible physical dimensions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEPhysicalDimensions[] GetPhysicalDimensions()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _physicalDimensionsDictionary.Values.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// gets physical dimension by isocode physical dimension field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMEPhysicalDimensions GetPhysicalDimensionByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _physicalDimensionsDictionary.ContainsKey(key) ? _physicalDimensionsDictionary[key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets all possible positions
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MMEPositions[] GetPositions()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
return _positionsDictionary.Values.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
readonly Dictionary<string, MMETransducerMainLocation> _expiredMainLocations = new Dictionary<string, MMETransducerMainLocation>();
|
||||
/// <summary>
|
||||
/// gets a main location given an isocode main location field
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public MMETransducerMainLocation GetMainLocationByIso(string key)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
if (_transducerMainLoc.ContainsKey(key)) { return _transducerMainLoc[key]; }
|
||||
if (_expiredMainLocations.ContainsKey(key)) { throw new ExpiredISOFieldException(_expiredMainLocations[key].Remarks); }
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// writes a possible channel to the datapro db
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
public void Commit(MMEPossibleChannels channel, bool bNotify)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
lock (RefreshLock)
|
||||
{
|
||||
if (null == _mmePossibleChannelsDictOurs)
|
||||
{
|
||||
GetPossibleChannel(-1, (int)MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
if (channel.MMEChannelType == (int)MMEPossibleChannels.MMEChannelTypes.SQL && channel.Id != -1)
|
||||
{
|
||||
if (!_mmePossibleChannelsDictOurs.ContainsKey(channel.Id))
|
||||
{
|
||||
channel.Insert();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
sql.CommandType = System.Data.CommandType.Text;
|
||||
sql.CommandText = "SELECT ID FROM tblMMEPossibleChannels where TEXT_L1=@TextL1";
|
||||
DbOperations.CreateParam(sql, "@TextL1", System.Data.SqlDbType.NVarChar,
|
||||
channel.Text_L1);
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
channel.SetId(Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
sql.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
_mmePossibleChannelsDictOurs[channel.Id] = channel;
|
||||
}
|
||||
else
|
||||
{
|
||||
//we might be incorrectly updating the wrong channel if this is from an import ...
|
||||
channel.Commit();
|
||||
_mmePossibleChannelsDictOurs[channel.Id] = channel;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
channel.Commit();
|
||||
}
|
||||
}
|
||||
if (bNotify)
|
||||
{
|
||||
RefreshAllData();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _bLoaded = false;
|
||||
|
||||
public void UnloadAllData()
|
||||
{
|
||||
lock (RefreshLock)
|
||||
{
|
||||
_bLoaded = false;
|
||||
_mmePossibleChannelsDict?.Clear();
|
||||
_mmePossibleChannelsDict = null;
|
||||
_mmePossibleChannelsDictOurs?.Clear();
|
||||
_mmePossibleChannelsDictOurs = null;
|
||||
_uniquePossibleChannelTypes = null;
|
||||
_directionsDictionary?.Clear();
|
||||
_filterClassesDictionary?.Clear();
|
||||
_fineLoc1Dictionary?.Clear();
|
||||
_fineLoc2Dictionary?.Clear();
|
||||
_fineLoc3Dictionary?.Clear();
|
||||
_possibleChannelsByType?.Clear();
|
||||
_physicalDimensionsDictionary?.Clear();
|
||||
_positionsDictionary?.Clear();
|
||||
_possibleChannels?.Clear();
|
||||
_testObjectsDictionary?.Clear();
|
||||
_transducerMainLoc?.Clear();
|
||||
_expiredMainLocations?.Clear();
|
||||
}
|
||||
}
|
||||
private static readonly object RefreshLock = new object();
|
||||
|
||||
private void ProcessPossibleChannels()
|
||||
{
|
||||
foreach (var pc in _possibleChannels)
|
||||
{
|
||||
//Don't include 2535, the Thoracic Compression Criterion channel which contains an expired main location (TCCR), but isn't itself marked as expired (FB 9891).
|
||||
if (pc.Id == 2535 ||
|
||||
pc.Direction == "R" && !pc.Text_L1.ToLower().Contains("seat") && !pc.Text_L1.ToLower().Contains("load") ||
|
||||
pc.Expired || pc.Default_Filter_Class == "V") { continue; }
|
||||
|
||||
if (!_possibleChannelsByType.ContainsKey(pc.Type))
|
||||
{
|
||||
_possibleChannelsByType[pc.Type] = new List<MMEPossibleChannels>();
|
||||
}
|
||||
_possibleChannelsByType[pc.Type].Add(pc);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanConnect()
|
||||
{
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMEDirections";
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// loads all data from iso13499 and datapro databases
|
||||
/// </summary>
|
||||
public void RefreshAllData()
|
||||
{
|
||||
lock (RefreshLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mmePossibleChannelsDict = new Dictionary<long, MMEPossibleChannels>();
|
||||
_mmePossibleChannelsDictOurs = new Dictionary<long, MMEPossibleChannels>();
|
||||
_uniquePossibleChannelTypes = null;
|
||||
_directionsDictionary.Clear();
|
||||
_filterClassesDictionary.Clear();
|
||||
_fineLoc1Dictionary.Clear();
|
||||
_fineLoc2Dictionary.Clear();
|
||||
_fineLoc3Dictionary.Clear();
|
||||
_possibleChannelsByType.Clear();
|
||||
_physicalDimensionsDictionary.Clear();
|
||||
_positionsDictionary.Clear();
|
||||
_possibleChannels.Clear();
|
||||
_testObjectsDictionary.Clear();
|
||||
_transducerMainLoc.Clear();
|
||||
_expiredMainLocations.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var dir in MMEDirections.GetDirections()) { if (!_directionsDictionary.ContainsKey(dir.Direction)) { _directionsDictionary.Add(dir.Direction, dir); } }
|
||||
|
||||
foreach (var fc in MMEFilterClasses.GetFilterClasses()) { if (!_filterClassesDictionary.ContainsKey(fc.Filter_Class)) { _filterClassesDictionary.Add(fc.Filter_Class, fc); } }
|
||||
|
||||
foreach (var loc in MMEFineLocations1.GetFineLocations1()) { if (!_fineLoc1Dictionary.ContainsKey(loc.Fine_Loc_1)) { _fineLoc1Dictionary.Add(loc.Fine_Loc_1, loc); } }
|
||||
|
||||
foreach (var loc in MMEFineLocations2.GetFineLocations2()) { if (!_fineLoc2Dictionary.ContainsKey(loc.FINE_LOC_2)) { _fineLoc2Dictionary.Add(loc.FINE_LOC_2, loc); } }
|
||||
|
||||
foreach (var loc in MMEFineLocations3.GetFineLocations3()) { if (!_fineLoc3Dictionary.ContainsKey(loc.FINE_LOC_3)) { _fineLoc3Dictionary.Add(loc.FINE_LOC_3, loc); } }
|
||||
|
||||
foreach (var pd in MMEPhysicalDimensions.GetPhysicalDimensions()) { if (!_physicalDimensionsDictionary.ContainsKey(pd.Physical_Dimension)) { _physicalDimensionsDictionary.Add(pd.Physical_Dimension, pd); } }
|
||||
|
||||
foreach (var pos in MMEPositions.GetPositions()) { if (!_positionsDictionary.ContainsKey(pos.Position)) { _positionsDictionary.Add(pos.Position, pos); } }
|
||||
|
||||
_possibleChannels.AddRange(MMEPossibleChannels.GetPossibleChannels());
|
||||
|
||||
ProcessPossibleChannels();
|
||||
|
||||
foreach (var to in MMETestObjects.GetTestObjects()) { if (!_testObjectsDictionary.ContainsKey(to.Test_Object)) { _testObjectsDictionary.Add(to.Test_Object, to); } }
|
||||
|
||||
foreach (var mainloc in MMETransducerMainLocation.GetTransducerMainLocations())
|
||||
{
|
||||
if (mainloc.Expired) { if (!_expiredMainLocations.ContainsKey(mainloc.Trans_Main_Loc)) { _expiredMainLocations.Add(mainloc.Trans_Main_Loc, mainloc); } }
|
||||
else { if (!_transducerMainLoc.ContainsKey(mainloc.Trans_Main_Loc)) { _transducerMainLoc.Add(mainloc.Trans_Main_Loc, mainloc); } }
|
||||
}
|
||||
|
||||
foreach (var pc in _possibleChannels)
|
||||
{
|
||||
if (pc.MMEChannelType == (int)MMEPossibleChannels.MMEChannelTypes.SQL) { _mmePossibleChannelsDictOurs[pc.Id] = pc; }
|
||||
else { _mmePossibleChannelsDict[pc.Id] = pc; }
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failure to load ISO tables", ex);
|
||||
}
|
||||
_bLoaded = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_bLoaded = false;
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class IsoMDBFile
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
using DTS.Common.XMLUtils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
|
||||
public class TestPlan : IXmlSerializable
|
||||
{
|
||||
/// <summary>
|
||||
/// part of IXmlSerializable - from MS documentation this should return null
|
||||
/// when implementing IXmlSerializable
|
||||
/// https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.ixmlserializable.getschema?view=net-9.0
|
||||
/// </summary>
|
||||
public XmlSchema GetSchema() { return null; }
|
||||
/// <summary>
|
||||
/// deserializes class from xml
|
||||
/// </summary>
|
||||
public void ReadXml(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("TestPlan::ReadXml - XmlReader was null"); }
|
||||
reader.ReadStartElement("TestPlan");
|
||||
|
||||
ReadFields(reader);
|
||||
ReadTestObjects(reader);
|
||||
ReadExtraProperties(reader);
|
||||
ReadTestObjectFiles(reader);
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
/// <summary>
|
||||
/// serializes class to xml
|
||||
/// </summary>
|
||||
public void WriteXml(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("TestPlan::WriteXml - XmlWriter was null"); }
|
||||
writer.WriteStartElement("TestPlan");
|
||||
writer.WriteAttributeString("Version", "1");
|
||||
WriteFields(writer);
|
||||
WriteTestObjects(writer);
|
||||
WriteExtraProperties(writer);
|
||||
WriteTestObjectFiles(writer);
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
private void ReadExtraProperties(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("TestPlan::ReadExtraProperties - XmlReader was null"); }
|
||||
var properties = new List<KeyValuePair<string, string>>();
|
||||
|
||||
if (reader.Name == "ExtraProperties" && reader.IsEmptyElement) { reader.Read(); }
|
||||
else
|
||||
{
|
||||
reader.ReadStartElement("ExtraProperties");
|
||||
|
||||
while (reader.IsStartElement("ExtraProperty"))
|
||||
{
|
||||
|
||||
var key = reader.GetAttribute("Key");
|
||||
var value = reader.GetAttribute("Value");
|
||||
|
||||
properties.Add(new KeyValuePair<string, string>(key, value));
|
||||
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
ExtraProperties = properties.ToArray();
|
||||
}
|
||||
private void WriteExtraProperties(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("TestPlan::WriteExtraProperties - XmlWriter was null"); }
|
||||
writer.WriteStartElement("ExtraProperties");
|
||||
|
||||
foreach (var property in ExtraProperties)
|
||||
{
|
||||
writer.WriteStartElement("ExtraProperty");
|
||||
|
||||
writer.WriteAttributeString("Key", property.Key);
|
||||
writer.WriteAttributeString("Value", property.Value);
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
private void ReadTestObjects(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("TestPlan::ReadTestObjects - XmlReader was null"); }
|
||||
reader.ReadStartElement("TestObjects");
|
||||
|
||||
var list = new List<MMETestObjectWrapper>();
|
||||
while (reader.IsStartElement() && reader.Name == "TestObject")
|
||||
{
|
||||
var wrapper = new MMETestObjectWrapper();
|
||||
wrapper.ReadXml(reader);
|
||||
if (!Array.Exists(ISOTestObjects, x => x.TypeOfTestObject.Equals(wrapper.TypeOfTestObject)))
|
||||
{
|
||||
//if the test object from the xml file doesn't exist in the test, ignore it.
|
||||
//this is the case where the xml file contains test objects not in the test
|
||||
continue;
|
||||
}
|
||||
list.Add(wrapper);
|
||||
}
|
||||
//now for any test objects in the test that _aren't_ in the xml, add them to the list
|
||||
//this is the case where the test has test objects not in the xml
|
||||
var existingObjectsNotInXml = from existingTestObject in ISOTestObjects where !list.Exists(y => y.TypeOfTestObject.Equals(existingTestObject.TypeOfTestObject)) select existingTestObject;
|
||||
if (existingObjectsNotInXml.Any())
|
||||
{
|
||||
foreach (var existingObject in existingObjectsNotInXml)
|
||||
{
|
||||
list.Add(existingObject);
|
||||
}
|
||||
}
|
||||
|
||||
ISOTestObjects = list.ToArray();
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
private void WriteTestObjects(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("TestPlan::WriteTestObjects - XmlWriter was null"); }
|
||||
writer.WriteStartElement("TestObjects");
|
||||
|
||||
if (null != ISOTestObjects)
|
||||
{
|
||||
foreach (var obj in ISOTestObjects)
|
||||
{
|
||||
obj.WriteXml(writer);
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private void ReadTestObjectFiles(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("TestPlan::ReadTestObjectFiles - XmlReader was null"); }
|
||||
var list = new List<string>();
|
||||
if (reader.IsEmptyElement) { reader.Read(); }
|
||||
else
|
||||
{
|
||||
reader.ReadStartElement("ISOFiles");
|
||||
|
||||
while (reader.IsStartElement() && reader.Name == "File")
|
||||
{
|
||||
list.Add(DTSXMLFile.GetInnerXML(reader));
|
||||
}
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
TestObjectFiles = list.ToArray();
|
||||
}
|
||||
private void WriteTestObjectFiles(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("TestPlan::WriteTestObjectFiles - XmlWriter was null"); }
|
||||
writer.WriteStartElement("ISOFiles");
|
||||
|
||||
foreach (var file in IsoTestObjectFiles)
|
||||
{
|
||||
writer.WriteStartElement("File");
|
||||
writer.WriteString(file);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
private void ReadFields(XmlReader reader)
|
||||
{
|
||||
if (null == reader) { throw new ArgumentException("TestPlan::ReadFields - XmlReader was null"); }
|
||||
if (reader.Name != "Fields") { throw new XmlException("Invalid XML"); }
|
||||
var fields = Enum.GetValues(typeof(IsoFields)).Cast<IsoFields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
//skip title since it comes from the setup name, we probably don't want to overwrite it
|
||||
if (field == IsoFields.Title) { continue; }
|
||||
SetField(field, reader.GetAttribute(field.ToString()));
|
||||
}
|
||||
//it's all in one element, so read the start and end element all in one
|
||||
reader.ReadStartElement("Fields");
|
||||
}
|
||||
|
||||
private void WriteFields(XmlWriter writer)
|
||||
{
|
||||
if (null == writer) { throw new ArgumentException("TestPlan::WriteFields - XmlWriter was null"); }
|
||||
writer.WriteStartElement("Fields");
|
||||
|
||||
var fields = Enum.GetValues(typeof(IsoFields)).Cast<IsoFields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
writer.WriteAttributeString(field.ToString(), GetField(field));
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public string Name { get; set; } = "New Test Plan";
|
||||
|
||||
public string Description { get; set; } = "New Test";
|
||||
|
||||
public DateTime InceptionDate { get; } = DateTime.Now;
|
||||
|
||||
public string[] TestObjectFiles { get; set; } = new string[0];
|
||||
|
||||
public MMETestObjectWrapper[] ISOTestObjects { get; set; } = new MMETestObjectWrapper[0];
|
||||
|
||||
private LabratoryDetails _lab;
|
||||
private LabratoryDetails GetLabratoryDetails()
|
||||
{
|
||||
return _lab ?? (_lab = new LabratoryDetails());
|
||||
}
|
||||
|
||||
private CustomerDetails _customer;
|
||||
private CustomerDetails GetCustomer()
|
||||
{
|
||||
return _customer ?? (_customer = new CustomerDetails());
|
||||
}
|
||||
|
||||
private TestEngineerDetails _testEngineer;
|
||||
private TestEngineerDetails GetTestEngineer()
|
||||
{
|
||||
return _testEngineer ?? (_testEngineer = new TestEngineerDetails());
|
||||
}
|
||||
|
||||
public string Title { get; set; } = "NOVALUE";
|
||||
|
||||
public string MediaNumber { get; set; }
|
||||
|
||||
public string TypeOfTest { get; set; } = "NOVALUE";
|
||||
|
||||
public string SubTypeofTest { get; set; } = "NOVALUE";
|
||||
|
||||
public string Regulation { get; set; } = "NOVALUE";
|
||||
|
||||
public string ReferenceTemperature { get; set; } = "NOVALUE";
|
||||
|
||||
public string RelativeAirHumidity { get; set; } = "NOVALUE";
|
||||
|
||||
public string DateOfTest { get; set; } = "NOVALUE";
|
||||
|
||||
public string TestComment { get; set; } = "NOVALUE";
|
||||
|
||||
public KeyValuePair<string, string>[] ExtraProperties { get; set; } = new KeyValuePair<string, string>[0];
|
||||
|
||||
public string[] IsoTestObjectFiles { get; set; } = new string[0];
|
||||
|
||||
|
||||
public enum IsoFields
|
||||
{
|
||||
CustName,
|
||||
CustomerCostUnit,
|
||||
CustomerName,
|
||||
CustomerOrderNumber,
|
||||
CustomerProjectReferenceNumber,
|
||||
TEName,
|
||||
TestEngineerEmail,
|
||||
TestEngineerFax,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
CustomerTestReferenceNumber,
|
||||
Date,
|
||||
ExtraProperties,
|
||||
LabName,
|
||||
LaboratoryContactEmail,
|
||||
LaboratoryContactFax,
|
||||
LaboratoryContactName,
|
||||
LaboratoryContactPhone,
|
||||
LaboratoryName,
|
||||
LaboratoryTestReferenceNumber,
|
||||
LaboratoryProjectReferenceNumber,
|
||||
NumberOfMedia,
|
||||
NumberOfTestObjects,
|
||||
ReferenceTemperature,
|
||||
Regulation,
|
||||
RelativeAirHumidity,
|
||||
Subtype,
|
||||
TestComment,
|
||||
Title,
|
||||
Type
|
||||
}
|
||||
|
||||
public string NumberOfMedia { get; set; }
|
||||
|
||||
|
||||
public string NumberOfTestObjects => ISOTestObjects.Length.ToString();
|
||||
|
||||
public string GetField(IsoFields field)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case IsoFields.CustName:
|
||||
return GetCustomer().Name;
|
||||
case IsoFields.CustomerCostUnit:
|
||||
return GetCustomer().CustomerCostUnit;
|
||||
case IsoFields.CustomerName:
|
||||
return GetCustomer().CustomerName;
|
||||
case IsoFields.CustomerOrderNumber:
|
||||
return GetCustomer().CustomerOrderNumber;
|
||||
case IsoFields.CustomerProjectReferenceNumber:
|
||||
return GetCustomer().ProjectRefNumber;
|
||||
case IsoFields.TEName:
|
||||
return GetTestEngineer().Name;
|
||||
case IsoFields.TestEngineerEmail:
|
||||
return GetTestEngineer().TestEngineerEmail;
|
||||
case IsoFields.TestEngineerFax:
|
||||
return GetTestEngineer().TestEngineerFax;
|
||||
case IsoFields.TestEngineerName:
|
||||
return GetTestEngineer().TestEngineerName;
|
||||
case IsoFields.TestEngineerPhone:
|
||||
return GetTestEngineer().TestEngineerPhone;
|
||||
case IsoFields.CustomerTestReferenceNumber:
|
||||
return GetCustomer().CustomerTestRefNumber;
|
||||
case IsoFields.Date:
|
||||
return DateOfTest;
|
||||
case IsoFields.LabName:
|
||||
return GetLabratoryDetails().Name;
|
||||
case IsoFields.LaboratoryContactEmail:
|
||||
return GetLabratoryDetails().LabratoryContactEmail;
|
||||
case IsoFields.LaboratoryContactFax:
|
||||
return GetLabratoryDetails().LabratoryContactFax;
|
||||
case IsoFields.LaboratoryContactName:
|
||||
return GetLabratoryDetails().LabratoryContactName;
|
||||
case IsoFields.LaboratoryContactPhone:
|
||||
return GetLabratoryDetails().LabratoryContactPhone;
|
||||
case IsoFields.LaboratoryName:
|
||||
return GetLabratoryDetails().LabratoryName;
|
||||
case IsoFields.LaboratoryTestReferenceNumber:
|
||||
return GetLabratoryDetails().LabratoryTestRefNumber;
|
||||
case IsoFields.LaboratoryProjectReferenceNumber:
|
||||
return GetLabratoryDetails().LabratoryProjectRefNumber;
|
||||
case IsoFields.NumberOfMedia:
|
||||
return NumberOfMedia;
|
||||
case IsoFields.NumberOfTestObjects:
|
||||
return NumberOfTestObjects;
|
||||
case IsoFields.ReferenceTemperature:
|
||||
return ReferenceTemperature;
|
||||
case IsoFields.Regulation:
|
||||
return Regulation;
|
||||
case IsoFields.RelativeAirHumidity:
|
||||
return RelativeAirHumidity;
|
||||
case IsoFields.Subtype:
|
||||
return SubTypeofTest;
|
||||
case IsoFields.TestComment:
|
||||
return TestComment;
|
||||
case IsoFields.Title:
|
||||
return Title;
|
||||
case IsoFields.Type:
|
||||
return TypeOfTest;
|
||||
default:
|
||||
return "NOVALUE";
|
||||
}
|
||||
}
|
||||
|
||||
public void SetField(IsoFields field, string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) { return; }
|
||||
switch (field)
|
||||
{
|
||||
case IsoFields.CustName:
|
||||
GetCustomer().Name = value;
|
||||
break;
|
||||
case IsoFields.CustomerCostUnit:
|
||||
GetCustomer().CustomerCostUnit = value;
|
||||
break;
|
||||
case IsoFields.CustomerName:
|
||||
GetCustomer().CustomerName = value;
|
||||
break;
|
||||
case IsoFields.CustomerOrderNumber:
|
||||
GetCustomer().CustomerOrderNumber = value;
|
||||
break;
|
||||
case IsoFields.CustomerProjectReferenceNumber:
|
||||
GetCustomer().ProjectRefNumber = value;
|
||||
break;
|
||||
case IsoFields.TEName:
|
||||
GetTestEngineer().Name = value;
|
||||
break;
|
||||
case IsoFields.TestEngineerEmail:
|
||||
GetTestEngineer().TestEngineerEmail = value;
|
||||
break;
|
||||
case IsoFields.TestEngineerFax:
|
||||
GetTestEngineer().TestEngineerFax = value;
|
||||
break;
|
||||
case IsoFields.TestEngineerName:
|
||||
GetTestEngineer().TestEngineerName = value;
|
||||
break;
|
||||
case IsoFields.TestEngineerPhone:
|
||||
GetTestEngineer().TestEngineerPhone = value;
|
||||
break;
|
||||
case IsoFields.CustomerTestReferenceNumber:
|
||||
GetCustomer().CustomerTestRefNumber = value;
|
||||
break;
|
||||
case IsoFields.Date:
|
||||
DateOfTest = value;
|
||||
break;
|
||||
case IsoFields.ExtraProperties:
|
||||
break;
|
||||
case IsoFields.LabName:
|
||||
GetLabratoryDetails().Name = value;
|
||||
break;
|
||||
case IsoFields.LaboratoryContactEmail:
|
||||
GetLabratoryDetails().LabratoryContactEmail = value;
|
||||
break;
|
||||
case IsoFields.LaboratoryContactFax:
|
||||
GetLabratoryDetails().LabratoryContactFax = value;
|
||||
break;
|
||||
case IsoFields.LaboratoryContactName:
|
||||
GetLabratoryDetails().LabratoryContactName = value;
|
||||
break;
|
||||
case IsoFields.LaboratoryContactPhone:
|
||||
GetLabratoryDetails().LabratoryContactPhone = value;
|
||||
break;
|
||||
case IsoFields.LaboratoryName:
|
||||
GetLabratoryDetails().LabratoryName = value;
|
||||
break;
|
||||
case IsoFields.LaboratoryTestReferenceNumber:
|
||||
GetLabratoryDetails().LabratoryTestRefNumber = value;
|
||||
break;
|
||||
case IsoFields.LaboratoryProjectReferenceNumber:
|
||||
GetLabratoryDetails().LabratoryProjectRefNumber = value;
|
||||
break;
|
||||
case IsoFields.NumberOfMedia:
|
||||
NumberOfMedia = value;
|
||||
break;
|
||||
case IsoFields.NumberOfTestObjects:
|
||||
break;
|
||||
case IsoFields.ReferenceTemperature:
|
||||
ReferenceTemperature = value;
|
||||
break;
|
||||
case IsoFields.Regulation:
|
||||
Regulation = value;
|
||||
break;
|
||||
case IsoFields.RelativeAirHumidity:
|
||||
RelativeAirHumidity = value;
|
||||
break;
|
||||
case IsoFields.Subtype:
|
||||
SubTypeofTest = value;
|
||||
break;
|
||||
case IsoFields.TestComment:
|
||||
TestComment = value;
|
||||
break;
|
||||
case IsoFields.Title:
|
||||
Title = value;
|
||||
break;
|
||||
case IsoFields.Type:
|
||||
TypeOfTest = value;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("unknown iso field " + field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ISO")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ISO")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("566d4127-454b-42d1-8ac6-a9b94bd8c378")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMEFineLocations1 : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Fine_Loc_1 { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
/// <summary>
|
||||
/// import a singular fine location 1 node
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
/// <param name="page"></param>
|
||||
public static MMEFineLocations1 ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(CustomFinLoc1Fields)).Cast<CustomFinLoc1Fields>().ToArray();
|
||||
|
||||
string sGuid = "", fineLoc1 = "", textL1 = "", textL2 = "", remarks = "", sortKey = "", lastChangeText = "", history = "";
|
||||
long version = 0;
|
||||
var expired = false;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case CustomFinLoc1Fields.Date:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFinLoc1Fields.Expired:
|
||||
expired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case CustomFinLoc1Fields.Fine_Loc_1:
|
||||
fineLoc1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case CustomFinLoc1Fields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.S_GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.SortKey:
|
||||
sortKey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case CustomFinLoc1Fields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomFineLoc1 unsupported field: " + field);
|
||||
}
|
||||
}
|
||||
|
||||
return new MMEFineLocations1(sGuid, fineLoc1, textL1, textL2, version, date, remarks, expired, sortKey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
public MMEFineLocations1(string sGuid, string fineLoc1, string textL1, string textL2, long version, DateTime date,
|
||||
string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText, string history,
|
||||
MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Fine_Loc_1 = fineLoc1;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
public MMEFineLocations1()
|
||||
{
|
||||
}
|
||||
|
||||
public static MMEFineLocations1[] GetFineLocations1()
|
||||
{
|
||||
var fineLocations1 = new List<MMEFineLocations1>();
|
||||
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEFineLocations1";
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string sFineLoc1 = ISOReader["FINE_LOC_1"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = Convert.ToInt64(ISOReader["VERSION"]);
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
fineLocations1.Add(new MMEFineLocations1(sGuid, sFineLoc1, textL1, textL2, version,
|
||||
date,
|
||||
remarks, expired, sortkey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process fine loc 1 ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return fineLocations1.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,52 @@
|
||||
using System.Text;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class IsoCodeStatics
|
||||
{
|
||||
public static string GetString(MMEPossibleChannels channel, MMETestObjects container, MMEPositions position, MMEFilterClasses fc)
|
||||
{
|
||||
var iso = new IsoCode("");
|
||||
iso.Direction = channel.Direction;
|
||||
iso.FilterClass = channel.Default_Filter_Class;
|
||||
iso.FineLocation1 = channel.Fine_Loc_1;
|
||||
iso.FineLocation2 = channel.Fine_Loc_2;
|
||||
iso.FineLocation3 = channel.Fine_Loc_3;
|
||||
iso.MainLocation = channel.Trans_Main_Loc;
|
||||
iso.PhysicalDimension = channel.Physical_Dimension;
|
||||
iso.Position = position?.Position ?? "?";
|
||||
iso.TestObject = container?.Test_Object ?? "?";
|
||||
iso.FilterClass = fc?.Filter_Class ?? "?";
|
||||
return iso.StringRepresentation;
|
||||
}
|
||||
/// <summary>
|
||||
/// returns the isocode for a channel
|
||||
/// considers whether it should mask the test time fields in the isocode
|
||||
/// test time fields are test object, and filterclass
|
||||
/// returns isocode
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <param name="careAboutTestTimeFields"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetString(MMEPossibleChannels channel, bool careAboutTestTimeFields)
|
||||
{
|
||||
var iso = new IsoCode("")
|
||||
{
|
||||
Direction = channel.Direction,
|
||||
FineLocation1 = channel.Fine_Loc_1,
|
||||
FineLocation2 = channel.Fine_Loc_2,
|
||||
FineLocation3 = channel.Fine_Loc_3,
|
||||
MainLocation = channel.Trans_Main_Loc,
|
||||
PhysicalDimension = channel.Physical_Dimension,
|
||||
Position = channel.Position,
|
||||
TestObject = careAboutTestTimeFields ? channel.Test_Object : "??",
|
||||
FilterClass = careAboutTestTimeFields ? channel.Default_Filter_Class : "?"
|
||||
};
|
||||
return iso.StringRepresentation;
|
||||
}
|
||||
public static string GetString(string testObject, string position, string main, string floc1, string floc2, string floc3, string physdim, string dir, string fc)
|
||||
{
|
||||
return $"{testObject}{position}{main}{floc1}{floc2}{floc3}{physdim}{dir}{fc}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,282 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// a test object is a top level object in the ISO database
|
||||
/// given a test object, it is possible to find all possible channels as defined in ISO
|
||||
/// note there is a ? test object ...
|
||||
/// I'll use these to build templates
|
||||
/// </summary>
|
||||
public class MMETestObjects : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Test_Object { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
public static void WriteXML(ref XmlWriter writer, MMETestObjects[] testObjects)
|
||||
{
|
||||
writer.WriteStartElement(TopLevelFields.CustomTestObjects.ToString());
|
||||
|
||||
foreach (var to in testObjects)
|
||||
{
|
||||
writer.Flush();
|
||||
to.WriteXML(ref writer);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
/// <summary>
|
||||
/// imports a singular transducer main location
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
/// <param name="page"></param>
|
||||
public static MMETestObjects ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(TestObjectFields)).Cast<TestObjectFields>().ToArray();
|
||||
|
||||
string sGuid = "", sTestObject = "", textL1 = "", textL2 = "", remarks = "", sortkey = "", lastChangeText = "", history = "";
|
||||
long version = 0;
|
||||
var expired = false;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case TestObjectFields.DATE:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case TestObjectFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case TestObjectFields.HISTORY:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.LAST_CHANGE:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case TestObjectFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.REMARKS:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.s_GUID:
|
||||
sGuid = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.SORTKEY:
|
||||
sortkey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.TEST_OBJECT:
|
||||
sTestObject = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.TEXT_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.TEXT_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case TestObjectFields.VERSION:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportTestObject unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
return new MMETestObjects(sGuid, sTestObject, textL1, textL2, version, date, remarks, expired, sortkey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
/// <summary>
|
||||
/// writes an ISODll.MMETransducerMainLocation to xml
|
||||
/// </summary>
|
||||
/// <param name="m"></param>
|
||||
/// <param name="writer"></param>
|
||||
public void WriteXML(ref XmlWriter writer)
|
||||
{
|
||||
writer.WriteStartElement("TestObject");
|
||||
|
||||
var fields = Enum.GetValues(typeof(TestObjectFields)).Cast<TestObjectFields>().ToArray();
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var sVal = "";
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case TestObjectFields.DATE: sVal = Date.ToString(System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case TestObjectFields.EXPIRED: sVal = Expired.ToString(); break;
|
||||
case TestObjectFields.HISTORY: sVal = History; break;
|
||||
case TestObjectFields.LAST_CHANGE: sVal = Last_Change.ToString(System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
case TestObjectFields.LAST_CHANGE_TEXT: sVal = Last_Change_Text; break;
|
||||
case TestObjectFields.REMARKS: sVal = Remarks; break;
|
||||
case TestObjectFields.s_GUID: sVal = S_GUID; break;
|
||||
case TestObjectFields.SORTKEY: sVal = SortKey; break;
|
||||
case TestObjectFields.TEST_OBJECT: sVal = Test_Object; break;
|
||||
case TestObjectFields.TEXT_L1: sVal = Text_L1; break;
|
||||
case TestObjectFields.TEXT_L2: sVal = Text_L2; break;
|
||||
case TestObjectFields.VERSION: sVal = Version.ToString(System.Globalization.CultureInfo.InvariantCulture); break;
|
||||
default: throw new NotSupportedException("ExportTestSetup::WriteTestObject unsupported field: " + field);
|
||||
}
|
||||
|
||||
writer.WriteAttributeString(field.ToString(), sVal);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
public MMETestObjects(string textL1)
|
||||
{
|
||||
Text_L1 = textL1;
|
||||
}
|
||||
|
||||
public MMETestObjects(string sGuid, string testObject, string textL1, string textL2, long version,
|
||||
DateTime date, string remarks, bool expired, string sortkey, DateTime lastChange, string lastChangeText,
|
||||
string history, MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGuid;
|
||||
Test_Object = testObject;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortkey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMETestObjectsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(S_GUID) });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEST_OBJECT", SqlDbType.NVarChar, 50) { Value = Test_Object });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 50) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 50) { Value = Text_L2 });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = Date });
|
||||
cmd.Parameters.Add(new SqlParameter("@REMARKS", SqlDbType.NVarChar, 50) { Value = Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = Expired });
|
||||
cmd.Parameters.Add(new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = SortKey });
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = Last_Change });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 50) { Value = Last_Change_Text });
|
||||
cmd.Parameters.Add(new SqlParameter("@HISTORY", SqlDbType.NVarChar, 50) { Value = History });
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MMETestObjects[] GetTestObjects()
|
||||
{
|
||||
var testObjects = new List<MMETestObjects>();
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandText = "SELECT * FROM MMETestObjects";
|
||||
cmd.CommandType = CommandType.Text;
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string testObject = ISOReader["TEST_OBJECT"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
testObjects.Add(new MMETestObjects(sGuid, testObject, textL1, textL2, version, date,
|
||||
remarks, expired,
|
||||
sortkey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process test objects", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return testObjects.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,629 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
using System.ComponentModel;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text;
|
||||
using DTS.Common.DAS.Concepts;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using DTS.Common.Interface.DASFactory.Diagnostics;
|
||||
using DTS.Common.Enums.Hardware;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using ISO.Strings;
|
||||
using DTS.Common.Classes.Hardware;
|
||||
using DTS.Common.Interface.DataRecorders;
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable CheckNamespace
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
// ReSharper disable ConvertToAutoProperty
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class Hardware : DASDBRecord, INotifyPropertyChanged, IISOHardware
|
||||
{
|
||||
|
||||
public enum ChannelType
|
||||
{
|
||||
Analog,
|
||||
IEPE,
|
||||
Squib,
|
||||
DigitalOutput,
|
||||
RTC,
|
||||
UART,
|
||||
StreamOutput,
|
||||
StreamInput,
|
||||
Thermocoupler
|
||||
}
|
||||
#region Properties
|
||||
|
||||
public bool IsInvalidDate(DateTime input)
|
||||
{
|
||||
return input.Date.Equals(DASDBRecord.INVALID_DATE.Date);
|
||||
}
|
||||
|
||||
private int _calInterval = 365;
|
||||
|
||||
public int CalInterval
|
||||
{
|
||||
get => _calInterval;
|
||||
set => _calInterval = value;
|
||||
}
|
||||
|
||||
public void GetChannelsString(out int analog, out int digitalIn, out int digitalOut, out int squib, out int uart, out int streamOut, out int streamIn)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
analog = 0;
|
||||
digitalIn = 0;
|
||||
digitalOut = 0;
|
||||
squib = 0;
|
||||
uart = 0;
|
||||
streamOut = 0;
|
||||
streamIn = 0;
|
||||
//was returning "1" for ethernet controllers which don't have a channel ...
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
return;
|
||||
}
|
||||
if (null != ISOChannels && ISOChannels.Any())
|
||||
{
|
||||
foreach (var ch in ISOChannels)
|
||||
{
|
||||
if (ch.IsSupported(SensorConstants.BridgeType.SQUIB))
|
||||
{
|
||||
squib++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.DigitalInput))
|
||||
{
|
||||
digitalIn++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.TOMDigital))
|
||||
{
|
||||
digitalOut++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.UART))
|
||||
{
|
||||
uart++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.StreamOut))
|
||||
{
|
||||
streamOut++;
|
||||
}
|
||||
else if (ch.IsSupported(SensorConstants.BridgeType.StreamIn))
|
||||
{
|
||||
streamIn++;
|
||||
}
|
||||
else analog++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public string IPAddress
|
||||
{
|
||||
get => Connection;
|
||||
set
|
||||
{
|
||||
Connection = value;
|
||||
OnPropertyChanged("IPAddress");
|
||||
}
|
||||
}
|
||||
#endregion Properties
|
||||
|
||||
public Hardware()
|
||||
{
|
||||
|
||||
}
|
||||
public Hardware(Hardware copy)
|
||||
{
|
||||
DASId = copy.DASId;
|
||||
Version = copy.Version;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
ProtocolVersion = copy.ProtocolVersion;
|
||||
Position = copy.Position;
|
||||
MinSampleRate = copy.MinSampleRate;
|
||||
MaxSampleRate = copy.MaxSampleRate;
|
||||
MaxAAFRate = copy.MaxAAFRate;
|
||||
MaxModules = copy.MaxModules;
|
||||
MaxMemory = copy.MaxMemory;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
LastUsedBy = copy.LastUsedBy;
|
||||
LastUsed = copy.LastUsed;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LastModified = copy.LastModified;
|
||||
IsReconfigurable = copy.IsReconfigurable;
|
||||
IsProgrammable = copy.IsProgrammable;
|
||||
ISOChannels = copy.ISOChannels.Select(c => new HardwareChannel(c, this)).ToArray();
|
||||
IPAddress = copy.IPAddress;
|
||||
FirmwareVersion = copy.FirmwareVersion;
|
||||
DASType = copy.DASType;
|
||||
var channeltypes = new int[copy.ChannelTypes.Length];
|
||||
Array.Copy(copy.ChannelTypes, channeltypes, copy.ChannelTypes.Length);
|
||||
ChannelTypes = channeltypes;
|
||||
Channels = copy.Channels;
|
||||
CalInterval = copy.CalInterval;
|
||||
CalDate = copy.CalDate;
|
||||
IsModule = copy.IsModule;
|
||||
ParentDAS = copy.ParentDAS;
|
||||
PositionOnChain = copy.PositionOnChain;
|
||||
PositionOnDistributor = copy.PositionOnDistributor;
|
||||
Port = copy.Port;
|
||||
IsFirstUseValid = copy.IsFirstUseValid;
|
||||
FirstUseDate = copy.FirstUseDate;
|
||||
StandIn = copy.StandIn;
|
||||
TestId = copy.TestId;
|
||||
GroupId = copy.GroupId;
|
||||
}
|
||||
public HardwareTypes DASTypeEnum
|
||||
{
|
||||
get => (HardwareTypes)DASType;
|
||||
set
|
||||
{
|
||||
DASType = (int)value;
|
||||
OnPropertyChanged("DASTypeEnum");
|
||||
}
|
||||
}
|
||||
public bool IsPseudoRackModule()
|
||||
{
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
case HardwareTypes.SLICE2_Base:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public bool IsTSRAIR()
|
||||
{
|
||||
return IsTSRAIR(DASTypeEnum);
|
||||
}
|
||||
|
||||
public static bool IsTSRAIR(HardwareTypes dasType)
|
||||
{
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
case HardwareTypes.DKR:
|
||||
case HardwareTypes.DIR:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public bool IsTSRAIRModule()
|
||||
{
|
||||
return IsTSRAIRModule(DASTypeEnum);
|
||||
}
|
||||
public static bool IsTSRAIRModule(HardwareTypes dasType)
|
||||
{
|
||||
switch (dasType)
|
||||
{
|
||||
case HardwareTypes.EMB_ANG_ACC:
|
||||
case HardwareTypes.EMB_ANG_ARS:
|
||||
case HardwareTypes.EMB_ATM:
|
||||
case HardwareTypes.EMB_LIN_ACC_HI:
|
||||
case HardwareTypes.EMB_LIN_ACC_LO:
|
||||
case HardwareTypes.EMB_MAG:
|
||||
case HardwareTypes.EMB_MAG_SWITCH:
|
||||
case HardwareTypes.EMB_MIC:
|
||||
case HardwareTypes.EMB_OPT:
|
||||
case HardwareTypes.EMB_RTC_S_MARK:
|
||||
case HardwareTypes.EMB_RTC_NS_PAD:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public Hardware(IDASDBRecord copy) : base(copy)
|
||||
{
|
||||
}
|
||||
public Hardware(IDataReader reader) : base(reader)
|
||||
{
|
||||
}
|
||||
|
||||
public static List<HardwareChannel> GetDASISOChannels(string hardwareId, Hardware das)
|
||||
{
|
||||
var channelList = new List<HardwareChannel>();
|
||||
|
||||
var hResult = DbOperations.DASChannelsGet(hardwareId, out var dbChannels);
|
||||
|
||||
if (0 == hResult && null != dbChannels && dbChannels.Any())
|
||||
{
|
||||
foreach (var dbChannel in dbChannels)
|
||||
{
|
||||
channelList.Add(new HardwareChannel(dbChannel, das));
|
||||
}
|
||||
}
|
||||
channelList.Sort(HardwareChannel.PhysicalCompare);
|
||||
return channelList;
|
||||
}
|
||||
private static void GetAllDASISOChannels(Dictionary<string, Hardware> serialNumberToHardware)
|
||||
{
|
||||
var channelsByDASKey = new Dictionary<string, List<HardwareChannel>>();
|
||||
|
||||
var hResult = DbOperations.DASChannelsGet(null, out var dbChannels);
|
||||
|
||||
foreach (var dbChannel in dbChannels)
|
||||
{
|
||||
if (!serialNumberToHardware.ContainsKey(dbChannel.HardwareId)) { continue; }
|
||||
var hardware = serialNumberToHardware[dbChannel.HardwareId];
|
||||
var hc = new HardwareChannel(dbChannel, hardware);
|
||||
if (!channelsByDASKey.ContainsKey(dbChannel.HardwareId))
|
||||
{
|
||||
channelsByDASKey[dbChannel.HardwareId] = new List<HardwareChannel>();
|
||||
}
|
||||
channelsByDASKey[dbChannel.HardwareId].Add(hc);
|
||||
}
|
||||
using (var enumHardware = serialNumberToHardware.GetEnumerator())
|
||||
{
|
||||
while (enumHardware.MoveNext())
|
||||
{
|
||||
var hardware = enumHardware.Current.Value;
|
||||
if (!channelsByDASKey.ContainsKey(enumHardware.Current.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var list = channelsByDASKey[enumHardware.Current.Key];
|
||||
list.Sort(HardwareChannel.PhysicalCompare);
|
||||
hardware.ISOChannels = list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<HardwareChannel> _isoChannels = new List<HardwareChannel>();
|
||||
public HardwareChannel[] ISOChannels
|
||||
{
|
||||
get => _isoChannels.ToArray();
|
||||
set => SetProperty(ref _isoChannels, new List<HardwareChannel>(value), "ISOChannels");
|
||||
}
|
||||
|
||||
public static Hardware[] GetAllDAS()
|
||||
{
|
||||
return GetAllDAS(null, null);
|
||||
}
|
||||
public static Hardware[] GetSingleDAS(string serialNumber, string position)
|
||||
{
|
||||
var list = new List<Hardware>();
|
||||
try
|
||||
{
|
||||
var hResult = DbOperations.DASGet(serialNumber, position, out var dbDAS);
|
||||
if (0 == hResult)
|
||||
{
|
||||
foreach (var curDas in dbDAS)
|
||||
{
|
||||
list.Add(new Hardware(curDas));
|
||||
}
|
||||
}
|
||||
foreach (var das in list)
|
||||
{
|
||||
var channels = GetDASISOChannels(das.SerialNumber, das);
|
||||
channels.Sort(HardwareChannel.PhysicalCompare);
|
||||
das.ISOChannels = channels.ToArray();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("failed to retrieve all das, ", ex); }
|
||||
list.Sort(new HardwareCompare());
|
||||
return list.ToArray();
|
||||
}
|
||||
public static Hardware[] GetAllDAS(string serialNumber, string position)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(serialNumber))
|
||||
{
|
||||
return GetSingleDAS(serialNumber, position);
|
||||
}
|
||||
var list = new List<Hardware>();
|
||||
try
|
||||
{
|
||||
var hResult = DbOperations.DASGet(serialNumber, position, out var dbDAS);
|
||||
if (0 == hResult && null != dbDAS)
|
||||
{
|
||||
foreach (var curDas in dbDAS)
|
||||
{
|
||||
list.Add(new Hardware(curDas));
|
||||
}
|
||||
}
|
||||
var serialNumberToDAS = new Dictionary<string, Hardware>();
|
||||
foreach (var das in list)
|
||||
{
|
||||
serialNumberToDAS[$"{das.SerialNumber}_{das.DASType}"] = das;
|
||||
}
|
||||
GetAllDASISOChannels(serialNumberToDAS);
|
||||
}
|
||||
catch (Exception ex) { APILogger.Log("failed to retrieve all das, ", ex); }
|
||||
list.Sort(new HardwareCompare());
|
||||
return list.ToArray();
|
||||
}
|
||||
public class HardwareCompare : Comparer<Hardware>
|
||||
{
|
||||
public override int Compare(Hardware x, Hardware y)
|
||||
{
|
||||
var ret = string.Compare(x.SerialNumber, y.SerialNumber, StringComparison.Ordinal);
|
||||
if (0 == ret) { ret = string.Compare(x.IPAddress, y.IPAddress, StringComparison.Ordinal); }
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
var embedded = HardwareConstants.HasEmbeddedSensors(DASTypeEnum);
|
||||
_ = DbOperations.DASDelete(DASId, null, embedded);
|
||||
}
|
||||
private void DeleteChannels()
|
||||
{
|
||||
_ = DbOperations.DASChannelsDelete(GetId());
|
||||
}
|
||||
|
||||
public void Insert()
|
||||
{
|
||||
DbOperations.DASInsert(this);
|
||||
InsertChannels();
|
||||
}
|
||||
private void InsertChannels()
|
||||
{
|
||||
foreach (var channel in ISOChannels)
|
||||
{
|
||||
channel.Insert();
|
||||
}
|
||||
}
|
||||
public bool IsDummyObject => SerialNumber.Contains("Dummy");
|
||||
|
||||
public void Update()
|
||||
{
|
||||
DbOperations.DASUpdate(this);
|
||||
|
||||
DeleteChannels();
|
||||
InsertChannels();
|
||||
}
|
||||
|
||||
public string GetId()
|
||||
{
|
||||
return GetId(SerialNumber, DASType.ToString(), IPAddress);
|
||||
}
|
||||
public string GetIdOld()
|
||||
{
|
||||
return $"{SerialNumber}_{DASType}_{IPAddress}";
|
||||
}
|
||||
public static string GetId(string sn, string dastype, string ip)
|
||||
{
|
||||
return $"{sn}_{dastype}";
|
||||
}
|
||||
public void SetChannel(HardwareChannel channel)
|
||||
{
|
||||
for (var i = 0; i < _isoChannels.Count; i++)
|
||||
{
|
||||
if (ISOChannels[i].ChannelIdx != channel.ChannelIdx) continue;
|
||||
_isoChannels[i] = channel; return;
|
||||
}
|
||||
_isoChannels.Add(channel);
|
||||
}
|
||||
|
||||
private const string TDAS_RACK_PREPEND = "DR";
|
||||
private const string TDAS_LABRACK_PREPEND = "LR";
|
||||
private const string SLICE6_PREPEND = "SL6";
|
||||
private const string SLICE6AIR_PREPEND = "S6A";
|
||||
private const string SLICE6AIRBR_PREPEND = "S6BR";
|
||||
private const string SLICE6AIRBR_PREPEND2 = "S6ABR";
|
||||
private const string SLICE2SIM_PREPEND = "SPS";
|
||||
private const string SLICE2LABSIM_PREPEND = "SLS";
|
||||
private const string SLICE2TOM_PREPEND = "SPT";
|
||||
private const string SLICE2LABTOM_PREPEND = "SLT";
|
||||
private const string SLICE2DIM_PREPEND = "SPD";
|
||||
private const string SLICE2LABDIM_PREPEND = "SLD";
|
||||
private const string SLICENANO_PREPEND = "BA5";
|
||||
private const string SLICEMICRO_PREPEND = "BA0";
|
||||
private const string SLICE15NANO_PREPEND = "BA5";
|
||||
private const string SLICE15MICRO_PREPEND = "BA0";
|
||||
private const string SLICELABETHERNET_PREPEND = "SLE";
|
||||
private const string SLICE_PRO_DB_PREPEND = "SPDB";
|
||||
private const string SLICE6DB_PREPEND = "S6DB";
|
||||
private const string SLICE6DB3_PREPEND = "S6DB3";
|
||||
private const string SLICEG5_PREPEND = "SG5";
|
||||
private const string G5_PREPEND = "5M";
|
||||
private const string SLICEPROETHERNET_PREPEND = "SPE";
|
||||
private const string SLICEDB_PREPEND = "SD";
|
||||
private const string POWERPRO_PREPEND = "PPR";
|
||||
private const string SLICEMINIDB_PREPEND = "SPM";
|
||||
private const string DIR_PREPEND = "DI";
|
||||
private const string DKR_PREPEND = "DK";
|
||||
private const string SLICETC_PREPEND = "STC";
|
||||
|
||||
private void ValidateSN(ref List<string> errors, ref bool bValid, string prepend, string error, string alternativePrepend = null)
|
||||
{
|
||||
if (SerialNumber.Contains(DFConstantsAndEnums.SERIAL_SEPARATOR) && !StandIn)
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add($"{Strings.Strings.InvalidCharacterInSerialNumber} '{DFConstantsAndEnums.SERIAL_SEPARATOR}'");
|
||||
}
|
||||
if (SerialNumber.Contains(DFConstantsAndEnums.CHANNEL_SEPARATOR) && !StandIn)
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add($"{Strings.Strings.InvalidCharacterInSerialNumber} '{DFConstantsAndEnums.CHANNEL_SEPARATOR}'");
|
||||
}
|
||||
if (!SerialNumber.StartsWith(prepend)
|
||||
&& (string.IsNullOrEmpty(alternativePrepend) || !SerialNumber.StartsWith(alternativePrepend)))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add(error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateNotSN(ref List<string> errors, ref bool bValid, string prepend, string error)
|
||||
{
|
||||
if (SerialNumber.StartsWith(prepend))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add($"{error} ({DASTypeEnum.ToString()})");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateIPAddress(ref List<string> errors)
|
||||
{
|
||||
var bValid = true;
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
case HardwareTypes.SLICE6DB:
|
||||
case HardwareTypes.SLICE6DB3:
|
||||
case HardwareTypes.SLICE_Pro_Distributor:
|
||||
//case HardwareTypes.SLICE6DB_AIR:
|
||||
case HardwareTypes.SLICE6DB_InDummy:
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
case HardwareTypes.G5VDS:
|
||||
//case ISODll.Hardware.HardwareTypes.G5IPORT:
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(IPAddress))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add(StringResources.AutoDetectDAS_IPAddressRequired);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return bValid;
|
||||
}
|
||||
public bool ValidateSerialNumber(ref List<string> errors)
|
||||
{
|
||||
var bValid = true;
|
||||
if (string.IsNullOrWhiteSpace(SerialNumber))
|
||||
{
|
||||
bValid = false;
|
||||
errors.Add(StringResources.AutoDetectDAS_SerialNumberRequired);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (DASTypeEnum)
|
||||
{
|
||||
case HardwareTypes.TDAS_Pro_Rack:
|
||||
ValidateSN(ref errors, ref bValid, TDAS_RACK_PREPEND, StringResources.AutoDetectDas_TDASRackShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.TDAS_LabRack:
|
||||
ValidateSN(ref errors, ref bValid, TDAS_LABRACK_PREPEND, StringResources.AutoDetectDAS_TDASLabRackShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6_PREPEND, StringResources.AutoDetectDas_SLICE6ShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6AIR_PREPEND, StringResources.AutoDetectDas_SLICE6AIRShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_BR:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6AIRBR_PREPEND, StringResources.AutoDetectDas_SLICE6AIRBRShouldStartWith, SLICE6AIRBR_PREPEND2);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SIM:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2SIM_PREPEND, StringResources.AutoDetectDas_SIMShouldStartWithSPS);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLS:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2LABSIM_PREPEND, StringResources.AutoDetectDAS_SLSShouldStartWithSLS);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_TOM:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2TOM_PREPEND, StringResources.AutoDetectDas_TOMShouldStartWithSPT);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLT:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2LABTOM_PREPEND, StringResources.AutoDetectDAS_SLTShouldStartWithSLT);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_DIM:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2DIM_PREPEND, StringResources.AutoDetectDas_DIMShouldStartWithSPD);
|
||||
break;
|
||||
case HardwareTypes.SLICE2_SLD:
|
||||
ValidateSN(ref errors, ref bValid, SLICE2LABDIM_PREPEND, StringResources.AutoDetectDAS_SLDShouldStartWithSLD);
|
||||
break;
|
||||
case HardwareTypes.SLICE_NANO_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICENANO_PREPEND, StringResources.AutoDetectDas_SLICENanoShouldStartWithBA5);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Micro_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICEMICRO_PREPEND, StringResources.AutoDetectDas_MicroSerialNumberShouldStartWithBA0);
|
||||
break;
|
||||
case HardwareTypes.SLICE1_5_Nano_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICE15NANO_PREPEND, StringResources.AutoDetectDAS_NANOBasePlusShouldStartWithBA5);
|
||||
break;
|
||||
case HardwareTypes.SLICE1_5_Micro_Base:
|
||||
ValidateSN(ref errors, ref bValid, SLICE15MICRO_PREPEND, StringResources.AutoDetectDAS_MICROBasePlusShouldStartWithBA0);
|
||||
break;
|
||||
case HardwareTypes.SLICE_LabEthernet:
|
||||
ValidateSN(ref errors, ref bValid, SLICELABETHERNET_PREPEND, StringResources.AutoDetectDAS_SliceLabEthernetShouldStartWithSLE);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Pro_Distributor:
|
||||
ValidateSN(ref errors, ref bValid, SLICE_PRO_DB_PREPEND, StringResources.AutoDetectDAS_SLICEPRODBShouldStartWithSPDB);
|
||||
break;
|
||||
case HardwareTypes.SLICE6DB3:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6DB3_PREPEND, StringResources.AutoDetectDas_SLICE6DB3ShouldStartWith);
|
||||
break;
|
||||
case HardwareTypes.SLICE6DB:
|
||||
ValidateSN(ref errors, ref bValid, SLICE6DB_PREPEND, StringResources.AutoDetectDas_Slice6DBShouldStartWithS6DB);
|
||||
break;
|
||||
case HardwareTypes.SLICE1_G5Stack:
|
||||
ValidateSN(ref errors, ref bValid, SLICEG5_PREPEND, StringResources.AutoDetectDas_SliceG5ShouldStartWithSG5);
|
||||
break;
|
||||
case HardwareTypes.G5INDUMMY:
|
||||
case HardwareTypes.G5VDS:
|
||||
ValidateSN(ref errors, ref bValid, G5_PREPEND, StringResources.AutoDetectDas_G5ShouldStartWith5M);
|
||||
break;
|
||||
case HardwareTypes.SLICE_EthernetController:
|
||||
ValidateSN(ref errors, ref bValid, SLICEPROETHERNET_PREPEND, StringResources.AutoDetectDas_SliceECM);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Mini_Distributor:
|
||||
ValidateSN(ref errors, ref bValid, SLICEMINIDB_PREPEND, StringResources.AutoDetectDas_SliceSPM);
|
||||
break;
|
||||
case HardwareTypes.SLICE_Distributor:
|
||||
ValidateSN(ref errors, ref bValid, SLICEDB_PREPEND, StringResources.AutoDetectDas_SliceDBShouldStartWithSDB);
|
||||
break;
|
||||
case HardwareTypes.PowerPro:
|
||||
ValidateSN(ref errors, ref bValid, POWERPRO_PREPEND, StringResources.AutoDetectDas_PowerProShouldStartWithPPRO);
|
||||
break;
|
||||
case HardwareTypes.TSR_AIR:
|
||||
case HardwareTypes.TSR_AIR_RevB:
|
||||
ValidateSN(ref errors, ref bValid, HardwareConstants.TSR_AIR_PREPEND, StringResources.AutoDetectDas_TSRAIRShouldStartWithTA);
|
||||
break;
|
||||
case HardwareTypes.DKR:
|
||||
ValidateSN(ref errors, ref bValid, DKR_PREPEND, StringResources.AutoDetectDas_DKRShouldStartWithDK);
|
||||
break;
|
||||
case HardwareTypes.DIR:
|
||||
ValidateSN(ref errors, ref bValid, DIR_PREPEND, StringResources.AutoDetectDas_DIRShouldStartWithDI);
|
||||
break;
|
||||
case HardwareTypes.SLICE6_AIR_TC:
|
||||
ValidateSN(ref errors, ref bValid, SLICETC_PREPEND, string.Format(StringResources.AutoDetectDas_TypeShouldStartWithPrepend, Strings.Strings.SLICE_TC_Description, SLICETC_PREPEND));
|
||||
break;
|
||||
default:
|
||||
|
||||
ValidateNotSN(ref errors, ref bValid, G5_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToAG5);
|
||||
ValidateNotSN(ref errors, ref bValid, TDAS_RACK_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToATDASRack);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICENANO_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToANano);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICEMICRO_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToAMicro);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2SIM_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToASLICEProSim);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2LABSIM_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToASLICEPROLabSIM);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICEG5_PREPEND, StringResources.AutoDetectDas_SerialNumberBelongsToASLICEG5);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICELABETHERNET_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToASlicePROLabSLE);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2DIM_PREPEND, StringResources.AutoDetectDas_SLICE_SerialNumberBelongsToASLICEProDIM);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2LABTOM_PREPEND, StringResources.AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABTOM);
|
||||
ValidateNotSN(ref errors, ref bValid, SLICE2LABDIM_PREPEND, StringResources.AutoDetectDAS_SLICE_SerialNumberBelongsToASLICELABDIM);
|
||||
ValidateNotSN(ref errors, ref bValid, TDAS_LABRACK_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToATDASLabRack);
|
||||
ValidateNotSN(ref errors, ref bValid, POWERPRO_PREPEND, StringResources.AutoDetectDAS_SerialNumberBelongsToAPowerPRO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bValid;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public interface ISerializableFile
|
||||
{
|
||||
string GetDirectory();
|
||||
string GetExtension();
|
||||
string GetFilter();
|
||||
string GetFileLocation();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using DTS.Common.Interface.GroupTemplate;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// this class is a wrapper for the group template per the db, it's supposed to be a lighter weight version of concept of a test object template, with no
|
||||
/// connection to UI, just serialization and structure
|
||||
/// </summary>
|
||||
public class TestObjectTemplate : ITestObjectTemplate
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// name of the test object template, this could be a GUID in the case of embedded test object templates
|
||||
/// </summary>
|
||||
public string TemplateName { get; set; }
|
||||
/// <summary>
|
||||
/// a human readable name for the template, for an embedded template this is the original template name, for
|
||||
/// a non embedded template, this is the template name (embedded templates have guids for names)
|
||||
/// </summary>
|
||||
public string TemplateNameOrOriginalTemplateName => Embedded ? OriginalTemplateName : TemplateName;
|
||||
|
||||
/// <summary>
|
||||
/// the icon for the template
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
/// <summary>
|
||||
/// description for the template
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// whether this template is intended to only be used locally or not
|
||||
/// </summary>
|
||||
public bool LocalOnly { get; set; }
|
||||
/// <summary>
|
||||
/// the version number of this template [not currently used?]
|
||||
/// </summary>
|
||||
public int Version { get; set; }
|
||||
/// <summary>
|
||||
/// last person to modify this template
|
||||
/// </summary>
|
||||
public string LastModifiedBy { get; set; }
|
||||
/// <summary>
|
||||
/// when this template was last modified
|
||||
/// </summary>
|
||||
public DateTime LastModified { get; set; }
|
||||
/// <summary>
|
||||
/// a CRC32 for the template, but not currently used
|
||||
/// original idea was to allow us to not have to check changes in the template, just quickly calculate whether anything has changed
|
||||
/// </summary>
|
||||
public int CRC32 { get; set; }
|
||||
/// <summary>
|
||||
/// test object (iso meta field) for this template
|
||||
/// </summary>
|
||||
public string TestObject { get; set; }
|
||||
/// <summary>
|
||||
/// test object type (iso meta field) for this template, all channels are of this type ...
|
||||
/// </summary>
|
||||
public string TestObjectType { get; set; }
|
||||
/// <summary>
|
||||
/// unsure if this is still used, was originally used to build up templates from sub templates,
|
||||
/// so an ATD could be composed of leg, arm, head, etc
|
||||
/// </summary>
|
||||
public string TemplateParent { get; set; }
|
||||
/// <summary>
|
||||
/// unsure, I think this is whether the group is dynamically added or an existing
|
||||
/// </summary>
|
||||
public bool SysBuilt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// all channels for the template
|
||||
/// </summary>
|
||||
public TestObjectTemplateChannel[] Channels { get; set; }
|
||||
/// <summary>
|
||||
/// the original template name [if we are embedded we got a new name that was a guid, but we store the old name here for readability purposes]
|
||||
/// </summary>
|
||||
public string OriginalTemplateName { get; set; }
|
||||
/// <summary>
|
||||
/// whether this group is embedded in a test setup, or is a user created and living on it's own template
|
||||
/// </summary>
|
||||
public bool Embedded { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors and initializers
|
||||
|
||||
public bool IsISOMode()
|
||||
{
|
||||
return !(TestObjectType.Contains(Classes.GroupTemplates.Constants.NON_ISO_TESTOBJECT_CHANNEL_TYPE) ||
|
||||
TestObjectType.Contains(TestObjectTemplateChannel.NONISOCHANNELTYPE));
|
||||
}
|
||||
public TestObjectTemplate(string templateName, bool bLocalOnly)
|
||||
{
|
||||
Version = 1;
|
||||
TemplateName = templateName;
|
||||
LocalOnly = bLocalOnly;
|
||||
Channels = new TestObjectTemplateChannel[0];
|
||||
}
|
||||
public TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)
|
||||
{
|
||||
if (copy?.TemplateName != null)
|
||||
{
|
||||
TemplateName = copy.TemplateName;
|
||||
}
|
||||
if (copy == null) return;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
CRC32 = copy.CRC32;
|
||||
Description = copy.Description;
|
||||
Embedded = copy.Embedded;
|
||||
OriginalTemplateName = copy.OriginalTemplateName;
|
||||
Icon = copy.Icon;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
LocalOnly = copy.LocalOnly;
|
||||
SysBuilt = copy.SysBuilt;
|
||||
TemplateParent = copy.TemplateParent;
|
||||
TestObject = copy.TestObject;
|
||||
TestObjectType = copy.TestObjectType;
|
||||
Version = copy.Version;
|
||||
var lookup = new Dictionary<string, bool>();
|
||||
var channels = new List<TestObjectTemplateChannel>();
|
||||
foreach (var c in copy.Channels)
|
||||
{
|
||||
var ch = new TestObjectTemplateChannel(c, this);
|
||||
ch.SetTemplate(this);
|
||||
channels.Add(ch);
|
||||
lookup[$"{c.Channel.Id}x{c.Channel.MMEChannelType}"] = true;
|
||||
}
|
||||
var possibleChannels = db.GetPossibleChannelsForType(TestObjectType);
|
||||
foreach (var pc in possibleChannels)
|
||||
{
|
||||
var key = $"{pc.Id}x{pc.MMEChannelType}";
|
||||
if (lookup.ContainsKey(key)) continue;
|
||||
lookup[key] = true;
|
||||
var ch = new TestObjectTemplateChannel(pc);
|
||||
ch.SetTemplate(this);
|
||||
channels.Insert(0, ch);
|
||||
}
|
||||
AssignOrders(channels);
|
||||
Channels = channels.ToArray();
|
||||
}
|
||||
|
||||
private void AssignOrders(List<TestObjectTemplateChannel> channels)
|
||||
{
|
||||
if (!channels.Any()) { return; }
|
||||
channels.Sort();
|
||||
var maxDisplayOrder = (from ch in channels select ch.DisplayOrder).Max();
|
||||
foreach (var ch in channels)
|
||||
{
|
||||
if (-1 == ch.DisplayOrder)
|
||||
{
|
||||
ch.DisplayOrder = ++maxDisplayOrder;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion Constructors And Initializers
|
||||
|
||||
|
||||
#region static functions
|
||||
|
||||
|
||||
public static TestObjectTemplate GetTemplate(ref ISO13499FileDb db, string name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
public override string ToString()
|
||||
{
|
||||
return TemplateNameOrOriginalTemplateName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
/* Copyright 2017 Diversified Technical Systems
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Classes.TestSetups;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
/// <summary>
|
||||
/// this class will probably become an abstract base class in the future but for now since we only have
|
||||
/// summed realtime channels, we can be a little less formal
|
||||
/// </summary>
|
||||
public class CalculatedValueClass : CalculatedChannelRecord
|
||||
{
|
||||
public CalculatedValueClass() { }
|
||||
public CalculatedValueClass(CalculatedValueClass copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
Operation = copy.Operation;
|
||||
TestSetupName = copy.TestSetupName;
|
||||
Name = copy.Name;
|
||||
foreach (var a in copy.Attributes)
|
||||
{
|
||||
_attributes.Add(a.Copy());
|
||||
}
|
||||
CalculatedValueCode = copy.CalculatedValueCode;
|
||||
CFCForInputChannels = copy.CFCForInputChannels;
|
||||
ChannelFilterClassForOutput = copy.ChannelFilterClassForOutput;
|
||||
var ids = new List<string>(copy.InputChannelIds);
|
||||
_inputChannelIds = ids.ToArray();
|
||||
ViewInRealtime = copy.ViewInRealtime;
|
||||
ClipLength = copy.ClipLength;
|
||||
}
|
||||
public CalculatedValueClass(ICalculatedChannelRecord record)
|
||||
: base(record)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// returns true if the calculation channel supports realtime
|
||||
/// </summary>
|
||||
public bool SupportsRealtime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!ViewInRealtime) { return false; }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool IsValid(Dictionary<string, bool> channelIdLookup)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name)) { return false; }
|
||||
if (InputChannelIds.Length < 1) { return false; }
|
||||
foreach (var id in _inputChannelIds) { if (!channelIdLookup.ContainsKey(id)) { return false; } }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public new Operations Operation
|
||||
{
|
||||
get => base.Operation;
|
||||
set
|
||||
{
|
||||
base.Operation = value;
|
||||
OnPropertyChanged("ViewInRealtime");
|
||||
OnPropertyChanged("CanChangeViewInRealtime");
|
||||
}
|
||||
}
|
||||
|
||||
public new bool ViewInRealtime
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Operation)
|
||||
{
|
||||
case Operations.IRTRACC3D:
|
||||
case Operations.IRTRACC3D_ABDOMEN:
|
||||
case Operations.IRTRACC3D_LOWERTHORAX:
|
||||
case Operations.HIC:
|
||||
return false;
|
||||
}
|
||||
return base.ViewInRealtime;
|
||||
}
|
||||
set => base.ViewInRealtime = value;
|
||||
}
|
||||
|
||||
public bool CanChangeViewInRealtime
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Operation)
|
||||
{
|
||||
case Operations.IRTRACC3D:
|
||||
case Operations.IRTRACC3D_ABDOMEN:
|
||||
case Operations.IRTRACC3D_LOWERTHORAX:
|
||||
case Operations.HIC:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public new string[] InputChannelIds
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_channels.Any())
|
||||
{
|
||||
var ids = new List<string>();
|
||||
foreach (var ch in _channels)
|
||||
{
|
||||
if (null == ch)
|
||||
{
|
||||
ids.Add("-1");
|
||||
}
|
||||
else
|
||||
{
|
||||
ids.Add(ch.Id.ToString());
|
||||
}
|
||||
}
|
||||
_inputChannelIds = ids.ToArray();
|
||||
}
|
||||
|
||||
return base.InputChannelIds;
|
||||
}
|
||||
set => base.InputChannelIds = value;
|
||||
}
|
||||
|
||||
private List<IGroupChannel> _channels = new List<IGroupChannel>();
|
||||
|
||||
public List<TestObjectChannel> TestObjectChannels { get; set; } = new List<TestObjectChannel>();
|
||||
|
||||
public void SetChannels(IGroupChannel[] groupChannels)
|
||||
{
|
||||
_channels = new List<IGroupChannel>(groupChannels);
|
||||
}
|
||||
|
||||
public void SetTestObjectChannels(TestObjectChannel[] testObjectChannels)
|
||||
{
|
||||
TestObjectChannels = new List<TestObjectChannel>(testObjectChannels);
|
||||
}
|
||||
public byte[] InputChannelIdsBlob
|
||||
{
|
||||
get
|
||||
{
|
||||
var text = string.Join(CultureInfo.InvariantCulture.TextInfo.ListSeparator, InputChannelIds);
|
||||
return Encoding.UTF8.GetBytes(text);
|
||||
}
|
||||
set
|
||||
{
|
||||
var text = Encoding.UTF8.GetString(value);
|
||||
var ids = new List<string>(text.Split(
|
||||
new[] { CultureInfo.InvariantCulture.TextInfo.ListSeparator },
|
||||
StringSplitOptions.None));
|
||||
_inputChannelIds = ids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<CCAttributeBase> _attributes = new List<CCAttributeBase>();
|
||||
public CCAttributeBase[] Attributes
|
||||
{
|
||||
get => _attributes.ToArray();
|
||||
set { _attributes.Clear(); _attributes.AddRange(value); }
|
||||
}
|
||||
public void ReplaceInputChannelIdAtIndex(int index, string newId)
|
||||
{
|
||||
_inputChannelIds[index] = newId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the design here is so that we can attach attributes to calculated channels that need them (HIC, Head Contact Duration), but let them be a bit variable and dynamic
|
||||
/// </summary>
|
||||
public abstract class CCAttributeBase
|
||||
{
|
||||
protected int _attributeId;
|
||||
public int AttributeId => _attributeId;
|
||||
|
||||
protected object _attributeValue;
|
||||
public abstract string GetSerializedValue();
|
||||
|
||||
public abstract string GetDefaultValue();
|
||||
|
||||
public abstract string GetNameResourceId { get; }
|
||||
public abstract CCAttributeBase Copy();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using DTS.Common.Enums.DBExport;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class MMEPhysicalDimensions : AbstractOLEDbWrapper
|
||||
{
|
||||
public string S_GUID { get; }
|
||||
|
||||
public string Physical_Dimension { get; }
|
||||
|
||||
public string Text_L1 { get; }
|
||||
|
||||
public string Text_L2 { get; }
|
||||
|
||||
public string Default_Unit { get; }
|
||||
|
||||
public long Length_EXP { get; }
|
||||
|
||||
public long Time_EXP { get; }
|
||||
|
||||
public long Mass_EXP { get; }
|
||||
|
||||
public long Electric_Current_EXP { get; }
|
||||
|
||||
public long Temperature_EXP { get; }
|
||||
|
||||
public long Luminous_Intensity_Exp { get; }
|
||||
|
||||
public long Amount_Of_Substance_EXP { get; }
|
||||
|
||||
public long Version { get; }
|
||||
|
||||
public DateTime Date { get; }
|
||||
|
||||
public string Remarks { get; }
|
||||
|
||||
public bool Expired { get; }
|
||||
|
||||
public string SortKey { get; }
|
||||
|
||||
public DateTime Last_Change { get; }
|
||||
|
||||
public string Last_Change_Text { get; }
|
||||
|
||||
public string History { get; }
|
||||
|
||||
public MMEPossibleChannels.MMEChannelTypes RecordType { get; } = MMEPossibleChannels.MMEChannelTypes.ISO13499_106;
|
||||
|
||||
/// <summary>
|
||||
/// imports a singular physical dimension
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <param name="setStatus"></param>
|
||||
/// <param name="page"></param>
|
||||
public static MMEPhysicalDimensions ReadXML(XmlElement node)
|
||||
{
|
||||
var fields = Enum.GetValues(typeof(PhysicalDimensionFields)).Cast<PhysicalDimensionFields>().ToArray();
|
||||
|
||||
string sGUID = "", physicalDimension = "", textL1 = "", textL2 = "", defaultUnit = "", remarks = "", sortKey = "", lastChangeText = "", history = "";
|
||||
long lengthExp = 0, timeExp = 0, massExp = 0, currentExp = 0, temperatureExp = 0, luminiousExp = 0, amountExp = 0, version = 0;
|
||||
var expired = false;
|
||||
DateTime date = DateTime.Now, lastChange = DateTime.Now;
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case PhysicalDimensionFields.Amount_Of_Substance_EXP:
|
||||
amountExp = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Date:
|
||||
date = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Default_Unit:
|
||||
defaultUnit = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.Electric_Current_EXP:
|
||||
currentExp = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Expired:
|
||||
expired = Convert.ToBoolean(node.GetAttribute(field.ToString()));
|
||||
break;
|
||||
case PhysicalDimensionFields.History:
|
||||
history = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.Last_Change:
|
||||
lastChange = DateTime.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Last_Change_Text:
|
||||
lastChangeText = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.Length_EXP:
|
||||
lengthExp = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Luminous_Intensity_Exp:
|
||||
luminiousExp = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Mass_EXP:
|
||||
massExp = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Physical_Dimension:
|
||||
physicalDimension = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.RecordType:
|
||||
break;
|
||||
case PhysicalDimensionFields.Remarks:
|
||||
remarks = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.S_GUID:
|
||||
sGUID = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.SortKey:
|
||||
sortKey = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.Temperature_EXP:
|
||||
temperatureExp = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Text_L1:
|
||||
textL1 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.Text_L2:
|
||||
textL2 = node.GetAttribute(field.ToString());
|
||||
break;
|
||||
case PhysicalDimensionFields.Time_EXP:
|
||||
timeExp = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case PhysicalDimensionFields.Version:
|
||||
version = long.Parse(node.GetAttribute(field.ToString()), System.Globalization.CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("ImportTestSetup::ImportCustomPhysicalDimension unsupported field: " + field.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
return new MMEPhysicalDimensions(sGUID, physicalDimension, textL1, textL2, defaultUnit, lengthExp, timeExp, massExp, currentExp, temperatureExp, luminiousExp, amountExp, version, date, remarks, expired, sortKey, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL);
|
||||
}
|
||||
|
||||
public MMEPhysicalDimensions(string sGUID, string physicalDimension, string textL1, string textL2, string defaultUnit,
|
||||
long lengthExp, long timeExp, long massExp, long currentExp, long temperatureExp, long luminiousExp, long amountExp,
|
||||
long version, DateTime date, string remarks, bool expired, string sortKey, DateTime lastChange, string lastChangeText,
|
||||
string history, MMEPossibleChannels.MMEChannelTypes type)
|
||||
{
|
||||
RecordType = type;
|
||||
S_GUID = sGUID;
|
||||
Physical_Dimension = physicalDimension;
|
||||
Text_L1 = textL1;
|
||||
Text_L2 = textL2;
|
||||
Default_Unit = defaultUnit;
|
||||
Length_EXP = lengthExp;
|
||||
Time_EXP = timeExp;
|
||||
Mass_EXP = massExp;
|
||||
Electric_Current_EXP = currentExp;
|
||||
Temperature_EXP = temperatureExp;
|
||||
Luminous_Intensity_Exp = luminiousExp;
|
||||
Amount_Of_Substance_EXP = amountExp;
|
||||
Version = version;
|
||||
Date = date;
|
||||
Remarks = remarks;
|
||||
Expired = expired;
|
||||
SortKey = sortKey;
|
||||
Last_Change = lastChange;
|
||||
Last_Change_Text = lastChangeText;
|
||||
History = history;
|
||||
}
|
||||
|
||||
public static MMEPhysicalDimensions[] GetPhysicalDimensions()
|
||||
{
|
||||
var physicalDimensions = new List<MMEPhysicalDimensions>();
|
||||
|
||||
using (var cmd = DbOperations.GetISOCommand())
|
||||
{
|
||||
cmd.CommandType = CommandType.Text;
|
||||
cmd.CommandText = "SELECT * FROM MMEPhysicalDimensions";
|
||||
try
|
||||
{
|
||||
using (var ISOReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (ISOReader.Read())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sGuid = ISOReader["s_GUID"].ToString();
|
||||
string physicalDimension = ISOReader["PHYSICAL_DIMENSION"].ToString();
|
||||
string textL1 = ISOReader["TEXT_L1"].ToString();
|
||||
string textL2 = ISOReader["TEXT_L2"].ToString();
|
||||
string defaultUnit = ISOReader["DEFAULT_UNIT"].ToString();
|
||||
long lengthExp = GetLong(ISOReader, "LENGTH_EXP");
|
||||
long timeExp = GetLong(ISOReader, "TIME_EXP");
|
||||
long massExp = GetLong(ISOReader, "MASS_EXP");
|
||||
long electricCurrentExp = GetLong(ISOReader, "ELECTRIC_CURRENT_EXP");
|
||||
long temperatureExp = GetLong(ISOReader, "TEMPERATURE_EXP");
|
||||
long luminiousExp = GetLong(ISOReader, "LUMINOUS_INTENSITY_EXP");
|
||||
long amountExp = GetLong(ISOReader, "AMOUNT_OF_SUBSTANCE_EXP");
|
||||
long version = GetLong(ISOReader, "VERSION");
|
||||
DateTime date = (DateTime)ISOReader["DATE"];
|
||||
string remarks = ISOReader["REMARKS"].ToString();
|
||||
bool expired = (bool)ISOReader["EXPIRED"];
|
||||
string sortkey = ISOReader["SORTKEY"].ToString();
|
||||
DateTime lastChange = GetDate(ISOReader, "LAST_CHANGE");
|
||||
string lastChangeText = ISOReader["LAST_CHANGE_TEXT"].ToString();
|
||||
string history = ISOReader["HISTORY"].ToString();
|
||||
|
||||
physicalDimensions.Add(new MMEPhysicalDimensions(sGuid, physicalDimension, textL1,
|
||||
textL2, defaultUnit, lengthExp,
|
||||
timeExp, massExp, electricCurrentExp, temperatureExp, luminiousExp, amountExp,
|
||||
version, date, remarks, expired, sortkey, lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process dimension", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
return physicalDimensions.ToArray();
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPhysicalDimensionsUpdateInsert.ToString();
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(S_GUID) });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@PHYSICAL_DIMENSION", SqlDbType.NVarChar, 50) { Value = Physical_Dimension });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L1", SqlDbType.NVarChar, 50) { Value = Text_L1 });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEXT_L2", SqlDbType.NVarChar, 50) { Value = Text_L2 });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@DEFAULT_UNIT", SqlDbType.NVarChar, 50) { Value = Default_Unit });
|
||||
cmd.Parameters.Add(new SqlParameter("@LENGTH_EXP", SqlDbType.Int) { Value = Length_EXP });
|
||||
cmd.Parameters.Add(new SqlParameter("@TIME_EXP", SqlDbType.Int) { Value = Time_EXP });
|
||||
cmd.Parameters.Add(new SqlParameter("@MASS_EXP", SqlDbType.Int) { Value = Mass_EXP });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@ELECTRIC_CURRENT_EXP", SqlDbType.Int) { Value = Electric_Current_EXP });
|
||||
cmd.Parameters.Add(new SqlParameter("@TEMPERATURE_EXP", SqlDbType.Int) { Value = Temperature_EXP });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LUMINOUS_INTENSITY_EXP", SqlDbType.Int) { Value = Luminous_Intensity_Exp });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@AMOUNT_OFSUBSTANCE_EXP", SqlDbType.Int) { Value = Amount_Of_Substance_EXP });
|
||||
cmd.Parameters.Add(new SqlParameter("@VERSION", SqlDbType.Int) { Value = Version });
|
||||
cmd.Parameters.Add(new SqlParameter("@DATE", SqlDbType.DateTime) { Value = Date });
|
||||
cmd.Parameters.Add(new SqlParameter("@REMARKS", SqlDbType.NVarChar, 50) { Value = Remarks });
|
||||
cmd.Parameters.Add(new SqlParameter("@EXPIRED", SqlDbType.Bit) { Value = Expired });
|
||||
cmd.Parameters.Add(new SqlParameter("@SORTKEY", SqlDbType.NVarChar, 50) { Value = SortKey });
|
||||
cmd.Parameters.Add(new SqlParameter("@LAST_CHANGE", SqlDbType.DateTime) { Value = Last_Change });
|
||||
cmd.Parameters.Add(
|
||||
new SqlParameter("@LAST_CHANGE_TEXT", SqlDbType.NVarChar, 50) { Value = Last_Change_Text });
|
||||
cmd.Parameters.Add(new SqlParameter("@HISTORY", SqlDbType.NVarChar, 50) { Value = History });
|
||||
var newIdParam = new SqlParameter("@new_id", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(newIdParam);
|
||||
var errorNumberParam =
|
||||
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam =
|
||||
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,83 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DTS.Common.ISO {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ISO.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap DTS_2C_Logo {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("DTS_2C_Logo", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap DTS_2C_web_small {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("DTS_2C_web_small", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.ISO
|
||||
{
|
||||
public class TestObjectMetaData
|
||||
{
|
||||
public static double Version { get; set; } = 1.06;
|
||||
public const string NOVALUE = "NOVALUE";
|
||||
|
||||
public void SetProperty(MetaData meta)
|
||||
{
|
||||
_properties[meta.Name] = meta;
|
||||
}
|
||||
public MetaData GetProperty(string name)
|
||||
{
|
||||
return _properties.ContainsKey(name) ? _properties[name] : new MetaData(name, true, NOVALUE, Version);
|
||||
}
|
||||
public string GetPropertyValue(CommentFields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public string GetPropertyValue(Fields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public string GetPropertyValue(OptionFields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public void SetPropertyValue(CommentFields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public void SetPropertyValue(Fields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public void SetPropertyValue(string field, string value)
|
||||
{
|
||||
GetProperty(field).Value = value;
|
||||
}
|
||||
public void SetPropertyValue(OptionFields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public enum CommentFields
|
||||
{
|
||||
Comment1,
|
||||
Comment2,
|
||||
Comment3,
|
||||
}
|
||||
public enum Fields
|
||||
{
|
||||
NameOfTestObject,
|
||||
VelocityOfTestObject,
|
||||
MassOfTestObject,
|
||||
DriverPositionObject,
|
||||
ImpactSideTestObject,
|
||||
TypeOfTestObject,
|
||||
ClassOfTestObject,
|
||||
CodeOfTestObject,
|
||||
RefNumberOfTestObject,
|
||||
TestObjectComments,
|
||||
VelocityMeasurementUnit,
|
||||
ExtraProperties
|
||||
}
|
||||
public enum OptionFields
|
||||
{
|
||||
Offset,
|
||||
BarrierWidth,
|
||||
BarrierHeight,
|
||||
YawAngle,
|
||||
ReferenceSystem,
|
||||
OriginX,
|
||||
OriginY,
|
||||
OriginZ,
|
||||
NumberOfLoadCells
|
||||
}
|
||||
private readonly Dictionary<string, MetaData> _properties = new Dictionary<string, MetaData>();
|
||||
|
||||
public TestObjectMetaData(char testobject, int testObjectNumber)
|
||||
{
|
||||
TestObject = testobject;
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
var optional = Enum.GetValues(typeof(OptionFields)).Cast<OptionFields>().ToArray();
|
||||
_properties.Add(CommentFields.Comment1.ToString(), new MetaData(CommentFields.Comment1.ToString(), false, string.Empty, Version));
|
||||
_properties.Add(CommentFields.Comment2.ToString(), new MetaData(CommentFields.Comment2.ToString(), false, $" The following block describes test object '{testobject}'", Version));
|
||||
_properties.Add(CommentFields.Comment3.ToString(), new MetaData(CommentFields.Comment3.ToString(), false, string.Empty, Version));
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.VelocityOfTestObject:
|
||||
case Fields.MassOfTestObject:
|
||||
case Fields.ImpactSideTestObject:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, string.Empty, Version));
|
||||
break;
|
||||
default:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var ofield in optional)
|
||||
{
|
||||
_properties.Add(ofield.ToString(), new MetaData(ofield.ToString(), true, NOVALUE, Version));
|
||||
}
|
||||
}
|
||||
public TestObjectMetaData(char testobject)
|
||||
{
|
||||
TestObject = testobject;
|
||||
var comments = Enum.GetValues(typeof(CommentFields)).Cast<CommentFields>().ToArray();
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
var optional = Enum.GetValues(typeof(OptionFields)).Cast<OptionFields>().ToArray();
|
||||
foreach (var cfield in comments) { _properties.Add(cfield.ToString(), new MetaData(cfield.ToString(), false, NOVALUE, Version)); }
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.VelocityOfTestObject:
|
||||
case Fields.MassOfTestObject:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, string.Empty, Version));
|
||||
break;
|
||||
default:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (var ofield in optional)
|
||||
{
|
||||
_properties.Add(ofield.ToString(), new MetaData(ofield.ToString(), true, NOVALUE, Version));
|
||||
}
|
||||
}
|
||||
public TestObjectMetaData(TestObjectMetaData copy)
|
||||
{
|
||||
TestObject = copy.TestObject;
|
||||
foreach (var p in copy._properties)
|
||||
{
|
||||
_properties.Add(p.Key, new MetaData(p.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public TestObjectMetaData(char newTestObject, TestObjectMetaData copy)
|
||||
{
|
||||
TestObject = newTestObject;
|
||||
foreach (var p in copy._properties)
|
||||
{
|
||||
_properties.Add(p.Key, new MetaData(p.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public char TestObject { get; } = '?';
|
||||
|
||||
public MetaData[] Properties => _properties.Values.ToArray();
|
||||
}
|
||||
public class MetaData
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public bool IsOptional { get; } = false;
|
||||
|
||||
public double Version { get; } = 1.06D;
|
||||
|
||||
public string Value { get; set; } = "NOVALUE";
|
||||
|
||||
public MetaData(string name, bool optional, string value, double version)
|
||||
{
|
||||
Name = name;
|
||||
IsOptional = optional;
|
||||
Value = value;
|
||||
Version = version;
|
||||
}
|
||||
public MetaData(MetaData copy)
|
||||
{
|
||||
Name = copy.Name;
|
||||
IsOptional = copy.IsOptional;
|
||||
Value = copy.Value;
|
||||
Version = copy.Version;
|
||||
}
|
||||
}
|
||||
public class TestSetupMetaData
|
||||
{
|
||||
public double Version { get; set; } = 1.06;
|
||||
public const string NOVALUE = "NOVALUE";
|
||||
public const string MEDIADEFAULT = "1/1";
|
||||
|
||||
public void SetProperty(MetaData meta, bool requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
switch (meta.Name)
|
||||
{
|
||||
case "LaboratoryName":
|
||||
case "LaboratoryContactName":
|
||||
case "LaboratoryTestReferenceNumber":
|
||||
case "CustomerName":
|
||||
case "CustomerTestReferenceNumber":
|
||||
if ((meta.Value == NOVALUE) && requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
meta.Value = string.Empty;
|
||||
}
|
||||
break;
|
||||
}
|
||||
_properties[meta.Name] = meta;
|
||||
}
|
||||
public MetaData GetProperty(string name)
|
||||
{
|
||||
if (_properties.ContainsKey(name)) { return _properties[name]; }
|
||||
else { return new MetaData(name, true, NOVALUE, Version); }
|
||||
}
|
||||
public string GetPropertyValue(Fields field)
|
||||
{
|
||||
return GetProperty(field.ToString()).Value;
|
||||
}
|
||||
public void SetPropertyValue(Fields field, string value)
|
||||
{
|
||||
GetProperty(field.ToString()).Value = value;
|
||||
}
|
||||
public enum Fields
|
||||
{
|
||||
LabName,
|
||||
LaboratoryContactName,
|
||||
LaboratoryContactPhone,
|
||||
LaboratoryContactFax,
|
||||
LaboratoryContactEmail,
|
||||
LaboratoryName,
|
||||
LaboratoryTestReferenceNumber,
|
||||
LaboratoryProjectReferenceNumber,
|
||||
|
||||
CustName,
|
||||
CustomerName,
|
||||
CustomerTestReferenceNumber,
|
||||
CustomerProjectReferenceNumber,
|
||||
CustomerOrderNumber,
|
||||
CustomerCostUnit,
|
||||
|
||||
TEName,
|
||||
TestEngineerName,
|
||||
TestEngineerPhone,
|
||||
TestEngineerFax,
|
||||
TestEngineerEmail,
|
||||
|
||||
Title,
|
||||
MediumNoNumberOfMedia,
|
||||
TestComment,
|
||||
TypeOfTheTest,
|
||||
ReferenceTemperature,
|
||||
RelativeAirHumidity,
|
||||
Regulation,
|
||||
Subtype,
|
||||
DateOfTheTest
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, MetaData> _properties = new Dictionary<string, MetaData>();
|
||||
public TestSetupMetaData(bool requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
TestObject = '_';
|
||||
var fields = Enum.GetValues(typeof(Fields)).Cast<Fields>().ToArray();
|
||||
foreach (var field in fields)
|
||||
{
|
||||
switch (field)
|
||||
{
|
||||
case Fields.MediumNoNumberOfMedia:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, MEDIADEFAULT, Version));
|
||||
break;
|
||||
case Fields.LaboratoryName:
|
||||
case Fields.LaboratoryContactName:
|
||||
case Fields.LaboratoryTestReferenceNumber:
|
||||
case Fields.CustomerName:
|
||||
case Fields.CustomerTestReferenceNumber:
|
||||
if (requireXCrashCompatibilityForISOExports)
|
||||
{
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, string.Empty, Version));
|
||||
}
|
||||
else
|
||||
{
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_properties.Add(field.ToString(), new MetaData(field.ToString(), false, NOVALUE, Version));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
_properties.Clear();
|
||||
}
|
||||
public TestSetupMetaData(TestSetupMetaData copy)
|
||||
{
|
||||
TestObject = copy.TestObject;
|
||||
foreach (var p in copy._properties)
|
||||
{
|
||||
_properties.Add(p.Key, new MetaData(p.Value));
|
||||
}
|
||||
}
|
||||
|
||||
public char TestObject { get; } = '_';
|
||||
|
||||
public MetaData[] Properties => _properties.Values.ToArray();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
BIN
Common/DTS.Common.ISO/.svn/wc.db
Normal file
BIN
Common/DTS.Common.ISO/.svn/wc.db
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user