172 lines
7.4 KiB
C#
172 lines
7.4 KiB
C#
|
|
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();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|