diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs index 1a267331..0f763b38 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs @@ -10,6 +10,7 @@ using ENI2.Util; using System.Windows.Controls; using System.Windows.Media.Imaging; using System; +using System.Collections.Generic; namespace ENI2.DetailViewControls { @@ -342,7 +343,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(marpol); this.haz.MARPOLPositions.Remove(marpol); - DatabaseEntity.ResetIdentifiers(haz.MARPOLPositions); + DatabaseEntity.ResetIdentifiers(new List(haz.MARPOLPositions)); this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); this.dataGridMARPOLItems.Items.Refresh(); } @@ -423,7 +424,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(imsbc); this.haz.IMSBCPositions.Remove(imsbc); - DatabaseEntity.ResetIdentifiers(haz.IMSBCPositions); + DatabaseEntity.ResetIdentifiers(new List(haz.IMSBCPositions)); this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); this.dataGridIMSBCItems.Items.Refresh(); } @@ -503,7 +504,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(igc); this.haz.IGCPositions.Remove(igc); - DatabaseEntity.ResetIdentifiers(haz.IGCPositions); + DatabaseEntity.ResetIdentifiers(new List(haz.IGCPositions)); this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); this.dataGridIGCItems.Items.Refresh(); } @@ -582,7 +583,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ibc); this.haz.IBCPositions.Remove(ibc); - DatabaseEntity.ResetIdentifiers(haz.IBCPositions); + DatabaseEntity.ResetIdentifiers(new List(haz.IBCPositions)); this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); this.dataGridIBCItems.Items.Refresh(); } @@ -661,7 +662,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(imdg); this.haz.IMDGPositions.Remove(imdg); - DatabaseEntity.ResetIdentifiers(haz.IMDGPositions); + DatabaseEntity.ResetIdentifiers(new List(haz.IMDGPositions)); this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZD : Message.NotificationClass.HAZA); this.dataGridIMDGItems.Items.Refresh(); } diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs index 1f351473..67b9b065 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/MaritimeHealthDeclarationDetailControl.xaml.cs @@ -8,7 +8,7 @@ using System.Windows.Controls; using ENI2.EditControls; using ENI2.Util; using bsmd.database; - +using System.Collections.Generic; namespace ENI2.DetailViewControls { @@ -306,7 +306,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class _mdh.SanitaryMeasuresDetails.Remove(smd); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(smd); - DatabaseEntity.ResetIdentifiers(_mdh.SanitaryMeasuresDetails); + DatabaseEntity.ResetIdentifiers(new List(_mdh.SanitaryMeasuresDetails)); this.SublistElementChanged(Message.NotificationClass.MDH); this.dataGridSanitaryMeasures.Items.Refresh(); } @@ -380,7 +380,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class _mdh.InfectedAreas.Remove(ia); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(ia); - DatabaseEntity.ResetIdentifiers(_mdh.InfectedAreas); + DatabaseEntity.ResetIdentifiers(new List(_mdh.InfectedAreas)); this.SublistElementChanged(Message.NotificationClass.MDH); this.dataGridInfectedAreas.Items.Refresh(); } @@ -455,7 +455,7 @@ namespace ENI2.DetailViewControls _mdh.PortOfCallLast30Days.Remove(poc30d); poc30d.DeleteElements(); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(poc30d); - DatabaseEntity.ResetIdentifiers(_mdh.PortOfCallLast30Days); + DatabaseEntity.ResetIdentifiers(new List(_mdh.PortOfCallLast30Days)); this.SublistElementChanged(Message.NotificationClass.MDH); this.dataGridPortOfCallLast30Days.Items.Refresh(); } diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs index b67ee983..d0594538 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortCallDetailControl.xaml.cs @@ -3,6 +3,7 @@ // using System; +using System.Collections.Generic; using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; @@ -118,7 +119,7 @@ namespace ENI2.DetailViewControls // are you sure dialog is in base class _noa_nod.CallPurposes.Remove(cp); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(cp); - DatabaseEntity.ResetIdentifiers(_noa_nod.CallPurposes); + DatabaseEntity.ResetIdentifiers(new List(_noa_nod.CallPurposes)); this.SublistElementChanged(Message.NotificationClass.NOA_NOD); this.dataGridCallPurposes.Items.Refresh(); } diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml.cs index dd09672b..a19a9053 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml.cs @@ -334,7 +334,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/WasteDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/WasteDetailControl.xaml.cs index fd0af334..d333e724 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/WasteDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/WasteDetailControl.xaml.cs @@ -165,8 +165,8 @@ namespace ENI2.DetailViewControls { // are you sure dialog is in base class _was.Waste.Remove(waste); - DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(waste); - DatabaseEntity.ResetIdentifiers(_was.Waste); + DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(waste); + DatabaseEntity.ResetIdentifiers(new List(_was.Waste)); this.SublistElementChanged(Message.NotificationClass.WAS); this.dataGridWaste.Items.Refresh(); } @@ -242,7 +242,7 @@ namespace ENI2.DetailViewControls ofd.Filter = "Excel Files|*.xls;*.xlsx"; 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/EditControls/MessageHistoryDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/MessageHistoryDialog.xaml index 653770cc..23931cb1 100644 --- a/ENI-2/ENI2/ENI2/EditControls/MessageHistoryDialog.xaml +++ b/ENI-2/ENI2/ENI2/EditControls/MessageHistoryDialog.xaml @@ -16,7 +16,8 @@ + SelectionMode="Single" AutoGenerateColumns="False" Margin="5,5,5,0" x:Name="dataGridMessageHistories" + MouseDoubleClick="DataGridViolations_MouseDoubleClick" CanUserAddRows="False"> diff --git a/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/App.config b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/App.config new file mode 100644 index 00000000..28c972e1 --- /dev/null +++ b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/App.config @@ -0,0 +1,18 @@ + + + + +
+ + + + + + + + + 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 + + + + \ No newline at end of file diff --git a/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Program.cs b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Program.cs new file mode 100644 index 00000000..c2913c10 --- /dev/null +++ b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Program.cs @@ -0,0 +1,69 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using bsmd.database; +using System.Text.RegularExpressions; + +namespace UpdateIdentifierTool +{ + static class Program + { + static void Main(string[] args) + { + try + { + SqlConnection con = new SqlConnection(Properties.Settings.Default.ConnectionString); + con.Open(); + Console.WriteLine(); + Console.Write("LOAD.."); + // alles message histories laden... + string query = "SELECT Id, ReportingPartyId, EntityId, EntityType, EntityName, EntityValues, Timestamp, Identifier FROM MessageHistory ORDER BY Timestamp"; + SqlCommand cmd = new SqlCommand(query, con); + IDataReader reader = cmd.ExecuteReader(); + List allHistories = MessageHistory.LoadList(reader); + reader.Close(); + + string updateString = "UPDATE MessageHistory SET Identifier = @IDENTIFIER WHERE ID = @ID"; + SqlCommand updateCmd = new SqlCommand(updateString, con); + SqlParameter p1 = new SqlParameter("@IDENTIFIER", SqlDbType.Int); + SqlParameter p2 = new SqlParameter("@ID", SqlDbType.UniqueIdentifier); + updateCmd.Parameters.Add(p1); + updateCmd.Parameters.Add(p2); + + int cnt = 0; + + foreach(MessageHistory mh in allHistories) + { + object o = mh.CreateObjectFromValues(); + if(o is ISublistElement) + { + string identString = ((ISublistElement)o).Identifier; + Regex re = new Regex(@"\d+"); + Match m = re.Match(identString); + if (m.Success) + { + mh.Identifier = Int32.Parse(m.Value); + p1.Value = mh.Identifier; + p2.Value = mh.Id; + updateCmd.ExecuteNonQuery(); + } + } + + double percentage = 100 * (double) cnt / (double) allHistories.Count; + Console.Write("\b\b\b\b\b\b"); + Console.Write("{0:0.###}", percentage); + cnt++; + } + Console.WriteLine(); + } + catch(Exception ex) + { + Console.WriteLine(ex); + } + } + } +} diff --git a/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/AssemblyInfo.cs b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..de648726 --- /dev/null +++ b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("UpdateIdentifierTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UpdateIdentifierTool")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a30955c4-8580-4c51-8622-053c7ae52d77")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/Settings.Designer.cs b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/Settings.Designer.cs new file mode 100644 index 00000000..3eb039d9 --- /dev/null +++ b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/Settings.Designer.cs @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace UpdateIdentifierTool.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=E:\\DATA\\DB\\NSW.MDF;Integrated " + + "Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;Appl" + + "icationIntent=ReadWrite;MultiSubnetFailover=False")] + public string ConnectionString { + get { + return ((string)(this["ConnectionString"])); + } + } + } +} diff --git a/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/Settings.settings b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/Settings.settings new file mode 100644 index 00000000..28a61076 --- /dev/null +++ b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + 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 + + + \ No newline at end of file diff --git a/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/UpdateIdentifierTool.csproj b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/UpdateIdentifierTool.csproj new file mode 100644 index 00000000..2bcb0fcc --- /dev/null +++ b/nsw/Source/UpdateIdentifierTool/UpdateIdentifierTool/UpdateIdentifierTool.csproj @@ -0,0 +1,68 @@ + + + + + Debug + AnyCPU + {A30955C4-8580-4C51-8622-053C7AE52D77} + Exe + UpdateIdentifierTool + UpdateIdentifierTool + v4.5.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + True + True + Settings.settings + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {19945af2-379b-46a5-b27a-303b5ec1d557} + bsmd.database + + + + \ No newline at end of file diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs index bc5631b9..672cf9e0 100644 --- a/nsw/Source/bsmd.database/DBManager.cs +++ b/nsw/Source/bsmd.database/DBManager.cs @@ -15,6 +15,7 @@ using System.Diagnostics; using Newtonsoft.Json; using log4net; using System.Reflection; +using System.Text.RegularExpressions; namespace bsmd.database { @@ -772,7 +773,15 @@ namespace bsmd.database mh.EntityValues = JsonConvert.SerializeObject(entity); if (ReportingParty.CurrentReportingParty != null) mh.ReportingPartyId = ReportingParty.CurrentReportingParty.Id.Value; - + if (entity is ISublistElement) + { + string stringIdentifier = ((ISublistElement)entity).Identifier; + Regex re = new Regex(@"\d+"); + Match m = re.Match(stringIdentifier); + if (m.Success) + mh.Identifier = Int32.Parse(m.Value); + } + // 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 SqlCommand cmd = new SqlCommand(); diff --git a/nsw/Source/bsmd.database/HAZ.cs b/nsw/Source/bsmd.database/HAZ.cs index 0f5062b6..af02f625 100644 --- a/nsw/Source/bsmd.database/HAZ.cs +++ b/nsw/Source/bsmd.database/HAZ.cs @@ -16,16 +16,6 @@ namespace bsmd.database public class HAZ : DatabaseEntity, ISublistContainer { - #region Fields - - private ObservableCollection imdgPositions = new ObservableCollection(); - private ObservableCollection ibcPositions = new ObservableCollection(); - private ObservableCollection igcPositions = new ObservableCollection(); - private ObservableCollection imsbcPositions = new ObservableCollection(); - private ObservableCollection marpolPositions = new ObservableCollection(); - - #endregion - public HAZ() { } @@ -71,16 +61,16 @@ namespace bsmd.database [ENI2Validation] [MaxLength(64)] public string DPGContactPhone { get; set; } - - public ObservableCollection IMDGPositions { get { return this.imdgPositions; } } - - public ObservableCollection IBCPositions { get { return this.ibcPositions; } } - public ObservableCollection IGCPositions { get { return this.igcPositions; } } + public ObservableCollection IMDGPositions { get; private set; } = new ObservableCollection(); - public ObservableCollection IMSBCPositions { get { return this.imsbcPositions; } } + public ObservableCollection IBCPositions { get; private set; } = new ObservableCollection(); - public ObservableCollection MARPOLPositions { get { return this.marpolPositions; } } + public ObservableCollection IGCPositions { get; private set; } = new ObservableCollection(); + + public ObservableCollection IMSBCPositions { get; private set; } = new ObservableCollection(); + + public ObservableCollection MARPOLPositions { get; private set; } = new ObservableCollection(); // selektor HAZA / HAZD [ENI2Validation] @@ -558,11 +548,11 @@ namespace bsmd.database { HAZ haz = this.MemberwiseClone() as HAZ; haz.id = null; - haz.imdgPositions = new ObservableCollection(); - haz.ibcPositions = new ObservableCollection(); - haz.igcPositions = new ObservableCollection(); - haz.imsbcPositions = new ObservableCollection(); - haz.marpolPositions = new ObservableCollection(); + haz.IMDGPositions = new ObservableCollection(); + haz.IBCPositions = new ObservableCollection(); + haz.IGCPositions = new ObservableCollection(); + haz.IMSBCPositions = new ObservableCollection(); + haz.MARPOLPositions = new ObservableCollection(); foreach (IMDGPosition imdgPosition in this.IMDGPositions) { diff --git a/nsw/Source/bsmd.database/MDH.cs b/nsw/Source/bsmd.database/MDH.cs index 5ee04790..cc47c5c7 100644 --- a/nsw/Source/bsmd.database/MDH.cs +++ b/nsw/Source/bsmd.database/MDH.cs @@ -25,13 +25,13 @@ namespace bsmd.database #region Properties - public ObservableCollection PortOfCallLast30Days { get; private set; } = new ObservableCollection(); + public ObservableCollection PortOfCallLast30Days { get; private set; } = new ObservableCollection(); - public ObservableCollection SanitaryMeasuresDetails { get; private set; } = new ObservableCollection(); + public ObservableCollection SanitaryMeasuresDetails { get; private set; } = new ObservableCollection(); - public ObservableCollection StowawaysJoiningLocations { get; private set; } = new ObservableCollection(); + public ObservableCollection StowawaysJoiningLocations { get; private set; } = new ObservableCollection(); - public ObservableCollection InfectedAreas { get; private set; } = new ObservableCollection(); + public ObservableCollection InfectedAreas { get; private set; } = new ObservableCollection(); [ShowReport] [Validation1(ValidationCode.NOT_NULL)] @@ -630,10 +630,10 @@ namespace bsmd.database { MDH mdh = this.MemberwiseClone() as MDH; mdh.id = null; - mdh.InfectedAreas = new ObservableCollection(); - mdh.PortOfCallLast30Days = new ObservableCollection(); - mdh.SanitaryMeasuresDetails = new ObservableCollection(); - mdh.StowawaysJoiningLocations = new ObservableCollection(); + mdh.InfectedAreas = new ObservableCollection(); + mdh.PortOfCallLast30Days = new ObservableCollection(); + mdh.SanitaryMeasuresDetails = new ObservableCollection(); + mdh.StowawaysJoiningLocations = new ObservableCollection(); foreach (InfectedArea ia in this.InfectedAreas) { diff --git a/nsw/Source/bsmd.database/MessageHistory.cs b/nsw/Source/bsmd.database/MessageHistory.cs index 881d1db4..235de4eb 100644 --- a/nsw/Source/bsmd.database/MessageHistory.cs +++ b/nsw/Source/bsmd.database/MessageHistory.cs @@ -36,6 +36,8 @@ namespace bsmd.database public DateTime Created { get; private set; } + public int Identifier { get; set; } + /// /// ENI Grid helper property /// @@ -56,7 +58,7 @@ namespace bsmd.database internal static string GetLoadCommand() { - return "SELECT Id, ReportingPartyId, EntityId, EntityType, EntityName, EntityValues, Timestamp FROM MessageHistory WHERE EntityId=@ENTITYID ORDER BY Timestamp"; + return "SELECT Id, ReportingPartyId, EntityId, EntityType, EntityName, EntityValues, Timestamp, Identifier FROM MessageHistory WHERE EntityId = @ENTITYID ORDER BY Timestamp, Identifier"; } public object CreateObjectFromValues() @@ -104,14 +106,18 @@ namespace bsmd.database } // Elemente nach dem ausgewählten Element hinzufügen (wenn sie zur gleichen Gruppe gehören) - indexIdentifier = myIdentifier; - for(int tmpIndex = selIndex + 1; (indexIdentifier != 1) && (tmpIndex < tmpList.Count); tmpIndex++) + if ((tmpList.Count - 1) > selIndex) { - DatabaseEntity nextEntity = tmpList[tmpIndex].CreateObjectFromValues() as DatabaseEntity; + DatabaseEntity nextEntity = tmpList[selIndex + 1].CreateObjectFromValues() as DatabaseEntity; indexIdentifier = Int32.Parse(((ISublistElement)nextEntity).Identifier); - tmpResult.AddLast(nextEntity); - } + for (int tmpIndex = selIndex + 2; (indexIdentifier != 1) && (tmpIndex < tmpList.Count); tmpIndex++) + { + tmpResult.AddLast(nextEntity); + nextEntity = tmpList[tmpIndex].CreateObjectFromValues() as DatabaseEntity; + indexIdentifier = Int32.Parse(((ISublistElement)nextEntity).Identifier); + } + } } return new List(tmpResult); @@ -135,9 +141,10 @@ namespace bsmd.database scmd.Parameters.AddWithValue("@P4", this.EntityName); scmd.Parameters.AddWithValue("@P5", this.EntityValues); scmd.Parameters.AddWithValue("@P6", DateTime.Now); + scmd.Parameters.AddWithValue("@P7", this.Identifier); cmd.CommandText = string.Format("INSERT INTO {0} (Id, ReportingPartyId, EntityId, EntityType, " + - "EntityName, EntityValues, Timestamp) VALUES (@ID, @P1, @P2, @P3, @P4, @P5, @P6)", this.Tablename); + "EntityName, EntityValues, Timestamp, Identifier) VALUES (@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7)", this.Tablename); } public void PrepareDelete(IDbCommand cmd) @@ -147,7 +154,7 @@ namespace bsmd.database scmd.Parameters.AddWithValue("@ID", this.Id); } - internal static List LoadList(IDataReader reader) + public static List LoadList(IDataReader reader) { List result = new List(); @@ -161,6 +168,7 @@ namespace bsmd.database if (!reader.IsDBNull(4)) mh.EntityName = reader.GetString(4); if (!reader.IsDBNull(5)) mh.EntityValues = reader.GetString(5); if (!reader.IsDBNull(6)) mh.Created = reader.GetDateTime(6); + if (!reader.IsDBNull(7)) mh.Identifier = reader.GetInt32(7); result.Add(mh); } diff --git a/nsw/Source/bsmd.database/NOA_NOD.cs b/nsw/Source/bsmd.database/NOA_NOD.cs index 7a0b54b8..911539d1 100644 --- a/nsw/Source/bsmd.database/NOA_NOD.cs +++ b/nsw/Source/bsmd.database/NOA_NOD.cs @@ -35,7 +35,7 @@ namespace bsmd.database public DateTime? ETDFromPortOfCall { get; set; } [Validation1(ValidationCode.LIST_EMPTY)] - public ObservableCollection CallPurposes { get; } = new ObservableCollection(); + public ObservableCollection CallPurposes { get; } = new ObservableCollection(); [ShowReport] [Validation2(ValidationCode.NOT_NULL)] diff --git a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs index fb735d5e..ad329b0b 100644 --- a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs +++ b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs @@ -28,7 +28,7 @@ namespace bsmd.database [JsonIgnore] public MDH MDH { get; set; } - public List CrewJoinedShip { get; private set; } = new List(); + public List CrewJoinedShip { get; private set; } = new List(); [ShowReport] [Validation2(ValidationCode.LOCODE)] [MaxLength(5)] @@ -116,7 +116,7 @@ namespace bsmd.database this.CrewJoinedShip.Clear(); // add existing and new crew this.CrewJoinedShip.AddRange(foundList); - DatabaseEntity.ResetIdentifiers(this.CrewJoinedShip); + DatabaseEntity.ResetIdentifiers(new List(this.CrewJoinedShip)); } } } @@ -273,7 +273,7 @@ namespace bsmd.database { PortOfCallLast30Days p30 = this.MemberwiseClone() as PortOfCallLast30Days; p30.id = null; - p30.CrewJoinedShip = new List(); + p30.CrewJoinedShip = new List(); foreach (PortOfCallLast30DaysCrewJoinedShip p30Crew in this.CrewJoinedShip) { diff --git a/nsw/Source/bsmd.database/WAS.cs b/nsw/Source/bsmd.database/WAS.cs index 6d0664b2..f47c8255 100644 --- a/nsw/Source/bsmd.database/WAS.cs +++ b/nsw/Source/bsmd.database/WAS.cs @@ -65,9 +65,9 @@ namespace bsmd.database [ENI2Validation] public bool? ConfirmationOfSufficiency { get; set; } - public ObservableCollection Waste { get; private set; } = new ObservableCollection(); + public ObservableCollection Waste { get; private set; } = new ObservableCollection(); - public ObservableCollection WasteDisposalServiceProvider { get; private set; } = new ObservableCollection(); + public ObservableCollection WasteDisposalServiceProvider { get; private set; } = new ObservableCollection(); /// /// Hilfsproperty, um eine kommaseparierte Liste von WasteDisposalServiceProvider (analog ANSW) im ENI-2 anzuzeigen, @@ -137,7 +137,8 @@ namespace bsmd.database // add existing and new providers foreach(WasteDisposalServiceProvider wdsp in foundList) this.WasteDisposalServiceProvider.Add(wdsp); - DatabaseEntity.ResetIdentifiers(this.WasteDisposalServiceProvider); + List tmpList = new List(this.WasteDisposalServiceProvider); + DatabaseEntity.ResetIdentifiers(tmpList); } } } @@ -490,8 +491,8 @@ namespace bsmd.database { WAS was = this.MemberwiseClone() as WAS; was.id = null; - was.Waste = new ObservableCollection(); - was.WasteDisposalServiceProvider = new ObservableCollection(); + was.Waste = new ObservableCollection(); + was.WasteDisposalServiceProvider = new ObservableCollection(); foreach (Waste waste in this.Waste) {