Commit b7293c57 by guanzhenshan

1

parent 83529a49
...@@ -10,18 +10,18 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -10,18 +10,18 @@ namespace Bailun.DC.DailyItemNoProfitRate
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
//Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
//{ {
// services.AddHostedService<Services>(); services.AddHostedService<Services>();
//}); });
//await builder.RunConsoleAsync(); await builder.RunConsoleAsync();
var _service = new Services(); //var _service = new Services();
var day = DateTime.Parse(DateTime.Now.AddDays(-2).ToShortDateString()); //var day = DateTime.Parse(DateTime.Now.AddDays(-2).ToShortDateString());
_service.Init(day.AddDays(-20), day); //_service.Init(day.AddDays(-20), day);
_service.OneDayItemNoProfitRate(day.AddDays(-1), day); //_service.OneDayItemNoProfitRate(day.AddDays(-1), day);
} }
} }
} }
...@@ -24,18 +24,20 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -24,18 +24,20 @@ namespace Bailun.DC.DailyItemNoProfitRate
private void DoWork(object state) private void DoWork(object state)
{ {
var day = DateTime.Parse(now.AddDays(-2).ToShortDateString());
try try
{ {
var now = DateTime.Now; var now = DateTime.Now;
if ((now.Hour == 10 && now.Minute == 05)) //17:05启动 if ((now.Hour == 10 && now.Minute == 45)) //17:05启动
{ {
Console.WriteLine("开始启动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("开始启动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
var day = DateTime.Parse(now.AddDays(-1).ToShortDateString());
Init(day.AddDays(-20),day); Init(day.AddDays(-20),day);
Console.WriteLine("开始生成一天的itemno利润率" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("开始生成一天的itemno利润率" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
OneDayItemNoProfitRate(day.AddDays(-1), day); OneDayItemNoProfitRate(day.AddDays(-2), day);
Console.WriteLine("任务运行完成 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("任务运行完成 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
} }
...@@ -43,6 +45,15 @@ namespace Bailun.DC.DailyItemNoProfitRate ...@@ -43,6 +45,15 @@ namespace Bailun.DC.DailyItemNoProfitRate
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex.Message); Console.WriteLine(ex.Message);
Console.WriteLine("出现异常,10分钟后重跑"+DateTime.Now);
Thread.Sleep(10 * 60);
Console.WriteLine("开始启动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Init(day.AddDays(-20), day);
Console.WriteLine("开始生成一天的itemno利润率" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
OneDayItemNoProfitRate(day.AddDays(-2), day);
} }
} }
......
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