MessageHistory erster Wurf
This commit is contained in:
parent
0a24890733
commit
08740bf6fd
@ -258,27 +258,23 @@ namespace ENI2
|
||||
{
|
||||
efMode = true;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
this.UnlockOpenCores();
|
||||
|
||||
DBManager.Instance.Disconnect();
|
||||
Properties.Settings.Default.MainWindowPlacement = this.GetPlacement();
|
||||
Properties.Settings.Default.Save();
|
||||
Microsoft.Win32.SystemEvents.SessionEnded -= SystemEvents_SessionEnded;
|
||||
}
|
||||
|
||||
private void Window_SourceInitialized(object sender, EventArgs e)
|
||||
@ -329,7 +325,11 @@ namespace ENI2
|
||||
|
||||
e.CanExecute = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region window control events
|
||||
|
||||
private void buttonNewTransitIdClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@ -538,7 +538,27 @@ namespace ENI2
|
||||
this.Close();
|
||||
}
|
||||
|
||||
#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,7 +569,8 @@ namespace bsmd.database
|
||||
entity.PrepareSave(cmd);
|
||||
int queryResult = this.PerformNonQuery(cmd);
|
||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||
|
||||
this.CreateEntityHistoryEntry(entity);
|
||||
|
||||
if (this._closeConnectionAfterUse) this.Disconnect();
|
||||
}
|
||||
|
||||
@ -622,7 +623,7 @@ namespace bsmd.database
|
||||
SqlCommand cmd = new SqlCommand();
|
||||
core.PrepareSave(cmd);
|
||||
int queryResult = this.PerformNonQuery(cmd);
|
||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||
|
||||
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()
|
||||
|
||||
/// <summary>
|
||||
@ -758,6 +772,8 @@ namespace bsmd.database
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadDependingLists
|
||||
|
||||
/// <summary>
|
||||
/// Loads inner lists / collections
|
||||
/// </summary>
|
||||
@ -1022,6 +1038,10 @@ namespace bsmd.database
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Error / Violation
|
||||
|
||||
internal void LoadErrorList(Message message)
|
||||
{
|
||||
MessageError aMessageError = new MessageError();
|
||||
@ -1055,6 +1075,42 @@ namespace bsmd.database
|
||||
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)
|
||||
{
|
||||
if (core.CustomerId.HasValue)
|
||||
@ -1155,37 +1211,7 @@ namespace bsmd.database
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
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 DB access methods
|
||||
|
||||
|
||||
@ -14,15 +14,22 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
using log4net;
|
||||
|
||||
namespace bsmd.database
|
||||
{
|
||||
|
||||
[XmlInclude(typeof(Message))]
|
||||
[XmlInclude(typeof(MessageCore))]
|
||||
[XmlInclude(typeof(AGNT))]
|
||||
public abstract class DatabaseEntity : IMessageParagraph, IEquatable<DatabaseEntity>, ICloneable
|
||||
{
|
||||
protected Guid? id;
|
||||
protected string tablename;
|
||||
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
|
||||
// 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
|
||||
|
||||
#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="LookupNameAttribute.cs" />
|
||||
<Compile Include="MARPOL_Annex_I_Position.cs" />
|
||||
<Compile Include="MessageHistory.cs" />
|
||||
<Compile Include="PortArea.cs" />
|
||||
<Compile Include="Properties\AssemblyProductInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyProjectInfo.cs" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user