diff --git a/AIS/AISAdmin/AISAdmin.csproj b/AIS/AISAdmin/AISAdmin.csproj
index 8e1e787c..c7245a41 100644
--- a/AIS/AISAdmin/AISAdmin.csproj
+++ b/AIS/AISAdmin/AISAdmin.csproj
@@ -49,6 +49,11 @@
True
Resources.resx
+
+ True
+ True
+ Settings.settings
+
@@ -58,4 +63,11 @@
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
\ No newline at end of file
diff --git a/AIS/AISAdmin/App.config b/AIS/AISAdmin/App.config
new file mode 100644
index 00000000..13de9119
--- /dev/null
+++ b/AIS/AISAdmin/App.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+ Data Source=E:\temp\ais.db;Version=3;
+
+
+
+
\ No newline at end of file
diff --git a/AIS/AISAdmin/Main.Designer.cs b/AIS/AISAdmin/Main.Designer.cs
index 68eff238..f272119e 100644
--- a/AIS/AISAdmin/Main.Designer.cs
+++ b/AIS/AISAdmin/Main.Designer.cs
@@ -232,12 +232,12 @@
this.listBoxTargets.ItemHeight = 15;
this.listBoxTargets.Location = new System.Drawing.Point(401, 37);
this.listBoxTargets.Name = "listBoxTargets";
+ this.listBoxTargets.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
this.listBoxTargets.Size = new System.Drawing.Size(369, 154);
this.listBoxTargets.TabIndex = 7;
//
// buttonAssignSelectedTarget
//
- this.buttonAssignSelectedTarget.Enabled = false;
this.buttonAssignSelectedTarget.Image = global::AISAdmin.Properties.Resources.arrow_left_green;
this.buttonAssignSelectedTarget.Location = new System.Drawing.Point(358, 111);
this.buttonAssignSelectedTarget.Name = "buttonAssignSelectedTarget";
@@ -248,7 +248,6 @@
//
// buttonDeleteAssignment
//
- this.buttonDeleteAssignment.Enabled = false;
this.buttonDeleteAssignment.Image = global::AISAdmin.Properties.Resources.delete;
this.buttonDeleteAssignment.Location = new System.Drawing.Point(358, 74);
this.buttonDeleteAssignment.Name = "buttonDeleteAssignment";
@@ -271,7 +270,6 @@
//
this.listBoxAssignment.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
- this.listBoxAssignment.Enabled = false;
this.listBoxAssignment.FormattingEnabled = true;
this.listBoxAssignment.ItemHeight = 15;
this.listBoxAssignment.Location = new System.Drawing.Point(6, 37);
diff --git a/AIS/AISAdmin/Main.cs b/AIS/AISAdmin/Main.cs
index 77a85d88..bc8f901f 100644
--- a/AIS/AISAdmin/Main.cs
+++ b/AIS/AISAdmin/Main.cs
@@ -112,7 +112,7 @@ namespace AISAdmin
private async void Main_Load(object sender, EventArgs e)
{
- _storage = new AIS_SQLiteStorage(null);
+ _storage = new AIS_SQLiteStorage(Properties.Settings.Default.SQLiteDBConnectionString);
_monitorGroups = new BindingList(_storage.LoadGroups());
List zones = _storage.LoadMonitorZones();
foreach(MonitorGroup mg in _monitorGroups)
@@ -135,6 +135,8 @@ namespace AISAdmin
this._allTargets.Add(allTargets[mmsi]);
this._allTargets.Sort();
this.listBoxTargets.DataSource = this._allTargets;
+ if (this._allTargets.Count > 0)
+ this.listBoxTargets.Enabled = true;
}
private void comboBoxGroup_SelectedIndexChanged(object sender, EventArgs e)
@@ -226,8 +228,7 @@ namespace AISAdmin
private void buttonAssignSelectedTarget_Click(object sender, EventArgs e)
{
- AIS_Target? target = (AIS_Target)this.listBoxTargets.SelectedItem;
- if(target != null)
+ foreach (AIS_Target target in this.listBoxTargets.SelectedItems)
{
this.AddOrUpdateAssignmentForAllGroupZones(target.MMSI, MonitorAssignment.ZoneMonitorType.ENTER);
}
diff --git a/AIS/AISAdmin/Properties/Settings.Designer.cs b/AIS/AISAdmin/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..f7505ed3
--- /dev/null
+++ b/AIS/AISAdmin/Properties/Settings.Designer.cs
@@ -0,0 +1,35 @@
+//------------------------------------------------------------------------------
+//
+// 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 AISAdmin.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.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=E:\\temp\\ais.db;Version=3;")]
+ public string SQLiteDBConnectionString {
+ get {
+ return ((string)(this["SQLiteDBConnectionString"]));
+ }
+ }
+ }
+}
diff --git a/AIS/AISAdmin/Properties/Settings.settings b/AIS/AISAdmin/Properties/Settings.settings
new file mode 100644
index 00000000..1ac8d598
--- /dev/null
+++ b/AIS/AISAdmin/Properties/Settings.settings
@@ -0,0 +1,9 @@
+
+
+
+
+
+ Data Source=E:\temp\ais.db;Version=3;
+
+
+
\ No newline at end of file
diff --git a/AIS/bsmd.AIS2Service/AIS_SQLiteStorage.cs b/AIS/bsmd.AIS2Service/AIS_SQLiteStorage.cs
index b11da2eb..8ce456ec 100644
--- a/AIS/bsmd.AIS2Service/AIS_SQLiteStorage.cs
+++ b/AIS/bsmd.AIS2Service/AIS_SQLiteStorage.cs
@@ -38,6 +38,12 @@ namespace bsmd.AIS2Service
_connection.Open();
}
+ public AIS_SQLiteStorage(string connectionString)
+ {
+ _connection = new SQLiteConnection(connectionString);
+ _connection.Open();
+ }
+
#endregion
#region public methods
@@ -323,11 +329,22 @@ namespace bsmd.AIS2Service
public bool Save(MonitorAssignment assignment)
{
if (assignment == null) return false;
- string saveGeoPointString = $"INSERT INTO zone_assignment (mmsi, monitor_zone_id, type) VALUES ({assignment.MMSI}, {assignment.MonitorZoneId}, {(int) assignment.MonitorType})";
- SQLiteCommand cmd = new SQLiteCommand(saveGeoPointString, _connection);
- int insertedRows = cmd.ExecuteNonQuery();
- cmd.Dispose();
- return insertedRows == 1;
+ if (assignment.Id <= 0) // insert
+ {
+ string saveAssignmentString = $"INSERT INTO zone_assignment (mmsi, monitor_zone_id, type) VALUES ({assignment.MMSI}, {assignment.MonitorZoneId}, {(int)assignment.MonitorType})";
+ SQLiteCommand cmd = new SQLiteCommand(saveAssignmentString, _connection);
+ int insertedRows = cmd.ExecuteNonQuery();
+ cmd.Dispose();
+ return insertedRows == 1;
+ }
+ else // update
+ {
+ string saveAssignmentString = $"UPDATE zone_assignment SET type = {(int) assignment.MonitorType} WHERE id = {assignment.Id}";
+ SQLiteCommand cmd = new SQLiteCommand(saveAssignmentString, _connection);
+ int updatedRows = cmd.ExecuteNonQuery();
+ cmd.Dispose();
+ return updatedRows == 1;
+ }
}
public List LoadAssignmentsForZone(long zoneId)