using AutoTurnOver.DB;
using AutoTurnOver.Models;
using AutoTurnOver.Services;
using Bailun.ServiceFabric;
using Dapper;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ShortagePush;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;

namespace AutoGeneratePurchaseAdvise
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine("采购建议计算任务启动...");
            
            try
            {

                //PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")));
                //PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 17:30:00")));

                //PurchaseAdviseServices.GenerateTemp(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 13:13:00")));
                //PurchaseAdviseServices.AutoPushBuySys(2);

                //PurchaseAdviseServices.AutoPushBuySys(1);
                //PurchaseAdviseServices.AutoPushBuySys(2);
                //PurchaseAdviseServices.AutoPushBuySys(3);
                //PurchaseAdviseServices.AutoPushBuySys(6);
                //PurchaseAdviseServices.AutoPushBuySys(7);
                //report.ResetTransExpectArrivaltime();
                //PurchaseAdviseServices.AutoPushBuySys(1);
                //report.PurchaseWeekBackUp();
                //report.ResetTransExpectArrivaltime();
                //PurchaseAdviseServices.AutoPushBuySys(4);
                //PurchaseAdviseServices.AutoPushBuySys(4);
                //purchase_advise.ReplaceLogistics(DateTime.Now, "935619301", "MMDUKFBA");
                //PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")));
                //report.PurchaseWeekBackUp();
                //PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")));
                //PurchaseAdviseServices.Generate(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"))); 
                //PurchaseAdviseServices.AutoPushBuySys(4);
                //new SkuAutoTurnServices().ResetPurchaseAdvise();
                //new SkuAutoTurnServices().ResetPurchaseAdvise();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
          
            var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
                {
                    services.AddHostedService<GeneratePurchaseAdviseBackgroundService>();
                    services.AddHostedService<FirstBackgroundService>();
                });

            await builder.RunConsoleAsync();
        }
    }
}
