using COMMON;
using Models;
using Quartz;
using Serilog;
using SERVER;
using SERVER.DataServer;
using SERVER.LIB;
using System;
using System.Threading.Tasks;
using TcpServer;

namespace WebUI.LIB
{
    public class Jobs : IJob
    {
        // 检测tcp是否运行
        public Task Execute(IJobExecutionContext context)
        {

            return Task.Run(() =>
            {
                try
                {
                    Tcp.Listener();
                    //
                    // Client.Init();
                    // TestingServices.ISok("BLV RUCS", 1);
                }
                catch (Exception ex)
                {
                    LogHelp.Error(ex.ToString());
                }
            });
        }
    }
    public class JobsOne : IJob
    {
        // 同步数据
        public Task Execute(IJobExecutionContext context)
        {
            return Task.Run(() =>
            {
                LogHelp.Warning("同步数据:" + DateTime.Now.ToString("G"));
                SYNC_DATA.SYNC_DATA_ALL();
            });
        }
    }

    public class JobsTwo : IJob
    {
        public static DateTime first = ConfigEntity.Instance.STARTTIME;
        // 统计小时的字节数据等
        public Task Execute(IJobExecutionContext context)
        {
            return Task.Run(() =>
            {
                try
                {
                    DateTime now = DateTime.Now;
                    // 阿里sls  的话 只需要定时执行 如下两个方法
                    if (1 == 1)
                    {

                        CHARTSSERVER.GetCHARTS(XC_Data.GetLogDataBase(), new[] { 1, 2, 3, 4 }, new[] { 1, 2, 3, 4 }, first.ToString("yyyy-MM-dd HH:mm:ss"), now.ToString("yyyy-MM-dd HH:mm:ss"));
                        CHARTSSERVER.GetErrorSucess(XC_Data.GetLogDataBase(), first.ToString("yyyy-MM-dd HH:mm:ss"), now.ToString("yyyy-MM-dd HH:mm:ss"));
                    }
                    else
                    {
                        CHARTSSERVER.GetProt(first, now);
                        CHARTSSERVER.GetProt(first, now, "RX");
                        CHARTSSERVER.GetPROCESSINGTIME(first, now);
                        CHARTSSERVER.GetRevDelayDateTime(first, now);
                        CHARTSSERVER.GetCMDpie(first, now);
                        CHARTSSERVER.GetCMDpie(first, now, "RX");
                    }

                    LogHelp.Warning("统计小时的字节数据等:" + first.ToString("G"));
                    first = now;
                }
                catch (Exception EX)
                {
                    LogHelp.Warning("统计小时的字节数据等:" + EX.Message.ToString());

                }
            });
        }
    }

}
