216 lines
12 KiB
C#
216 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace DatabaseImport
|
|
{
|
|
public class MMEFineLocations1 //: AbstractOLEDbWrapper
|
|
{
|
|
public string S_GUID { get; }
|
|
|
|
public string Fine_Loc_1 { 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;
|
|
public MMEFineLocations1(string sGuid, string fineLoc1, 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_1 = fineLoc1;
|
|
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 void DeleteFineLocations1()
|
|
{
|
|
try
|
|
{
|
|
using (var cmd = DbOperations.GetSQLCommand(true))
|
|
{
|
|
try
|
|
{
|
|
cmd.CommandType = CommandType.StoredProcedure;
|
|
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations1Delete.ToString();
|
|
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.UniqueIdentifier) { Value = null });
|
|
var errorNumberParam =
|
|
new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
|
cmd.Parameters.Add(errorNumberParam);
|
|
var errorMessageParam =
|
|
new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
|
{
|
|
Direction = ParameterDirection.Output
|
|
};
|
|
cmd.Parameters.Add(errorMessageParam);
|
|
|
|
cmd.ExecuteNonQuery();
|
|
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
|
{
|
|
//errorMessageParam.Value
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
cmd.Connection.Dispose();
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception) { /*APILogger.Log("failed to delete fine locations1, ", ex); */}
|
|
}
|
|
public static MMEFineLocations1[] GetFineLocations1()
|
|
{
|
|
var fineLocations1 = new List<MMEFineLocations1>();
|
|
|
|
try
|
|
{
|
|
using (var cmd = DbOperations.GetSQLCommand(true))
|
|
{
|
|
try
|
|
{
|
|
cmd.CommandType = CommandType.StoredProcedure;
|
|
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations1Get.ToString();
|
|
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
|
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
|
{
|
|
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
fineLocations1.AddRange(from DataRow dr in ds.Tables[0].Rows
|
|
let date = Convert.ToDateTime(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.DATE.ToString()])
|
|
let expired = Convert.ToBoolean(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.EXPIRED.ToString()])
|
|
let fineLoc1 = Convert.ToString(dr[
|
|
DbOperations.MMETables.MMEFineLocations1Fields.FINE_LOC_1.ToString()])
|
|
let history = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.HISTORY.ToString()])
|
|
let lastChange = Convert.ToDateTime(dr[
|
|
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE.ToString()])
|
|
let lastChangeText = Convert.ToString(dr[
|
|
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE_TEXT.ToString()])
|
|
let remarks = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.REMARKS.ToString()])
|
|
let sGuid = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.s_GUID.ToString()])
|
|
let sortKey = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.SORTKEY.ToString()])
|
|
let text1 = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L1.ToString()])
|
|
let text2 = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L2.ToString()])
|
|
let version = Convert.ToInt32(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.VERSION.ToString()])
|
|
select new MMEFineLocations1(sGuid, fineLoc1, text1, text2,
|
|
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
|
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//APILogger.Log("Failed to parse fine locations1:", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
cmd.Connection.Dispose();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { /*APILogger.Log("failed to retrieve fine locations1, ", ex);*/ }
|
|
|
|
try
|
|
{
|
|
using (var cmd = DbOperations.GetSQLCommand(true))
|
|
{
|
|
try
|
|
{
|
|
cmd.CommandType = CommandType.StoredProcedure;
|
|
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEFineLocations1GetCustom.ToString();
|
|
cmd.Parameters.Add(new SqlParameter("@s_GUID", SqlDbType.NVarChar) { Value = null });
|
|
using (var ds = DbOperations.Connection.QueryDataSet(cmd))
|
|
{
|
|
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
try
|
|
{
|
|
fineLocations1.AddRange(from DataRow dr in ds.Tables[0].Rows
|
|
let date = Convert.ToDateTime(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.DATE.ToString()])
|
|
let expired = Convert.ToBoolean(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.EXPIRED.ToString()])
|
|
let fineLoc1 = Convert.ToString(dr[
|
|
DbOperations.MMETables.MMEFineLocations1Fields.FINE_LOC_1.ToString()])
|
|
let history = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.HISTORY.ToString()])
|
|
let lastChange = Convert.ToDateTime(dr[
|
|
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE.ToString()])
|
|
let lastChangeText = Convert.ToString(dr[
|
|
DbOperations.MMETables.MMEFineLocations1Fields.LAST_CHANGE_TEXT.ToString()])
|
|
let remarks = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.REMARKS.ToString()])
|
|
let sGuid = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.s_GUID.ToString()])
|
|
let sortKey = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.SORTKEY.ToString()])
|
|
let text1 = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L1.ToString()])
|
|
let text2 = Convert.ToString(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.TEXT_L2.ToString()])
|
|
let version = Convert.ToInt32(
|
|
dr[DbOperations.MMETables.MMEFineLocations1Fields.VERSION.ToString()])
|
|
select new MMEFineLocations1(sGuid, fineLoc1, text1, text2,
|
|
Convert.ToInt64(version), date, remarks, expired, sortKey, lastChange,
|
|
lastChangeText, history, MMEPossibleChannels.MMEChannelTypes.SQL));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
//APILogger.Log("Failed to parse custom fine locations1:", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
cmd.Connection.Dispose();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { /*APILogger.Log("failed to retrieve custom fine locations1, ", ex);*/ }
|
|
|
|
return fineLocations1.ToArray();
|
|
}
|
|
}
|
|
}
|