using AutoTurnOver.DB;
using AutoTurnOver.Services;
using AutoTurnOver.Utility;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;

namespace ResetOutofstock
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine("刷新缺货数据任务启动...");
            try
            {
                
                var now = DateTime.Now;
                //dc_base_supplier_dao.SynchroBailunSupplier();
                //dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-3), DateTime.Now);

                //base_supplier_holiday_time_dao.SynchroData();
                //report.ResetCashFlowData();
                //report.StockWeekBackUp();
                //report.PurchaseWeekBackUp();
                //report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
                //report_cash_flow_dao.SynchroTransferCost();

                //dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-3), DateTime.Now);
                //dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-1), DateTime.Now);
                //dc_report_finance_dao.CalculationRefund(DateTime.Now.AddYears(-1));
                //dc_report_finance_dao.CalculationRaise(DateTime.Now.AddYears(-1));
                //dc_report_finance_dao.CalculationAccounts(DateTime.Now.AddYears(-1));
            }
            catch (Exception ex)
            {

                throw;
            }
           

            var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
            {
                services.AddHostedService<ResetOutofstockBackgrounService>();
                services.AddHostedService<CaseFlowBackgrounService>();
                services.AddHostedService<StockBackgrounService>();
                services.AddHostedService<ReportFinanceBackgrounService>();
            });

            await builder.RunConsoleAsync();
        }
    }
}
