From 44471ec9325c0b4ecb4caf4699f325a8fdbd49e1 Mon Sep 17 00:00:00 2001 From: yanghongwei Date: Tue, 27 Aug 2024 22:19:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=BC=BA=E5=88=B6=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E6=97=B6=E9=97=B4365=E5=A4=A9=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- langguanApi.xml | 45 ++++++++++++++++++++++++++++++++++++++++++ langguanApi/Program.cs | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/langguanApi.xml b/langguanApi.xml index 8c9530f..8aa625d 100644 --- a/langguanApi.xml +++ b/langguanApi.xml @@ -810,41 +810,81 @@ 国五百分比 + + + 国五比例数量 + + 国五运输量百分比 + + + 国五运输量比例 + + 国六百分比 + + + 国六运输量 + + 国六运输量百分比 + + + 国六运输量 + + 电动百分比 + + + 电动运输量 + + 电动运输量百分比 + + + 电动运输量 + + 其他百分比 + + + 其他运输量 + + 其他运输量百分比 + + + 其他运输量 + + @@ -2321,6 +2361,11 @@ 有效期限 + + + 排放标准(0-7是国1-7,D:电动 X:无排放阶段) + + 地磅 diff --git a/langguanApi/Program.cs b/langguanApi/Program.cs index cf916ff..fcec32e 100644 --- a/langguanApi/Program.cs +++ b/langguanApi/Program.cs @@ -5,6 +5,8 @@ using langguanApi.Middleware; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options; using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Linq; +using System.Net; using System.Text.Json; var builder = WebApplication.CreateBuilder(args); @@ -87,9 +89,44 @@ app.UseSwaggerUI(); app.UseCors("CorsPolicy"); //app.UseAuthorization(); + + + app.MapControllers(); app.Run(); + + +if (!await GetNowTimeAsync()) +{ + Console.WriteLine("ǰʱ䲻ڿʱ䷶ΧڣϵӦ̡"); + Environment.Exit(0); +} +/// +/// ȡǰʱǷڿʱ䷶Χ +static async Task GetNowTimeAsync() +{ + try + { + DateTime startTime = DateTime.Parse("2024-09-01"); + //ӹϻȡǰʱ + var url = "http://www.worldtimeapi.org/api/ip"; + var request = WebRequest.Create(url); + var response = await request.GetResponseAsync(); + var stream = response.GetResponseStream(); + var reader = new StreamReader(stream); + var content = reader.ReadToEnd(); + var time = JObject.Parse(content)["datetime"].ToString(); + var now = DateTime.Parse(time); + Console.WriteLine($"ǰʱ䣺{now}ʱ䣺{startTime.AddDays(365)}ʱ仹У{(startTime.AddDays(30) - now).Days} "); + return startTime.AddDays(365) > now ? true : false; + } + catch + { + return false; + } +} + /// /// ݴ ///