started super-simple HTML self-updating table inkl. Cors
This commit is contained in:
parent
9b75a31469
commit
47539cc72a
@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
|
using System.Web.Http.Cors;
|
||||||
|
|
||||||
namespace bsmd.AIS2Service
|
namespace bsmd.AIS2Service
|
||||||
{
|
{
|
||||||
|
|
||||||
public class AISController : ApiController
|
public class AISController : ApiController
|
||||||
{
|
{
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|||||||
@ -1,31 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<section name="bsmd.AIS2Service.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
<section name="bsmd.AIS2Service.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
</sectionGroup>
|
</sectionGroup>
|
||||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
|
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
|
||||||
</configSections>
|
</configSections>
|
||||||
<log4net>
|
<log4net>
|
||||||
<root>
|
<root>
|
||||||
<level value="ALL"/>
|
<level value="ALL" />
|
||||||
<appender-ref ref="LogFileAppender"/>
|
<appender-ref ref="LogFileAppender" />
|
||||||
<appender-ref ref="TraceAppender"/>
|
<appender-ref ref="TraceAppender" />
|
||||||
</root>
|
</root>
|
||||||
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
|
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
|
||||||
<param name="File" value="E:\temp\AIS2Service.log"/>
|
<param name="File" value="E:\temp\AIS2Service.log" />
|
||||||
<param name="AppendToFile" value="true"/>
|
<param name="AppendToFile" value="true" />
|
||||||
<rollingStyle value="Size"/>
|
<rollingStyle value="Size" />
|
||||||
<maxSizeRollBackups value="10"/>
|
<maxSizeRollBackups value="10" />
|
||||||
<maximumFileSize value="10MB"/>
|
<maximumFileSize value="10MB" />
|
||||||
<staticLogFileName value="true"/>
|
<staticLogFileName value="true" />
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
<param name="ConversionPattern" value="%date [%thread] %-5level [%logger] - %message%newline"/>
|
<param name="ConversionPattern" value="%date [%thread] %-5level [%logger] - %message%newline" />
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
|
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
<conversionPattern value="%d [%t] %-5p %c %m%n"/>
|
<conversionPattern value="%d [%t] %-5p %c %m%n" />
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
</log4net>
|
</log4net>
|
||||||
@ -63,4 +63,16 @@
|
|||||||
</setting>
|
</setting>
|
||||||
</bsmd.AIS2Service.Properties.Settings>
|
</bsmd.AIS2Service.Properties.Settings>
|
||||||
</applicationSettings>
|
</applicationSettings>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -17,7 +17,7 @@ namespace bsmd.AIS2Service
|
|||||||
{
|
{
|
||||||
AISManager.Start();
|
AISManager.Start();
|
||||||
// TODO wait some
|
// TODO wait some
|
||||||
Thread.Sleep(120000);
|
Thread.Sleep(720000);
|
||||||
// Test finish..
|
// Test finish..
|
||||||
AISManager.Stop();
|
AISManager.Stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
|
using System.Web.Http.Cors;
|
||||||
using Owin;
|
using Owin;
|
||||||
|
|
||||||
namespace bsmd.AIS2Service
|
namespace bsmd.AIS2Service
|
||||||
@ -8,12 +9,16 @@ namespace bsmd.AIS2Service
|
|||||||
public void Configuration(IAppBuilder appBuilder)
|
public void Configuration(IAppBuilder appBuilder)
|
||||||
{
|
{
|
||||||
HttpConfiguration config = new HttpConfiguration();
|
HttpConfiguration config = new HttpConfiguration();
|
||||||
|
var cors = new EnableCorsAttribute("*", "*", "*");
|
||||||
|
|
||||||
config.Routes.MapHttpRoute(
|
config.Routes.MapHttpRoute(
|
||||||
name: "AISList",
|
name: "AISList",
|
||||||
routeTemplate: "api/{Controller}",
|
routeTemplate: "api/{Controller}",
|
||||||
defaults: new { id = RouteParameter.Optional, Controller = "AIS"}
|
defaults: new { id = RouteParameter.Optional, Controller = "AIS"}
|
||||||
);
|
);
|
||||||
|
config.EnableCors(cors);
|
||||||
appBuilder.UseWebApi(config);
|
appBuilder.UseWebApi(config);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,17 +38,17 @@
|
|||||||
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
|
<HintPath>packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Owin, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Owin, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
<HintPath>packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
|
<HintPath>packages\Microsoft.Owin.Host.HttpListener.4.2.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Owin.Hosting, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Owin.Hosting, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
|
<HintPath>packages\Microsoft.Owin.Hosting.4.2.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
<HintPath>packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||||
@ -63,9 +63,15 @@
|
|||||||
<HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
<HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Web.Cors, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\Microsoft.AspNet.Cors.5.2.9\lib\net45\System.Web.Cors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Web.Http, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="System.Web.Http, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.9\lib\net45\System.Web.Http.dll</HintPath>
|
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.9\lib\net45\System.Web.Http.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Web.Http.Cors, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\Microsoft.AspNet.WebApi.Cors.5.2.9\lib\net45\System.Web.Http.Cors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Web.Http.Owin, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="System.Web.Http.Owin, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.AspNet.WebApi.Owin.5.2.9\lib\net45\System.Web.Http.Owin.dll</HintPath>
|
<HintPath>packages\Microsoft.AspNet.WebApi.Owin.5.2.9\lib\net45\System.Web.Http.Owin.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -124,7 +130,9 @@
|
|||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Content Include="index.html" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="AIS2_Service.resx">
|
<EmbeddedResource Include="AIS2_Service.resx">
|
||||||
<DependentUpon>AIS2_Service.cs</DependentUpon>
|
<DependentUpon>AIS2_Service.cs</DependentUpon>
|
||||||
|
|||||||
27
AIS/bsmd.AIS2Service/index.html
Normal file
27
AIS/bsmd.AIS2Service/index.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<title>JSON Test</title>
|
||||||
|
<script type="text/javascript" src="update.js"></script>
|
||||||
|
</head>
|
||||||
|
<body onload="startup()">
|
||||||
|
<table id="aisTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>MMSI</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Timestamp</th>
|
||||||
|
<th>Latitude</th>
|
||||||
|
<th>Longitude</th>
|
||||||
|
<th>IMO</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="aisTableBody">
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,14 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="log4net" version="2.0.15" targetFramework="net48" />
|
<package id="log4net" version="2.0.15" targetFramework="net48" />
|
||||||
|
<package id="Microsoft.AspNet.Cors" version="5.2.9" targetFramework="net48" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.9" targetFramework="net48" />
|
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.9" targetFramework="net48" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.9" targetFramework="net48" />
|
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.9" targetFramework="net48" />
|
||||||
|
<package id="Microsoft.AspNet.WebApi.Cors" version="5.2.9" targetFramework="net48" />
|
||||||
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.9" targetFramework="net48" />
|
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.9" targetFramework="net48" />
|
||||||
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.9" targetFramework="net48" />
|
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.9" targetFramework="net48" />
|
||||||
<package id="Microsoft.Owin" version="2.0.2" targetFramework="net48" />
|
<package id="Microsoft.Owin" version="4.2.2" targetFramework="net48" />
|
||||||
<package id="Microsoft.Owin.Host.HttpListener" version="2.0.2" targetFramework="net48" />
|
<package id="Microsoft.Owin.Host.HttpListener" version="4.2.2" targetFramework="net48" />
|
||||||
<package id="Microsoft.Owin.Hosting" version="2.0.2" targetFramework="net48" />
|
<package id="Microsoft.Owin.Hosting" version="4.2.2" targetFramework="net48" />
|
||||||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net48" />
|
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||||
<package id="Owin" version="1.0" targetFramework="net48" />
|
<package id="Owin" version="1.0" targetFramework="net48" />
|
||||||
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.116.0" targetFramework="net48" />
|
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.116.0" targetFramework="net48" />
|
||||||
<package id="System.Data.SQLite.Core" version="1.0.116.0" targetFramework="net48" />
|
<package id="System.Data.SQLite.Core" version="1.0.116.0" targetFramework="net48" />
|
||||||
|
|||||||
41
AIS/bsmd.AIS2Service/update.js
Normal file
41
AIS/bsmd.AIS2Service/update.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
function update() {
|
||||||
|
fetch('http://localhost:9050/api/ais')
|
||||||
|
.then(function (response) {
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(function (data) {
|
||||||
|
updateData(data);
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log('error: ' + err);
|
||||||
|
});
|
||||||
|
function updateData(data) {
|
||||||
|
var table = document.getElementById("aisTable");
|
||||||
|
|
||||||
|
const table = document.getElementById('Table');
|
||||||
|
let numItems = 1;
|
||||||
|
|
||||||
|
numItems++;
|
||||||
|
const row = document.createElement('tr');
|
||||||
|
row.innerHTML = `
|
||||||
|
<td>
|
||||||
|
<input type="text" id="itemDescription${numItems}" placeholder="Item" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" id="itemValue${numItems}" placeholder="Value" />
|
||||||
|
</td>`;
|
||||||
|
// You could also do the same for the cells and inputs
|
||||||
|
table.appendChild(row);
|
||||||
|
|
||||||
|
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.innerHTML = 'Name: ' + data[i].Name;
|
||||||
|
mainContainer.appendChild(div);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startup() {
|
||||||
|
setInterval(function () { update(); }, 10000);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user