You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB
C#

1 year ago
using Admin.Core.Common;
using Admin.Core.IService.ISys;
using Admin.Core.Model.Sys;
using Admin.Core.Tasks;
using Aucma.Core.Scanner;
using log4net;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Admin.Core.Extensions
{
/// <summary>
///扫码器服务
/// </summary>
public static class ScannerMildd
{
private static readonly ILog log = LogManager.GetLogger(typeof(ScannerMildd));
public static async void UseScannerMildd(this IApplicationBuilder app, IScannerService scaner)
{
if (app == null) throw new ArgumentNullException(nameof(app));
try
{
if (Appsettings.app("Middleware", "Scanner", "Enabled").ObjToBool())
{
await scaner.StartScannerAsync();
}
}
catch (Exception e)
{
log.Error($"An error was reported when starting the job service.\n{e.Message}");
throw;
}
}
}
}