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
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
|
||||
@ -10,11 +10,16 @@ namespace bsmd.pasttrack.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>();
|
||||
|
||||
if (Int32.TryParse(mmsi, out int mmsi_val) && Int32.TryParse(mins, out int mins_val))
|
||||
if (!string.IsNullOrEmpty(lookup))
|
||||
{
|
||||
|
||||
if (lookup.Length == 9)
|
||||
{
|
||||
if (Int32.TryParse(lookup, out int mmsi_val) && Int32.TryParse(mins, out int mins_val))
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -43,12 +48,58 @@ namespace bsmd.pasttrack.service
|
||||
{
|
||||
_log.ErrorFormat("Error on data query: {0}", ex.ToString());
|
||||
}
|
||||
} else
|
||||
{
|
||||
_log.WarnFormat("invalid parameters: mins {0} mmsi {1}", mins, mmsi);
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.WarnFormat("invalid parameters: mins {0} mmsi {1}", mins, lookup);
|
||||
}
|
||||
}
|
||||
else if(lookup.Length == 7)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
_log.InfoFormat("Result pasttrack array contains {0} elems", aList.Count);
|
||||
return aList.ToArray();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
<StartupObject>ENI2.App</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>bsmdKey.snk</AssemblyOriginatorKeyFile>
|
||||
@ -87,7 +87,7 @@
|
||||
<ManifestCertificateThumbprint>DBA67DB331E10F18BBF1E67B125EC87AB5389EA4</ManifestCertificateThumbprint>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>false</SignManifests>
|
||||
<SignManifests>true</SignManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ManifestKeyFile>ENI2_3_TemporaryKey.pfx</ManifestKeyFile>
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user