|
- using BPA.ApolloClient;
- using BPA.ApolloClient.Options;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.Hosting;
- using System;
- using System.Runtime.InteropServices;
-
- namespace DataVAPI
- {
- public class Program
- {
- public delegate bool ControlCtrlDelegate(int CtrlType);
- [DllImport("kernel32.dll")]
- private static extern bool SetConsoleCtrlHandler(ControlCtrlDelegate HandlerRoutine, bool Add);
- private static ControlCtrlDelegate cancelHandler = new ControlCtrlDelegate(HandlerRoutine);
-
- public static bool HandlerRoutine(int CtrlType)
- {
- //数据保存
- switch (CtrlType)
- {
- case 0:
- //Console.WriteLine("0工具被强制关闭"); //Ctrl+C关闭
- break;
- case 2:
- //Console.WriteLine("2工具被强制关闭");//按控制台关闭按钮关闭
- break;
- }
- Console.ReadLine();
- return false;
- }
-
-
- public static void Main(string[] args)
- {
- CreateHostBuilder(args).Build().Run();
-
- }
-
- public static IHostBuilder CreateHostBuilder(string[] args) =>
- Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>
- {
- //配置阿波罗
- webBuilder.ConfigureAppConfiguration((context, builder) =>
- {
- builder.AddApolloConfiguration(op =>
- {
- builder.Build().GetSection(nameof(ApolloOptions)).Bind(op);
- });
- })
- .UseUrls("http://*:80")// 这里默认是http://*:5000 .现在改成8003端口
- .UseStartup<Startup>();
- });
- }
- }
|