diff --git a/ENI-2/ENI2/ENI2/App.config b/ENI-2/ENI2/ENI2/App.config
index 5951f566..1ce5b944 100644
--- a/ENI-2/ENI2/ENI2/App.config
+++ b/ENI-2/ENI2/ENI2/App.config
@@ -26,12 +26,12 @@
1000
- http://192.168.2.4/LockingService/LockingService.svc
-
+
+ http://heupferd/bsmd.LockingService/LockingService.svc
- Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False
-
+
+ Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=E:\DATA\DB\NSW.MDF;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
diff --git a/ENI-2/ENI2/ENI2/App.xaml.cs b/ENI-2/ENI2/ENI2/App.xaml.cs
index 4c4c46bf..f8cc4b82 100644
--- a/ENI-2/ENI2/ENI2/App.xaml.cs
+++ b/ENI-2/ENI2/ENI2/App.xaml.cs
@@ -11,6 +11,7 @@ using System.Windows.Input;
using System;
using System.Net;
using ENI2.LockingServiceReference;
+using ENI2.Util;
using System.Threading;
namespace ENI2
@@ -84,6 +85,50 @@ namespace ENI2
RuleEngine.RegisterPortAreaChecker(LocalizedLookup.PortAreaExists);
RuleEngine.RegisterNationalityChecker(LocalizedLookup.CheckNationality);
+ // Register expandable Properties
+ // WAS
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(WAS));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(Waste));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ // NOA_NOD
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(NOA_NOD));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(CallPurpose));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ // SEC
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(SEC));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(LastTenPortFacilitiesCalled));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(ShipToShipActivitiesDuringLastTenPortFacilitiesCalled));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ // MDH
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(MDH));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(SanitaryMeasuresDetail));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(StowawaysJoiningLocation));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(PortOfCallLast30Days));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(PortOfCallLast30DaysCrewJoinedShip));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(InfectedArea));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ // BPOL
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(BPOL));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(PortOfItinerary));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ // HAZ
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(HAZ));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(IMDGPosition));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(IBCPosition));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(IGCPosition));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(IMSBCPosition));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+ TypeDecorationManager.AddExpandableObjectConverter(typeof(MARPOL_Annex_I_Position));
+ TypeDecorationManager.AddExpandableIListConverter(typeof(IList));
+
// Connect to locking service (if enabled)
try
{
diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
index 62e8fdda..810e0757 100644
--- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
@@ -376,24 +376,25 @@ namespace ENI2
}
message.ChangedBy = string.Format("{0} at {1}", userName, DateTime.Now);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(message);
- if (message.MessageNotificationClass == Message.NotificationClass.CREW)
- {
- foreach(CREW crew in message.Elements)
- {
- if (crew.IsNew || crew.IsDirty) DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(crew);
- }
- }
- else if (message.MessageNotificationClass == Message.NotificationClass.PAS)
- {
- foreach(PAS pas in message.Elements)
- {
- if(pas.IsNew || pas.IsDirty) DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(pas);
- }
- }
- else
- {
+
+ //if (message.MessageNotificationClass == Message.NotificationClass.CREW)
+ //{
+ // foreach(CREW crew in message.Elements)
+ // {
+ // if (crew.IsNew || crew.IsDirty) DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(crew);
+ // }
+ //}
+ //else if (message.MessageNotificationClass == Message.NotificationClass.PAS)
+ //{
+ // foreach(PAS pas in message.Elements)
+ // {
+ // if(pas.IsNew || pas.IsDirty) DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(pas);
+ // }
+ //}
+ //else
+ //{
message.SaveElements();
- }
+ //}
message.IsDirty = false;
if(message.MessageNotificationClass == Message.NotificationClass.ATA)
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
index 55d8a118..9b198dfb 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
@@ -191,7 +191,7 @@ namespace ENI2.DetailViewControls
// are you sure dialog is in base class
_bpol.PortOfItineraries.Remove(poi);
DBManager.Instance.Delete(poi);
- DatabaseEntity.ResetIdentifiers(_bpol.PortOfItineraries);
+ DatabaseEntity.ResetIdentifiers(new List(_bpol.PortOfItineraries));
this.SublistElementChanged(Message.NotificationClass.BPOL);
this.dataGridPortOfItinerary.Items.Refresh();
}
@@ -475,7 +475,7 @@ namespace ENI2.DetailViewControls
};
if (ofd.ShowDialog() ?? false)
{
- FileStream stream = null;
+ FileStream stream;
try
{
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
@@ -549,7 +549,7 @@ namespace ENI2.DetailViewControls
};
if (ofd.ShowDialog() ?? false)
{
- FileStream stream = null;
+ FileStream stream;
try
{
stream = File.Open(ofd.FileName, FileMode.Open, FileAccess.Read);
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
index 2dcd4417..d4fa6218 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
@@ -23,7 +23,7 @@ namespace ENI2.DetailViewControls
private Message _servMessage;
private Message _ladgMessage;
- private static string[] shippingAreas = {
+ private static readonly string[] shippingAreas = {
Properties.Resources.textShippingAreaNORTHBALTIC,
Properties.Resources.textShippingAreaEUROPE,
Properties.Resources.textShippingAreaOverseas
@@ -185,8 +185,7 @@ namespace ENI2.DetailViewControls
private void DataGridLADG_DeleteRequested(DatabaseEntity obj)
{
- LADG ladg = obj as LADG;
- if (ladg != null)
+ if (obj is LADG ladg)
{
// are you sure dialog is in base class
this._ladgMessage.Elements.Remove(ladg);
@@ -267,8 +266,7 @@ namespace ENI2.DetailViewControls
private void DataGridSERV_DeleteRequested(DatabaseEntity obj)
{
- SERV serv = obj as SERV;
- if (serv != null)
+ if (obj is SERV serv)
{
// are you sure dialog is in base class
_servMessage.Elements.Remove(serv);
diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj
index 1c5367cf..d13a249d 100644
--- a/ENI-2/ENI2/ENI2/ENI2.csproj
+++ b/ENI-2/ENI2/ENI2/ENI2.csproj
@@ -34,8 +34,8 @@
3.5.1.0
true
publish.html
- 4
- 5.2.0.%2a
+ 0
+ 5.2.1.%2a
false
true
true
@@ -338,6 +338,7 @@
+
diff --git a/ENI-2/ENI2/ENI2/EditControls/MessageHistoryDialog.xaml.cs b/ENI-2/ENI2/ENI2/EditControls/MessageHistoryDialog.xaml.cs
index f2e2720b..36b5432c 100644
--- a/ENI-2/ENI2/ENI2/EditControls/MessageHistoryDialog.xaml.cs
+++ b/ENI-2/ENI2/ENI2/EditControls/MessageHistoryDialog.xaml.cs
@@ -93,7 +93,10 @@ namespace ENI2.EditControls
Message targetMessage = null;
foreach (Message aMessage in this.Messages)
{
- if (aMessage.MessageNotificationClassDisplay.Equals(selectedHistory.EntityName))
+ if (aMessage.MessageNotificationClassDisplay.Equals(selectedHistory.EntityName) ||
+ (aMessage.MessageNotificationClassDisplay.Equals("BKRA") && selectedHistory.EntityName.Equals("BRKA")) ||
+ (aMessage.MessageNotificationClassDisplay.Equals("BKRD") && selectedHistory.EntityName.Equals("BRKD"))
+ )
{
targetMessage = aMessage;
break;
@@ -106,8 +109,10 @@ namespace ENI2.EditControls
// Fallunterscheidung: a) ISublistElement oder nicht? Falls ja müssen die anderen Elemente zusammengesucht werden
if(Message.IsListClass(targetMessage.MessageNotificationClass)) // Meldeklasse ist also z.B. LADG, CREW, PAS..
{
- foreach (DatabaseEntity oldElement in targetMessage.Elements)
+ foreach (DatabaseEntity oldElement in targetMessage.Elements)
DBManager.Instance.Delete(oldElement);
+ targetMessage.Elements.Clear();
+
foreach (DatabaseEntity element in selectedHistory.GetGroup(this.MessageHistories))
{
targetMessage.Elements.Add(element);
diff --git a/ENI-2/ENI2/ENI2/EditControls/SimplePropertyViewDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/SimplePropertyViewDialog.xaml
index c54eba11..884c5a4a 100644
--- a/ENI-2/ENI2/ENI2/EditControls/SimplePropertyViewDialog.xaml
+++ b/ENI-2/ENI2/ENI2/EditControls/SimplePropertyViewDialog.xaml
@@ -8,12 +8,12 @@
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
- Title="SimplePropertyViewDialog" Height="640" Width="480" WindowStyle="ToolWindow" ResizeMode="NoResize"
+ Title="SimplePropertyViewDialog" Height="640" Width="480" WindowStyle="ToolWindow" ResizeMode="CanResize"
Background="White">
+ HideInheritedProperties="True" ShowSearchBox="True" ShowSortOptions="True" />
diff --git a/ENI-2/ENI2/ENI2/Util/ExpandableListConverter.cs b/ENI-2/ENI2/ENI2/Util/ExpandableListConverter.cs
new file mode 100644
index 00000000..87b61e83
--- /dev/null
+++ b/ENI-2/ENI2/ENI2/Util/ExpandableListConverter.cs
@@ -0,0 +1,145 @@
+// Copyright (c) 2019 schick Informatik
+// Description: Hilfsklasse zur Darstellung von untergeordneten Listen
+// im XCeed PropertyGrid
+// Idee von der 2. Antwort hier:
+// https://stackoverflow.com/questions/36286530/xceed-wpf-propertygrid-show-item-for-expanded-collection
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.ComponentModel;
+using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
+using System.Collections;
+
+namespace ENI2.Util
+{
+
+ #region class ENIExpandableIListConverter
+
+ public class ENIExpandableIListConverter : ExpandableObjectConverter
+ {
+
+ public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
+ {
+ if (value is IList)
+ {
+ IList list = value as IList;
+ PropertyDescriptorCollection propDescriptions = new PropertyDescriptorCollection(null);
+ IEnumerator enumerator = list.GetEnumerator();
+ int counter = -1;
+ while (enumerator.MoveNext())
+ {
+ counter++;
+ propDescriptions.Add(new ListItemPropertyDescriptor(list, counter));
+
+ }
+ return propDescriptions;
+ }
+ else
+ {
+ return base.GetProperties(context, value, attributes);
+ }
+ }
+ }
+
+ #endregion
+
+ #region class ListItemPropertyDescriptor
+
+ public class ListItemPropertyDescriptor : PropertyDescriptor
+ {
+ private readonly IList _owner;
+ private readonly int index;
+
+ public ListItemPropertyDescriptor(IList owner, int index) : base("[" + index + "]", null)
+ {
+ this._owner = owner;
+ this.index = index;
+
+ }
+
+ public override AttributeCollection Attributes
+ {
+ get
+ {
+ var attributes = TypeDescriptor.GetAttributes(GetValue(null), false);
+ //If the Xceed expandable object attribute is not applied then apply it
+ if (!attributes.OfType().Any())
+ {
+ attributes = AddAttribute(new ExpandableObjectAttribute(), attributes);
+ }
+
+ //set the xceed order attribute
+ return AddAttribute(new PropertyOrderAttribute(index), attributes);
+ }
+ }
+
+ private AttributeCollection AddAttribute(Attribute newAttribute, AttributeCollection oldAttributes)
+ {
+ Attribute[] newAttributes = new Attribute[oldAttributes.Count + 1];
+ oldAttributes.CopyTo(newAttributes, 1);
+ newAttributes[0] = newAttribute;
+
+ return new AttributeCollection(newAttributes);
+ }
+
+ public override bool CanResetValue(object component)
+ {
+ return false;
+ }
+
+ public override object GetValue(object component)
+ {
+ return Value;
+ }
+
+ private T Value
+ => _owner[index];
+
+ public override void ResetValue(object component)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void SetValue(object component, object value)
+ {
+ _owner[index] = (T)value;
+ }
+
+ public override bool ShouldSerializeValue(object component)
+ {
+ return false;
+ }
+
+ public override Type ComponentType
+ => _owner.GetType();
+
+ public override bool IsReadOnly
+ => false;
+
+ public override Type PropertyType
+ => Value?.GetType();
+ }
+
+ #endregion
+
+ #region class TypeDecorationManager
+
+ public static class TypeDecorationManager
+ {
+ public static void AddExpandableObjectConverter(Type T)
+ {
+ TypeDescriptor.AddAttributes(T, new TypeConverterAttribute(typeof(ExpandableObjectConverter)));
+ TypeDescriptor.AddAttributes(T, new ExpandableObjectAttribute());
+ }
+
+ public static void AddExpandableIListConverter(Type T)
+ {
+ TypeDescriptor.AddAttributes(T, new TypeConverterAttribute(typeof(ENIExpandableIListConverter)));
+ TypeDescriptor.AddAttributes(T, new ExpandableObjectAttribute());
+ }
+ }
+
+ #endregion
+
+}
diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx
index 7c9e4acf..c5bce840 100644
Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ
diff --git a/nsw/Serverumzug.txt b/nsw/Serverumzug.txt
index 9a6a7b9d..c2290ceb 100644
--- a/nsw/Serverumzug.txt
+++ b/nsw/Serverumzug.txt
@@ -29,5 +29,7 @@ AIS
User Mapping nach Backup-Restore der Datenbank wiederherstellen: (ausgeführt auf der importierten DB)
exec sp_change_users_login 'UPDATE_ONE', 'aisuser', 'aisuser'
exec sp_change_users_login 'REPORT'
+delete from aisposreport WHERE [Timestamp] < DATEADD(day, -3, GETDATE())
+
diff --git a/nsw/Source/bsmd.database/BKRA.cs b/nsw/Source/bsmd.database/BKRA.cs
index 1bb0aa38..b638d07a 100644
--- a/nsw/Source/bsmd.database/BKRA.cs
+++ b/nsw/Source/bsmd.database/BKRA.cs
@@ -11,6 +11,7 @@ using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
+using System.ComponentModel;
namespace bsmd.database
{
@@ -37,6 +38,7 @@ namespace bsmd.database
public string Identifier { get; set; }
+ [Browsable(false)]
public string SublistCollectionKey { get { return "bkra"; } }
#endregion
diff --git a/nsw/Source/bsmd.database/BPOL.cs b/nsw/Source/bsmd.database/BPOL.cs
index 37ff34fa..3d023069 100644
--- a/nsw/Source/bsmd.database/BPOL.cs
+++ b/nsw/Source/bsmd.database/BPOL.cs
@@ -11,14 +11,16 @@ using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.ComponentModel;
+using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class BPOL : DatabaseEntity, ISublistContainer
{
-
- private ObservableCollection poi = new ObservableCollection();
-
public BPOL()
{
this.tablename = "[dbo].[BPOL]";
@@ -36,7 +38,7 @@ namespace bsmd.database
[ENI2Validation]
public bool? CruiseShip { get; set; }
- public ObservableCollection PortOfItineraries { get { return this.poi; } }
+ public ObservableCollection PortOfItineraries { get; private set; } = new ObservableCollection();
#endregion
@@ -135,6 +137,8 @@ namespace bsmd.database
return null;
}
+ [Browsable(false)]
+ [JsonIgnore]
public int NumberOfExcelRows
{
get { return 1; }
@@ -198,7 +202,7 @@ namespace bsmd.database
{
BPOL bpol = this.MemberwiseClone() as BPOL;
bpol.id = null;
- bpol.poi = new ObservableCollection();
+ bpol.PortOfItineraries = new ObservableCollection();
foreach (PortOfItinerary po in this.PortOfItineraries)
{
diff --git a/nsw/Source/bsmd.database/BRKD.cs b/nsw/Source/bsmd.database/BRKD.cs
index 54d95d43..e2067245 100644
--- a/nsw/Source/bsmd.database/BRKD.cs
+++ b/nsw/Source/bsmd.database/BRKD.cs
@@ -11,6 +11,7 @@ using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
+using System.ComponentModel;
namespace bsmd.database
{
@@ -37,6 +38,7 @@ namespace bsmd.database
public string Identifier { get; set; }
+ [Browsable(false)]
public string SublistCollectionKey { get { return "bkrd"; } }
#endregion
diff --git a/nsw/Source/bsmd.database/CallPurpose.cs b/nsw/Source/bsmd.database/CallPurpose.cs
index d92bbeee..fb4d33b5 100644
--- a/nsw/Source/bsmd.database/CallPurpose.cs
+++ b/nsw/Source/bsmd.database/CallPurpose.cs
@@ -12,9 +12,13 @@ using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class CallPurpose : DatabaseEntity, ISublistElement
{
@@ -26,6 +30,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public NOA_NOD NOA_NOD { get; set; }
[ShowReport]
@@ -65,7 +70,7 @@ namespace bsmd.database
}
else
{
- scmd.Parameters.AddWithValue(@"ID", this.Id);
+ scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET CallPurposeCode = @P2, CallPurposeDescription = @P3, Identifier = @P4 " +
"WHERE Id = @ID", this.Tablename);
}
@@ -119,5 +124,5 @@ namespace bsmd.database
#endregion
- }
+ }
}
diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs
index 672cf9e0..1ea53535 100644
--- a/nsw/Source/bsmd.database/DBManager.cs
+++ b/nsw/Source/bsmd.database/DBManager.cs
@@ -773,9 +773,9 @@ namespace bsmd.database
mh.EntityValues = JsonConvert.SerializeObject(entity);
if (ReportingParty.CurrentReportingParty != null)
mh.ReportingPartyId = ReportingParty.CurrentReportingParty.Id.Value;
- if (entity is ISublistElement)
+ if (entity is ISublistElement sublistElement)
{
- string stringIdentifier = ((ISublistElement)entity).Identifier;
+ string stringIdentifier = (sublistElement).Identifier;
Regex re = new Regex(@"\d+");
Match m = re.Match(stringIdentifier);
if (m.Success)
@@ -819,7 +819,8 @@ namespace bsmd.database
{ typeof(TIEFD), typeof(TIEFD).Name },
{ typeof(TOWA), typeof(TOWA).Name },
{ typeof(TOWD), typeof(TOWD).Name },
- { typeof(WAS), typeof(WAS).Name }
+ { typeof(WAS), typeof(WAS).Name },
+ { typeof(BPOL), typeof(BPOL).Name }
};
}
diff --git a/nsw/Source/bsmd.database/DatabaseEntity.cs b/nsw/Source/bsmd.database/DatabaseEntity.cs
index af047ad0..36f1abec 100644
--- a/nsw/Source/bsmd.database/DatabaseEntity.cs
+++ b/nsw/Source/bsmd.database/DatabaseEntity.cs
@@ -18,6 +18,7 @@ using System.Xml.Serialization;
using System.IO;
using Newtonsoft.Json;
using log4net;
+using System.ComponentModel;
namespace bsmd.database
{
@@ -55,9 +56,11 @@ namespace bsmd.database
/// Nachrichtentyp der abgeleiteten Meldeklassen
///
[JsonIgnore]
+ [Browsable(false)]
public Message.NotificationClass MessageNotificationClass { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string MessageNotificationClassDisplay
{
get
@@ -70,35 +73,42 @@ namespace bsmd.database
/// Referenz zur eigentlichen Schiffankunft
///
[JsonIgnore]
+ [Browsable(false)]
public MessageCore MessageCore { get; set; }
///
/// gemeinschaftliche Daten
///
[JsonIgnore]
+ [Browsable(false)]
public Message MessageHeader { get; set; }
///
/// SQL Table name to construct queries
///
[JsonIgnore]
+ [Browsable(false)]
public virtual string Tablename { get { return this.tablename; } }
///
/// primary key
- ///
+ ///
+ [JsonIgnore]
+ [Browsable(false)]
public Guid? Id { get { return this.id; } }
///
/// IsNew Flag
///
[JsonIgnore]
+ [Browsable(false)]
public bool IsNew { get { return !this.id.HasValue; } }
///
/// Flag zeigt an ob das Objekt geändert wurde
///
[JsonIgnore]
+ [Browsable(false)]
public bool IsDirty { get; set; }
#endregion
@@ -314,6 +324,7 @@ namespace bsmd.database
#region IMessageParagraph implementation
[JsonIgnore]
+ [Browsable(false)]
public virtual string Title
{
get
@@ -324,12 +335,14 @@ namespace bsmd.database
}
[JsonIgnore]
+ [Browsable(false)]
public virtual string Subtitle
{
get { return string.Empty; }
}
[JsonIgnore]
+ [Browsable(false)]
public virtual bool ShowChildrenAsTable
{
get { return false; }
@@ -339,6 +352,7 @@ namespace bsmd.database
/// must be overridden if it must make sense
///
[JsonIgnore]
+ [Browsable(false)]
public virtual List> MessageText
{
get {
@@ -399,6 +413,7 @@ namespace bsmd.database
}
[JsonIgnore]
+ [Browsable(false)]
public virtual List ChildParagraphs { get { return null; } }
#endregion
diff --git a/nsw/Source/bsmd.database/HAZ.cs b/nsw/Source/bsmd.database/HAZ.cs
index af02f625..932e976d 100644
--- a/nsw/Source/bsmd.database/HAZ.cs
+++ b/nsw/Source/bsmd.database/HAZ.cs
@@ -7,12 +7,17 @@
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
+using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.ComponentModel;
using System.Data.SqlClient;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class HAZ : DatabaseEntity, ISublistContainer
{
@@ -82,6 +87,8 @@ namespace bsmd.database
[ENI2Validation]
public string TransmissionType { get; set; }
+ [Browsable(false)]
+ [JsonIgnore]
public bool HasPositions
{
get
@@ -98,6 +105,8 @@ namespace bsmd.database
///
/// Hilfsstruktur für Packagetype Darstellung (IMDG) im ENI-2
///
+ [JsonIgnore]
+ [Browsable(false)]
public static Dictionary PackageTypes { get; set; }
#endregion
@@ -324,6 +333,8 @@ namespace bsmd.database
return null;
}
+ [Browsable(false)]
+ [JsonIgnore]
public int NumberOfExcelRows { get { return 0; } }
public IGCPosition GetIGCPositionWithIdentifier(string identifier)
@@ -434,7 +445,7 @@ namespace bsmd.database
{
MessageParagraph containerParagraph = new MessageParagraph();
containerParagraph.Title = "IMDGPositions";
- List sublist = new List();
+ //List sublist = new List();
foreach (IMessageParagraph imp in this.IMDGPositions)
containerParagraph.ChildParagraphs.Add(imp);
allChildParagraphs.Add(containerParagraph);
@@ -444,7 +455,7 @@ namespace bsmd.database
{
MessageParagraph containerParagraph = new MessageParagraph();
containerParagraph.Title = "IBCPositions";
- List sublist = new List();
+ //List sublist = new List();
foreach (IMessageParagraph imp in this.IBCPositions)
containerParagraph.ChildParagraphs.Add(imp);
allChildParagraphs.Add(containerParagraph);
@@ -454,7 +465,7 @@ namespace bsmd.database
{
MessageParagraph containerParagraph = new MessageParagraph();
containerParagraph.Title = "IGCPositions";
- List sublist = new List();
+ //List sublist = new List();
foreach (IMessageParagraph imp in this.IGCPositions)
containerParagraph.ChildParagraphs.Add(imp);
allChildParagraphs.Add(containerParagraph);
@@ -464,7 +475,7 @@ namespace bsmd.database
{
MessageParagraph containerParagraph = new MessageParagraph();
containerParagraph.Title = "IMSBCPositions";
- List sublist = new List();
+ //List sublist = new List();
foreach (IMessageParagraph imp in this.IMSBCPositions)
containerParagraph.ChildParagraphs.Add(imp);
allChildParagraphs.Add(containerParagraph);
@@ -474,7 +485,7 @@ namespace bsmd.database
{
MessageParagraph containerParagraph = new MessageParagraph();
containerParagraph.Title = "MARPOLPositions";
- List sublist = new List();
+ //List sublist = new List();
foreach (IMessageParagraph imp in this.MARPOLPositions)
containerParagraph.ChildParagraphs.Add(imp);
allChildParagraphs.Add(containerParagraph);
diff --git a/nsw/Source/bsmd.database/IBCPosition.cs b/nsw/Source/bsmd.database/IBCPosition.cs
index ab2626ca..49a2ebdd 100644
--- a/nsw/Source/bsmd.database/IBCPosition.cs
+++ b/nsw/Source/bsmd.database/IBCPosition.cs
@@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;
@@ -17,6 +18,9 @@ using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class IBCPosition : DatabaseEntity, ISublistElement
{
@@ -58,6 +62,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public HAZ HAZ { get; set; }
[ShowReport]
@@ -158,6 +163,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "ibc"; } }
#endregion
diff --git a/nsw/Source/bsmd.database/IGCPosition.cs b/nsw/Source/bsmd.database/IGCPosition.cs
index 5f14edc7..e7c790c7 100644
--- a/nsw/Source/bsmd.database/IGCPosition.cs
+++ b/nsw/Source/bsmd.database/IGCPosition.cs
@@ -9,12 +9,16 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using Newtonsoft.Json;
namespace bsmd.database
-{
+{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class IGCPosition : DatabaseEntity, ISublistElement
{
@@ -26,6 +30,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public HAZ HAZ { get; set; }
[ShowReport]
@@ -75,6 +80,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "igc"; } }
#endregion
@@ -106,7 +112,7 @@ namespace bsmd.database
}
else
{
- scmd.Parameters.AddWithValue(@"ID", this.Id);
+ scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET UNNumber = @P2, IMOClass = @P3, ProductName = @P4, " +
"Quantity_KGM = @P5, StowagePosition = @P6, PortOfLoading = @P7, PortOfDischarge = @P8, Remarks = @P9, " +
"Identifier = @P10 WHERE ID = @ID", this.Tablename);
diff --git a/nsw/Source/bsmd.database/IMDGPosition.cs b/nsw/Source/bsmd.database/IMDGPosition.cs
index 5be004bd..0f39d541 100644
--- a/nsw/Source/bsmd.database/IMDGPosition.cs
+++ b/nsw/Source/bsmd.database/IMDGPosition.cs
@@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Text;
@@ -17,6 +18,9 @@ using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class IMDGPosition : DatabaseEntity, ISublistElement
{
public IMDGPosition()
@@ -27,6 +31,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public HAZ HAZ { get; set; }
[ShowReport]
@@ -326,7 +331,7 @@ namespace bsmd.database
}
else
{
- scmd.Parameters.AddWithValue(@"ID", this.Id);
+ scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET UNNumber = @P2, PackingGroup = @P3, ProperShippingName = @P4, " +
"IMOClass = @P5, CompatibilityGroup = @P6, TechnicalName = @P7, NetExplosiveMass_KGM = @P8, " +
"Flashpoint_CEL = @P9, Class7NuclideName = @P10, Class7MaxActivity_BQL = @P11, Class7Category = @P12, " +
@@ -454,7 +459,7 @@ namespace bsmd.database
if (!this.Flashpoint_CEL.IsNullOrEmpty())
{
- string pattern = @"^[<>]?\-?[0-9]+(\.[0-9]+)?$";
+ const string pattern = @"^[<>]?\-?[0-9]+(\.[0-9]+)?$";
Regex regex = new Regex(pattern);
if (!regex.IsMatch(this.Flashpoint_CEL))
@@ -463,7 +468,7 @@ namespace bsmd.database
if(!this.IMOClass.IsNullOrEmpty())
{
- string pattern = @"^[1-9]{1}(\.[1-9]{1}([A-Z]{1})?)?$";
+ const string pattern = @"^[1-9]{1}(\.[1-9]{1}([A-Z]{1})?)?$";
Regex regex = new Regex(pattern);
if (!regex.IsMatch(this.IMOClass))
diff --git a/nsw/Source/bsmd.database/IMSBCPosition.cs b/nsw/Source/bsmd.database/IMSBCPosition.cs
index 8ae483bd..01f8d106 100644
--- a/nsw/Source/bsmd.database/IMSBCPosition.cs
+++ b/nsw/Source/bsmd.database/IMSBCPosition.cs
@@ -9,12 +9,16 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class IMSBCPosition : DatabaseEntity, ISublistElement
{
@@ -26,6 +30,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public HAZ HAZ { get; set; }
[ShowReport]
@@ -80,6 +85,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "imsbc"; } }
#endregion
diff --git a/nsw/Source/bsmd.database/InfectedArea.cs b/nsw/Source/bsmd.database/InfectedArea.cs
index ce3c491b..6e14c0dc 100644
--- a/nsw/Source/bsmd.database/InfectedArea.cs
+++ b/nsw/Source/bsmd.database/InfectedArea.cs
@@ -9,12 +9,16 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class InfectedArea : DatabaseEntity, ISublistElement
{
@@ -26,6 +30,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public MDH MDH { get; set; }
[ShowReport]
@@ -40,6 +45,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "infectedarea"; } }
#endregion
diff --git a/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs b/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs
index ecaa4903..bee4171d 100644
--- a/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs
+++ b/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs
@@ -12,9 +12,13 @@ using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class LastTenPortFacilitiesCalled : DatabaseEntity, ISublistElement
{
@@ -26,6 +30,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public SEC SEC { get; set; }
[ShowReport]
@@ -79,6 +84,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "l10pfc"; } }
#endregion
@@ -191,6 +197,6 @@ namespace bsmd.database
#endregion
- }
+ }
}
diff --git a/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs b/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs
index f1108a3d..7533ab85 100644
--- a/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs
+++ b/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs
@@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
@@ -16,6 +17,9 @@ using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class MARPOL_Annex_I_Position : DatabaseEntity, ISublistElement
{
@@ -27,6 +31,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public HAZ HAZ { get; set; }
[ShowReport]
@@ -45,7 +50,7 @@ namespace bsmd.database
{
get
{
- if (this.FlashpointInformation.HasValue && (this.FlashpointInformation.Value >= 0) && (this.FlashpointInformation.Value < IBCPosition.flashpointInformations.Length))
+ if (this.FlashpointInformation.HasValue && (this.FlashpointInformation.Value < IBCPosition.flashpointInformations.Length))
return IBCPosition.flashpointInformations[this.FlashpointInformation.Value];
return "";
}
@@ -88,6 +93,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "marpol"; } }
#endregion
diff --git a/nsw/Source/bsmd.database/MDH.cs b/nsw/Source/bsmd.database/MDH.cs
index cc47c5c7..af94aecc 100644
--- a/nsw/Source/bsmd.database/MDH.cs
+++ b/nsw/Source/bsmd.database/MDH.cs
@@ -12,9 +12,13 @@ using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
+using System.ComponentModel;
+using Newtonsoft.Json;
namespace bsmd.database
-{
+{
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class MDH : DatabaseEntity, ISublistContainer
{
public MDH()
@@ -467,6 +471,8 @@ namespace bsmd.database
return null;
}
+ [Browsable(false)]
+ [JsonIgnore]
public int NumberOfExcelRows
{
get { return 37; }
@@ -557,6 +563,8 @@ namespace bsmd.database
}
}
+ [Browsable(false)]
+ [JsonIgnore]
public override List ChildParagraphs
{
get
@@ -669,4 +677,32 @@ namespace bsmd.database
#endregion
}
+
+ #region class MDHConverter
+
+ public class MDHConverter : TypeConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+ {
+ if (value is string)
+ {
+ string s = value.ToString();
+ //s = s.Replace("\\", "");
+ return JsonConvert.DeserializeObject(s);
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+
+ #endregion
+
}
diff --git a/nsw/Source/bsmd.database/Message.cs b/nsw/Source/bsmd.database/Message.cs
index 71c58767..f4933479 100644
--- a/nsw/Source/bsmd.database/Message.cs
+++ b/nsw/Source/bsmd.database/Message.cs
@@ -1,9 +1,13 @@
-using System;
+// Copyright (c) 2015-present schick Informatik
+// Description: Container für alle Meldeklassen
+
+using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using Newtonsoft.Json;
namespace bsmd.database
{
@@ -629,6 +633,8 @@ namespace bsmd.database
return null;
}
+ [Browsable(false)]
+ [JsonIgnore]
public int NumberOfExcelRows
{
get
diff --git a/nsw/Source/bsmd.database/MessageHistory.cs b/nsw/Source/bsmd.database/MessageHistory.cs
index 235de4eb..b6e09fac 100644
--- a/nsw/Source/bsmd.database/MessageHistory.cs
+++ b/nsw/Source/bsmd.database/MessageHistory.cs
@@ -93,29 +93,32 @@ namespace bsmd.database
int selIndex = tmpList.IndexOf(this);
tmpResult.AddLast(refEntity);
- int myIdentifier = Int32.Parse((sublistElement).Identifier);
-
+
// Elemente vor dem ausgewählten Element der Linked List hinzufügen
- int indexIdentifier = myIdentifier;
-
- for (int tmpIndex = selIndex - 1; (indexIdentifier != 1) && (tmpIndex >= 0); tmpIndex--)
+ int indexIdentifier = Util.GetNumericIdentifier(sublistElement).Value;
+ int refIdentifier = indexIdentifier;
+
+ for (int tmpIndex = selIndex - 1; tmpIndex >= 0; tmpIndex--)
{
DatabaseEntity prevEntity = tmpList[tmpIndex].CreateObjectFromValues() as DatabaseEntity;
- indexIdentifier = Int32.Parse(((ISublistElement)prevEntity).Identifier);
+ int nextIdentifier = Util.GetNumericIdentifier((ISublistElement)prevEntity).Value;
+ if (nextIdentifier >= indexIdentifier) break;
+ indexIdentifier = nextIdentifier;
tmpResult.AddFirst(prevEntity);
}
// Elemente nach dem ausgewählten Element hinzufügen (wenn sie zur gleichen Gruppe gehören)
if ((tmpList.Count - 1) > selIndex)
{
- DatabaseEntity nextEntity = tmpList[selIndex + 1].CreateObjectFromValues() as DatabaseEntity;
- indexIdentifier = Int32.Parse(((ISublistElement)nextEntity).Identifier);
+ indexIdentifier = refIdentifier;
- for (int tmpIndex = selIndex + 2; (indexIdentifier != 1) && (tmpIndex < tmpList.Count); tmpIndex++)
+ for (int tmpIndex = selIndex + 2; tmpIndex < tmpList.Count; tmpIndex++)
{
- tmpResult.AddLast(nextEntity);
- nextEntity = tmpList[tmpIndex].CreateObjectFromValues() as DatabaseEntity;
- indexIdentifier = Int32.Parse(((ISublistElement)nextEntity).Identifier);
+ DatabaseEntity nextEntity = tmpList[tmpIndex].CreateObjectFromValues() as DatabaseEntity;
+ int nextIdentifier = Util.GetNumericIdentifier((ISublistElement)nextEntity).Value;
+ if (nextIdentifier <= indexIdentifier) break;
+ indexIdentifier = nextIdentifier;
+ tmpResult.AddLast(nextEntity);
}
}
}
diff --git a/nsw/Source/bsmd.database/NOA_NOD.cs b/nsw/Source/bsmd.database/NOA_NOD.cs
index 911539d1..5443ea41 100644
--- a/nsw/Source/bsmd.database/NOA_NOD.cs
+++ b/nsw/Source/bsmd.database/NOA_NOD.cs
@@ -12,9 +12,14 @@ using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.ComponentModel;
+using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class NOA_NOD : DatabaseEntity, ISublistContainer
{
public NOA_NOD()
@@ -35,7 +40,7 @@ namespace bsmd.database
public DateTime? ETDFromPortOfCall { get; set; }
[Validation1(ValidationCode.LIST_EMPTY)]
- public ObservableCollection CallPurposes { get; } = new ObservableCollection();
+ public ObservableCollection CallPurposes { get; set; } = new ObservableCollection();
[ShowReport]
[Validation2(ValidationCode.NOT_NULL)]
@@ -184,6 +189,8 @@ namespace bsmd.database
return null;
}
+ [Browsable(false)]
+ [JsonIgnore]
public int NumberOfExcelRows
{
get { return 3; }
@@ -210,6 +217,7 @@ namespace bsmd.database
#region IMessageParagraph implementation
+ [Browsable(false)]
public override string Subtitle
{
get
@@ -218,6 +226,7 @@ namespace bsmd.database
}
}
+ [Browsable(false)]
public override List ChildParagraphs
{
get
@@ -350,5 +359,5 @@ namespace bsmd.database
#endregion
- }
+ }
}
diff --git a/nsw/Source/bsmd.database/NoTypeConverterJsonConverter.cs b/nsw/Source/bsmd.database/NoTypeConverterJsonConverter.cs
new file mode 100644
index 00000000..6f3b291f
--- /dev/null
+++ b/nsw/Source/bsmd.database/NoTypeConverterJsonConverter.cs
@@ -0,0 +1,74 @@
+// Copyright (c) 2015-2017 schick Informatik
+// Description: Helper Klasse damit die Deserialisierung richtig funktioniert, auch wenn man
+// einen TypeConverter auf die Klasse loslässt..
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
+using System;
+using System.ComponentModel;
+
+namespace bsmd.database
+{
+ public class NoTypeConverterJsonConverter : JsonConverter
+ {
+ private static readonly IContractResolver resolver = new NoTypeConverterContractResolver();
+
+ private class NoTypeConverterContractResolver : DefaultContractResolver
+ {
+ protected override JsonContract CreateContract(Type objectType)
+ {
+ if (typeof(T).IsAssignableFrom(objectType))
+ {
+ var contract = this.CreateObjectContract(objectType);
+ contract.Converter = null; // Also null out the converter to prevent infinite recursion.
+ return contract;
+ }
+ return base.CreateContract(objectType);
+ }
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return typeof(T).IsAssignableFrom(objectType);
+ }
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ {
+ return JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = resolver }).Deserialize(reader, objectType);
+ }
+
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = resolver }).Serialize(writer, value);
+ }
+
+ }
+
+ #region class MessageClassConverter
+
+ public class MessageClassConverter : TypeConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+ {
+ if (value is string)
+ {
+ string s = value.ToString();
+ //s = s.Replace("\\", "");
+ return JsonConvert.DeserializeObject(s);
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+
+ #endregion
+
+}
diff --git a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs
index ad329b0b..4aa741a7 100644
--- a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs
+++ b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs
@@ -13,9 +13,13 @@ using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class PortOfCallLast30Days : DatabaseEntity, ISublistElement, ISublistContainer
{
public PortOfCallLast30Days()
@@ -26,9 +30,11 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public MDH MDH { get; set; }
public List CrewJoinedShip { get; private set; } = new List();
+
[ShowReport]
[Validation2(ValidationCode.LOCODE)]
[MaxLength(5)]
@@ -48,6 +54,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "pocl30d"; } }
///
@@ -205,6 +212,8 @@ namespace bsmd.database
return null;
}
+ [Browsable(false)]
+ [JsonIgnore]
public int NumberOfExcelRows
{
get { return 1; }
diff --git a/nsw/Source/bsmd.database/PortOfCallLast30DaysCrewJoinedShip.cs b/nsw/Source/bsmd.database/PortOfCallLast30DaysCrewJoinedShip.cs
index c2d384d8..f4bb32c1 100644
--- a/nsw/Source/bsmd.database/PortOfCallLast30DaysCrewJoinedShip.cs
+++ b/nsw/Source/bsmd.database/PortOfCallLast30DaysCrewJoinedShip.cs
@@ -12,9 +12,13 @@ using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class PortOfCallLast30DaysCrewJoinedShip : DatabaseEntity, ISublistElement
{
diff --git a/nsw/Source/bsmd.database/PortOfItinerary.cs b/nsw/Source/bsmd.database/PortOfItinerary.cs
index aa9ff25e..84f094f5 100644
--- a/nsw/Source/bsmd.database/PortOfItinerary.cs
+++ b/nsw/Source/bsmd.database/PortOfItinerary.cs
@@ -12,9 +12,12 @@ using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class PortOfItinerary : DatabaseEntity, ISublistElement
{
@@ -26,6 +29,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public BPOL BPOL { get; set; }
[ShowReport]
@@ -46,6 +50,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "poi"; } }
#endregion
@@ -72,7 +77,7 @@ namespace bsmd.database
}
else
{
- scmd.Parameters.AddWithValue(@"ID", this.Id);
+ scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET PortOfItineraryName = @P2, PortOfItineraryETA = @P3, " +
"PortOfItineraryLocode = @P5, Identifier = @P4 WHERE Id = @ID", this.Tablename);
}
diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs
index fa20ec3d..d27d6b86 100644
--- a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs
+++ b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs
@@ -2,6 +2,6 @@
[assembly: AssemblyCompany("schick Informatik")]
[assembly: AssemblyProduct("BSMD NSW interface")]
-[assembly: AssemblyInformationalVersion("5.2.0")]
+[assembly: AssemblyInformationalVersion("5.2.1")]
[assembly: AssemblyCopyright("Copyright © 2014-2019 schick Informatik")]
[assembly: AssemblyTrademark("")]
\ No newline at end of file
diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs
index 7cb9a222..f648c0b9 100644
--- a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs
+++ b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs
@@ -1,4 +1,4 @@
using System.Reflection;
-[assembly: AssemblyVersion("5.2.0.*")]
+[assembly: AssemblyVersion("5.2.1.*")]
diff --git a/nsw/Source/bsmd.database/SEC.cs b/nsw/Source/bsmd.database/SEC.cs
index ff01aa3a..878f232a 100644
--- a/nsw/Source/bsmd.database/SEC.cs
+++ b/nsw/Source/bsmd.database/SEC.cs
@@ -12,9 +12,14 @@ using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.ComponentModel;
+using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class SEC : DatabaseEntity, ISublistContainer
{
public SEC()
@@ -84,6 +89,7 @@ namespace bsmd.database
[ENI2Validation]
public byte? ISSCType { get; set; }
+ [JsonIgnore]
[ShowReport]
[ReportDisplayName("ISSC type")]
public string ISSCTypeDisplay { get { return Util.GetISSCTypeDisplay(this.ISSCType); } }
@@ -93,6 +99,7 @@ namespace bsmd.database
// [LookupName("SEC.ISSCIssuerType")] // wird manuell gescannt und konvertiert
public byte? ISSCIssuerType { get; set; }
+ [JsonIgnore]
[ShowReport]
[ReportDisplayName("ISSC issuer type")]
public string ISSCIssuerTypeDisplay { get { return Util.GetISSCIssuerTypeDisplay(this.ISSCIssuerType); } }
@@ -337,6 +344,7 @@ namespace bsmd.database
#region IMessageParagraph implementation
+ [Browsable(false)]
public override string Subtitle
{
get
@@ -358,6 +366,8 @@ namespace bsmd.database
}
}
+ [Browsable(false)]
+ [JsonIgnore]
int ISublistContainer.NumberOfExcelRows
{
get
@@ -489,5 +499,5 @@ namespace bsmd.database
#endregion
- }
+ }
}
diff --git a/nsw/Source/bsmd.database/STAT.cs b/nsw/Source/bsmd.database/STAT.cs
index 01ff340f..4b352d2d 100644
--- a/nsw/Source/bsmd.database/STAT.cs
+++ b/nsw/Source/bsmd.database/STAT.cs
@@ -11,6 +11,8 @@ using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
+using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
@@ -89,6 +91,7 @@ namespace bsmd.database
public string TransportMode { get; set; }
[ShowReport]
+ [JsonIgnore]
public string TransportModeDisplay
{
get
@@ -145,6 +148,7 @@ namespace bsmd.database
[ENI2Validation]
public string ISMCompanyCountry { get; set; }
+ [Browsable(false)]
public override string Subtitle
{
get
@@ -166,8 +170,10 @@ namespace bsmd.database
[ENI2Validation]
public string CertificateOfRegistryNumber { get; set; }
+ [JsonIgnore]
public static Dictionary VesselTypeDict { get; set; }
+ [JsonIgnore]
public static Dictionary TransportModeDict { get; set; }
#endregion
diff --git a/nsw/Source/bsmd.database/SanitaryMeasuresDetail.cs b/nsw/Source/bsmd.database/SanitaryMeasuresDetail.cs
index d65e11f8..aec6b9cd 100644
--- a/nsw/Source/bsmd.database/SanitaryMeasuresDetail.cs
+++ b/nsw/Source/bsmd.database/SanitaryMeasuresDetail.cs
@@ -13,9 +13,13 @@ using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class SanitaryMeasuresDetail : DatabaseEntity, ISublistElement
{
@@ -48,6 +52,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "smd"; } }
#endregion
@@ -125,4 +130,32 @@ namespace bsmd.database
}
+
+ #region class SanitaryMeasuresDetailConverter
+
+ public class SanitaryMeasuresDetailConverter : TypeConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+ {
+ if (value is string)
+ {
+ string s = value.ToString();
+ //s = s.Replace("\\", "");
+ return JsonConvert.DeserializeObject(s);
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+
+ #endregion
+
}
diff --git a/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs b/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs
index 2ce4267e..ddf72238 100644
--- a/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs
+++ b/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs
@@ -12,9 +12,12 @@ using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class ShipToShipActivitiesDuringLastTenPortFacilitiesCalled : DatabaseEntity, ISublistElement
{
@@ -26,6 +29,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public SEC SEC { get; set; }
[ShowReport]
@@ -74,6 +78,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "s2s"; } }
#endregion
@@ -109,7 +114,7 @@ namespace bsmd.database
}
else
{
- scmd.Parameters.AddWithValue(@"ID", this.Id);
+ scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET ShipToShipActivityLocationName = @P2, ShipToShipActivityLocationLoCode = @P3, " +
"ShipToShipActivityLocationCoordinatesLatitude = @P4, ShipToShipActivityLocationCoordinatesLongitude = @P5, ShipToShipActivityDateFrom = @P6," +
"ShipToShipActivityDateTo = @P7, ShipToShipActivityType = @P8, ShipToShipActivitySecurityMattersToReport = @P9, Identifier = @P10, " +
@@ -210,4 +215,5 @@ namespace bsmd.database
#endregion
}
+
}
\ No newline at end of file
diff --git a/nsw/Source/bsmd.database/StowawaysJoiningLocation.cs b/nsw/Source/bsmd.database/StowawaysJoiningLocation.cs
index 8accc63f..9b5bdb30 100644
--- a/nsw/Source/bsmd.database/StowawaysJoiningLocation.cs
+++ b/nsw/Source/bsmd.database/StowawaysJoiningLocation.cs
@@ -13,9 +13,13 @@ using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class StowawaysJoiningLocation : DatabaseEntity, ISublistElement
{
@@ -27,6 +31,7 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public MDH MDH { get; set; }
[ShowReport]
diff --git a/nsw/Source/bsmd.database/Util.cs b/nsw/Source/bsmd.database/Util.cs
index 10fbe4b5..b0aa2f6c 100644
--- a/nsw/Source/bsmd.database/Util.cs
+++ b/nsw/Source/bsmd.database/Util.cs
@@ -212,6 +212,21 @@ namespace bsmd.database
return result;
}
+ public static int? GetNumericIdentifier(ISublistElement element)
+ {
+ if (element != null)
+ {
+ string stringIdentifier = element.Identifier;
+ Regex re = new Regex(@"\d+");
+ Match m = re.Match(stringIdentifier);
+ if (m.Success)
+ {
+ return Int32.Parse(m.Value);
+ }
+ }
+ return null;
+ }
+
#region CoordinateTransformation
public static double NSWToDecimalDegrees(int nswCoordinate)
diff --git a/nsw/Source/bsmd.database/WAS.cs b/nsw/Source/bsmd.database/WAS.cs
index f47c8255..5fd3815e 100644
--- a/nsw/Source/bsmd.database/WAS.cs
+++ b/nsw/Source/bsmd.database/WAS.cs
@@ -12,9 +12,14 @@ using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.ComponentModel;
+using Newtonsoft.Json;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class WAS : DatabaseEntity, ISublistContainer
{
public WAS()
@@ -25,12 +30,16 @@ namespace bsmd.database
#region Properties
+ [JsonIgnore]
public static int[] DKWasteCodes { get; } = { 1100, 1200, 1300, 2100, 2200, 2300, 2311, 2308, 2600, 2300, 2309, 3000, 5100, 5200, 5300, 2300 };
+ [JsonIgnore]
public static string[] DKWasteTypes { get; } = { "Waste oils - Sludge", "Waste oils - Bilge water", "Waste oils - Other", "Garbage - Food waste", "Garbage - Plastic", "Garbage - Other", "Garbage - Other - Cooking oil", "Garbage - Other - Incinerator ashes and clinkers", "Operational wastes", "Garbage - Other", "Garbage - Other - Animal carcasses", "Sewage", "Cargo residues - Marpol Annex I - Other", "Cargo residues - Marpol Annex II - Other", "Cargo residues - Marpol Annex V - Other", "Garbage - Other" };
+ [JsonIgnore]
public static int[] RequiredCodes { get; } = { 1100, 1200, 1300, 2100, 2200, 2300, 2311, 2308, 2600, 2309, 3000, 5100, 5200, 5300 };
+ [JsonIgnore]
public static string[] RequiredTypes { get; } = { "Oily Residues (sludge)", "Oily Bilge Water", "Waste oil - others (specify)", "Food waste", "Plastics", "Domestic wastes", "Cooking oil", "Incinerator ashes", "Operational wastes", "Animal carcass(es)", "Sewage", "Cargo residues - Marpol Annex I", "Cargo residues - Marpol Annex II", "Cargo residues - Marpol Annex V" };
[ShowReport]
@@ -64,9 +73,10 @@ namespace bsmd.database
[LookupName("WAS.ConfirmationOfSufficiency")]
[ENI2Validation]
public bool? ConfirmationOfSufficiency { get; set; }
-
+
public ObservableCollection Waste { get; private set; } = new ObservableCollection();
+ [Browsable(false)]
public ObservableCollection WasteDisposalServiceProvider { get; private set; } = new ObservableCollection();
///
@@ -270,6 +280,8 @@ namespace bsmd.database
return null;
}
+ [Browsable(false)]
+ [JsonIgnore]
public int NumberOfExcelRows
{
get { return 15; }
@@ -307,6 +319,8 @@ namespace bsmd.database
#region IMessageParagraph implementation
+ [Browsable(false)]
+ [JsonIgnore]
public override string Subtitle
{
get
@@ -315,6 +329,8 @@ namespace bsmd.database
}
}
+ [Browsable(false)]
+ [JsonIgnore]
public override List ChildParagraphs
{
get
@@ -514,5 +530,5 @@ namespace bsmd.database
#endregion
- }
+ }
}
diff --git a/nsw/Source/bsmd.database/Waste.cs b/nsw/Source/bsmd.database/Waste.cs
index 1618c6f5..2cb3a737 100644
--- a/nsw/Source/bsmd.database/Waste.cs
+++ b/nsw/Source/bsmd.database/Waste.cs
@@ -10,9 +10,13 @@
using System.Data.SqlClient;
using System.Collections.Generic;
using Newtonsoft.Json;
+using System.ComponentModel;
namespace bsmd.database
{
+
+ [TypeConverter(typeof(MessageClassConverter))]
+ [JsonConverter(typeof(NoTypeConverterJsonConverter))]
public class Waste : DatabaseEntity, ISublistElement
{
@@ -24,9 +28,11 @@ namespace bsmd.database
#region Properties
[JsonIgnore]
+ [Browsable(false)]
public WAS WAS { get; set; }
[JsonIgnore]
+ [Browsable(false)]
[ShowReport]
public string WasteTypeDisplay
{
@@ -128,6 +134,7 @@ namespace bsmd.database
public string Identifier { get; set; }
[JsonIgnore]
+ [Browsable(false)]
public string SublistCollectionKey { get { return "waste"; } }
[JsonIgnore]
@@ -261,5 +268,5 @@ namespace bsmd.database
#endregion
- }
+ }
}
diff --git a/nsw/Source/bsmd.database/bsmd.database.csproj b/nsw/Source/bsmd.database/bsmd.database.csproj
index d4f21d48..92383c70 100644
--- a/nsw/Source/bsmd.database/bsmd.database.csproj
+++ b/nsw/Source/bsmd.database/bsmd.database.csproj
@@ -81,6 +81,7 @@
+
diff --git a/nsw/Source/bsmd.database/bsmd.database.licenseheader b/nsw/Source/bsmd.database/bsmd.database.licenseheader
index 19cf4bb6..d6f3d796 100644
--- a/nsw/Source/bsmd.database/bsmd.database.licenseheader
+++ b/nsw/Source/bsmd.database/bsmd.database.licenseheader
@@ -5,7 +5,7 @@ extensions: .cs .cpp .h
extensions: .aspx .ascx
<%--
-Copyright (c) 2015-2017 schick Informatik
+Copyright (c) 2015-present schick Informatik
--%>
extensions: .vb
'Sample license text.