JLChen
2021-11-30 efad979b6fae76fb37a4de7e94e6bac0a85cb72c
HDL_ON/DAL/Server/HttpUtil.cs
@@ -26,7 +26,7 @@
        /// <summary>
        /// 请求超时时间
        /// </summary>
        public const int TIME_OUT = 10;
        public const int TIME_OUT = 15;
        /// <summary>
        /// 特殊接口请求超时时间
        /// </summary>
@@ -50,7 +50,7 @@
        /// <param name="replaceToken"></param>
        /// <param name="mTimeout"></param>
        /// <returns></returns>
        public static ResponsePackNew RequestHttpsGet(string apiPath, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 10)
        public static ResponsePackNew RequestHttpsGet(string apiPath, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = TIME_OUT)
        {
            return RequestHttps(Method.GET, apiPath, null, queryDictionary, urlSegmentDictionary, urlHead, replaceToken, mTimeout);
        }
@@ -67,7 +67,7 @@
        ///// <param name="mTimeout">请求超时时间,默认10</param>
        ///// <param name="urlHead"></param>
        ///// <returns></returns>
        //public static ResponsePackNew RequestHttpsBase(Method method, string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 10, bool needErrorTip = true)
        //public static ResponsePackNew RequestHttpsBase(Method method, string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = TIME_OUT, bool needErrorTip = true)
        //{
        //    var mResponsePackNew = RequestHttps(method, apiPath, bodyParameterJson, queryDictionary, urlSegmentDictionary, urlHead, replaceToken, mTimeout);
        //    if (needErrorTip)
@@ -90,7 +90,7 @@
        /// <param name="bodyParameterJson"></param>
        /// <param name="mTimeout"></param>
        /// <returns></returns>
        public static ResponsePackNew RequestHttpsPostFroHome(string apiPath, string bodyParameterJson, int mTimeout = 10)
        public static ResponsePackNew RequestHttpsPostFroHome(string apiPath, string bodyParameterJson, int mTimeout = TIME_OUT)
        {
            string urlHead = DB_ResidenceData.Instance.CurrentRegion.regionUrl;
            //var replaceToken = "";
@@ -111,7 +111,7 @@
        /// <param name="replaceToken"></param>
        /// <param name="mTimeout"></param>
        /// <returns></returns>
        public static ResponsePackNew RequestHttpsPost(string apiPath, string bodyParameterJson, string urlHead = "", string replaceToken = "", int mTimeout = 10)
        public static ResponsePackNew RequestHttpsPost(string apiPath, string bodyParameterJson, string urlHead = "", string replaceToken = "", int mTimeout = TIME_OUT)
        {
            return RequestHttps(Method.POST, apiPath, bodyParameterJson, null, null, urlHead, replaceToken, mTimeout);
        }
@@ -126,7 +126,7 @@
        /// <param name="replaceToken"></param>
        /// <param name="mTimeout"></param>
        /// <returns></returns>
        public static ResponsePackNew RequestHttpsPost(string apiPath, Dictionary<string, object> queryDictionary, string urlHead = "", string replaceToken = "", int mTimeout = 10)
        public static ResponsePackNew RequestHttpsPost(string apiPath, Dictionary<string, object> queryDictionary, string urlHead = "", string replaceToken = "", int mTimeout = TIME_OUT)
        {
            return RequestHttps(Method.POST, apiPath, null, queryDictionary, null, urlHead, replaceToken, mTimeout);
        }
@@ -143,8 +143,14 @@
        /// <param name="replaceToken"></param>
        /// <param name="mTimeout"></param>
        /// <returns></returns>
        static ResponsePackNew RequestHttpsBase(Method method, string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 10)
        static ResponsePackNew RequestHttpsBase(Method method, string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = TIME_OUT)
        {
            //Dome模式登录
            if(MainPage.NoLoginMode)
            {
                return new ResponsePackNew() { Code = "0" };
            }
            #region HttpWebRequest
            try
            {
@@ -153,15 +159,8 @@
                {
                    urlHead = OnAppConfig.Instance.RequestHttpsHost;
                }
                //"https://test-gz.hdlcontrol.com";
                //"https://bahrain-gateway.hdlcontrol.com";
                //urlHead="https://china-gateway.hdlcontrol.com";
                string requestFullUrl = urlHead + apiPath;
                ////**************测试**************
                //string requestFullUrl = GlobalRequestHttpsHost + apiPath;
                ////**************测试**************
                RestClient client = new RestClient(requestFullUrl);
@@ -259,7 +258,7 @@
        /// <param name="replaceToken"></param>
        /// <param name="mTimeout"></param>
        /// <returns></returns>
        public static ResponsePackNew RequestHttps(Method method, string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 10)
        public static ResponsePackNew RequestHttps(Method method, string apiPath, string bodyParameterJson = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = TIME_OUT)
        {
            var responsePackNew = RequestHttpsBase(method, apiPath, bodyParameterJson, queryDictionary, urlSegmentDictionary, urlHead, replaceToken, mTimeout);
            //*****************Token过期处理*****************
@@ -280,7 +279,7 @@
        /// <summary>
        /// 刷新Token
        /// 刷新  Token
        /// </summary>
        /// <returns></returns>
        static bool RefreshToken()
@@ -329,10 +328,6 @@
                    urlHead = OnAppConfig.Instance.RequestHttpsHost;
                }
                string requestFullUrl = urlHead + apiPath;
                ////**************测试**************
                //string requestFullUrl = GlobalRequestHttpsHost + apiPath;
                ////**************测试**************
                RestClient client = new RestClient(requestFullUrl);
                RestRequest request = new RestRequest(Method.POST);
@@ -388,7 +383,7 @@
        /// <param name="replaceToken"></param>
        /// <param name="mTimeout"></param>
        /// <returns></returns>
        public static ResponsePackNew RequestHttpsUpload(Method method, string apiPath, object bodyParameterObject = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 10)
        public static ResponsePackNew RequestHttpsUpload(Method method, string apiPath, object bodyParameterObject = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = TIME_OUT)
        {
            #region HttpWebRequest
            try
@@ -572,12 +567,15 @@
        /// 计算sign签名
        /// </summary>
        /// <returns></returns>
        public static string GetSignRequestJson(object requestObj)
        public static string GetSignRequestJson(object requestObj,Dictionary<string,object> paramDictionary = null)
        {
            try
            {
                //1. 将model实体转为Dictionary<string, object>
                var paramDictionary = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(Newtonsoft.Json.JsonConvert.SerializeObject(requestObj));
                if (paramDictionary == null)
                {
                    paramDictionary = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(Newtonsoft.Json.JsonConvert.SerializeObject(requestObj));
                }
                //2. 计算sign
                if (paramDictionary != null)
                {
@@ -652,7 +650,7 @@
        /// <summary>
        /// 响应错误信息
        /// </summary>
        public string message;
        public string message = "";
        /// <summary>
        /// 这个是请求错误时的扩展数据,以后所有的附带扩展数据都会放在这里面动态维护