using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Data;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Threading;
using Library;
using LitJson;

namespace MySystem.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Error()
        {
            string isapi = Request.Headers["Api"].ToString();
            if (isapi != "1")
            {
                if (Response.StatusCode == 500)
                {
                    return Redirect("/public/errpage/pc/500.html");
                }
                else if (Response.StatusCode == 502)
                {
                    return Redirect("/public/errpage/pc/502.html");
                }
                else if (Response.StatusCode == 404)
                {
                    return Redirect("/public/errpage/pc/404.html");
                }
            }
            return View();
        }

        public string test()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("Operater", "testman");
            dic.Add("SqlString", "select * from HelpProfitExchange");
            dic.Add("FileName", "测试文件");
            dic.Add("MaxCount", "0");
            RedisDbconn.Instance.AddList("ExportQueue", Newtonsoft.Json.JsonConvert.SerializeObject(dic));
            return "ok";
        }
    }
}