diff --git a/AIS/bsmd.AISService/AIS/AIS_PosReport.cs b/AIS/bsmd.AISService/AIS/AIS_PosReport.cs index f1f00fc4..20a9fb94 100644 --- a/AIS/bsmd.AISService/AIS/AIS_PosReport.cs +++ b/AIS/bsmd.AISService/AIS/AIS_PosReport.cs @@ -23,7 +23,7 @@ namespace bsmd.AISService.AIS private int raim; private int commstate; - private static ILog _log = LogManager.GetLogger(typeof(AIS_PosReport)); + private static readonly ILog _log = LogManager.GetLogger(typeof(AIS_PosReport)); #region Properties diff --git a/AIS/bsmd.AISService/AISService.cs b/AIS/bsmd.AISService/AISService.cs index 22a4db27..844070eb 100644 --- a/AIS/bsmd.AISService/AISService.cs +++ b/AIS/bsmd.AISService/AISService.cs @@ -18,7 +18,7 @@ namespace bsmd.AISService public partial class AISService : ServiceBase { private const string config_filename = "ais_config.xml"; - private ILog _log = LogManager.GetLogger(typeof(AISService)); + private readonly ILog _log = LogManager.GetLogger(typeof(AISService)); private AIS_QueueManager qManager; public AISService() @@ -45,7 +45,6 @@ namespace bsmd.AISService { _log.ErrorFormat("AIS Service start failed: {0}", errorMessage); } - } internal void DebugStart() @@ -74,8 +73,7 @@ namespace bsmd.AISService return; } - DBConnector dbConnector = new DBConnector(); - dbConnector.ConnectionString = configuration.DBConnectionString; + DBConnector dbConnector = new DBConnector { ConnectionString = configuration.DBConnectionString }; if (!dbConnector.Open()) { _log.Error("Error connecting to database"); diff --git a/AIS/bsmd.AISService/DB/AISPosReport.cs b/AIS/bsmd.AISService/DB/AISPosReport.cs index 4bd1fbc5..dbf9aa70 100644 --- a/AIS/bsmd.AISService/DB/AISPosReport.cs +++ b/AIS/bsmd.AISService/DB/AISPosReport.cs @@ -11,7 +11,7 @@ namespace bsmd.AISService.DB { internal class AISPosReport : AISBaseEntity { - private static ILog _log = LogManager.GetLogger(typeof(AISPosReport)); + private static readonly ILog _log = LogManager.GetLogger(typeof(AISPosReport)); /// /// Saves a (class A or B) position report diff --git a/AIS/bsmd.AISService/bsmd.AISService.licenseheader b/AIS/bsmd.AISService/bsmd.AISService.licenseheader index fa18f4f0..262df3b1 100644 --- a/AIS/bsmd.AISService/bsmd.AISService.licenseheader +++ b/AIS/bsmd.AISService/bsmd.AISService.licenseheader @@ -1,12 +1,12 @@ extensions: designer.cs generated.cs extensions: .cs .cpp .h -// Copyright (c) 2008-2018 schick Informatik +// Copyright (c) 2008-2019 schick Informatik // Description: // extensions: .aspx .ascx <%-- -Copyright (c) 2008-2018 schick Informatik +Copyright (c) 2008-2019 schick Informatik --%> extensions: .vb 'Sample license text. diff --git a/AIS/puls200.AIS2Excel/AISVessel.cs b/AIS/puls200.AIS2Excel/AISVessel.cs index c0f0869a..de7e68de 100644 --- a/AIS/puls200.AIS2Excel/AISVessel.cs +++ b/AIS/puls200.AIS2Excel/AISVessel.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// Copyright (c) 2008-2019 schick Informatik +// Description: Erzeugt eine CSV Datei aus dem Query +// + +using System; using System.Data; using System.Data.SqlClient; using System.IO; @@ -11,9 +11,11 @@ namespace puls200.AIS2Excel { public static class AISVessel { - const string ExportQuery = "SELECT aisposreport.MMSI, aisposreport.timestamp, aisposreport.latitude, aisposreport.longitude, aisposreport.stationid, aisposreport.cog, aisposreport.heading, aisposreport.navstatus, aisstaticdata.callsign, aisstaticdata.name, aisstaticdata.shiptype, aisstaticdata.classb, aisstaticdata.shipdescription " + - "FROM aisstaticdata JOIN aisposreport ON aisposreport.mmsi = aisstaticdata.mmsi " + - "WHERE lat lon timestamp ORDER BY posreport.timestamp"; + const string ExportQuery = "SELECT ap.MMSI, ap.timestamp, ap.latitude, ap.longitude, ap.ROT, ap.COG, ap.SOG, ap.Accuracy, ap.heading, ap.NavStatus, ap.CommState, ap.Raim, " + + "sd.aisversion, sd.imoNumber, sd.callsign, sd.name, sd.shiptype, sd.dimension, sd.typeofdevice, sd.maxpresetstaticdraught, sd.dte, sd.classb, sd.breadth, sd.length " + + "FROM aisstaticdata sd JOIN aisposreport ap ON ap.mmsi = sd.mmsi " + + "WHERE ap.Latitude > @LRLAT AND ap.Latitude < @ULLAT AND ap.Longitude > @ULLON AND ap.Longitude < @LRLON AND ap.Timestamp > @FROM AND ap.Timestamp < @TO " + + "ORDER BY ap.Timestamp"; public static void Export(DateTime from, DateTime to, double ulLat, double ulLon, double lrLat, double lrLon, string filename) @@ -25,6 +27,13 @@ namespace puls200.AIS2Excel con.Open(); SqlCommand cmd = new SqlCommand(ExportQuery, con); + cmd.Parameters.AddWithValue("FROM", from); + cmd.Parameters.AddWithValue("TO", to); + cmd.Parameters.AddWithValue("ULLAT", ulLat * 600000); + cmd.Parameters.AddWithValue("ULLON", ulLon * 600000); + cmd.Parameters.AddWithValue("LRLAT", lrLat * 600000); + cmd.Parameters.AddWithValue("LRLON", lrLon * 600000); + IDataReader reader = cmd.ExecuteReader(); createCsvFile(reader, sw); reader.Close(); @@ -35,7 +44,7 @@ namespace puls200.AIS2Excel public static void createCsvFile(IDataReader reader, StreamWriter writer) { const string Delimiter = "\""; - const string Separator = ","; + const string Separator = ";"; // write header row for (int columnCounter = 0; columnCounter < reader.FieldCount; columnCounter++) diff --git a/AIS/puls200.AIS2Excel/App.config b/AIS/puls200.AIS2Excel/App.config index 37de7fc6..747f81fd 100644 --- a/AIS/puls200.AIS2Excel/App.config +++ b/AIS/puls200.AIS2Excel/App.config @@ -11,7 +11,7 @@ - + Data Source=192.168.2.12;Initial Catalog=ais;Uid=aisuser;Pwd=aispasswd;Connect Timeout=30;Encrypt=False; diff --git a/AIS/puls200.AIS2Excel/Main.Designer.cs b/AIS/puls200.AIS2Excel/Main.Designer.cs index 710e3e04..58886f15 100644 --- a/AIS/puls200.AIS2Excel/Main.Designer.cs +++ b/AIS/puls200.AIS2Excel/Main.Designer.cs @@ -102,6 +102,11 @@ this.numericUpDownULLongitude.Name = "numericUpDownULLongitude"; this.numericUpDownULLongitude.Size = new System.Drawing.Size(83, 20); this.numericUpDownULLongitude.TabIndex = 3; + this.numericUpDownULLongitude.Value = new decimal(new int[] { + 907, + 0, + 0, + 131072}); // // numericUpDownULLatitude // @@ -120,6 +125,11 @@ this.numericUpDownULLatitude.Name = "numericUpDownULLatitude"; this.numericUpDownULLatitude.Size = new System.Drawing.Size(83, 20); this.numericUpDownULLatitude.TabIndex = 2; + this.numericUpDownULLatitude.Value = new decimal(new int[] { + 5391, + 0, + 0, + 131072}); // // groupBox2 // @@ -150,7 +160,12 @@ -2147483648}); this.numericUpDownLRLongitude.Name = "numericUpDownLRLongitude"; this.numericUpDownLRLongitude.Size = new System.Drawing.Size(83, 20); - this.numericUpDownLRLongitude.TabIndex = 4; + this.numericUpDownLRLongitude.TabIndex = 5; + this.numericUpDownLRLongitude.Value = new decimal(new int[] { + 921, + 0, + 0, + 131072}); // // numericUpDownLRLatitude // @@ -168,7 +183,12 @@ -2147483648}); this.numericUpDownLRLatitude.Name = "numericUpDownLRLatitude"; this.numericUpDownLRLatitude.Size = new System.Drawing.Size(83, 20); - this.numericUpDownLRLatitude.TabIndex = 5; + this.numericUpDownLRLatitude.TabIndex = 4; + this.numericUpDownLRLatitude.Value = new decimal(new int[] { + 5385, + 0, + 0, + 131072}); // // label4 // @@ -202,7 +222,7 @@ this.textBoxExportFile.Location = new System.Drawing.Point(101, 163); this.textBoxExportFile.Name = "textBoxExportFile"; this.textBoxExportFile.Size = new System.Drawing.Size(254, 20); - this.textBoxExportFile.TabIndex = 5; + this.textBoxExportFile.TabIndex = 8; // // buttonFileBrowse // @@ -221,7 +241,7 @@ this.buttonExport.Location = new System.Drawing.Point(101, 189); this.buttonExport.Name = "buttonExport"; this.buttonExport.Size = new System.Drawing.Size(83, 23); - this.buttonExport.TabIndex = 7; + this.buttonExport.TabIndex = 9; this.buttonExport.Text = "Export"; this.buttonExport.UseVisualStyleBackColor = false; this.buttonExport.Click += new System.EventHandler(this.ButtonExport_Click); @@ -251,7 +271,7 @@ this.dateTimePickerFrom.Location = new System.Drawing.Point(101, 102); this.dateTimePickerFrom.Name = "dateTimePickerFrom"; this.dateTimePickerFrom.Size = new System.Drawing.Size(254, 20); - this.dateTimePickerFrom.TabIndex = 10; + this.dateTimePickerFrom.TabIndex = 6; // // dateTimePickerTo // @@ -260,7 +280,7 @@ this.dateTimePickerTo.Location = new System.Drawing.Point(101, 128); this.dateTimePickerTo.Name = "dateTimePickerTo"; this.dateTimePickerTo.Size = new System.Drawing.Size(254, 20); - this.dateTimePickerTo.TabIndex = 11; + this.dateTimePickerTo.TabIndex = 7; // // Main // diff --git a/AIS/puls200.AIS2Excel/puls200.AIS2Excel.csproj b/AIS/puls200.AIS2Excel/puls200.AIS2Excel.csproj index c036c31f..75405dc4 100644 --- a/AIS/puls200.AIS2Excel/puls200.AIS2Excel.csproj +++ b/AIS/puls200.AIS2Excel/puls200.AIS2Excel.csproj @@ -67,6 +67,9 @@ True Resources.resx + + bsmd.AISService.licenseheader + SettingsSingleFileGenerator Settings.Designer.cs