コード例 #1
0
 void IJob.Execute()
 {
     using (var sc = new ServicesController())
     {
         Core.ConsoleTo.Log(sc.ExecTask(TaskItem.ResetDataBase).ToJson());
     }
 }
コード例 #2
0
 void IJob.Execute()
 {
     using (var sc = new ServicesController())
     {
         Core.ConsoleTo.Log(sc.ExecTask(TaskItem.ClearTemp).ToJson());
     }
 }
コード例 #3
0
            protected override async Task ExecuteAsync(CancellationToken stoppingToken)
            {
                while (!stoppingToken.IsCancellationRequested)
                {
                    try
                    {
                        var sc = new ServicesController();

                        //执行结果
                        var vm = new ActionResultVM
                        {
                            code = -9
                        };
                        var now = DateTime.Now;

                        //重置一次数据库
                        if (now.ToString("HHmm") == "0404")
                        {
                            vm = sc.ExecTask("resetdatabase");
                        }

                        //清理临时目录
                        if (now.Day % 2 == 0 && now.ToString("HHmm") == "0303")
                        {
                            vm = sc.ExecTask("cleartemp");
                        }

                        //记录任务日志
                        if (vm.code != -9)
                        {
                            string msg = "Tasking:" + now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine + vm.ToJson();
                            Core.ConsoleTo.Log(msg);
                        }
                    }
                    catch (Exception ex)
                    {
                        Core.ConsoleTo.Log(ex);
                    }

                    //1分钟
                    await Task.Delay(1000 * 60 * 1, stoppingToken);
                }
            }