init
This commit is contained in:
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
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 void DeleteTransducerMainLocations()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsDelete.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 main locations, ", ex); */}
|
||||
}
|
||||
public static MMETransducerMainLocation[] GetTransducerMainLocations()
|
||||
{
|
||||
var transducerMainLocations = new List<MMETransducerMainLocation>();
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsGet.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
|
||||
{
|
||||
transducerMainLocations.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let pictureShortName = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.PICTURE_SHORTNAME.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.REMARKS.ToString()])
|
||||
let guid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.s_GUID.ToString()])
|
||||
let sortkey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L2.ToString()])
|
||||
let mainLoc = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.TRANS_MAIN_LOC.ToString()])
|
||||
let type = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TYPE.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.VERSION.ToString()])
|
||||
select new MMETransducerMainLocation(guid, type, mainLoc, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortkey, pictureShortName,
|
||||
lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.ISO13499_106));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process main locations: ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve main locations, ", ex);*/ }
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = DbOperations.GetSQLCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = DbOperationsEnum.StoredProcedure.sp_MMEMainLocationsGetCustom.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
|
||||
{
|
||||
transducerMainLocations.AddRange(from DataRow dr in ds.Tables[0].Rows
|
||||
let date = Convert.ToDateTime(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.DATE.ToString()])
|
||||
let expired = Convert.ToBoolean(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.EXPIRED.ToString()])
|
||||
let history = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.HISTORY.ToString()])
|
||||
let lastChange = Convert.ToDateTime(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE.ToString()])
|
||||
let lastChangeText = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.LAST_CHANGE_TEXT.ToString()])
|
||||
let pictureShortName = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.PICTURE_SHORTNAME.ToString()])
|
||||
let remarks = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.REMARKS.ToString()])
|
||||
let guid = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.s_GUID.ToString()])
|
||||
let sortkey = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.SORTKEY.ToString()])
|
||||
let text1 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L1.ToString()])
|
||||
let text2 = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TEXT_L2.ToString()])
|
||||
let mainLoc = Convert.ToString(dr[
|
||||
DbOperations.MMETables.MMEMainLocationsFields.TRANS_MAIN_LOC.ToString()])
|
||||
let type = Convert.ToString(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.TYPE.ToString()])
|
||||
let version = Convert.ToInt32(
|
||||
dr[DbOperations.MMETables.MMEMainLocationsFields.VERSION.ToString()])
|
||||
select new MMETransducerMainLocation(guid, type, mainLoc, text1, text2,
|
||||
Convert.ToInt64(version), date, remarks, expired, sortkey, pictureShortName,
|
||||
lastChange, lastChangeText, history,
|
||||
MMEPossibleChannels.MMEChannelTypes.SQL));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//APILogger.Log("Failed to process custom main locations: ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { /*APILogger.Log("failed to retrieve custom main locations, ", ex); */}
|
||||
|
||||
return transducerMainLocations.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user