wxr
2021-11-29 dd7e4794fd611de967c6322dd0bb7ffda41c2f7b
HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -45,13 +45,13 @@
        /// <param name="deviceId">设备ID</param>
        /// <param name="deviceKey">功能查询类型:pm25</param>
        /// <returns></returns>
        public ResponsePackNew GetSensorHistory(string qType, string deviceId,string deviceKey)
        public ResponsePackNew GetSensorHistory(string qType, string deviceId, string deviceKey)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("type", qType);
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
            d.Add("deviceId",  deviceId );
            d.Add("key",  deviceKey );
            d.Add("deviceId", deviceId);
            d.Add("key", deviceKey);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_EnvironmentalSensorHistoricalData, requestJson);
@@ -63,7 +63,7 @@
        /// <param name="pageSize">页面大小</param>
        /// <param name="pageNo">页号</param>
        /// <returns></returns>
        public ResponsePackNew GetArmSensorHistory( string deviceId,string pageSize, string pageNo)
        public ResponsePackNew GetArmSensorHistory(string deviceId, string pageSize, string pageNo)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
@@ -78,7 +78,7 @@
        /// 读取最近一个月的数据
        /// </summary>
        /// <returns></returns>
        public ResponsePackNew GetLastMonthHistory(string deviceId,string key)
        public ResponsePackNew GetLastMonthHistory(string deviceId, string key)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
@@ -146,6 +146,12 @@
                UserInfo.Current.RefreshToken = revertData.refreshToken;
                UserInfo.Current.LastTime = DateTime.Now;
                UserInfo.Current.SaveUserInfo();
#if __IOS__
                var sdm = new SiriKit.SceneDateManager();
                sdm.AccessToken = UserInfo.Current.LoginTokenString;
                sdm.RefreshToken = UserInfo.Current.RefreshToken;
#endif
            }
            return revertObj.Code;
        }
@@ -234,7 +240,19 @@
                account = account,
                loginPwd = password
            });
            return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson);
            var pack = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson);
            if (pack != null)
            {
                if (pack.Code == StateCode.SUCCESS)
                {
#if __IOS__
                    var sdm = new SiriKit.SceneDateManager();
                    sdm.IsLgoin = true;
#endif
                }
            }
            return pack;
        }
        /// <summary>
@@ -251,7 +269,19 @@
                verifyCode = vCode,
                grantType = "verify"
            });
            return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson);
            var pack = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson);
            if (pack != null)
            {
                if (pack.Code == StateCode.SUCCESS)
                {
#if __IOS__
                    var sdm = new SiriKit.SceneDateManager();
                    sdm.IsLgoin = true;
#endif
                }
            }
            return pack;
        }
        /// <summary>
@@ -264,7 +294,7 @@
        /// <returns></returns>
        public ResponsePackNew ValidataCodeAndRegister(string account, string password, string code, bool isPhone = false)
        {
            var requestObj = new RegisterObj() { loginPwd = password, verifyCode = code};//, memberName = account
            var requestObj = new RegisterObj() { loginPwd = password, verifyCode = code };//, memberName = account
            if (isPhone)
            {
                requestObj.memberPhone = account;
@@ -345,7 +375,7 @@
                UserInfo.Current.userEmailInfo = info.memberEmail;
                UserInfo.Current.userMobileInfo = info.memberPhone;
                UserInfo.Current.userName = info.memberName;
                if (!string.IsNullOrEmpty(info.memberPhonePrefix))
                {
                    UserInfo.Current.areaCode = info.memberPhonePrefix;
@@ -482,7 +512,7 @@
        /// <summary>
        /// 获取住宅列表
        /// </summary>
        public string GetHomePager(HomeTypeEnum homeType = HomeTypeEnum.ALL,string homeId = "")
        public string GetHomePager(HomeTypeEnum homeType = HomeTypeEnum.ALL, string homeId = "")
        {
            var requestJson = HttpUtil.GetSignRequestJson(new GetHomeListObj() { homeType = homeType.ToString() });
            var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Gethomepager, requestJson);
@@ -510,7 +540,7 @@
                            }
                        }
                    }
                    if(UserInfo.Current.regionList.Count== 0)
                    if (UserInfo.Current.regionList.Count == 0)
                    {
                        return "null";
                    }
@@ -553,6 +583,12 @@
                            GetHomeGatewayList();
                        }
                    }
#if __IOS__
                    var sdm = new SiriKit.SceneDateManager();
                    sdm.RegionUrl = DB_ResidenceData.Instance.CurrentRegion.regionUrl;
                    sdm.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;
#endif
                }
            }
@@ -785,7 +821,7 @@
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Share_GetList, requestJson);
        }
        #endregion
        ///// <summary>
@@ -934,7 +970,7 @@
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
            d.Add("debugPerm", debugPerm);
            var jsonString = HttpUtil.GetSignRequestJson(d,d);
            var jsonString = HttpUtil.GetSignRequestJson(d, d);
            var pack = HttpUtil.RequestHttpsPost(NewAPI.API_Post_Home_UpdateDebugPerm, jsonString);
            return pack;
        }
