wxr
2023-10-27 326a8e72d7bb6def4147fc1e711d3cfa2aa8f4d1
修复Siri Token过期无法刷新的问题
8个文件已修改
137 ■■■■■ 已修改文件
HDL-ON_Android/SplashActivity.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_iOS/AppDelegate.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Common/OnAppConfig.cs 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Server/HttpServerRequest.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Server/HttpUtil.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SiriIntents/Server/HttpUtil.cs 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SiriKit/Data/SceneDateManager.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_Android/SplashActivity.cs
@@ -85,10 +85,10 @@
                {
                    Language.CurrentLanguage = "български";
                }
                //else if (localeList.Language == "uk")
                //{
                //    Language.CurrentLanguage = "Ukraine";
                //}
                else if (localeList.Language == "uk")
                {
                    Language.CurrentLanguage = "Ukraine";
                }
                else
                {
                    Language.CurrentLanguage = "English";
HDL-ON_iOS/AppDelegate.cs
@@ -248,6 +248,7 @@
            //    Shared.IOS.HDLFVSDK.Video.FVapplicationDidBecomeActive(application);
            //}
            Console.WriteLine("OnActivated");
            base.OnActivated(application);
            //HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
@@ -289,9 +290,9 @@
                {
                    Language.CurrentLanguage = "Spanish";
                }
                //else if(NSLocale.PreferredLanguages[0].Contains("uk-")){
                //    Language.CurrentLanguage = "Ukraine";
                //}
                else if(NSLocale.PreferredLanguages[0].Contains("uk-")){
                    Language.CurrentLanguage = "Ukraine";
                }
                else
                {
                    Language.CurrentLanguage = "English";
HDL_ON/Common/OnAppConfig.cs
@@ -77,10 +77,24 @@
        public List<UserAccount> UserList = new List<UserAccount>();
        #region 服务器数据
        public string _RequestHttpsHost = "https://china.hdlcontrol.com";
        /// <summary>
        ///  账号注册服务器信息
        /// </summary>
        public string RequestHttpsHost = "https://china.hdlcontrol.com";
        public string RequestHttpsHost {
            get
            {
                return _RequestHttpsHost;
            }
            set
            {
#if __IOS__
                var sdm = new SiriKit.SceneDateManager();
                sdm.GlobalRequestHttpsHost = value;
#endif
                _RequestHttpsHost = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -161,7 +161,7 @@
        /// 刷新Token
        /// </summary>
        /// <returns></returns>
        public string RefreshToken()
        public string RefreshToken(bool canRefresh = true)
        {
            var requestJson = HttpUtil.GetSignRequestJson(new RefreshTokenObj()
            {
@@ -187,6 +187,18 @@
            {
                UserInfo.Current.LastTime = DateTime.MinValue;
            }
#if __IOS__
            else if (revertObj.Code == "10001")
            {
                if (canRefresh)
                {
                    MainPage.Log($"UserInfo.Current.RefreshToken 1 : " + UserInfo.Current.RefreshToken);
                    UserInfo.Current.RefreshToken = SiriKit.NSUserDefaultsHelper.DataSuite.StringForKey(SiriKit.NSUserDefaultsHelper.StorageKeys.GLOBAL_GAccessToken);
                    MainPage.Log($"UserInfo.Current.RefreshToken 2 : " + UserInfo.Current.RefreshToken);
                    RefreshToken(false);
                }
            }
#endif
            return revertObj.Code;
        }
HDL_ON/DAL/Server/HttpUtil.cs
@@ -4,11 +4,9 @@
using System.Net;
using System.Security.Cryptography;
using System.Text;
using Foundation;
using HDL_ON.Entity;
using RestSharp;
using Shared;
using SiriKit;
namespace HDL_ON.DAL.Server
{
@@ -212,6 +210,11 @@
                }
                IRestResponse response = client.Execute(request);
                HDL_ON.Utlis.WriteLine("发送", requestFullUrl, response.Request.Body?.Value.ToString());
                if(apiPath == NewAPI.API_POST_Login)
                {
                    var ddd = Newtonsoft.Json.JsonConvert.SerializeObject(response);
                    Console.WriteLine(ddd);
                }
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    try
@@ -304,7 +307,7 @@
        /// 刷新  Token
        /// </summary>
        /// <returns></returns>
        static bool RefreshToken()
        static bool RefreshToken(bool canRefresh = true)
        {
            try
            {
@@ -325,7 +328,6 @@
                    var sdm = new SiriKit.SceneDateManager();
                    sdm.AccessToken = UserInfo.Current.LoginTokenString;
                    sdm.RefreshToken = UserInfo.Current.RefreshToken;
                    //var sss = NSUserDefaultsHelper.DataSuite.StringForKey(NSUserDefaultsHelper.StorageKeys.GLOBAL_GAccessToken);
#endif
                    return true;
                }
@@ -541,7 +543,7 @@
        }
        #endregion
#endregion
        #region **********签名校验**********
HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs
@@ -661,12 +661,14 @@
            {
                new System.Threading.Thread(() =>
                {
                    foreach (var tempSensor in sensorList)
                    {
                        if (index >= 6)
                        {
                            break;
                        }
                        if (tempSensor.sid == function.sid)
                        {
                            continue;
@@ -729,7 +731,7 @@
                                TextAlignment = TextAlignment.CenterLeft,
                                TextColor = CSS_Color.FirstLevelTitleColor,
                                TextSize = CSS_FontSize.TextFontSize,
                                Text = function.name,
                                Text = tempSensor.name,
                                IsBold = true,
                            };
                            otherInfoView.AddChidren(btnSensorName);
@@ -824,6 +826,12 @@
                        });
                        System.Threading.Thread.Sleep(50);
                    }
                    Application.RunOnMainThread(() => {
                        if (index > 1)
                        {
                            contentView.ScrollEnabled = true;
                        }
                    });
                }).Start();
            }
            catch(Exception ex)
@@ -836,6 +844,7 @@
            LoadMothed_GetSensorHistoryData();
            LoadEvent_ChangeSensorHistoryShowType();
        }
    }
@@ -900,7 +909,7 @@
                                    }
                                    ebl.InitXdataText(vs);
                                }
                                yDataString += ebl.InitYdataText(sr.name, revertData, tipColorStringList[i]);
                                yDataString += ebl.InitYdataText("", revertData, tipColorStringList[i]);
                            }
                        }
                        i++;
