init
This commit is contained in:
@@ -0,0 +1,293 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 void DeletePhysicalDimensions()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPhysicalDimensionsDelete.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 physical dimensions", ex);*/ }
|
||||
}
|
||||
public static MMEPhysicalDimensions[] GetPhysicalDimensions()
|
||||
{
|
||||
var physicalDimensions = new List<MMEPhysicalDimensions>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPhysicalDimensionsGet.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
|
||||
{
|
||||
physicalDimensions.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let amountOfSubstanceExp = Convert.ToInt32(
|
||||
dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.AMOUNT_OFSUBSTANCE_EXP
|
||||
.ToString()])
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPhysicalDimensionFields.DATE.ToString()])
|
||||
let defaultUnit = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.DEFAULT_UNIT.ToString()])
|
||||
let electricalExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.ELECTRIC_CURRENT_EXP
|
||||
.ToString()])
|
||||
let expired = Convert.ToBoolean(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE_TEXT
|
||||
.ToString()])
|
||||
let lengthExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LENGTH_EXP.ToString()])
|
||||
let lumIntExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LUMINOUS_INTENSITY_EXP
|
||||
.ToString()])
|
||||
let massExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.MASS_EXP.ToString()])
|
||||
let physicalDimension = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.PHYSICAL_DIMENSION
|
||||
.ToString()])
|
||||
let remarks = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.SORTKEY.ToString()])
|
||||
let tempExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEMPERATURE_EXP
|
||||
.ToString()])
|
||||
let text1 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L2.ToString()])
|
||||
let timeExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TIME_EXP.ToString()])
|
||||
let version = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.VERSION.ToString()])
|
||||
select new MMEPhysicalDimensions(sGuid, 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.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to parse physical dimensions: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve physical dimensions", ex);*/ }
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEPhysicalDimensionsGetCustom.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
|
||||
{
|
||||
physicalDimensions.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let amountOfSubstanceExp = Convert.ToInt32(
|
||||
dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.AMOUNT_OFSUBSTANCE_EXP
|
||||
.ToString()])
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEPhysicalDimensionFields.DATE.ToString()])
|
||||
let defaultUnit = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.DEFAULT_UNIT.ToString()])
|
||||
let electricalExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.ELECTRIC_CURRENT_EXP
|
||||
.ToString()])
|
||||
let expired = Convert.ToBoolean(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LAST_CHANGE_TEXT
|
||||
.ToString()])
|
||||
let lengthExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LENGTH_EXP.ToString()])
|
||||
let lumIntExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.LUMINOUS_INTENSITY_EXP
|
||||
.ToString()])
|
||||
let massExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.MASS_EXP.ToString()])
|
||||
let physicalDimension = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.PHYSICAL_DIMENSION
|
||||
.ToString()])
|
||||
let remarks = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.REMARKS.ToString()])
|
||||
let sGuid = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.s_GUID.ToString()])
|
||||
let sortKey = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.SORTKEY.ToString()])
|
||||
let tempExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEMPERATURE_EXP
|
||||
.ToString()])
|
||||
let text1 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TEXT_L2.ToString()])
|
||||
let timeExp = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.TIME_EXP.ToString()])
|
||||
let version = Convert.ToInt32(dr[
|
||||
DbOperations.MMETables.MMEPhysicalDimensionFields.VERSION.ToString()])
|
||||
select new MMEPhysicalDimensions(sGuid, 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));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to parse custom physical dimensions: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve custom physical dimensions", ex); */}
|
||||
|
||||
return physicalDimensions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user