using System.Timers;
using CliWrap;
using CliWrap.Buffered;
using Common;

namespace 回收
{
    internal class Program
    {
        public static System.Timers.Timer timer;
        async static Task Main(string[] args)
        {
            timer = new System.Timers.Timer();
            timer.Elapsed += Timer_Elapsed;
            timer.Interval = 20000;
            timer.Start();
            Console.ReadLine();
        }

        static void Timer_Elapsed(object? sender, ElapsedEventArgs e)
        {
            try
            {
                Console.WriteLine("go...");
                string Key = "IISRecycle";
                int isnew = CSRedisCacheHelper.redis3.Get<int>(Key);
                if (isnew == 1)
                {
                    Console.WriteLine("回收了");
                    var cmd = Cli.Wrap("1.cmd")
                    .WithWorkingDirectory("D:\\BLW_Data\\cricsSQL")
                    .ExecuteBufferedAsync();
                    CSRedisCacheHelper.redis3.Set(Key, 0);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}
