@@ -1,12 +0,0 @@ | |||
{ | |||
"version": 1, | |||
"isRoot": true, | |||
"tools": { | |||
"dotnet-ef": { | |||
"version": "3.1.5", | |||
"commands": [ | |||
"dotnet-ef" | |||
] | |||
} | |||
} | |||
} |
@@ -1,43 +1,20 @@ | |||
<Project Sdk="Microsoft.NET.Sdk.Web"> | |||
<PropertyGroup> | |||
<TargetFramework>netstandard2.1</TargetFramework> | |||
<LangVersion>8.0</LangVersion> | |||
<RazorLangVersion>3.0</RazorLangVersion> | |||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||
<UserSecretsId>203b72c5-3ccb-4c06-a644-1983ba94fba2</UserSecretsId> | |||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Compile Remove="JsonConvert\**" /> | |||
<Content Remove="JsonConvert\**" /> | |||
<EmbeddedResource Remove="JsonConvert\**" /> | |||
<None Remove="JsonConvert\**" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Remove="Pages\_Host.cshtml" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="JsonConvert\ByteArrayHexConverter.cs" /> | |||
</ItemGroup> | |||
<PropertyGroup> | |||
<!--https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/configure-linker?view=aspnetcore-3.1#configure-the-linker-for-internationalization--> | |||
<BlazorWebAssemblyI18NAssemblies>all</BlazorWebAssemblyI18NAssemblies> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" /> | |||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" /> | |||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.4" /> | |||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" /> | |||
<PackageReference Include="BlazorStrap" Version="1.3.2" /> | |||
<PackageReference Include="JT1078" Version="1.0.2" /> | |||
<PackageReference Include="JT808" Version="2.2.10" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.JT1078" Version="2.2.9.1" /> | |||
<PackageReference Include="JT808.Protocol.Extensions.JTActiveSafety" Version="1.0.4" /> | |||
<PackageReference Include="JT809" Version="2.1.4-preview4" /> | |||
<PackageReference Include="JT809.Protocol.Extensions.JT1078" Version="2.1.4-preview4" /> | |||
<PackageReference Include="JT809.Protocol.Extensions.JT1078" Version="2.1.4-preview1" /> | |||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.4" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> | |||
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.4" /> | |||
</ItemGroup> | |||
@@ -0,0 +1,37 @@ | |||
using Microsoft.AspNetCore.Http; | |||
using Microsoft.AspNetCore.Mvc.Formatters; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Text.Json; | |||
using System.Text.Json.Serialization; | |||
using System.Threading.Tasks; | |||
namespace JTTools.JsonConvert | |||
{ | |||
/// <summary> | |||
/// | |||
/// ref:https://github.com/dotnet/corefx/blob/release/3.0/src/System.Text.Json/tests/Serialization/CustomConverterTests.Array.cs | |||
/// </summary> | |||
public class ByteArrayHexTextJsonConverter : JsonConverter<byte[]> | |||
{ | |||
public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | |||
{ | |||
//string hexJson = reader.get(); | |||
var hexJson = reader.GetString(); | |||
var list = new List<byte>(); | |||
foreach (string str in hexJson.Split(new string[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries)) | |||
{ | |||
list.Add(Convert.ToByte(str, 16)); | |||
} | |||
return list.ToArray(); | |||
} | |||
public override void Write(Utf8JsonWriter writer, byte[] value, JsonSerializerOptions options) | |||
{ | |||
var hexString = string.Join(" ", (value).Select(p => p.ToString("X2"))); | |||
writer.WriteStringValue(hexString); | |||
} | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
@page "/" | |||
@namespace JTTools.Pages | |||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | |||
@{ | |||
Layout = null; | |||
} | |||
<!DOCTYPE html> | |||
<html lang="en"> | |||
<head> | |||
<meta charset="utf-8" /> | |||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |||
<meta name="keywords" content="JT808|gb808|JT809|gb809|JT1078|JTT1078|JT19056|gb19056|在线解析工具"/> | |||
<meta name="description" content="道路运输车辆卫星定位协议在线解析工具"/> | |||
<title>JTTools解析工具</title> | |||
<base href="~/" /> | |||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> | |||
<link href="css/site.css" rel="stylesheet" /> | |||
</head> | |||
<body> | |||
<app> | |||
<component type="typeof(App)" render-mode="ServerPrerendered" /> | |||
</app> | |||
<div id="blazor-error-ui"> | |||
<environment include="Staging,Production"> | |||
An error has occurred. This application may no longer respond until reloaded. | |||
</environment> | |||
<environment include="Development"> | |||
An unhandled exception has occurred. See browser dev tools for details. | |||
</environment> | |||
<a href="" class="reload">Reload</a> | |||
<a class="dismiss">🗙</a> | |||
</div> | |||
<script src="_framework/blazor.server.js"></script> | |||
</body> | |||
</html> |
@@ -4,21 +4,21 @@ using JT808.Protocol.Extensions.JT1078; | |||
using JT808.Protocol.Extensions.JTActiveSafety; | |||
using JT809.Protocol; | |||
using JT809.Protocol.Extensions.JT1078; | |||
using Microsoft.AspNetCore.Hosting; | |||
using Microsoft.Extensions.Configuration; | |||
using Microsoft.Extensions.Hosting; | |||
using Microsoft.AspNetCore.Builder; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using Newtonsoft.Json.Serialization; | |||
using JTTools.Configs; | |||
using BlazorStrap; | |||
using Newtonsoft.Json; | |||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | |||
using System.Threading.Tasks; | |||
using System.Net.Http; | |||
namespace JTTools | |||
{ | |||
public class Program | |||
{ | |||
public static async Task Main(string[] args) | |||
public static void Main(string[] args) | |||
{ | |||
Newtonsoft.Json.JsonConvert.DefaultSettings = new Func<JsonSerializerSettings>(() => | |||
{ | |||
@@ -32,21 +32,83 @@ namespace JTTools | |||
settings.Converters.Add(new ByteArrayHexConverter()); | |||
return settings; | |||
}); | |||
Host.CreateDefaultBuilder(args) | |||
.ConfigureWebHostDefaults(webBuilder => | |||
{ | |||
webBuilder.ConfigureServices((hostingContext, services) => | |||
{ | |||
services.AddRazorPages(); | |||
services.AddServerSideBlazor(); | |||
services.AddControllers() | |||
//Microsoft.AspNetCore.Mvc.NewtonsoftJson | |||
.AddNewtonsoftJson(jsonOptions => | |||
{ | |||
jsonOptions.SerializerSettings.Converters.Add(new ByteArrayHexConverter()); | |||
jsonOptions.SerializerSettings.ContractResolver = new DefaultContractResolver(); | |||
//jsonOptions.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; | |||
}) | |||
//.AddJsonOptions(jsonOptions => | |||
//{ | |||
// jsonOptions.JsonSerializerOptions.MaxDepth = 64; | |||
WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args); | |||
builder.RootComponents.Add<App>("app"); | |||
builder.Services.AddBootstrapCss(); | |||
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); | |||
builder.Services.AddJT808Configure(); | |||
builder.Services.AddJT808Configure(new JT808_JTActiveSafety_Config()) | |||
.AddJTActiveSafetyConfigure(); | |||
builder.Services.AddJT808Configure(new JT808_JT1078_Config()) | |||
.AddJT1078Configure(); | |||
builder.Services.AddJT809Configure(new JT809_2011_Config()) | |||
.AddJT1078Configure(); | |||
builder.Services.AddJT809Configure(new JT809_2019_Config()) | |||
.AddJT1078Configure(); | |||
await builder.Build().RunAsync(); | |||
// jsonOptions.JsonSerializerOptions.Converters.Add(new ByteArrayHexTextJsonConverter()); | |||
//}) | |||
; | |||
services.AddCors(options => | |||
options.AddPolicy("Domain", builder => | |||
builder.WithOrigins(hostingContext.Configuration.GetSection("AllowedOrigins").Value.Split(",")) | |||
.AllowAnyMethod() | |||
.AllowAnyHeader() | |||
.AllowAnyOrigin())); | |||
services.AddBootstrapCss(); | |||
}) | |||
.ConfigureKestrel(ksOptions => | |||
{ | |||
ksOptions.ListenAnyIP(18888); | |||
}) | |||
.ConfigureLogging((context, logging) => { | |||
//if (Environment.OSVersion.Platform == PlatformID.Unix) | |||
//{ | |||
// NLog.LogManager.LoadConfiguration("Configs/nlog.unix.config"); | |||
//} | |||
//else | |||
//{ | |||
// NLog.LogManager.LoadConfiguration("Configs/nlog.win.config"); | |||
//} | |||
//logging.AddNLog(new NLogProviderOptions { CaptureMessageTemplates = true, CaptureMessageProperties = true }); | |||
//logging.SetMinimumLevel(LogLevel.Trace); | |||
}) | |||
.ConfigureAppConfiguration((hostingContext, config) => | |||
{ | |||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); | |||
}) | |||
.Configure(app => { | |||
app.UseRouting(); | |||
app.UseCors("Domain"); | |||
app.UseStaticFiles(); | |||
app.UseEndpoints(endpoints => | |||
{ | |||
endpoints.MapControllers(); | |||
endpoints.MapBlazorHub(); | |||
endpoints.MapFallbackToPage("/_Host"); | |||
}); | |||
}); | |||
}) | |||
.ConfigureServices(services => | |||
{ | |||
services.AddJT808Configure(); | |||
services.AddJT808Configure(new JT808_JTActiveSafety_Config()) | |||
.AddJTActiveSafetyConfigure(); | |||
services.AddJT808Configure(new JT808_JT1078_Config()) | |||
.AddJT1078Configure(); | |||
services.AddJT809Configure(new JT809_2011_Config()) | |||
.AddJT1078Configure(); | |||
services.AddJT809Configure(new JT809_2019_Config()) | |||
.AddJT1078Configure(); | |||
}) | |||
.Build() | |||
.Run(); | |||
} | |||
} | |||
} |
@@ -16,4 +16,4 @@ | |||
<div class="footer"> | |||
<a href="http://www.beian.miit.gov.cn" target="_blank">Copyright © 2015-2020 SmallChi. All Rights Reserved. 粤ICP备19128140号-1</a> | |||
</div> | |||
</div> | |||
</div> |
@@ -1,5 +1,6 @@ | |||
@using System.Net.Http | |||
@using Microsoft.AspNetCore.Authorization | |||
@using Microsoft.AspNetCore.Components.Authorization | |||
@using Microsoft.AspNetCore.Components.Forms | |||
@using Microsoft.AspNetCore.Components.Routing | |||
@using Microsoft.AspNetCore.Components.Web | |||
@@ -1,3 +1,5 @@ | |||
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); | |||
html, body { | |||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |||
} | |||