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,59 +590,72 @@ namespace bsmd.database
{ {
if (!entity.IsNew) if (!entity.IsNew)
{ {
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
{
entity.PrepareDelete(cmd); entity.PrepareDelete(cmd);
int queryResult = this.PerformNonQuery(cmd); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); 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); cmd.CommandText = string.Format("UPDATE Error SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id);
int queryResult = this.PerformNonQuery(cmd); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); 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); cmd.CommandText = string.Format("UPDATE Violation SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id);
int queryResult = this.PerformNonQuery(cmd); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); 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); cmd.CommandText = string.Format("UPDATE SystemError SET Deleted = 1 WHERE MessageHeaderId='{0}'", message.Id);
int queryResult = this.PerformNonQuery(cmd); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); 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); core.Customer.PrepareSave(cCmd);
_log.DebugFormat("Saved Customer to Core: {0}", this.PerformNonQuery(cCmd)); _log.DebugFormat("Saved Customer to Core: {0}", this.PerformNonQuery(cCmd));
core.CustomerId = core.Customer.Id; core.CustomerId = core.Customer.Id;
} }
}
SqlCommand cmd = new SqlCommand(); using (SqlCommand cmd = new SqlCommand())
{
core.PrepareSave(cmd); core.PrepareSave(cmd);
int queryResult = this.PerformNonQuery(cmd); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); 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); cmd.CommandText = string.Format("SELECT QueryNSWStatus FROM MessageCore WHERE Id = '{0}'", messageCoreId);
bool? result = this.PerformReadFlagQuery(cmd); bool? result = this.PerformReadFlagQuery(cmd);
@ -650,12 +663,14 @@ namespace bsmd.database
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.CommandText = MessageHistory.GetLoadCommand();
cmd.Parameters.AddWithValue("@ENTITYID", messageId); cmd.Parameters.AddWithValue("@ENTITYID", messageId);
IDataReader reader = this.PerformCommand(cmd); IDataReader reader = this.PerformCommand(cmd);
@ -663,6 +678,7 @@ namespace bsmd.database
reader.Close(); reader.Close();
return result; return result;
} }
}
catch(Exception ex) catch(Exception ex)
{ {
_log.ErrorFormat("Error loadin message history: {0}", ex.Message); _log.ErrorFormat("Error loadin message history: {0}", ex.Message);
@ -709,8 +725,8 @@ 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); DatabaseEntity msgClass = DBManager.CreateMessage(message.MessageNotificationClass);
if (msgClass != null) if (msgClass != null)
@ -733,12 +749,7 @@ namespace bsmd.database
} }
} }
} }
/* Meldung ist überflüssig
else
{
_log.DebugFormat("cannot create a message class for notification type {0}", message.MessageNotificationClass);
} }
*/
} }
} }
@ -784,12 +795,14 @@ 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); mh.PrepareSave(cmd);
int queryResult = this.PerformNonQuery(cmd); int queryResult = this.PerformNonQuery(cmd);
this.LogNonQueryResult(cmd.CommandText, queryResult); this.LogNonQueryResult(cmd.CommandText, queryResult);
} }
} }
}
private void InitializeMessageHistoryTypes() private void InitializeMessageHistoryTypes()
{ {
@ -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,7 +1196,8 @@ 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"; cmd.CommandText = "SELECT ErrorCode, ErrorText FROM ErrorText";
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
Dictionary<int, string> result = new Dictionary<int, string>(); Dictionary<int, string> result = new Dictionary<int, string>();
@ -1192,10 +1210,12 @@ namespace bsmd.database
reader.Close(); reader.Close();
return result; 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"; cmd.CommandText = "SELECT ViolationCode, ViolationText FROM ViolationText";
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
Dictionary<int, string> result = new Dictionary<int, string>(); Dictionary<int, string> result = new Dictionary<int, string>();
@ -1208,6 +1228,7 @@ namespace bsmd.database
reader.Close(); reader.Close();
return result; return result;
} }
}
#endregion #endregion
@ -1230,7 +1251,8 @@ 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.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); cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
@ -1248,11 +1270,13 @@ namespace bsmd.database
} }
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.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); cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
@ -1270,6 +1294,7 @@ namespace bsmd.database
} }
} }
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,7 +1313,8 @@ 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.CommandText = "SELECT ATA.ATAPortOfCall FROM ATA JOIN MessageHeader ON ATA.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id); cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
@ -1298,11 +1324,13 @@ namespace bsmd.database
} }
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.CommandText = "SELECT ATD.ATDPortOfCall FROM ATD JOIN MessageHeader ON ATD.MessageHeaderId = MessageHeader.Id WHERE MessageHeader.MessageCoreId = @ID";
cmd.Parameters.AddWithValue("@ID", core.Id); cmd.Parameters.AddWithValue("@ID", core.Id);
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
@ -1312,6 +1340,7 @@ namespace bsmd.database
} }
reader.Close(); reader.Close();
} }
}
#endregion #endregion