220 lines
12 KiB
C#
220 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Data.OleDb;
|
|
|
|
namespace DatabaseExport
|
|
{
|
|
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; }
|
|
|
|
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 MMETransducerMainLocation[] GetTransducerMainLocations()
|
|
{
|
|
var transducerMainLocations = new List<MMETransducerMainLocation>();
|
|
try
|
|
{
|
|
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)
|
|
{
|
|
//ignore
|
|
}
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
cmd.Connection.Dispose();
|
|
}
|
|
}
|
|
try
|
|
{
|
|
using (var cmd = DbOperations.GetCommand())
|
|
{
|
|
try
|
|
{
|
|
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.MMETables.MMEMainLocationTable);
|
|
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
|
{
|
|
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
var fields = Enum.GetValues(typeof(DbOperations.MMETables.MMEMainLocationsFields))
|
|
.Cast<DbOperations.MMETables.MMEMainLocationsFields>().ToArray();
|
|
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
|
{
|
|
var date = DateTime.Now;
|
|
var expired = false;
|
|
var history = "";
|
|
var lastChange = DateTime.Now;
|
|
var lastChangeText = "";
|
|
var pictureShortName = "";
|
|
var remarks = "";
|
|
var guid = "";
|
|
var sortkey = "";
|
|
var text1 = "";
|
|
var text2 = "";
|
|
var mainLoc = "????";
|
|
var type = "";
|
|
var version = 0;
|
|
foreach (var field in fields)
|
|
{
|
|
try
|
|
{
|
|
var o = dr[field.ToString()];
|
|
if (DBNull.Value.Equals(o)) { continue; }
|
|
|
|
switch (field)
|
|
{
|
|
case DbOperations.MMETables.MMEMainLocationsFields.DATE:
|
|
date = Convert.ToDateTime(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.EXPIRED:
|
|
expired = Convert.ToBoolean(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.HISTORY:
|
|
history = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE:
|
|
lastChange = Convert.ToDateTime(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE_TEXT:
|
|
lastChangeText = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.PICTURE_SHORTNAME:
|
|
pictureShortName = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.REMARKS:
|
|
remarks = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.s_GUID:
|
|
guid = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.SORTKEY:
|
|
sortkey = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.TEXT_L1:
|
|
text1 = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.TEXT_L2:
|
|
text2 = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.TRANS_MAIN_LOC:
|
|
mainLoc = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.TYPE:
|
|
type = Convert.ToString(o);
|
|
break;
|
|
case DbOperations.MMETables.MMEMainLocationsFields.VERSION:
|
|
version = Convert.ToInt32(o);
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//ignore
|
|
}
|
|
}
|
|
transducerMainLocations.Add(new MMETransducerMainLocation(guid.ToString(), type, mainLoc, text1, text2, Convert.ToInt64(version),
|
|
date, remarks, expired, sortkey, pictureShortName, lastChange, lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
cmd.Connection.Dispose();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//ignore
|
|
}
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//ignore
|
|
}
|
|
return transducerMainLocations.ToArray();
|
|
}
|
|
}
|
|
}
|