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()
        {
            MpMainModels2.WebCMSEntities db = new MpMainModels2.WebCMSEntities();
            MpMainModels2.MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 5660) ?? new MpMainModels2.MerchantAddInfo();
            
            SortedList<string, string> obj = new SortedList<string, string>();

            // obj.Add("create_time", "2024-08-19 15:13:00");
            // obj.Add("sn", "000068457494");
            // obj.Add("deposit", "399");
            // obj.Add("merch_no", merchantadd.MchtNo);

            obj.Add("create_time", "2024-08-19 15:13:00");
            obj.Add("sn", "000068457494");
            obj.Add("pay_money", "199");
            obj.Add("pay_mode", "1");
            obj.Add("order_no", "4545656767878978978");
            obj.Add("merch_no", merchantadd.MchtNo);

            obj.Add("maker_code", "C00000001");
            // PushHelper.Instance.Do(obj, "cashNotify");
            PushHelper.Instance.Do(obj);

            db.Dispose();
            return "ok";
        }
    
    
    }
}