add 加入后台服务
This commit is contained in:
60
Ewide.Nbzs.BackWorkerService/Worker.cs
Normal file
60
Ewide.Nbzs.BackWorkerService/Worker.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Furion;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Nbzs.BackWorkerService
|
||||
{
|
||||
public class Worker : BackgroundService
|
||||
{
|
||||
public SqlSugarClient db;
|
||||
private readonly ILogger<Worker> _logger;
|
||||
|
||||
public Worker(ILogger<Worker> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
List<ConnectionConfig> connectConfigList = new()
|
||||
{
|
||||
new ConnectionConfig
|
||||
{
|
||||
ConnectionString = App.Configuration["SqlServerConnectionString:DefaultConnection"],
|
||||
DbType = DbType.SqlServer,
|
||||
IsAutoCloseConnection = true,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
ConfigId = "0"
|
||||
}
|
||||
};
|
||||
db = new SqlSugarClient(connectConfigList);
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
ExecProcess();
|
||||
//var asd = db.Queryable<Ewide.NbzsZheliban.Entity.zjzwfwTickets>().ToList();
|
||||
var asd = db.Queryable<Ewide.NbzsZheliban.Entity.InvestigateTable>().ToList();
|
||||
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
await Task.Delay(1000, stoppingToken);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Ö´ÐÐÈÎÎñ ÿÃë
|
||||
/// </summary>
|
||||
private void ExecProcess()
|
||||
{
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
|
||||
private void ExecPushProcess()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user