@@ -993,7 +1029,8 @@
                isProduce = false;
#endif
                if (string.IsNullOrEmpty(OnAppConfig.Instance.PushDeviceToken)) {
                if (string.IsNullOrEmpty(OnAppConfig.Instance.PushDeviceToken))
                {
                    Utlis.WriteLine("PushDeviceToken 为空");
                    return false;
                }
@@ -1004,7 +1041,7 @@
                    deviceName = OnAppConfig.Instance.PhoneName,
                    deviceType = deviceType,
                    produce = isProduce,
                };
                mAddpushinfoObj.languageType = Utlis.GetPostLanguageType();
@@ -1027,11 +1064,11 @@
                            OnAppConfig.Instance.PushId = pushId;
                            OnAppConfig.Instance.SaveConfig();
                            Utlis.WriteLine("PushId: " + pushId);
                            return true;
                        }
                    }
                }
                else
                {
@@ -1115,10 +1152,11 @@
            if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false;
            try
            {
                var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() {
                var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj()
                {
                    pushId = OnAppConfig.Instance.PushId
                });
                var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_DeleteToken, requestJson);
                if (revertObj.Code == StateCode.SUCCESS)
                {
@@ -1303,13 +1341,13 @@
#endregion
        #endregion
#region 获取天气部分
        #region 获取天气部分
        /// <summary>
        /// 获取指定经纬度的城市信息
        /// 获取指定经纬度的城市信息天气信息
        /// </summary>
        public void GetCityInfo(string lon, string lat)
        public void GetCityWeatherInfo(string lon, string lat)
        {
            System.Threading.Tasks.Task.Run(() =>
            {
@@ -1372,11 +1410,64 @@
                });
            });
        }
        ///// <summary>
        ///// 获取指定经纬度的城市信息
        ///// </summary>
        ///// <param name="lon"></param>
        ///// <param name="lat"></param>
        //public void GetCityInfo()
        //{
        //    if (DB_ResidenceData.Instance.CurrentRegion.longitude == 0 && DB_ResidenceData.Instance.CurrentRegion.latitude == 0)
        //    {
        //        return;
        //    }
        //    string lon = DB_ResidenceData.Instance.CurrentRegion.longitude.ToString();
        //    string lat = DB_ResidenceData.Instance.CurrentRegion.latitude.ToString();
        //    System.Threading.Tasks.Task.Run(() =>
        //    {
        //        while (true)
        //        {
        //            var webClient = new WebClient();
        //            string url = $"https://developer.hdlcontrol.com/Weather/Weather/FindCity/?lon={lon}&lat={lat}";
        //            string responseString = null;
        //            try
        //            {
        //                responseString = Encoding.UTF8.GetString(webClient.DownloadData(url));
        //            }
        //            catch (Exception ex)
        //            {
        //                MainPage.Log(ex.Message);
        //            }
#endregion
        //            if (responseString != null)
        //            {
        //                try
        //                {
        //                    var revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(responseString);
        //                    JObject jt = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(revertObj.ResponseData.ToString());
        //                    DB_ResidenceData.cityInfo.location = jt.GetValue("Location").ToString();
        //                    DB_ResidenceData.cityInfo.province = jt.GetValue("Province").ToString();
        //                    DB_ResidenceData.cityInfo.country = jt.GetValue("Country").ToString();
        //                    DB_ResidenceData.cityInfo.timeZone = jt.GetValue("TimeZone").ToString();
        //                    DB_ResidenceData.Instance.SaveResidenceData();
        //                    return;
        //                }
        //                catch (Exception ex)
        //                {
        //                    MainPage.Log($"get weather error : {ex.Message}");
        //                }
        //            }
        //        }
        //    });
        //}
#region 备份部分
        #endregion
        #region 备份部分
        ///// <summary>
        ///// 获取住宅备份列表
        ///// </summary>
@@ -1847,10 +1938,10 @@
        }
        */
#endregion
        #endregion
#region Kaede --设备功能——————————————————————————————————
        #region Kaede --设备功能——————————————————————————————————
        /// <summary>
        /// 获取设备列表
        /// </summary>
@@ -1894,14 +1985,14 @@
        /// <param name="productPlatform"></param>
        /// <param name="productBrand"></param>
        /// <returns></returns>
        public ResponsePackNew Get3TyBrandDeviceList(string productPlatform,string productBrand)
        public ResponsePackNew Get3TyBrandDeviceList(string productPlatform, string productBrand)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("categoryType", 1);
            d.Add("productPlatform", productPlatform);
            d.Add("productBrand", productBrand);
            d.Add("networkConfig", true);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_Get3tyBrandDevcieList, requestJson);
        }
