AIS 2 CSV Tool completed
This commit is contained in:
parent
110a22d112
commit
549f78a6e9
@ -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
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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));
|
||||
|
||||
/// <summary>
|
||||
/// Saves a (class A or B) position report
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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++)
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<applicationSettings>
|
||||
<puls200.AIS2Excel.Properties.Settings>
|
||||
<setting name="ConnectionString" serializeAs="String">
|
||||
<value />
|
||||
<value>Data Source=192.168.2.12;Initial Catalog=ais;Uid=aisuser;Pwd=aispasswd;Connect Timeout=30;Encrypt=False;</value>
|
||||
</setting>
|
||||
</puls200.AIS2Excel.Properties.Settings>
|
||||
</applicationSettings>
|
||||
|
||||
32
AIS/puls200.AIS2Excel/Main.Designer.cs
generated
32
AIS/puls200.AIS2Excel/Main.Designer.cs
generated
@ -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
|
||||
//
|
||||
|
||||
@ -67,6 +67,9 @@
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="..\bsmd.AISService\bsmd.AISService.licenseheader">
|
||||
<Link>bsmd.AISService.licenseheader</Link>
|
||||
</None>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user