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 MySystem.PxcModels;
using System.Threading;
using Library;
using LitJson;
using System.Security.Cryptography;

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()
        {
            // string s = SetDepositPostService.Instance.LDZZBServiceFeeQuery("00007302225171000028");
            // string s = SetDepositPostService.Instance.LDZZBServiceFee("0000730222517E000019", 1);
            // string s = SetDepositPostService.Instance.LDZZBFeeRate("825815174643591", 0.63M, 0);
            // string s = SetDepositPostService.Instance.LDZZBFeeRateQuery("825815174643591");
            // JsonData jsonObj = JsonMapper.ToObject(s);
            // string aesKey = jsonObj["encryptKey"].ToString();
            // aesKey = SetDepositPostService.Instance.LDZZBDecrypt(aesKey);
            // string content = SetDepositPostService.Instance.AesDecrypt(jsonObj["data"].ToString(), aesKey);
            // return content;
            // string s = PublicImportDataService.Instance.LkbSetFee("00003102702301319427698", 0.63M, 0);
            // JsonData jsonObj = JsonMapper.ToObject(s);
            // string data = jsonObj["data"].ToString();
            // data = PublicImportDataService.Instance.LkbDecrypt(data);
            // return s + "\n<br>" + data;

            // string content = SetDepositPostService.Instance.LDZZBFeeRate("825816685857615", 0.68M, 3);
            // JsonData jsonObj = JsonMapper.ToObject(content);
            // string aesKey = jsonObj["encryptKey"].ToString();
            // aesKey = SetDepositPostService.Instance.LDZZBDecrypt(aesKey);
            // content += SetDepositPostService.Instance.AesDecrypt(jsonObj["data"].ToString(), aesKey);

            string content = PublicImportDataService.Instance.xyfFee("00007902C32549093725", "0.63", "3");
            
            return content;
        }
    
    }
}