diff --git a/AIS/bsmd.AISService/bsmd.AISService.sln b/AIS/bsmd.AISService/bsmd.AISService.sln index b90f496a..854ca03b 100644 --- a/AIS/bsmd.AISService/bsmd.AISService.sln +++ b/AIS/bsmd.AISService/bsmd.AISService.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.AISService", "bsmd.AIS EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "puls200.AIS2Excel", "..\puls200.AIS2Excel\puls200.AIS2Excel.csproj", "{43C4011A-FB61-4426-93C0-D6C2C6B1A4C3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.pasttrack.service", "..\bsmd.pasttrack.service\bsmd.pasttrack.service.csproj", "{3EE75297-37BB-4982-9973-DE76BAE7E90A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {43C4011A-FB61-4426-93C0-D6C2C6B1A4C3}.Debug|Any CPU.Build.0 = Debug|Any CPU {43C4011A-FB61-4426-93C0-D6C2C6B1A4C3}.Release|Any CPU.ActiveCfg = Release|Any CPU {43C4011A-FB61-4426-93C0-D6C2C6B1A4C3}.Release|Any CPU.Build.0 = Release|Any CPU + {3EE75297-37BB-4982-9973-DE76BAE7E90A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EE75297-37BB-4982-9973-DE76BAE7E90A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EE75297-37BB-4982-9973-DE76BAE7E90A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EE75297-37BB-4982-9973-DE76BAE7E90A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AIS/bsmd.pasttrack.service/GlobalSuppressions.cs b/AIS/bsmd.pasttrack.service/GlobalSuppressions.cs new file mode 100644 index 00000000..72dcfda6 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/GlobalSuppressions.cs @@ -0,0 +1,8 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Security", "CA2100:Review SQL queries for security vulnerabilities", Justification = "", Scope = "member", Target = "~M:bsmd.pasttrack.service.Service.GetPasttrack(System.Int32,System.Int32)~bsmd.pasttrack.service.Pasttrack[]")] diff --git a/AIS/bsmd.pasttrack.service/IService.cs b/AIS/bsmd.pasttrack.service/IService.cs new file mode 100644 index 00000000..29be855c --- /dev/null +++ b/AIS/bsmd.pasttrack.service/IService.cs @@ -0,0 +1,37 @@ +using System; +using System.Runtime.Serialization; +using System.ServiceModel; + +namespace bsmd.pasttrack.service +{ + // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together. + [ServiceContract] + public interface IService + { + [OperationContract] + Pasttrack[] GetPasttrack(int mmsi, int mins); + } + + + // Use a data contract as illustrated in the sample below to add composite types to service operations. + [DataContract] + public class Pasttrack + { + /* + * select top 1000 Latitude, Longitude, Heading from aisposreport where mmsi=224717000 +And timestamp > DATEADD(MINUTE, -120, GETDATE()) +order by timestamp desc + */ + + + + [DataMember] + public double Latitude { get; set; } + [DataMember] + public double Longitude { get; set; } + [DataMember] + public DateTime Timestamp { get; set; } + [DataMember] + public int Heading { get; set; } + } +} diff --git a/AIS/bsmd.pasttrack.service/Properties/AssemblyInfo.cs b/AIS/bsmd.pasttrack.service/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7f566ccf --- /dev/null +++ b/AIS/bsmd.pasttrack.service/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("bsmd.pasttrack.service")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("bsmd.pasttrack.service")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3ee75297-37bb-4982-9973-de76bae7e90a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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")] diff --git a/AIS/bsmd.pasttrack.service/Properties/Settings.Designer.cs b/AIS/bsmd.pasttrack.service/Properties/Settings.Designer.cs new file mode 100644 index 00000000..1a502180 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/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 bsmd.pasttrack.service.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.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("Server=192.168.2.25\\SQLEXPRESS;Database=ais;Uid=aisuser;Pwd=aispasswd")] + public string ConnectionString { + get { + return ((string)(this["ConnectionString"])); + } + } + } +} diff --git a/AIS/bsmd.pasttrack.service/Properties/Settings.settings b/AIS/bsmd.pasttrack.service/Properties/Settings.settings new file mode 100644 index 00000000..2fd8cd77 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + Server=192.168.2.25\SQLEXPRESS;Database=ais;Uid=aisuser;Pwd=aispasswd + + + \ No newline at end of file diff --git a/AIS/bsmd.pasttrack.service/Service.svc b/AIS/bsmd.pasttrack.service/Service.svc new file mode 100644 index 00000000..50506dd3 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/Service.svc @@ -0,0 +1 @@ +<%@ ServiceHost Language="C#" Debug="true" Service="bsmd.pasttrack.service.Service" CodeBehind="Service.svc.cs" %> \ No newline at end of file diff --git a/AIS/bsmd.pasttrack.service/Service.svc.cs b/AIS/bsmd.pasttrack.service/Service.svc.cs new file mode 100644 index 00000000..40bf916b --- /dev/null +++ b/AIS/bsmd.pasttrack.service/Service.svc.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using log4net; + +namespace bsmd.pasttrack.service +{ + public class Service : IService + { + private static ILog _log = LogManager.GetLogger(typeof(Service)); + + public Pasttrack[] GetPasttrack(int mmsi, int mins) + { + List aList = new List(); + + // Query + try + { + SqlConnection con = new SqlConnection(Properties.Settings.Default.ConnectionString); + 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); + cmd.Parameters.AddWithValue("@MIN", -mins); + SqlDataReader reader = cmd.ExecuteReader(); + while(reader.Read()) + { + Pasttrack p = new Pasttrack(); + p.Latitude = (double) reader.GetInt32(0) / 600000.0; + p.Longitude = (double) reader.GetInt32(1) / 600000.0; + p.Heading = reader.GetInt32(2); + p.Timestamp = reader.GetDateTime(3); + aList.Add(p); + } + reader.Close(); + con.Close(); + } catch (SqlException ex) + { + _log.ErrorFormat("Error on data query: {0}", ex.ToString()); + } + _log.InfoFormat("Result pasttrack array contains {0} elems", aList.Count); + return aList.ToArray(); + } + } +} diff --git a/AIS/bsmd.pasttrack.service/Web.Debug.config b/AIS/bsmd.pasttrack.service/Web.Debug.config new file mode 100644 index 00000000..c1a56423 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/AIS/bsmd.pasttrack.service/Web.Release.config b/AIS/bsmd.pasttrack.service/Web.Release.config new file mode 100644 index 00000000..19058ed3 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/AIS/bsmd.pasttrack.service/Web.config b/AIS/bsmd.pasttrack.service/Web.config new file mode 100644 index 00000000..88f03507 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/Web.config @@ -0,0 +1,54 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Server=192.168.2.25\SQLEXPRESS;Database=ais;Uid=aisuser;Pwd=aispasswd + + + + \ No newline at end of file diff --git a/AIS/bsmd.pasttrack.service/bsmd.pasttrack.service.csproj b/AIS/bsmd.pasttrack.service/bsmd.pasttrack.service.csproj new file mode 100644 index 00000000..6fea43c5 --- /dev/null +++ b/AIS/bsmd.pasttrack.service/bsmd.pasttrack.service.csproj @@ -0,0 +1,132 @@ + + + + Debug + AnyCPU + + + 2.0 + {3EE75297-37BB-4982-9973-DE76BAE7E90A} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + bsmd.pasttrack.service + bsmd.pasttrack.service + v4.5 + True + true + true + + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\bsmd.AISService\packages\log4net.2.0.8\lib\net45-full\log4net.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + Settings.settings + + + Service.svc + + + + + + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + Web.config + + + Web.config + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 27006 + / + http://localhost:27006/ + False + False + + + False + + + + + + \ No newline at end of file diff --git a/AIS/bsmd.pasttrack.service/packages.config b/AIS/bsmd.pasttrack.service/packages.config new file mode 100644 index 00000000..2b3696ab --- /dev/null +++ b/AIS/bsmd.pasttrack.service/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index d0728ceb..319c4720 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