init
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.OleDb;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
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; }
|
||||
|
||||
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>();
|
||||
try
|
||||
{
|
||||
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 )
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
||||
ISOReader.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = string.Format("SELECT * from {0}", DbOperations.MMETables.MMEDirectionsTable);
|
||||
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.MMEDirectionsFields)).Cast<DbOperations.MMETables.MMEDirectionsFields>().ToArray();
|
||||
foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
|
||||
var date = DateTime.Now;
|
||||
var direction = "?";
|
||||
var expired = false;
|
||||
var history = "";
|
||||
var lastChange = DateTime.Now;
|
||||
var lastChangeText = "";
|
||||
var remarks = "";
|
||||
var sGuid = "";
|
||||
var sortKey = "";
|
||||
var text1 = "";
|
||||
var text2 = "";
|
||||
var version = 0;
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DBNull.Value.Equals(dr[field.ToString()])) { continue; }
|
||||
switch (field)
|
||||
{
|
||||
case DbOperations.MMETables.MMEDirectionsFields.VERSION:
|
||||
version = Convert.ToInt32(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.TEXT_L2:
|
||||
text2 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.TEXT_L1:
|
||||
text1 = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.SORTKEY:
|
||||
sortKey = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.s_GUID:
|
||||
sGuid = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.REMARKS:
|
||||
remarks = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE_TEXT:
|
||||
lastChangeText = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.LAST_CHANGE:
|
||||
lastChange = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.HISTORY:
|
||||
history = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.EXPIRED:
|
||||
expired = Convert.ToBoolean(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.DIRECTION:
|
||||
direction = Convert.ToString(dr[field.ToString()]);
|
||||
break;
|
||||
case DbOperations.MMETables.MMEDirectionsFields.DATE:
|
||||
date = Convert.ToDateTime(dr[field.ToString()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
directions.Add(new MMEDirections(sGuid.ToString(), direction, text1, text2, date, Convert.ToInt64(version),
|
||||
expired, remarks, lastChange, lastChangeText, history, sortKey, MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
return directions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user