Laden und Speichern DB in Arbeit
This commit is contained in:
parent
62c97b6f4b
commit
4c829e3d30
Binary file not shown.
40
nsw/Source/SendNSWMessageService.sln
Normal file
40
nsw/Source/SendNSWMessageService.sln
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.21005.1
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendNSWMessageService", "SendNSWMessageService\SendNSWMessageService.csproj", "{E6F8F110-77E7-4348-9875-CAD095BF8E24}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.dbh", "bsmd.dbh\bsmd.dbh.csproj", "{DF625FF0-2265-4686-9CB6-2A8511CB3B9D}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.database", "bsmd.database\bsmd.database.csproj", "{19945AF2-379B-46A5-B27A-303B5EC1D557}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.dakosy", "bsmd.dakosy\bsmd.dakosy.csproj", "{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{E6F8F110-77E7-4348-9875-CAD095BF8E24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E6F8F110-77E7-4348-9875-CAD095BF8E24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E6F8F110-77E7-4348-9875-CAD095BF8E24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E6F8F110-77E7-4348-9875-CAD095BF8E24}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@ -65,44 +65,47 @@ namespace SendNSWMessageService
|
|||||||
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
|
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
|
||||||
{
|
{
|
||||||
|
|
||||||
// Datenbank auf zu sendende Objekte überprüfen und laden
|
// Datenbank auf zu sendende Objekte überprüfen und laden
|
||||||
|
|
||||||
|
List<Message> messagesToSendList = DBManager.Instance.GetToSendMessageList();
|
||||||
|
|
||||||
// "Core"-Messages sind Erst-Anmeldungen (für VISIT/TRANSIT Id) am NSW
|
foreach (Message message in messagesToSendList)
|
||||||
List<MessageCore> toSendList = DBManager.Instance.GetToSendMessageCoreList();
|
|
||||||
|
|
||||||
|
|
||||||
foreach (MessageCore aMessageCore in toSendList)
|
|
||||||
{
|
{
|
||||||
string message = string.Format("Sending CORE message for {0} application to {1}",
|
try
|
||||||
aMessageCore.IsTransit ? "TRANSIT" : "VISIT", aMessageCore.InitialHIS.ToString());
|
|
||||||
_log.Info(message);
|
|
||||||
|
|
||||||
// switch über passendes HIS / Schnittstelle
|
|
||||||
switch (aMessageCore.InitialHIS)
|
|
||||||
{
|
{
|
||||||
case Message.NSWProvider.DBH:
|
_log.InfoFormat("Sending CORE message for {0} application to {1}",
|
||||||
//bsmd.dbh.Request.SendMessage()
|
message.MessageCore.IsTransit ? "TRANSIT" : "VISIT", message.MessageCore.InitialHIS.ToString());
|
||||||
|
|
||||||
break;
|
// switch über passendes HIS / Schnittstelle
|
||||||
case Message.NSWProvider.DAKOSY:
|
switch (message.MessageCore.InitialHIS)
|
||||||
|
{
|
||||||
|
case Message.NSWProvider.DBH:
|
||||||
|
bsmd.dbh.Request.SendMessage(message);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case Message.NSWProvider.DAKOSY:
|
||||||
|
|
||||||
case Message.NSWProvider.DUDR:
|
break;
|
||||||
|
|
||||||
break;
|
case Message.NSWProvider.DUDR:
|
||||||
default:
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// senden
|
||||||
|
|
||||||
|
// ..
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
// senden
|
{
|
||||||
|
_log.ErrorFormat("SENDING message {0}: {1}", message.ToString(), ex.Message);
|
||||||
// ..
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBManager.Instance.Disconnect();
|
DBManager.Instance.Disconnect();
|
||||||
|
|||||||
4
nsw/Source/SendNSWMessageService/packages.config
Normal file
4
nsw/Source/SendNSWMessageService/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="log4net" version="2.0.3" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
4
nsw/Source/bsmd.dakosy/packages.config
Normal file
4
nsw/Source/bsmd.dakosy/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="log4net" version="2.0.3" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
197
nsw/Source/bsmd.database/DBManager.cs
Normal file
197
nsw/Source/bsmd.database/DBManager.cs
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
//
|
||||||
|
// Class: DBManager
|
||||||
|
// Current CLR: 4.0.30319.34209
|
||||||
|
// System: Microsoft Visual Studio 10.0
|
||||||
|
// Author: dani
|
||||||
|
// Created: 3/10/2015 7:25:55 AM
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using log4net;
|
||||||
|
|
||||||
|
namespace bsmd.database
|
||||||
|
{
|
||||||
|
public class DBManager
|
||||||
|
{
|
||||||
|
private SqlConnection _con;
|
||||||
|
private static DBManager _instance;
|
||||||
|
private ILog _log = LogManager.GetLogger(typeof(DBManager));
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public static DBManager Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_instance == null)
|
||||||
|
_instance = new DBManager();
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ConnectionString { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public DB funcs
|
||||||
|
|
||||||
|
public bool Connect(string dbConnectionString)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_con = new SqlConnection(dbConnectionString);
|
||||||
|
_con.Open();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.Error("DBManager cannot connect", ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Disconnect()
|
||||||
|
{
|
||||||
|
if ((this._con != null) && (this._con.State == ConnectionState.Open))
|
||||||
|
this._con.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public helper funcs
|
||||||
|
|
||||||
|
public Dictionary<Guid, MessageCore> GetToSendMessageCoreList()
|
||||||
|
{
|
||||||
|
MessageCore aMessageCore = new MessageCore();
|
||||||
|
SqlCommand cmd = new SqlCommand();
|
||||||
|
Message.LoadFilter filter = Message.LoadFilter.BSMDSTATUS;
|
||||||
|
aMessageCore.PrepareLoadCommand(cmd, filter, Message.BSMDStatus.TOSEND);
|
||||||
|
|
||||||
|
SqlDataReader reader = this.PerformCommand(cmd);
|
||||||
|
List<DatabaseEntity> cores = aMessageCore.LoadList(reader);
|
||||||
|
Dictionary<Guid, MessageCore> result = new Dictionary<Guid, MessageCore>();
|
||||||
|
foreach (MessageCore core in cores)
|
||||||
|
result.Add(core.Id.Value, core);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Message> GetToSendMessageList()
|
||||||
|
{
|
||||||
|
Message aMessage = new Message();
|
||||||
|
SqlCommand cmd = new SqlCommand();
|
||||||
|
Message.LoadFilter filter = Message.LoadFilter.BSMDSTATUS;
|
||||||
|
aMessage.PrepareLoadCommand(cmd, filter, Message.BSMDStatus.TOSEND);
|
||||||
|
|
||||||
|
SqlDataReader reader = this.PerformCommand(cmd);
|
||||||
|
List<DatabaseEntity> messages = aMessage.LoadList(reader);
|
||||||
|
List<Message> result = new List<Message>();
|
||||||
|
foreach (Message message in messages)
|
||||||
|
result.Add(message);
|
||||||
|
|
||||||
|
this.LoadMessageDependencies(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<Guid, ReportingParty> GetReportingPartyDict()
|
||||||
|
{
|
||||||
|
ReportingParty aRep = new ReportingParty();
|
||||||
|
SqlCommand cmd = new SqlCommand();
|
||||||
|
aRep.PrepareLoadCommand(cmd, Message.LoadFilter.ALL);
|
||||||
|
|
||||||
|
SqlDataReader reader = this.PerformCommand(cmd);
|
||||||
|
List<DatabaseEntity> reportingParties = aRep.LoadList(reader);
|
||||||
|
Dictionary<Guid, ReportingParty> result = new Dictionary<Guid, ReportingParty>();
|
||||||
|
foreach (ReportingParty rp in reportingParties)
|
||||||
|
result.Add(rp.Id.Value, rp);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region internal/private funcs
|
||||||
|
|
||||||
|
internal void LoadMessageDependencies(List<Message> messageList)
|
||||||
|
{
|
||||||
|
Dictionary<Guid, MessageCore> messageCoreDict = this.GetToSendMessageCoreList();
|
||||||
|
Dictionary<Guid, ReportingParty> reportingPartyDict = this.GetReportingPartyDict();
|
||||||
|
|
||||||
|
// Zuordnung MessageCore,Zuordnung Reporting party
|
||||||
|
Message.AssignReportingParties(messageList, reportingPartyDict);
|
||||||
|
Message.AssignMessageCores(messageList, messageCoreDict);
|
||||||
|
|
||||||
|
foreach (Message message in messageList)
|
||||||
|
{
|
||||||
|
this.LoadErrorList(message);
|
||||||
|
this.LoadViolationList(message);
|
||||||
|
|
||||||
|
SqlCommand cmd = new SqlCommand();
|
||||||
|
|
||||||
|
switch(message.MessageNotificationClass)
|
||||||
|
{
|
||||||
|
case Message.NotificationClass.STAT:
|
||||||
|
STAT stat = new STAT();
|
||||||
|
stat.PrepareLoadCommand(cmd, Message.LoadFilter.MESSAGEHEADER, message.Id);
|
||||||
|
SqlDataReader reader = this.PerformCommand(cmd);
|
||||||
|
List<DatabaseEntity> statList = stat.LoadList(reader);
|
||||||
|
if (statList.Count > 0)
|
||||||
|
message.DerivedMessage = statList[0];
|
||||||
|
((STAT)statList[0]).MessageHeader = message;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void LoadErrorList(Message message)
|
||||||
|
{
|
||||||
|
MessageError aMessageError = new MessageError();
|
||||||
|
SqlCommand cmd = new SqlCommand();
|
||||||
|
aMessageError.PrepareLoadCommand(cmd, Message.LoadFilter.MESSAGEHEADER, message.Id);
|
||||||
|
SqlDataReader reader = this.PerformCommand(cmd);
|
||||||
|
List<DatabaseEntity> errorList = aMessageError.LoadList(reader);
|
||||||
|
foreach (MessageError error in errorList)
|
||||||
|
message.ErrorList.Add(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void LoadViolationList(Message message)
|
||||||
|
{
|
||||||
|
MessageViolation aMessageViolation = new MessageViolation();
|
||||||
|
SqlCommand cmd = new SqlCommand();
|
||||||
|
aMessageViolation.PrepareLoadCommand(cmd, Message.LoadFilter.MESSAGEHEADER, message.Id);
|
||||||
|
SqlDataReader reader = this.PerformCommand(cmd);
|
||||||
|
List<DatabaseEntity> violationList = aMessageViolation.LoadList(reader);
|
||||||
|
foreach (MessageViolation violation in violationList)
|
||||||
|
message.ViolationList.Add(violation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal SqlDataReader PerformCommand(SqlCommand cmd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cmd.Connection = this._con;
|
||||||
|
SqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
return reader;
|
||||||
|
}
|
||||||
|
catch (SqlException ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Trace.WriteLine("SQL Exception:" + ex.Message);
|
||||||
|
_log.Error("Error performing command", ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
52
nsw/Source/bsmd.database/DatabaseEntity.cs
Normal file
52
nsw/Source/bsmd.database/DatabaseEntity.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// Class: IDatabaseEntity
|
||||||
|
// Current CLR: 4.0.30319.34209
|
||||||
|
// System: Microsoft Visual Studio 10.0
|
||||||
|
// Author: dani
|
||||||
|
// Created: 3/2/2015 9:08:47 PM
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace bsmd.database
|
||||||
|
{
|
||||||
|
|
||||||
|
public abstract class DatabaseEntity
|
||||||
|
{
|
||||||
|
protected Guid? id;
|
||||||
|
|
||||||
|
protected string tablename;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SQL Table name to construct queries
|
||||||
|
/// </summary>
|
||||||
|
public string Tablename { get { return this.tablename; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// primary key
|
||||||
|
/// </summary>
|
||||||
|
public Guid? Id { get { return this.id; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IsNew Flag
|
||||||
|
/// </summary>
|
||||||
|
public bool IsNew { get { return !this.id.HasValue; } }
|
||||||
|
|
||||||
|
public virtual void PrepareSave(IDbCommand cmd) { }
|
||||||
|
|
||||||
|
public virtual void PrepareDelete(IDbCommand cmd)
|
||||||
|
{
|
||||||
|
SqlCommand scmd = cmd as SqlCommand;
|
||||||
|
scmd.CommandText = string.Format("DELETE FROM {0} WHERE Id = @ID", Tablename);
|
||||||
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria);
|
||||||
|
|
||||||
|
public abstract List<DatabaseEntity> LoadList(IDataReader reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,15 +11,16 @@ namespace bsmd.database
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Basisklasse aller Nachrichtentypen, zentrale Klasse für die NSW App
|
/// Basisklasse aller Nachrichtentypen, zentrale Klasse für die NSW App
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Message : IDatabaseEntity
|
public class Message : DatabaseEntity
|
||||||
{
|
{
|
||||||
private Guid? id;
|
|
||||||
private Guid messageHeaderId;
|
private Guid messageHeaderId;
|
||||||
private Guid? messageCoreId;
|
private Guid? messageCoreId;
|
||||||
private MessageCore messageCore;
|
private MessageCore messageCore;
|
||||||
private Guid? reportingPartyId;
|
private Guid? reportingPartyId;
|
||||||
private ReportingParty reportingParty;
|
private ReportingParty reportingParty;
|
||||||
private DateTime? created;
|
private DateTime? created;
|
||||||
|
private List<MessageError> errorList = new List<MessageError>();
|
||||||
|
private List<MessageViolation> violationList = new List<MessageViolation>();
|
||||||
|
|
||||||
#region Enumerations
|
#region Enumerations
|
||||||
|
|
||||||
@ -76,12 +77,12 @@ namespace bsmd.database
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
public Message()
|
||||||
|
{
|
||||||
|
this.tablename = "[dbo].[MessageHeader]";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
#region Properties
|
||||||
/// Primärschlüssel
|
|
||||||
/// </summary>
|
|
||||||
public Guid? Id { get { return this.id; } }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dieser Wert wird vom NSW / HIS vergeben
|
/// Dieser Wert wird vom NSW / HIS vergeben
|
||||||
@ -129,21 +130,26 @@ namespace bsmd.database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public NSWProvider HIS { get; set; }
|
public NSWProvider HIS { get; set; }
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// Fehlerliste (Rückgabe vom NSW)
|
||||||
|
/// </summary>
|
||||||
|
public List<MessageError> ErrorList { get { return this.errorList; } }
|
||||||
|
|
||||||
#region public virtual methods
|
/// <summary>
|
||||||
|
/// Violation-Liste (Rückgabe vom NSW)
|
||||||
|
/// </summary>
|
||||||
|
public List<MessageViolation> ViolationList { get { return this.violationList; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vorwärtsreferenz auf spezielle Message (damit wir über Message loopen können)
|
||||||
|
/// </summary>
|
||||||
|
public DatabaseEntity DerivedMessage { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDatabaseEntity implementation
|
#region IDatabaseEntity implementation
|
||||||
|
|
||||||
public bool IsNew
|
public override void PrepareSave(IDbCommand cmdParam)
|
||||||
{
|
|
||||||
get { return !this.id.HasValue; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PrepareSave(IDbCommand cmdParam)
|
|
||||||
{
|
{
|
||||||
SqlCommand cmd = cmdParam as SqlCommand;
|
SqlCommand cmd = cmdParam as SqlCommand;
|
||||||
|
|
||||||
@ -181,30 +187,25 @@ namespace bsmd.database
|
|||||||
|
|
||||||
if (this.IsNew)
|
if (this.IsNew)
|
||||||
{
|
{
|
||||||
string query = "INSERT INTO [MessageHeader] (ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS) " +
|
string query = string.Format("INSERT INTO {0} (ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS) " +
|
||||||
"VALUES (@CLIENTREQUESTID, @MESSAGECOREID, @MESSAGEID, @SENTAT, @RECEIVEDAT, @REQUESTEDAT, @NOTIFICATIONCLASS, @RESET, @CANCEL, @STATUS, @REPORTINGPARTYID, @BSMDSTATUS, @HIS)";
|
"VALUES (@CLIENTREQUESTID, @MESSAGECOREID, @MESSAGEID, @SENTAT, @RECEIVEDAT, @REQUESTEDAT, @NOTIFICATIONCLASS, @RESET, @CANCEL, @STATUS, @REPORTINGPARTYID, @BSMDSTATUS, @HIS)",
|
||||||
|
this.Tablename);
|
||||||
cmd.CommandText = query;
|
cmd.CommandText = query;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd.CommandText = "UPDATE [MessageHeader] SET ClientRequestId = @CLIENTREQUESTID, MessageId = @MESSAGEID, SentAt = @SENTAT, ReceivedAt = @RECEIVEDAT, RequestedAt = @REQUESTEDAT, " +
|
cmd.CommandText = string.Format("UPDATE {0} SET ClientRequestId = @CLIENTREQUESTID, MessageId = @MESSAGEID, SentAt = @SENTAT, ReceivedAt = @RECEIVEDAT, RequestedAt = @REQUESTEDAT, " +
|
||||||
"NotificationClass = @NOTIFICATIONCLASS, Reset = @RESET, Cancel = @CANCEL, Status = @STATUS, ReportingPartyId = @REPORTINGPARTYID, BSMDStatus = @BSMDSTATUS, HIS = @HIS " +
|
"NotificationClass = @NOTIFICATIONCLASS, Reset = @RESET, Cancel = @CANCEL, Status = @STATUS, ReportingPartyId = @REPORTINGPARTYID, BSMDStatus = @BSMDSTATUS, HIS = @HIS " +
|
||||||
"WHERE Id = @ID";
|
"WHERE Id = @ID", this.Tablename);
|
||||||
cmd.Parameters.AddWithValue("@ID", this.messageHeaderId);
|
cmd.Parameters.AddWithValue("@ID", this.messageHeaderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void PrepareDelete(IDbCommand cmdParam)
|
public override void PrepareLoadCommand(IDbCommand cmd, LoadFilter filter, params object[] criteria )
|
||||||
{
|
{
|
||||||
SqlCommand cmd = cmdParam as SqlCommand;
|
string query = string.Format("SELECT Id, ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, " +
|
||||||
cmd.CommandText = "DELETE FROM [MessageHeader] WHERE Id = @ID";
|
"Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS, Created FROM {0} ", this.Tablename);
|
||||||
cmd.Parameters.AddWithValue("@ID", this.messageHeaderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PrepareLoadCommand(IDbCommand cmd, LoadFilter filter, params object[] criteria )
|
|
||||||
{
|
|
||||||
string query = "SELECT Id, ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, " +
|
|
||||||
"Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS, Created FROM MessageHeader ";
|
|
||||||
|
|
||||||
switch (filter)
|
switch (filter)
|
||||||
{
|
{
|
||||||
@ -214,6 +215,12 @@ namespace bsmd.database
|
|||||||
((SqlCommand)cmd).Parameters.AddWithValue("RPID", criteria[0]);
|
((SqlCommand)cmd).Parameters.AddWithValue("RPID", criteria[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LoadFilter.BSMDSTATUS:
|
||||||
|
{
|
||||||
|
query += "WHERE BSMDStatus = @BSMDSTATUS";
|
||||||
|
((SqlCommand)cmd).Parameters.AddWithValue("@BSMDSTATUS", criteria[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case LoadFilter.ALL:
|
case LoadFilter.ALL:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -222,9 +229,9 @@ namespace bsmd.database
|
|||||||
cmd.CommandText = query;
|
cmd.CommandText = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IDatabaseEntity> LoadList(IDataReader reader)
|
public override List<DatabaseEntity> LoadList(IDataReader reader)
|
||||||
{
|
{
|
||||||
List<IDatabaseEntity> result = new List<IDatabaseEntity>();
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
Message msg = new Message();
|
Message msg = new Message();
|
||||||
@ -245,10 +252,33 @@ namespace bsmd.database
|
|||||||
if (!reader.IsDBNull(14)) msg.created = reader.GetDateTime(14);
|
if (!reader.IsDBNull(14)) msg.created = reader.GetDateTime(14);
|
||||||
result.Add(msg);
|
result.Add(msg);
|
||||||
}
|
}
|
||||||
|
reader.Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region public static helpers
|
||||||
|
|
||||||
|
public static void AssignReportingParties(List<Message> messages, Dictionary<Guid, ReportingParty> reportingParties)
|
||||||
|
{
|
||||||
|
foreach (Message message in messages)
|
||||||
|
{
|
||||||
|
if (message.reportingPartyId.HasValue && reportingParties.ContainsKey(message.reportingPartyId.Value))
|
||||||
|
message.reportingParty = reportingParties[message.reportingPartyId.Value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AssignMessageCores(List<Message> messages, Dictionary<Guid, MessageCore> messageCores)
|
||||||
|
{
|
||||||
|
foreach (Message message in messages)
|
||||||
|
{
|
||||||
|
if (message.messageCoreId.HasValue && messageCores.ContainsKey(message.messageCoreId.Value))
|
||||||
|
message.messageCore = messageCores[message.messageCoreId.Value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,18 +8,20 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace bsmd.database
|
namespace bsmd.database
|
||||||
{
|
{
|
||||||
public class MessageCore : IDatabaseEntity
|
public class MessageCore : DatabaseEntity
|
||||||
{
|
{
|
||||||
private Guid id;
|
|
||||||
private Guid? previous;
|
private Guid? previous;
|
||||||
private Guid? next;
|
private Guid? next;
|
||||||
|
|
||||||
private Guid? customerId;
|
private Guid? customerId;
|
||||||
private int? wetris_zz_56_datensatz_id;
|
private int? wetris_zz_56_datensatz_id;
|
||||||
|
|
||||||
#region Properties
|
public MessageCore()
|
||||||
|
{
|
||||||
|
this.tablename = "[dbo].[MessageCore]";
|
||||||
|
}
|
||||||
|
|
||||||
public Guid? Id { get { return this.id; } }
|
#region Properties
|
||||||
|
|
||||||
public string VisitId { get; set; }
|
public string VisitId { get; set; }
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ namespace bsmd.database
|
|||||||
|
|
||||||
public string Portname { get; set; }
|
public string Portname { get; set; }
|
||||||
|
|
||||||
public DateTime ETA { get; set; }
|
public DateTime? ETA { get; set; }
|
||||||
|
|
||||||
public bool IsTransit { get; set; }
|
public bool IsTransit { get; set; }
|
||||||
|
|
||||||
@ -41,38 +43,60 @@ namespace bsmd.database
|
|||||||
|
|
||||||
public Message.NSWProvider InitialHIS { get; set; }
|
public Message.NSWProvider InitialHIS { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public override void PrepareSave(IDbCommand cmd)
|
||||||
public bool IsNew
|
|
||||||
{
|
{
|
||||||
get { return !this.Id.HasValue; }
|
SqlCommand scmd = cmd as SqlCommand;
|
||||||
}
|
|
||||||
|
if (this.VisitId != null) scmd.Parameters.AddWithValue("@P1", this.VisitId);
|
||||||
|
else scmd.Parameters.AddWithValue("@P1", DBNull.Value);
|
||||||
|
if (this.TransitId != null) scmd.Parameters.AddWithValue("@P2", this.TransitId);
|
||||||
|
else scmd.Parameters.AddWithValue("@P2", DBNull.Value);
|
||||||
|
if (this.IMO != null) scmd.Parameters.AddWithValue("@P3", this.IMO);
|
||||||
|
else scmd.Parameters.AddWithValue("@P3", DBNull.Value);
|
||||||
|
if (this.ENI != null) scmd.Parameters.AddWithValue("@P4", this.ENI);
|
||||||
|
else scmd.Parameters.AddWithValue("@P4", DBNull.Value);
|
||||||
|
if (this.PoC != null) scmd.Parameters.AddWithValue("@P5", this.PoC);
|
||||||
|
else scmd.Parameters.AddWithValue("@P5", DBNull.Value);
|
||||||
|
if (this.Portname != null) scmd.Parameters.AddWithValue("@P6", this.Portname);
|
||||||
|
else scmd.Parameters.AddWithValue("@P6", DBNull.Value);
|
||||||
|
if (this.ETA.HasValue) scmd.Parameters.AddWithValue("@P7", this.ETA);
|
||||||
|
else scmd.Parameters.AddWithValue("@P7", DBNull.Value);
|
||||||
|
if (this.customerId.HasValue) scmd.Parameters.AddWithValue("@P8", this.customerId);
|
||||||
|
else scmd.Parameters.AddWithValue("@P8", DBNull.Value);
|
||||||
|
if (this.previous.HasValue) scmd.Parameters.AddWithValue("@P9", this.previous);
|
||||||
|
else scmd.Parameters.AddWithValue("@P9", DBNull.Value);
|
||||||
|
if (this.next.HasValue) scmd.Parameters.AddWithValue("@P10", this.next);
|
||||||
|
else scmd.Parameters.AddWithValue("@P10", DBNull.Value);
|
||||||
|
scmd.Parameters.AddWithValue("@P11", this.IsTransit ? 1 : 0);
|
||||||
|
if (this.wetris_zz_56_datensatz_id.HasValue) scmd.Parameters.AddWithValue("@P12", this.wetris_zz_56_datensatz_id);
|
||||||
|
else scmd.Parameters.AddWithValue("@P12", DBNull.Value);
|
||||||
|
scmd.Parameters.AddWithValue("@P13", this.BSMDStatus);
|
||||||
|
scmd.Parameters.AddWithValue("@P14", this.InitialHIS);
|
||||||
|
|
||||||
public void PrepareSave(IDbCommand cmd)
|
|
||||||
{
|
|
||||||
if (this.IsNew)
|
if (this.IsNew)
|
||||||
{
|
{
|
||||||
string query = "INSERT INTO [MessageCore] (VisitId, TransitId, IMO, ENI, PoC, Portname, ETA, CustomerId, " +
|
string query = string.Format("INSERT INTO {0} (VisitId, TransitId, IMO, ENI, PoC, Portname, ETA, CustomerId, " +
|
||||||
"Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS) VALUES " +
|
"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)";
|
"(@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14)", this.Tablename);
|
||||||
|
scmd.CommandText = query;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||||
|
string query = string.Format("UPDATE {0} SET VisitId = @P1, TransitId = @P2, IMO = @P3, ENI = @P4, Poc = @P5, " +
|
||||||
|
"Portname = @P6, ETA = @P7, CustomerId = @P8, Previous = @P9, Next = @P10, IsTransit = @P11, " +
|
||||||
|
"Wetris_zz_56_datensatz_id = @P12, BSMDStatus = @P13, InitialHIS = @P14 WHERE Id = @ID", this.Tablename);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrepareDelete(IDbCommand cmd)
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
string query = string.Format("SELECT Id, VisitId, TransitId, IMO, ENI, PoC, Portname, " +
|
||||||
}
|
"ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS FROM {0} ",
|
||||||
|
this.Tablename);
|
||||||
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)
|
switch (filter)
|
||||||
{
|
{
|
||||||
@ -90,9 +114,9 @@ namespace bsmd.database
|
|||||||
cmd.CommandText = query;
|
cmd.CommandText = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IDatabaseEntity> LoadList(IDataReader reader)
|
public override List<DatabaseEntity> LoadList(IDataReader reader)
|
||||||
{
|
{
|
||||||
List<IDatabaseEntity> result = new List<IDatabaseEntity>();
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||||
while(reader.Read())
|
while(reader.Read())
|
||||||
{
|
{
|
||||||
MessageCore core = new MessageCore();
|
MessageCore core = new MessageCore();
|
||||||
|
|||||||
92
nsw/Source/bsmd.database/MessageError.cs
Normal file
92
nsw/Source/bsmd.database/MessageError.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
//
|
||||||
|
// Class: MessageError
|
||||||
|
// Current CLR: 4.0.30319.34209
|
||||||
|
// System: Microsoft Visual Studio 10.0
|
||||||
|
// Author: dani
|
||||||
|
// Created: 3/19/2015 7:54:06 AM
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace bsmd.database
|
||||||
|
{
|
||||||
|
public class MessageError : DatabaseEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
public MessageError()
|
||||||
|
{
|
||||||
|
this.tablename = "[dbo].[Error]";
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public int ErrorCode { get; set; }
|
||||||
|
|
||||||
|
public string ErrorText { get; set; }
|
||||||
|
|
||||||
|
public Guid MessageHeaderId { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDatabaseEntity implementation
|
||||||
|
|
||||||
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
||||||
|
{
|
||||||
|
SqlCommand scmd = cmd as SqlCommand;
|
||||||
|
|
||||||
|
scmd.Parameters.AddWithValue("@MHID", this.MessageHeaderId);
|
||||||
|
scmd.Parameters.AddWithValue("@VC", this.ErrorCode);
|
||||||
|
scmd.Parameters.AddWithValue("@VT", this.ErrorText);
|
||||||
|
|
||||||
|
if (this.IsNew)
|
||||||
|
{
|
||||||
|
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, ErrorCode, ErrorText) VALUES (@MHID, @VC, @VT)", this.Tablename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||||
|
scmd.CommandText = string.Format("UPDATE {0} SET MessageHeaderId = @MHID, ErrorCode = @VC, ErrorText = @VT WHERE Id = @ID", this.Tablename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||||
|
{
|
||||||
|
string query = string.Format("SELECT Id, ErrorCode, ErrorText FROM {0} ", this.Tablename);
|
||||||
|
|
||||||
|
switch (filter)
|
||||||
|
{
|
||||||
|
case Message.LoadFilter.MESSAGEHEADER:
|
||||||
|
query += "WHERE MessageHeaderId = @MHID";
|
||||||
|
((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]);
|
||||||
|
break;
|
||||||
|
case Message.LoadFilter.ALL:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.CommandText = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
||||||
|
{
|
||||||
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
MessageError me = new MessageError();
|
||||||
|
me.id = reader.GetGuid(0);
|
||||||
|
if (!reader.IsDBNull(1)) me.ErrorCode = reader.GetInt32(1);
|
||||||
|
if (!reader.IsDBNull(2)) me.ErrorText = reader.GetString(2);
|
||||||
|
result.Add(me);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
93
nsw/Source/bsmd.database/MessageViolation.cs
Normal file
93
nsw/Source/bsmd.database/MessageViolation.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
//
|
||||||
|
// Class: MessageViolation
|
||||||
|
// Current CLR: 4.0.30319.34209
|
||||||
|
// System: Microsoft Visual Studio 10.0
|
||||||
|
// Author: dani
|
||||||
|
// Created: 3/19/2015 7:54:25 AM
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace bsmd.database
|
||||||
|
{
|
||||||
|
public class MessageViolation : DatabaseEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
public MessageViolation()
|
||||||
|
{
|
||||||
|
this.tablename = "[dbo].[Violation]";
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public int ViolationCode { get; set; }
|
||||||
|
|
||||||
|
public string ViolationText { get; set; }
|
||||||
|
|
||||||
|
public Guid MessageHeaderId { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DatabaseEntity implementation
|
||||||
|
|
||||||
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
||||||
|
{
|
||||||
|
SqlCommand scmd = cmd as SqlCommand;
|
||||||
|
|
||||||
|
scmd.Parameters.AddWithValue("@MHID", this.MessageHeaderId);
|
||||||
|
scmd.Parameters.AddWithValue("@VC", this.ViolationCode);
|
||||||
|
scmd.Parameters.AddWithValue("@VT", this.ViolationText);
|
||||||
|
|
||||||
|
if (this.IsNew)
|
||||||
|
{
|
||||||
|
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, ViolationCode, ViolationText) VALUES (@MHID, @VC, @VT)", this.Tablename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||||
|
scmd.CommandText = string.Format("UPDATE {0} SET MessageHeaderId = @MHID, ViolationCode = @VC, ViolationText = @VT WHERE Id = @ID", this.Tablename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||||
|
{
|
||||||
|
|
||||||
|
string query = string.Format("SELECT Id, ViolationCode, ViolationText FROM {0} ", this.Tablename);
|
||||||
|
|
||||||
|
switch (filter)
|
||||||
|
{
|
||||||
|
case Message.LoadFilter.MESSAGEHEADER:
|
||||||
|
query += "WHERE MessageHeaderId = @MHID";
|
||||||
|
((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]);
|
||||||
|
break;
|
||||||
|
case Message.LoadFilter.ALL:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.CommandText = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
||||||
|
{
|
||||||
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
MessageViolation mv = new MessageViolation();
|
||||||
|
mv.id = reader.GetGuid(0);
|
||||||
|
if (!reader.IsDBNull(1)) mv.ViolationCode = reader.GetInt32(1);
|
||||||
|
if (!reader.IsDBNull(2)) mv.ViolationText = reader.GetString(2);
|
||||||
|
result.Add(mv);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -6,9 +8,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace bsmd.database
|
namespace bsmd.database
|
||||||
{
|
{
|
||||||
public class ReportingParty
|
public class ReportingParty : DatabaseEntity
|
||||||
{
|
{
|
||||||
private Guid id;
|
|
||||||
|
|
||||||
#region enumerations
|
#region enumerations
|
||||||
|
|
||||||
@ -17,9 +18,12 @@ namespace bsmd.database
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
public ReportingParty()
|
||||||
|
{
|
||||||
|
this.tablename = "[dbo].[ReportingParty]";
|
||||||
|
}
|
||||||
|
|
||||||
public Guid Id { get { return this.id; } }
|
#region Properties
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
@ -54,5 +58,58 @@ namespace bsmd.database
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IDatabaseEntity implementation
|
||||||
|
|
||||||
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||||
|
{
|
||||||
|
|
||||||
|
string query = string.Format("SELECT Id, RPName, RPStreetAndNumber, RPPostalCode, RPCity, RPCountry, RPLastName, " +
|
||||||
|
"RPFirstName, RPPhone, RPFax, RPEMail FROM {0} ", this.Tablename);
|
||||||
|
|
||||||
|
switch (filter)
|
||||||
|
{
|
||||||
|
/// tbd
|
||||||
|
|
||||||
|
case Message.LoadFilter.ALL:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.CommandText = query;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
||||||
|
{
|
||||||
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
ReportingParty rp = new ReportingParty();
|
||||||
|
|
||||||
|
rp.id = reader.GetGuid(0);
|
||||||
|
if (!reader.IsDBNull(1)) rp.Name = reader.GetString(1);
|
||||||
|
if (!reader.IsDBNull(2)) rp.StreetAndNumber = reader.GetString(2);
|
||||||
|
if (!reader.IsDBNull(3)) rp.PostalCode = reader.GetString(3);
|
||||||
|
if (!reader.IsDBNull(4)) rp.City = reader.GetString(4);
|
||||||
|
if (!reader.IsDBNull(5)) rp.Country = reader.GetString(5);
|
||||||
|
if (!reader.IsDBNull(6)) rp.LastName = reader.GetString(6);
|
||||||
|
if (!reader.IsDBNull(7)) rp.FirstName = reader.GetString(7);
|
||||||
|
if (!reader.IsDBNull(8)) rp.Phone = reader.GetString(8);
|
||||||
|
if (!reader.IsDBNull(9)) rp.Fax = reader.GetString(9);
|
||||||
|
if (!reader.IsDBNull(10)) rp.EMail = reader.GetString(10);
|
||||||
|
|
||||||
|
result.Add(rp);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
116
nsw/Source/bsmd.database/STAT.cs
Normal file
116
nsw/Source/bsmd.database/STAT.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
//
|
||||||
|
// Class: STAT
|
||||||
|
// Current CLR: 4.0.30319.34209
|
||||||
|
// System: Microsoft Visual Studio 10.0
|
||||||
|
// Author: dani
|
||||||
|
// Created: 3/19/2015 8:59:21 PM
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace bsmd.database
|
||||||
|
{
|
||||||
|
public class STAT : DatabaseEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
public STAT()
|
||||||
|
{
|
||||||
|
this.tablename = "[dbo].[STAT]";
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public Message MessageHeader { get; set; }
|
||||||
|
|
||||||
|
public string ShipName { get; set; }
|
||||||
|
|
||||||
|
public string CallSign { get; set; }
|
||||||
|
|
||||||
|
public string MMSINumber { get; set; }
|
||||||
|
|
||||||
|
public string Flag { get; set; }
|
||||||
|
|
||||||
|
public float? LengthOverall_MTR { get; set; }
|
||||||
|
|
||||||
|
public float? Beam_MTR { get; set; }
|
||||||
|
|
||||||
|
public int? GrossTonnage { get; set; }
|
||||||
|
|
||||||
|
public string PortOfRegistry { get; set; }
|
||||||
|
|
||||||
|
public string InmarsatCallNumber { get; set; }
|
||||||
|
|
||||||
|
public string ShipType { get; set; }
|
||||||
|
|
||||||
|
public string ISMCompanyName { get; set; }
|
||||||
|
|
||||||
|
public string ISMCompanyId { get; set; }
|
||||||
|
|
||||||
|
public string ISMCompanyStreetAndNumber { get; set; }
|
||||||
|
|
||||||
|
public string ISMCompanyPostalCode { get; set; }
|
||||||
|
|
||||||
|
public string ISMCompanyCity { get; set; }
|
||||||
|
|
||||||
|
public string ISMCompanyCountry { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||||
|
{
|
||||||
|
string query = string.Format("SELECT Id, ShipName, Callsign, MMSINumber, Flag, LengthOverall_MTR, Beam_MTR, " +
|
||||||
|
"GrossTonnage, PortOfRegistry, InmarsatCallNumber, ShipType, ISMCompanyName, ISMCompanyId, ISMCompanyStreetAndNumber, " +
|
||||||
|
"ISMCompanyPostalAddress, ISMCompanyCity, ISMCompanyCountry FROM {0}", this.Tablename);
|
||||||
|
|
||||||
|
switch (filter)
|
||||||
|
{
|
||||||
|
case Message.LoadFilter.MESSAGEHEADER:
|
||||||
|
query += "WHERE MessageHeaderId = @MHID";
|
||||||
|
((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]);
|
||||||
|
break;
|
||||||
|
case Message.LoadFilter.ALL:
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cmd.CommandText = query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
||||||
|
{
|
||||||
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||||
|
|
||||||
|
while(reader.Read())
|
||||||
|
{
|
||||||
|
STAT stat = new STAT();
|
||||||
|
|
||||||
|
stat.id = reader.GetGuid(0);
|
||||||
|
|
||||||
|
if (!reader.IsDBNull(1)) stat.ShipName = reader.GetString(1);
|
||||||
|
if (!reader.IsDBNull(2)) stat.CallSign = reader.GetString(2);
|
||||||
|
if (!reader.IsDBNull(3)) stat.MMSINumber = reader.GetString(3);
|
||||||
|
if (!reader.IsDBNull(4)) stat.Flag = reader.GetString(4);
|
||||||
|
if (!reader.IsDBNull(5)) stat.LengthOverall_MTR = reader.GetFloat(5);
|
||||||
|
if (!reader.IsDBNull(6)) stat.Beam_MTR = reader.GetFloat(6);
|
||||||
|
if (!reader.IsDBNull(7)) stat.GrossTonnage = reader.GetInt32(7);
|
||||||
|
if (!reader.IsDBNull(8)) stat.PortOfRegistry = reader.GetString(8);
|
||||||
|
if (!reader.IsDBNull(9)) stat.InmarsatCallNumber = reader.GetString(9);
|
||||||
|
if (!reader.IsDBNull(10)) stat.ShipType = reader.GetString(10);
|
||||||
|
if (!reader.IsDBNull(11)) stat.ISMCompanyName = reader.GetString(11);
|
||||||
|
if (!reader.IsDBNull(12)) stat.ISMCompanyId = reader.GetString(12);
|
||||||
|
if (!reader.IsDBNull(13)) stat.ISMCompanyStreetAndNumber = reader.GetString(13);
|
||||||
|
if (!reader.IsDBNull(14)) stat.ISMCompanyPostalCode = reader.GetString(14);
|
||||||
|
if (!reader.IsDBNull(15)) stat.ISMCompanyCity = reader.GetString(15);
|
||||||
|
if (!reader.IsDBNull(16)) stat.ISMCompanyCountry = reader.GetString(16);
|
||||||
|
|
||||||
|
result.Add(stat);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -46,11 +46,14 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DBManager.cs" />
|
<Compile Include="DBManager.cs" />
|
||||||
<Compile Include="IDatabaseEntity.cs" />
|
<Compile Include="DatabaseEntity.cs" />
|
||||||
<Compile Include="Message.cs" />
|
<Compile Include="Message.cs" />
|
||||||
<Compile Include="MessageCore.cs" />
|
<Compile Include="MessageCore.cs" />
|
||||||
|
<Compile Include="MessageError.cs" />
|
||||||
|
<Compile Include="MessageViolation.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ReportingParty.cs" />
|
<Compile Include="ReportingParty.cs" />
|
||||||
|
<Compile Include="STAT.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.Config" />
|
<None Include="App.Config" />
|
||||||
|
|||||||
4
nsw/Source/bsmd.database/packages.config
Normal file
4
nsw/Source/bsmd.database/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="log4net" version="2.0.3" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
@ -60,7 +60,7 @@ namespace bsmd.dbh
|
|||||||
}
|
}
|
||||||
|
|
||||||
((RootVisit)root.Item).PortOfCall = aMessage.MessageCore.PoC;
|
((RootVisit)root.Item).PortOfCall = aMessage.MessageCore.PoC;
|
||||||
((RootVisit)root.Item).ETAPortOfCall = aMessage.MessageCore.ETA;
|
((RootVisit)root.Item).ETAPortOfCall = aMessage.MessageCore.ETA.Value;
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -79,7 +79,12 @@ namespace bsmd.dbh
|
|||||||
((RootTransit)root.Item).Item = aMessage.MessageCore.ENI;
|
((RootTransit)root.Item).Item = aMessage.MessageCore.ENI;
|
||||||
}
|
}
|
||||||
|
|
||||||
((RootTransit)root.Item).ETAKielCanal = aMessage.MessageCore.ETA;
|
((RootTransit)root.Item).ETAKielCanal = aMessage.MessageCore.ETA.Value;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Message.NotificationClass.STAT:
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
4
nsw/Source/bsmd.dbh/packages.config
Normal file
4
nsw/Source/bsmd.dbh/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="log4net" version="2.0.3" targetFramework="net45" />
|
||||||
|
</packages>
|
||||||
BIN
nsw/Source/packages/log4net.2.0.3/log4net.2.0.3.nupkg
vendored
Normal file
BIN
nsw/Source/packages/log4net.2.0.3/log4net.2.0.3.nupkg
vendored
Normal file
Binary file not shown.
20
nsw/Source/packages/log4net.2.0.3/log4net.2.0.3.nuspec
vendored
Normal file
20
nsw/Source/packages/log4net.2.0.3/log4net.2.0.3.nuspec
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
|
<metadata>
|
||||||
|
<id>log4net</id>
|
||||||
|
<version>2.0.3</version>
|
||||||
|
<title>log4net [1.2.13]</title>
|
||||||
|
<authors>Apache Software Foundation</authors>
|
||||||
|
<owners>Apache Software Foundation</owners>
|
||||||
|
<licenseUrl>http://logging.apache.org/log4net/license.html</licenseUrl>
|
||||||
|
<projectUrl>http://logging.apache.org/log4net/</projectUrl>
|
||||||
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
<description>log4net is a tool to help the programmer output log statements to a variety of output targets. In case of problems with an application, it is helpful to enable logging so that the problem can be located. With log4net it is possible to enable logging at runtime without modifying the application binary. The log4net package is designed so that log statements can remain in shipped code without incurring a high performance cost. It follows that the speed of logging (or rather not logging) is crucial.
|
||||||
|
|
||||||
|
At the same time, log output can be so voluminous that it quickly becomes overwhelming. One of the distinctive features of log4net is the notion of hierarchical loggers. Using these loggers it is possible to selectively control which log statements are output at arbitrary granularity.
|
||||||
|
|
||||||
|
log4net is designed with two distinct goals in mind: speed and flexibility</description>
|
||||||
|
<summary>The Apache log4net library is a tool to help the programmer output log statements to a variety of output targets.</summary>
|
||||||
|
<tags>logging log tracing logfiles</tags>
|
||||||
|
</metadata>
|
||||||
|
</package>
|
||||||
7
nsw/Source/packages/repositories.config
Normal file
7
nsw/Source/packages/repositories.config
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<repositories>
|
||||||
|
<repository path="..\bsmd.dakosy\packages.config" />
|
||||||
|
<repository path="..\bsmd.database\packages.config" />
|
||||||
|
<repository path="..\bsmd.dbh\packages.config" />
|
||||||
|
<repository path="..\SendNSWMessageService\packages.config" />
|
||||||
|
</repositories>
|
||||||
Loading…
Reference in New Issue
Block a user