init
This commit is contained in:
@@ -0,0 +1,273 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
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;
|
||||
|
||||
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>();
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * FROM {0}", DbOperations.MMETables.MMEPhysicalDimensions);
|
||||
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.MMEPhysicalDimensionFields))
|
||||
.Cast<DbOperations.MMETables.MMEPhysicalDimensionFields>().ToArray();
|
||||
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
var version = 0;
|
||||
var timeExp = 0;
|
||||
var text2 = "";
|
||||
var text1 = "";
|
||||
var tempExp = 0;
|
||||
var sortKey = "";
|
||||
var sGuid = "";
|
||||
var remarks = "";
|
||||
var physicalDimension = "??";
|
||||
var massExp = 0;
|
||||
var lumIntExp = 0;
|
||||
var lengthExp = 0;
|
||||
var lastChangeText = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var history = "";
|
||||
var expired = false;
|
||||
var electricalExp = 0;
|
||||
var defaultUnit = "";
|
||||
var date = DateTime.Now;
|
||||
var amountOfSubstanceExp = 0;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()])) { continue; }
|
||||
var o = dr[field.ToString()];
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.AMOUNT_OFSUBSTANCE_EXP:
|
||||
amountOfSubstanceExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.DATE:
|
||||
date = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.DEFAULT_UNIT:
|
||||
defaultUnit = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.ELECTRIC_CURRENT_EXP:
|
||||
electricalExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.HISTORY:
|
||||
history = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LENGTH_EXP:
|
||||
lengthExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.LUMINOUS_INTENSITY_EXP:
|
||||
lumIntExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.MASS_EXP:
|
||||
massExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.PHYSICAL_DIMENSION:
|
||||
physicalDimension = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.REMARKS:
|
||||
remarks = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.s_GUID:
|
||||
sGuid = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.SORTKEY:
|
||||
sortKey = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TEMPERATURE_EXP:
|
||||
tempExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L1:
|
||||
text1 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L2:
|
||||
text2 = Convert.ToString(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.TIME_EXP:
|
||||
timeExp = Convert.ToInt32(o);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEPhysicalDimensionFields.VERSION:
|
||||
version = Convert.ToInt32(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
physicalDimensions.Add(new MMEPhysicalDimensions(sGuid.ToString(), physicalDimension, text1, text2, defaultUnit, Convert.ToInt64(lengthExp),
|
||||
Convert.ToInt64(timeExp), Convert.ToInt64(massExp), Convert.ToInt64(electricalExp), Convert.ToInt64(tempExp), Convert.ToInt64(lumIntExp),
|
||||
Convert.ToInt64(amountOfSubstanceExp), Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange, lastChangeText,
|
||||
history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return physicalDimensions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user