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.

46 lines
1.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Admin.Core.Common;
using Admin.Core.IService.ISys;
using Admin.Core.Model.Sys;
using Admin.Core.Tasks;
using Aucma.Core.Melsec;
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>
///三菱PLC
/// </summary>
public static class MelsecMildd
{
private static readonly ILog log = LogManager.GetLogger(typeof(MelsecMildd));
public static async void UseMelsecMildd(this IApplicationBuilder app, IMelsecService melsec)
{
if (app == null) throw new ArgumentNullException(nameof(app));
try
{
if (Appsettings.app("Middleware", "Melsec", "Enabled").ObjToBool())
{
await melsec.StartMelsecAsync();
//if (result)
// Console.WriteLine("三菱PLC服务启动成功");
//else
// Console.WriteLine("三菱PLC服务启动失败");
}
}
catch (Exception e)
{
log.Error($"An error was reported when starting the job service.\n{e.Message}");
throw;
}
}
}
}