Pasttrack Service erweitert auf Anfrage Michael: jetzt kann zusätzlich zur MMSI auch eine IMO Nummer angegeben werden (/imo/mins)
This commit is contained in:
parent
5f15b039e9
commit
6d2577631e
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||||
|
|||||||
@ -10,45 +10,96 @@ namespace bsmd.pasttrack.service
|
|||||||
{
|
{
|
||||||
private readonly static ILog _log = LogManager.GetLogger(typeof(Service));
|
private readonly static ILog _log = LogManager.GetLogger(typeof(Service));
|
||||||
|
|
||||||
public Pasttrack[] GetPasttrack(string mmsi, string mins)
|
public Pasttrack[] GetPasttrack(string lookup, string mins)
|
||||||
{
|
{
|
||||||
List<Pasttrack> aList = new List<Pasttrack>();
|
List<Pasttrack> aList = new List<Pasttrack>();
|
||||||
|
|
||||||
if (Int32.TryParse(mmsi, out int mmsi_val) && Int32.TryParse(mins, out int mins_val))
|
if (!string.IsNullOrEmpty(lookup))
|
||||||
{
|
{
|
||||||
try
|
|
||||||
|
if (lookup.Length == 9)
|
||||||
{
|
{
|
||||||
SqlConnection con = new SqlConnection(Properties.Settings.Default.ConnectionString);
|
if (Int32.TryParse(lookup, out int mmsi_val) && Int32.TryParse(mins, out int mins_val))
|
||||||
con.Open();
|
|
||||||
string cmdText = string.Format("select Latitude, Longitude, Heading, Timestamp from aisposreport where mmsi=@MMSI And timestamp > DATEADD(MINUTE, @MIN, GETDATE()) order by timestamp desc");
|
|
||||||
SqlCommand cmd = new SqlCommand(cmdText, con);
|
|
||||||
cmd.Parameters.AddWithValue("@MMSI", mmsi_val);
|
|
||||||
cmd.Parameters.AddWithValue("@MIN", -mins_val);
|
|
||||||
SqlDataReader reader = cmd.ExecuteReader();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
{
|
||||||
Pasttrack p = new Pasttrack
|
try
|
||||||
{
|
{
|
||||||
Latitude = (double)reader.GetInt32(0) / 600000.0,
|
SqlConnection con = new SqlConnection(Properties.Settings.Default.ConnectionString);
|
||||||
Longitude = (double)reader.GetInt32(1) / 600000.0,
|
con.Open();
|
||||||
Heading = reader.GetInt32(2),
|
string cmdText = string.Format("select Latitude, Longitude, Heading, Timestamp from aisposreport where mmsi=@MMSI And timestamp > DATEADD(MINUTE, @MIN, GETDATE()) order by timestamp desc");
|
||||||
Timestamp = reader.GetDateTime(3)
|
SqlCommand cmd = new SqlCommand(cmdText, con);
|
||||||
};
|
cmd.Parameters.AddWithValue("@MMSI", mmsi_val);
|
||||||
aList.Add(p);
|
cmd.Parameters.AddWithValue("@MIN", -mins_val);
|
||||||
|
SqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
Pasttrack p = new Pasttrack
|
||||||
|
{
|
||||||
|
Latitude = (double)reader.GetInt32(0) / 600000.0,
|
||||||
|
Longitude = (double)reader.GetInt32(1) / 600000.0,
|
||||||
|
Heading = reader.GetInt32(2),
|
||||||
|
Timestamp = reader.GetDateTime(3)
|
||||||
|
};
|
||||||
|
aList.Add(p);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
con.Close();
|
||||||
|
}
|
||||||
|
catch (SqlException ex)
|
||||||
|
{
|
||||||
|
_log.ErrorFormat("Error on data query: {0}", ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_log.WarnFormat("invalid parameters: mins {0} mmsi {1}", mins, lookup);
|
||||||
}
|
}
|
||||||
reader.Close();
|
}
|
||||||
con.Close();
|
else if(lookup.Length == 7)
|
||||||
}
|
|
||||||
catch (SqlException ex)
|
|
||||||
{
|
{
|
||||||
_log.ErrorFormat("Error on data query: {0}", ex.ToString());
|
if (Int32.TryParse(lookup, out int imo_val) && Int32.TryParse(mins, out int mins_val))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlConnection con = new SqlConnection(Properties.Settings.Default.ConnectionString);
|
||||||
|
con.Open();
|
||||||
|
string cmdText = string.Format("select Latitude, Longitude, Heading, Timestamp from aisposreport JOIN aisstaticdata ON aisposreport.MMSI = aisstaticdata.mmsi where imoNumber = @IMO AND timestamp > DATEADD(MINUTE, @MIN, GETDATE()) order by timestamp desc");
|
||||||
|
SqlCommand cmd = new SqlCommand(cmdText, con);
|
||||||
|
cmd.Parameters.AddWithValue("@IMO", imo_val);
|
||||||
|
cmd.Parameters.AddWithValue("@MIN", -mins_val);
|
||||||
|
SqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
Pasttrack p = new Pasttrack
|
||||||
|
{
|
||||||
|
Latitude = (double)reader.GetInt32(0) / 600000.0,
|
||||||
|
Longitude = (double)reader.GetInt32(1) / 600000.0,
|
||||||
|
Heading = reader.GetInt32(2),
|
||||||
|
Timestamp = reader.GetDateTime(3)
|
||||||
|
};
|
||||||
|
aList.Add(p);
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
con.Close();
|
||||||
|
}
|
||||||
|
catch (SqlException ex)
|
||||||
|
{
|
||||||
|
_log.ErrorFormat("Error on data query: {0}", ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_log.WarnFormat("invalid parameters: mins {0} mmsi {1}", mins, lookup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_log.WarnFormat("invalid parameters: mins {0} mmsi {1}", mins, lookup);
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
{
|
|
||||||
_log.WarnFormat("invalid parameters: mins {0} mmsi {1}", mins, mmsi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_log.InfoFormat("Result pasttrack array contains {0} elems", aList.Count);
|
_log.InfoFormat("Result pasttrack array contains {0} elems", aList.Count);
|
||||||
return aList.ToArray();
|
return aList.ToArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@
|
|||||||
<StartupObject>ENI2.App</StartupObject>
|
<StartupObject>ENI2.App</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AssemblyOriginatorKeyFile>bsmdKey.snk</AssemblyOriginatorKeyFile>
|
<AssemblyOriginatorKeyFile>bsmdKey.snk</AssemblyOriginatorKeyFile>
|
||||||
@ -87,7 +87,7 @@
|
|||||||
<ManifestCertificateThumbprint>DBA67DB331E10F18BBF1E67B125EC87AB5389EA4</ManifestCertificateThumbprint>
|
<ManifestCertificateThumbprint>DBA67DB331E10F18BBF1E67B125EC87AB5389EA4</ManifestCertificateThumbprint>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignManifests>false</SignManifests>
|
<SignManifests>true</SignManifests>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestKeyFile>ENI2_3_TemporaryKey.pfx</ManifestKeyFile>
|
<ManifestKeyFile>ENI2_3_TemporaryKey.pfx</ManifestKeyFile>
|
||||||
|
|||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user