Commit 5aee2158 by lizefeng

修改缺货改零推送方式

parent 55c81992
......@@ -10,29 +10,31 @@ namespace ShortagePush
{
public class ShortagePushBackgroundService : BackgroundService
{
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(5));
Task.Factory.StartNew(() => {
while (true)
{
System.Console.WriteLine($"开始推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().ShortagePush();
System.Console.WriteLine($"结束推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
System.Console.WriteLine($"开始推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().ReturnGoodsPush();
System.Console.WriteLine($"结束推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Thread.Sleep(5 * 60 * 1000);
}
});
return Task.CompletedTask;
}
private void DoWork(object state)
{
try
{
Console.WriteLine($"开始推送缺货数据任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().ShortagePush();
new ReportServices().ReturnGoodsPush();
Console.WriteLine($"结束推送缺货数据任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public override void Dispose()
{
base.Dispose();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment