61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using Autofac;
|
||
using Autofac.Extensions.DependencyInjection;
|
||
using HidSharp;
|
||
using OpenAuth.WebApi;
|
||
using SoftKey;
|
||
|
||
var builder = WebApplication.CreateBuilder(args);
|
||
|
||
/*
|
||
var list = DeviceList.Local;
|
||
var ytsoftkey = new F2K();
|
||
list.Changed += (sender, args) =>
|
||
{
|
||
if (ytsoftkey.CheckKeyByFindort_2() != 0)
|
||
{
|
||
Console.WriteLine(" 加密锁被拨出。");
|
||
throw new Exception("加密锁被拨出。");
|
||
}
|
||
};
|
||
|
||
|
||
String DevicePath = null;
|
||
short verex = 0;
|
||
short ver = 0;
|
||
//这个用于判断系统中是否存在着加密锁。不需要是指定的加密锁,
|
||
|
||
int ret = ytsoftkey.FindPort(0, ref DevicePath);
|
||
if (ret != 0)
|
||
{
|
||
throw new Exception("未找到加密锁,请插入加密锁后,再进行操作。");
|
||
}
|
||
|
||
// 从加密狗中读取密钥
|
||
String str = "";
|
||
byte[] length = new byte[1];
|
||
ret = ytsoftkey.YRead(length, 0, 1, "E1930089", "C7326137", DevicePath);
|
||
if (ret != 0)
|
||
{
|
||
throw new Exception("读取加密狗数据失败1!");
|
||
}
|
||
|
||
ret = ytsoftkey.YReadString(ref str, 1, length[0], "E1930089", "C7326137", DevicePath);
|
||
if (ret != 0)
|
||
{
|
||
throw new Exception("读取加密狗数据失败2!");
|
||
}
|
||
|
||
Console.WriteLine("读取数据:" + str);
|
||
*/
|
||
|
||
var startup = new Startup(builder.Configuration);
|
||
startup.ConfigureServices(builder.Services);
|
||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||
builder.Host.ConfigureContainer<ContainerBuilder>(startup.ConfigureContainer);
|
||
//builder.Configuration.AddJsonFile("appsettings.json", false, true);
|
||
var app = builder.Build();
|
||
startup.Configure(app, app.Environment);
|
||
//var url = app.Configuration.GetValue<string>("AppSetting:HttpHost");
|
||
//app.Urls.Add(url);
|
||
|
||
app.Run(); |