Neues Server Deployment

(Version 5.5)
This commit is contained in:
Daniel Schick 2019-08-16 05:41:45 +00:00
parent 39e9f4d9f2
commit a5950b3683
3 changed files with 155 additions and 126 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<!-- <!--
(c) 2017 Informatikbüro Daniel Schick (c) 2017-present Informatikbüro Daniel Schick
--> -->
<configuration> <configuration>
<configSections> <configSections>

Binary file not shown.

View File

@ -590,78 +590,94 @@ namespace bsmd.database
{ {
if (!entity.IsNew) if (!entity.IsNew)
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
entity.PrepareDelete(cmd); {
int queryResult = this.PerformNonQuery(cmd); entity.PrepareDelete(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult);
}
} }
if (this._closeConnectionAfterUse) this.Disconnect(); if (this._closeConnectionAfterUse) this.Disconnect();
} }
public void DeleteMessageErrors(Message message) public void DeleteMessageErrors(Message message)
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = string.Format("UPDATE Error SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id); {
int queryResult = this.PerformNonQuery(cmd); cmd.CommandText = string.Format("UPDATE Error SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id);
this.LogNonQueryResult(cmd.CommandText, queryResult); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult);
}
} }
public void DeleteMessageViolations(Message message) public void DeleteMessageViolations(Message message)
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = string.Format("UPDATE Violation SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id); {
int queryResult = this.PerformNonQuery(cmd); cmd.CommandText = string.Format("UPDATE Violation SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id);
this.LogNonQueryResult(cmd.CommandText, queryResult); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult);
}
} }
public void DeleteSystemErrors(Message message) public void DeleteSystemErrors(Message message)
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = string.Format("UPDATE SystemError SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id); {
int queryResult = this.PerformNonQuery(cmd); cmd.CommandText = string.Format("UPDATE SystemError SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id);
this.LogNonQueryResult(cmd.CommandText, queryResult); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult);
}
} }
public void Save(MessageCore core) public void Save(MessageCore core)
{ {
if (core.Customer != null) if (core.Customer != null)
{ {
SqlCommand cCmd = new SqlCommand(); using (SqlCommand cCmd = new SqlCommand())
core.Customer.PrepareSave(cCmd); {
_log.DebugFormat("Saved Customer to Core: {0}", this.PerformNonQuery(cCmd)); core.Customer.PrepareSave(cCmd);
core.CustomerId = core.Customer.Id; _log.DebugFormat("Saved Customer to Core: {0}", this.PerformNonQuery(cCmd));
core.CustomerId = core.Customer.Id;
}
} }
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
core.PrepareSave(cmd); {
int queryResult = this.PerformNonQuery(cmd); core.PrepareSave(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult);
}
if (this._closeConnectionAfterUse) this.Disconnect(); if (this._closeConnectionAfterUse) this.Disconnect();
} }
public bool? GetMessageCoreQueryStatusFlag(Guid messageCoreId) public bool? GetMessageCoreQueryStatusFlag(Guid messageCoreId)
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = string.Format("SELECT QueryNSWStatus FROM MessageCore WHERE Id = '{0}'", messageCoreId); {
bool? result = this.PerformReadFlagQuery(cmd); cmd.CommandText = string.Format("SELECT QueryNSWStatus FROM MessageCore WHERE Id = '{0}'", messageCoreId);
bool? result = this.PerformReadFlagQuery(cmd);
if (this._closeConnectionAfterUse) this.Disconnect(); if (this._closeConnectionAfterUse) this.Disconnect();
return result; return result;
}
} }
public List<MessageHistory> GetMessageHistories(Guid messageId) public List<MessageHistory> GetMessageHistories(Guid messageId)
{ {
try try
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = MessageHistory.GetLoadCommand(); {
cmd.Parameters.AddWithValue("@ENTITYID", messageId); cmd.CommandText = MessageHistory.GetLoadCommand();
IDataReader reader = this.PerformCommand(cmd); cmd.Parameters.AddWithValue("@ENTITYID", messageId);
List<MessageHistory> result = MessageHistory.LoadList(reader); IDataReader reader = this.PerformCommand(cmd);
reader.Close(); List<MessageHistory> result = MessageHistory.LoadList(reader);
return result; reader.Close();
return result;
}
} }
catch(Exception ex) catch(Exception ex)
{ {
@ -709,36 +725,31 @@ namespace bsmd.database
this.LoadViolationList(message); this.LoadViolationList(message);
this.LoadSystemErrorList(message); this.LoadSystemErrorList(message);
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
DatabaseEntity msgClass = DBManager.CreateMessage(message.MessageNotificationClass);
if (msgClass != null)
{ {
msgClass.PrepareLoadCommand(cmd, Message.LoadFilter.MESSAGEHEADER, message.Id); DatabaseEntity msgClass = DBManager.CreateMessage(message.MessageNotificationClass);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader != null) if (msgClass != null)
{ {
List<DatabaseEntity> statList = msgClass.LoadList(reader); msgClass.PrepareLoadCommand(cmd, Message.LoadFilter.MESSAGEHEADER, message.Id);
foreach (DatabaseEntity derivedMessage in statList) SqlDataReader reader = this.PerformCommand(cmd);
if (reader != null)
{ {
if(message.MessageNotificationClass == Message.NotificationClass.HAZD) List<DatabaseEntity> statList = msgClass.LoadList(reader);
foreach (DatabaseEntity derivedMessage in statList)
{ {
if(derivedMessage is HAZ hAZ) if (message.MessageNotificationClass == Message.NotificationClass.HAZD)
(hAZ).IsDeparture = true; {
if (derivedMessage is HAZ hAZ)
(hAZ).IsDeparture = true;
}
message.Elements.Add(derivedMessage);
derivedMessage.MessageHeader = message;
this.LoadDependingLists(derivedMessage);
} }
message.Elements.Add(derivedMessage);
derivedMessage.MessageHeader = message;
this.LoadDependingLists(derivedMessage);
} }
} }
} }
/* Meldung ist überflüssig
else
{
_log.DebugFormat("cannot create a message class for notification type {0}", message.MessageNotificationClass);
}
*/
} }
} }
@ -784,10 +795,12 @@ namespace bsmd.database
// 3. MessageHistory Element speichern // 3. MessageHistory Element speichern
// TODO: das könnte auch in einem Background Thread passieren, da der Wert erst irgendwann gelesen wird und aktuell nicht relevant ist // TODO: das könnte auch in einem Background Thread passieren, da der Wert erst irgendwann gelesen wird und aktuell nicht relevant ist
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
mh.PrepareSave(cmd); {
int queryResult = this.PerformNonQuery(cmd); mh.PrepareSave(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult);
}
} }
} }
@ -1130,14 +1143,18 @@ namespace bsmd.database
#region WasteDisposalServiceProvider #region WasteDisposalServiceProvider
/*
if (databaseEntity.GetType().IsAssignableFrom(typeof(WasteDisposalServiceProvider))) if (databaseEntity.GetType().IsAssignableFrom(typeof(WasteDisposalServiceProvider)))
{ {
WasteDisposalServiceProvider wdsp = databaseEntity as WasteDisposalServiceProvider; WasteDisposalServiceProvider wdsp = databaseEntity as WasteDisposalServiceProvider;
} }
*/
#endregion #endregion
cmd.Dispose();
} }
#endregion #endregion
@ -1179,34 +1196,38 @@ namespace bsmd.database
internal Dictionary<int, string> LoadErrorTexts() internal Dictionary<int, string> LoadErrorTexts()
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = "SELECT ErrorCode, ErrorText FROM ErrorText";
SqlDataReader reader = this.PerformCommand(cmd);
Dictionary<int, string> result = new Dictionary<int, string>();
while (reader.Read())
{ {
int errorCode = reader.GetInt32(0); cmd.CommandText = "SELECT ErrorCode, ErrorText FROM ErrorText";
string errorText = reader.GetString(1); SqlDataReader reader = this.PerformCommand(cmd);
result[errorCode] = errorText; Dictionary<int, string> result = new Dictionary<int, string>();
while (reader.Read())
{
int errorCode = reader.GetInt32(0);
string errorText = reader.GetString(1);
result[errorCode] = errorText;
}
reader.Close();
return result;
} }
reader.Close();
return result;
} }
internal Dictionary<int, string> LoadViolationTexts() internal Dictionary<int, string> LoadViolationTexts()
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = "SELECT ViolationCode, ViolationText FROM ViolationText";
SqlDataReader reader = this.PerformCommand(cmd);
Dictionary<int, string> result = new Dictionary<int, string>();
while (reader.Read())
{ {
int violationCode = reader.GetInt32(0); cmd.CommandText = "SELECT ViolationCode, ViolationText FROM ViolationText";
string violationText = reader.GetString(1); SqlDataReader reader = this.PerformCommand(cmd);
result[violationCode] = violationText; Dictionary<int, string> result = new Dictionary<int, string>();
while (reader.Read())
{
int violationCode = reader.GetInt32(0);
string violationText = reader.GetString(1);
result[violationCode] = violationText;
}
reader.Close();
return result;
} }
reader.Close();
return result;
} }
#endregion #endregion
@ -1230,46 +1251,50 @@ namespace bsmd.database
internal void LoadSTATShipName(MessageCore core) internal void LoadSTATShipName(MessageCore core)
{ {
if (core == null) return; if (core == null) return;
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = "SELECT STAT.ShipName, STAT.GrossTonnage FROM STAT JOIN MessageHeader ON STAT.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if(reader.Read())
{ {
if (reader.IsDBNull(0)) cmd.CommandText = "SELECT STAT.ShipName, STAT.GrossTonnage FROM STAT JOIN MessageHeader ON STAT.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
core.Shipname = ""; cmd.Parameters.AddWithValue("@ID", core.Id);
else SqlDataReader reader = this.PerformCommand(cmd);
core.Shipname = reader.GetString(0); if (reader.Read())
if(!reader.IsDBNull(1))
{ {
int grossTonnage = reader.GetInt32(1); if (reader.IsDBNull(0))
core.IsSmallShip = grossTonnage < 500; core.Shipname = "";
else
core.Shipname = reader.GetString(0);
if (!reader.IsDBNull(1))
{
int grossTonnage = reader.GetInt32(1);
core.IsSmallShip = grossTonnage < 500;
}
} }
reader.Close();
} }
reader.Close();
} }
internal void LoadETA_ETD(MessageCore core) internal void LoadETA_ETD(MessageCore core)
{ {
if (core == null) return; if (core == null) return;
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = "SELECT NOA_NOD.ETAToPortOfCall, NOA_NOD.ETAToKielCanal, NOA_NOD.ETDFromPortOfCall, NOA_NOD.ETDFromKielCanal FROM NOA_NOD JOIN MessageHeader ON NOA_NOD.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{ {
if (core.IsTransit) cmd.CommandText = "SELECT NOA_NOD.ETAToPortOfCall, NOA_NOD.ETAToKielCanal, NOA_NOD.ETDFromPortOfCall, NOA_NOD.ETDFromKielCanal FROM NOA_NOD JOIN MessageHeader ON NOA_NOD.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{ {
if (!reader.IsDBNull(1)) core.ETA_NOA_NOD = reader.GetDateTime(1); if (core.IsTransit)
if (!reader.IsDBNull(3)) core.ETD_NOA_NOD = reader.GetDateTime(3); {
} if (!reader.IsDBNull(1)) core.ETA_NOA_NOD = reader.GetDateTime(1);
else if (!reader.IsDBNull(3)) core.ETD_NOA_NOD = reader.GetDateTime(3);
{ }
if (!reader.IsDBNull(0)) core.ETA_NOA_NOD = reader.GetDateTime(0); else
if (!reader.IsDBNull(2)) core.ETD_NOA_NOD = reader.GetDateTime(2); {
if (!reader.IsDBNull(0)) core.ETA_NOA_NOD = reader.GetDateTime(0);
if (!reader.IsDBNull(2)) core.ETD_NOA_NOD = reader.GetDateTime(2);
}
} }
reader.Close();
} }
reader.Close();
if (!core.ETA_NOA_NOD.HasValue && !core.IsTransit && core.ETA.HasValue) if (!core.ETA_NOA_NOD.HasValue && !core.IsTransit && core.ETA.HasValue)
{ {
@ -1288,29 +1313,33 @@ namespace bsmd.database
internal void LoadATA(MessageCore core) internal void LoadATA(MessageCore core)
{ {
if (core == null) return; if (core == null) return;
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = "SELECT ATA.ATAPortOfCall FROM ATA JOIN MessageHeader ON ATA.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{ {
if (!reader.IsDBNull(0)) core.ATA = reader.GetDateTime(0); cmd.CommandText = "SELECT ATA.ATAPortOfCall FROM ATA JOIN MessageHeader ON ATA.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{
if (!reader.IsDBNull(0)) core.ATA = reader.GetDateTime(0);
}
reader.Close();
} }
reader.Close();
} }
internal void LoadATD(MessageCore core) internal void LoadATD(MessageCore core)
{ {
if (core == null) return; if (core == null) return;
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
cmd.CommandText = "SELECT ATD.ATDPortOfCall FROM ATD JOIN MessageHeader ON ATD.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{ {
if (!reader.IsDBNull(0)) core.ATD = reader.GetDateTime(0); cmd.CommandText = "SELECT ATD.ATDPortOfCall FROM ATD JOIN MessageHeader ON ATD.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd);
if (reader.Read())
{
if (!reader.IsDBNull(0)) core.ATD = reader.GetDateTime(0);
}
reader.Close();
} }
reader.Close();
} }
#endregion #endregion