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