@@ -1911,7 +2002,7 @@
        /// <param name="productPlatform"></param>
        /// <param name="productBrand"></param>
        /// <returns></returns>
        public ResponsePackNew IndependentRegister3TyDevcie(string spk,string extDevId,string deviceName,string pairCode = "")
        public ResponsePackNew IndependentRegister3TyDevcie(string spk, string extDevId, string deviceName, string pairCode = "")
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
@@ -2021,7 +2112,7 @@
        /// <summary>
        /// 设备绑定房间
        /// </summary>
        public ResponsePackNew BindDeviceToRoom(List<string> deviceIds,List<string> roomIds)
        public ResponsePackNew BindDeviceToRoom(List<string> deviceIds, List<string> roomIds)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
@@ -2064,7 +2155,7 @@
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
            d.Add("deviceIds",new List<string>() { deviceId });
            d.Add("deviceIds", new List<string>() { deviceId });
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CollectDevice, requestJson);
@@ -2082,9 +2173,9 @@
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CancelCollectDevice, requestJson);
        }
#endregion
        #endregion
#region Kaede --场景功能--------------------------
        #region Kaede --场景功能--------------------------
        /// <summary>
        /// 获取场景列表
        /// 房间ID可空,默认查询住宅下所有房间
@@ -2111,7 +2202,7 @@
        public ResponsePackNew GetSceneInfo(string seceneId)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("userSceneIds",new List<string>() { seceneId });
            d.Add("userSceneIds", new List<string>() { seceneId });
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson);
@@ -2216,9 +2307,9 @@
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CancelCollectScene, requestJson).Code;
        }
#endregion
        #endregion
#region Kaede --房间功能--------------------------
        #region Kaede --房间功能--------------------------
        /// <summary>
        /// 获取房间列表
        /// </summary>
@@ -2235,7 +2326,7 @@
            d.Add("pageSize", "1000");
            var requestJson = HttpUtil.GetSignRequestJson(d);
            var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetRoomList, requestJson);
            return pack;
        }
        /// <summary>
@@ -2293,10 +2384,10 @@
            return pack;
        }
#endregion
        #endregion
#region Kaede -- 安防接口____________________________
        #region Kaede -- 安防接口____________________________
        /// <summary>
        /// 获取安防列表
        /// </summary>
@@ -2436,7 +2527,7 @@
        /// <summary>
        /// 查询安防所有记录
        /// </summary>
        public ResponsePackNew GetSecurityLogList(string pageSize,string pageNo)
        public ResponsePackNew GetSecurityLogList(string pageSize, string pageNo)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
@@ -2460,10 +2551,10 @@
            return pack;
        }
#endregion
        #endregion
#region Kaede --第三方品牌功能--------------------------
        #region Kaede --第三方品牌功能--------------------------
        /// <summary>
        /// 获取第三方品牌列表
        /// </summary>
@@ -2488,9 +2579,9 @@
            return pack;
        }
#endregion
        #endregion
#region ■ 萤石云SDK相关接口_________________________
        #region ■ 萤石云SDK相关接口_________________________
        /// <summary>
        /// 河东获取萤石云子账号token的接口
        /// 2021-07-07 新方案接口调整对接
@@ -2503,10 +2594,10 @@
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_EZ_GetChildToken, requestJson);
        }
#endregion
        #endregion
#region ■ 可视对讲_________________________
        #region ■ 可视对讲_________________________
        /// <summary>
        /// 检查住宅是否绑定丰林
        /// </summary>
@@ -2516,12 +2607,12 @@
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            var pack = HttpUtil.RequestHttpsPostFroHome( NewAPI.API_POST_FL_Check, requestJson);
            var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_FL_Check, requestJson);
            return pack;
        }
#endregion
        #endregion
#region ■ 门锁相关____________________________
        #region ■ 门锁相关____________________________
        /// <summary>
        /// 获取门锁历史记录(按日期降序)
@@ -2590,8 +2681,8 @@
            return listSortLog;
        }
#endregion
#region ■ 音箱语言控制相关_________________________
        #endregion
        #region ■ 音箱语言控制相关_________________________
        /// <summary>
        /// 获取已授权的音箱列表
        /// </summary>
@@ -2655,8 +2746,20 @@
            var requestJson = HttpUtil.GetSignRequestJson(updateSpeakerDeviceListObj);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Speaker_DeviceList_Update, requestJson);
        }
#endregion
        #endregion
        /// <summary>
        /// 绑定source面板
        /// </summary>
        /// <returns></returns>
        public ResponsePackNew BindSourcePanel(string qrString)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
            d.Add("content", qrString);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_BindSourcePanel, requestJson);
        }
        /// <summary>
        /// 人脸录入
@@ -2666,7 +2769,7 @@
        public ResponsePackNew FaceSetting(string imageBytes)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("userFace", @"data:image/jpg;base64,"+imageBytes);
            d.Add("userFace", @"data:image/jpg;base64," + imageBytes);
            d.Add("houseId", DB_ResidenceData.Instance.CurrentRegion.id);
            //MainPage.Log(imageBytes);