using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Web;
using Newtonsoft.Json;
using RestSharp;
namespace BLWWS
{
    public class HttpSendData
    {
        //public static readonly string BaseURL = "http://www.higmkj.com:8056";
        public static readonly string BaseURL = "";
        private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();

        private static string NewMethod(PMSDataBase data, string url)
        {
            //var a = Newtonsoft.Json.JsonConvert.SerializeObject(data);
            var client123 = new RestClient(BaseURL);
            var request123 = new RestRequest(url, Method.Post);
            request123.AddHeader("Content-Type", "application/json");
            _logger.Error("发送的数据为:" + data);
            request123.AddJsonBody(data);
            //request123.AddStringBody(data, DataFormat.Json);
            var Response = client123.Execute(request123).Content;
            return Response;
        }
        public static void SendData(PMSDataBase data)
        {
            NewMethod(data, "/order/checkIn");
        }

        public static void SendData_CheckOut(PMSDataBase data)
        {

            var a = Newtonsoft.Json.JsonConvert.SerializeObject(data);
            _logger.Error("宝镜推送SendData_CheckOut数据:" + a);

            //WebReference.WebService1 w = new WebReference.WebService1();
            //var Response = w.HelloWorld("C24cAfK", a, "/order/checkOut");
            string Response = NewMethod(data, "/order/checkOut");
            _logger.Error("宝镜推送CheckOut:" + Response);
        }
    }
    public class PMSDataBase
    {
        public string hotel_code { get; set; } = "";
        public string time { get; set; } = "";
        public string sign { get; set; } = "";
        public string hotel_id { get; set; } = "";
        public string order_no { get; set; } = "";
        public string room_no { get; set; } = "";
        public string check_out_original { get; set; }
    }

    public class PMSData : PMSDataBase
    {
        public string checkIn { get; set; }
        public string checkOut { get; set; }
        public ushort is_breakfast { get; set; }
        public ushort breakfast { get; set; }
        public string rateCode { get; set; }
        public string amount { get; set; }
        public string order_original { get; set; }
        public List<Info> infos { get; set; }
    }
    public class Info
    {
        public string name { get; set; }
        public string mobile { get; set; }
        public int type { get; set; }
        public string idcard { get; set; }
        public int sex { get; set; }
        public string address { get; set; }
    }
}