123 lines
4.2 KiB
C#
123 lines
4.2 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
public class MessageCore : IDatabaseEntity
|
|
{
|
|
private Guid id;
|
|
private Guid? previous;
|
|
private Guid? next;
|
|
|
|
private Guid? customerId;
|
|
private int? wetris_zz_56_datensatz_id;
|
|
|
|
#region Properties
|
|
|
|
public Guid? Id { get { return this.id; } }
|
|
|
|
public string VisitId { get; set; }
|
|
|
|
public string TransitId { get; set; }
|
|
|
|
public string IMO { get; set; }
|
|
|
|
public string ENI { get; set; }
|
|
|
|
public string PoC { get; set; }
|
|
|
|
public string Portname { get; set; }
|
|
|
|
public DateTime ETA { get; set; }
|
|
|
|
public bool IsTransit { get; set; }
|
|
|
|
public Message.BSMDStatus BSMDStatus { get; set; }
|
|
|
|
public Message.NSWProvider InitialHIS { get; set; }
|
|
|
|
#endregion
|
|
|
|
|
|
public bool IsNew
|
|
{
|
|
get { return !this.Id.HasValue; }
|
|
}
|
|
|
|
public void PrepareSave(IDbCommand cmd)
|
|
{
|
|
if (this.IsNew)
|
|
{
|
|
string query = "INSERT INTO [MessageCore] (VisitId, TransitId, IMO, ENI, PoC, Portname, ETA, CustomerId, " +
|
|
"Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS) VALUES " +
|
|
"(@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14)";
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public void PrepareDelete(IDbCommand cmd)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = "SELECT Id, VisitId, TransitId, IMO, ENI, PoC, Portname, " +
|
|
"ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS FROM [MessageCore] ";
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.WETRIS_SHIP_ID:
|
|
{
|
|
query += "WHERE Wetris_zz_56_datensatz_id = @WETRIS";
|
|
((SqlCommand)cmd).Parameters.AddWithValue("WETRIS", criteria[0]);
|
|
break;
|
|
}
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
break;
|
|
}
|
|
|
|
cmd.CommandText = query;
|
|
}
|
|
|
|
public List<IDatabaseEntity> LoadList(IDataReader reader)
|
|
{
|
|
List<IDatabaseEntity> result = new List<IDatabaseEntity>();
|
|
while(reader.Read())
|
|
{
|
|
MessageCore core = new MessageCore();
|
|
core.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) core.VisitId = reader.GetString(1);
|
|
if (!reader.IsDBNull(2)) core.TransitId = reader.GetString(2);
|
|
if (!reader.IsDBNull(3)) core.IMO = reader.GetString(3);
|
|
if (!reader.IsDBNull(4)) core.ENI = reader.GetString(4);
|
|
if (!reader.IsDBNull(5)) core.PoC = reader.GetString(5);
|
|
if (!reader.IsDBNull(6)) core.Portname = reader.GetString(6);
|
|
if (!reader.IsDBNull(7)) core.ETA = reader.GetDateTime(7);
|
|
if (!reader.IsDBNull(8)) core.customerId = reader.GetGuid(8);
|
|
if (!reader.IsDBNull(9)) core.previous = reader.GetGuid(9);
|
|
if (!reader.IsDBNull(10)) core.next = reader.GetGuid(10);
|
|
core.IsTransit = reader.GetBoolean(11);
|
|
if (!reader.IsDBNull(12)) core.wetris_zz_56_datensatz_id = reader.GetInt32(12);
|
|
core.BSMDStatus = (Message.BSMDStatus) Enum.ToObject(typeof(Message.BSMDStatus), reader.GetByte(13));
|
|
core.InitialHIS = (Message.NSWProvider) Enum.ToObject(typeof(Message.NSWProvider), reader.GetByte(14));
|
|
|
|
result.Add(core);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
}
|
|
}
|