@@ -909,6 +918,8 @@
                    Application.RunOnMainThread(() =>
                    {
                        ebl.xTitle = "";
                        ebl.yTitle = "";
                        myEchartsView.ShowWithOption(ebl.InitOption());
                    });
SiriIntents/Server/HttpUtil.cs
@@ -16,13 +16,14 @@
        /// 固定域名,正式环境
        /// 公共域名就近解析
        /// </summary>
        //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";
        public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";
        const string APP_KEY = "HDL-HOME-APP-TEST";
        const string SECRET_KEY = "WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss";
        //public const string GlobalRequestHttpsHost = "http://59.41.255.150:7777";//mmmm
        //const string APP_KEY = "CPEVRLRT";
        //const string SECRET_KEY = "CPEVRLSJCPEVRLSZ";
        /// <summary>
        /// RegionMark
        /// </summary>
@@ -35,9 +36,9 @@
        /// 特殊接口请求超时时间
        /// </summary>
        public const int TIME_OUT_LONG = 20;
        /////// <summary>
        /////// Bearer 暂时设为空,从登陆成功的返回的headerPrefix参数动态获取
        /////// </summary>
        /// <summary>
        /// Bearer 暂时设为空,从登陆成功的返回的headerPrefix参数动态获取
        /// </summary>
        //public const string TOKEN_BEARER = "Bearer ";
        #endregion
@@ -114,6 +115,15 @@
            try
            {
                if (string.IsNullOrEmpty(urlHead))
                {
                    urlHead = HttpServerRequest.Ins.DataManager.GlobalRequestHttpsHost;
                    if (string.IsNullOrEmpty(urlHead))
                    {
                        urlHead = "https://nearest.hdlcontrol.com";
                    }
                }
                string requestFullUrl = urlHead + apiPath;
@@ -122,9 +132,10 @@
                RestRequest request = new RestRequest(method);
                request.Timeout = mTimeout * 1000;
                request.AddHeader("content-type", "application/json");
                request.AddHeader("language", "cn");
                request.AddHeader("Authorization", HttpServerRequest.Ins.DataManager.AccessToken);
                if (bodyParameterJson != null)
                {
                    request.AddParameter("application/json", bodyParameterJson, ParameterType.RequestBody);
@@ -174,6 +185,8 @@
                }
                else
                {
                    var ddd =Newtonsoft.Json.JsonConvert.SerializeObject(response);
                    return new ResponsePackNew() { Code = StateCode.NETWORK_ERROR };
                }
@@ -204,7 +217,7 @@
        {
            var responsePackNew = RequestHttpsBase(method, apiPath, bodyParameterJson, queryDictionary, urlSegmentDictionary, urlHead, replaceToken, mTimeout);
            //*****************Token过期处理*****************
            if (responsePackNew.Code == StateCode.TOKEN_EXPIRED)
            if (responsePackNew.Code == StateCode.TOKEN_EXPIRED )
            {
                //刷新Token
                if (RefreshToken()) {
SiriKit/Data/SceneDateManager.cs
@@ -10,29 +10,6 @@
        public SceneDateManager() { }//: base(new UserDefaultsStorageDescriptor(NSUserDefaultsHelper.StorageKeys.OrderHistory), new NSMutableArray<HDLSceneSiri.HDLSiriSceneModel>()) { }
        protected NSUserDefaults UserDefaults = NSUserDefaultsHelper.DataSuite;
        //#region Public API for clients of `SoupOrderDataManager`
        //// Convenience method to access the data with a property name that makes
        //// sense in the caller's context.
        //public NSMutableArray<HDLSceneSiri.HDLSiriSceneModel> OrderHistory
        //{
        //    get
        //    {
        //        return ManagedData as NSMutableArray<HDLSceneSiri.HDLSiriSceneModel>;
        //    }
        //}
        //#endregion
        //#region Support methods for unarchiving saved data
        //override protected void FinishUnarchiving(NSObject unarchivedData)
        //{
        //    var array = (NSArray)unarchivedData;
        //    HDLSceneSiri.HDLSiriSceneModel[] orders = NSArray.FromArray<HDLSceneSiri.HDLSiriSceneModel>(array);
        //    ManagedDataBackingInstance = new NSMutableArray<HDLSceneSiri.HDLSiriSceneModel>(orders);
        //}
        //#endregion
        public bool IsLgoin
        {
            get
@@ -100,5 +77,20 @@
                UserDefaults.SetString(value, NSUserDefaultsHelper.StorageKeys.GLOBAL_GHomeId);
            }
        }
        public string GlobalRequestHttpsHost
        {
            get
            {
                var d = UserDefaults.StringForKey("GlobalRequestHttpsHost");
                return d;
            }
            set
            {
                UserDefaults.SetString(value, "GlobalRequestHttpsHost");
            }
        }
    }
}