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.
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.Tasks;
|
|
|
|
|
using Aucma.Core.Scanner;
|
|
|
|
|
using Aucma.Core.Tasks;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Quartz;
|
|
|
|
|
using Quartz.Spi;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Admin.Core.Extensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 启动服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class AucmaTaskSetup
|
|
|
|
|
{
|
|
|
|
|
public static void AddAucmaTaskSetup(this IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddSingleton<IAucamTaskService, AucamTaskService>();
|
|
|
|
|
|
|
|
|
|
var baseType = typeof(IAucamTaskService);
|
|
|
|
|
var path = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
|
var referencedAssemblies = System.IO.Directory.GetFiles(path, "Aucma.Core.Tasks.dll").Select(Assembly.LoadFrom).ToArray();
|
|
|
|
|
var types = referencedAssemblies
|
|
|
|
|
.SelectMany(a => a.DefinedTypes)
|
|
|
|
|
.Select(type => type.AsType())
|
|
|
|
|
.Where(x => x != baseType && baseType.IsAssignableFrom(x)).ToArray();
|
|
|
|
|
var implementTypes = types.Where(x => x.IsClass).ToArray();
|
|
|
|
|
foreach (var implementType in implementTypes)
|
|
|
|
|
{
|
|
|
|
|
services.AddTransient(implementType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|