MessageHistory erster Wurf
This commit is contained in:
parent
0a24890733
commit
08740bf6fd
@ -259,26 +259,22 @@ namespace ENI2
|
|||||||
efMode = true;
|
efMode = true;
|
||||||
logoImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/ef_logo.png"));
|
logoImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/ef_logo.png"));
|
||||||
}
|
}
|
||||||
|
Microsoft.Win32.SystemEvents.SessionEnded += SystemEvents_SessionEnded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SystemEvents_SessionEnded(object sender, Microsoft.Win32.SessionEndedEventArgs e)
|
||||||
|
{
|
||||||
|
this.UnlockOpenCores();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
this.UnlockOpenCores();
|
||||||
{
|
|
||||||
// unlock all cores
|
|
||||||
foreach (ClosableTabItem tabItem in this.lockedCores.Keys)
|
|
||||||
{
|
|
||||||
App.LockingServiceClient.Unlock(lockedCores[tabItem], this.userEntity.Id.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
_log.ErrorFormat("LockingService.Unlock: {0}", ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
DBManager.Instance.Disconnect();
|
DBManager.Instance.Disconnect();
|
||||||
Properties.Settings.Default.MainWindowPlacement = this.GetPlacement();
|
Properties.Settings.Default.MainWindowPlacement = this.GetPlacement();
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
|
Microsoft.Win32.SystemEvents.SessionEnded -= SystemEvents_SessionEnded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_SourceInitialized(object sender, EventArgs e)
|
private void Window_SourceInitialized(object sender, EventArgs e)
|
||||||
@ -331,6 +327,10 @@ namespace ENI2
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region window control events
|
||||||
|
|
||||||
private void buttonNewTransitIdClick(object sender, RoutedEventArgs e)
|
private void buttonNewTransitIdClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -540,5 +540,25 @@ namespace ENI2
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region private methods
|
||||||
|
|
||||||
|
private void UnlockOpenCores()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// unlock all cores
|
||||||
|
foreach (ClosableTabItem tabItem in this.lockedCores.Keys)
|
||||||
|
{
|
||||||
|
App.LockingServiceClient.Unlock(lockedCores[tabItem], this.userEntity.Id.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.ErrorFormat("LockingService.Unlock: {0}", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
10
nsw/Source/SQL/Update_To_5.2.sql
Normal file
10
nsw/Source/SQL/Update_To_5.2.sql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
CREATE TABLE [dbo].[MessageHistory]
|
||||||
|
(
|
||||||
|
[Id] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY,
|
||||||
|
[ReportingPartyId] UNIQUEIDENTIFIER NULL,
|
||||||
|
[EntityId] UNIQUEIDENTIFIER NOT NULL,
|
||||||
|
[EntityType] NVARCHAR(100) NOT NULL,
|
||||||
|
[EntityName] NVARCHAR(50) NULL,
|
||||||
|
[EntityValues] NVARCHAR(MAX) NULL,
|
||||||
|
[Timestamp] DATETIME NOT NULL DEFAULT GETDATE()
|
||||||
|
)
|
||||||
@ -569,6 +569,7 @@ namespace bsmd.database
|
|||||||
entity.PrepareSave(cmd);
|
entity.PrepareSave(cmd);
|
||||||
int queryResult = this.PerformNonQuery(cmd);
|
int queryResult = this.PerformNonQuery(cmd);
|
||||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||||
|
this.CreateEntityHistoryEntry(entity);
|
||||||
|
|
||||||
if (this._closeConnectionAfterUse) this.Disconnect();
|
if (this._closeConnectionAfterUse) this.Disconnect();
|
||||||
}
|
}
|
||||||
@ -710,6 +711,19 @@ namespace bsmd.database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateEntityHistoryEntry(DatabaseEntity entity)
|
||||||
|
{
|
||||||
|
// switch(entity.)
|
||||||
|
// 1. prüfen ob für das Objekt ein Historieneintrag angelegt werden soll
|
||||||
|
|
||||||
|
// 2. falls ja Objekt serialisieren
|
||||||
|
|
||||||
|
// 3. MessageHistory Element speichern
|
||||||
|
// (das könnte auch in einem Background Thread passieren, da der Wert erst irgendwann gelesen wird und aktuell nicht relevant ist)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region CreateMessage()
|
#region CreateMessage()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -758,6 +772,8 @@ namespace bsmd.database
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region LoadDependingLists
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads inner lists / collections
|
/// Loads inner lists / collections
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -1022,6 +1038,10 @@ namespace bsmd.database
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Error / Violation
|
||||||
|
|
||||||
internal void LoadErrorList(Message message)
|
internal void LoadErrorList(Message message)
|
||||||
{
|
{
|
||||||
MessageError aMessageError = new MessageError();
|
MessageError aMessageError = new MessageError();
|
||||||
@ -1055,6 +1075,42 @@ namespace bsmd.database
|
|||||||
message.SystemErrorList.Add(sError);
|
message.SystemErrorList.Add(sError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal Dictionary<int, string> LoadErrorTexts()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
string errorText = reader.GetString(1);
|
||||||
|
result[errorCode] = errorText;
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Dictionary<int, string> LoadViolationTexts()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
string violationText = reader.GetString(1);
|
||||||
|
result[violationCode] = violationText;
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Convenience loading functions
|
||||||
|
|
||||||
internal void LoadCustomer(MessageCore core)
|
internal void LoadCustomer(MessageCore core)
|
||||||
{
|
{
|
||||||
if (core.CustomerId.HasValue)
|
if (core.CustomerId.HasValue)
|
||||||
@ -1155,37 +1211,7 @@ namespace bsmd.database
|
|||||||
reader.Close();
|
reader.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Dictionary<int, string> LoadErrorTexts()
|
#endregion
|
||||||
{
|
|
||||||
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);
|
|
||||||
string errorText = reader.GetString(1);
|
|
||||||
result[errorCode] = errorText;
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal Dictionary<int, string> LoadViolationTexts()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
string violationText = reader.GetString(1);
|
|
||||||
result[violationCode] = violationText;
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region DB access methods
|
#region DB access methods
|
||||||
|
|
||||||
|
|||||||
@ -14,15 +14,22 @@ using System.Linq;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.IO;
|
||||||
|
using log4net;
|
||||||
|
|
||||||
namespace bsmd.database
|
namespace bsmd.database
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[XmlInclude(typeof(Message))]
|
||||||
|
[XmlInclude(typeof(MessageCore))]
|
||||||
|
[XmlInclude(typeof(AGNT))]
|
||||||
public abstract class DatabaseEntity : IMessageParagraph, IEquatable<DatabaseEntity>, ICloneable
|
public abstract class DatabaseEntity : IMessageParagraph, IEquatable<DatabaseEntity>, ICloneable
|
||||||
{
|
{
|
||||||
protected Guid? id;
|
protected Guid? id;
|
||||||
protected string tablename;
|
protected string tablename;
|
||||||
private Guid instance_id = Guid.NewGuid(); // Comparison id in case entity has not been saved
|
private Guid instance_id = Guid.NewGuid(); // Comparison id in case entity has not been saved
|
||||||
|
private static readonly ILog _log = LogManager.GetLogger(typeof(DatabaseEntity));
|
||||||
|
|
||||||
#region delegate / events
|
#region delegate / events
|
||||||
// Ein etwas hakeliger Mechanismus, damit ein abhängiges Projekt (ReportGenerator) die Werte ersetzen kann ohne dass die ganze Logik
|
// Ein etwas hakeliger Mechanismus, damit ein abhängiges Projekt (ReportGenerator) die Werte ersetzen kann ohne dass die ganze Logik
|
||||||
@ -360,5 +367,33 @@ namespace bsmd.database
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Serialization
|
||||||
|
|
||||||
|
public static DatabaseEntity Deserialize(string serializedClass)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Serialize()
|
||||||
|
{
|
||||||
|
using (StringWriter sw = new StringWriter())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XmlSerializer serializer = new XmlSerializer(this.GetType());
|
||||||
|
serializer.Serialize(sw, this);
|
||||||
|
return sw.ToString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.ErrorFormat("Serialization failed: {0}", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
33
nsw/Source/bsmd.database/MessageHistory.cs
Normal file
33
nsw/Source/bsmd.database/MessageHistory.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2015-2017 schick Informatik
|
||||||
|
// Description:
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace bsmd.database
|
||||||
|
{
|
||||||
|
public class MessageHistory
|
||||||
|
{
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public Guid? ReportingPartyId { get; set; }
|
||||||
|
|
||||||
|
ReportingParty CreatedBy { get; set; }
|
||||||
|
|
||||||
|
public Guid EntityId { get; private set; }
|
||||||
|
|
||||||
|
public string EntityType { get; private set; }
|
||||||
|
|
||||||
|
public string EntityName { get; private set; }
|
||||||
|
|
||||||
|
public string EntityValues { get; private set; }
|
||||||
|
|
||||||
|
public DateTime Created { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -76,6 +76,7 @@
|
|||||||
<Compile Include="LastTenPortFacilitiesCalled.cs" />
|
<Compile Include="LastTenPortFacilitiesCalled.cs" />
|
||||||
<Compile Include="LookupNameAttribute.cs" />
|
<Compile Include="LookupNameAttribute.cs" />
|
||||||
<Compile Include="MARPOL_Annex_I_Position.cs" />
|
<Compile Include="MARPOL_Annex_I_Position.cs" />
|
||||||
|
<Compile Include="MessageHistory.cs" />
|
||||||
<Compile Include="PortArea.cs" />
|
<Compile Include="PortArea.cs" />
|
||||||
<Compile Include="Properties\AssemblyProductInfo.cs" />
|
<Compile Include="Properties\AssemblyProductInfo.cs" />
|
||||||
<Compile Include="Properties\AssemblyProjectInfo.cs" />
|
<Compile Include="Properties\AssemblyProjectInfo.cs" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user