wei
2021-04-01 ccdff82fac4bcc1067ec806ade5ae897f1214f4d
HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -37,34 +37,48 @@
        {
        }
        #region kaede ___________传感器历史数据__________________
        /// <summary>
        /// 获取传感器历史数据
        /// </summary>
        /// <param name="subnetId"></param>
        /// <param name="deviceId"></param>
        /// <param name="bigClass"></param>
        /// <param name="minClass"></param>
        /// <param name="queryType"></param>
        /// <param name="loopId"></param>
        /// <param name="nowMonth"></param>
        /// <param name="mac"></param>
        /// <param name="qType">时间查询类型:hour=近24小时、week=近一周、month = 近一月 </param>
        /// <param name="deviceId">设备ID</param>
        /// <param name="deviceKey">功能查询类型:pm25</param>
        /// <returns></returns>
        public ResponsePack GetSensorHistory(int subnetId, int deviceId, int bigClass, int minClass, int queryType, int loopId, int nowMonth, string mac)
        public ResponsePackNew GetSensorHistory(string qType, string deviceId,string deviceKey)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("SubnetID", subnetId);
            d.Add("DeviceID", deviceId);
            d.Add("LargeType", bigClass);
            d.Add("SmallType", minClass);
            d.Add("QueryType", queryType);
            d.Add("loopId", loopId);
            d.Add("NowMonth", nowMonth);
            d.Add("MAC", DB_ResidenceData.Instance.residenceGatewayMAC);
            d.Add("LocalTimeZone", 8);
            var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d);
            return RequestHttps("https://developer.hdlcontrol.com/api/GetSensorPushHistory", jsonString, true);
            d.Add("type", qType);
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("deviceId", new List<string>() { deviceId });
            d.Add("key", new List<string>() { deviceKey });
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_EnvironmentalSensorHistoricalData, requestJson);
        }
        /// <summary>
        /// 获取安防传感器历史数据
        /// </summary>
        /// <param name="deviceId">设备ID</param>
        /// <param name="pageSize">页面大小</param>
        /// <param name="pageNo">页号</param>
        /// <returns></returns>
        public ResponsePackNew GetArmSensorHistory( string deviceId,string pageSize, string pageNo)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("deviceId", deviceId);
            d.Add("pageSize", pageSize);
            d.Add("pageNo", pageNo);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_ArmSensorHistoricalData, requestJson);
        }
        #endregion
        //public string GetRequestResultMsg(string resultCode)
        //{
@@ -466,6 +480,7 @@
                            IsOthreShare = mHome.IsOtherShare,
                            accountType = mHome.accountType,
                            isRemoteControl = mHome.isRemoteControl,
                            isBindGateway = mHome.isBindGateway,
                            longitude = mHome.longitude,
                            latitude = mHome.latitude,
                            deliverstatus = mHome.deliverstatus,
@@ -477,7 +492,14 @@
                            Address = mHome.homeAddress,
                            isAllowCreateScene = mHome.isAllowCreateScene,
                        };
                        UserInfo.Current.regionList.Add(home);
                        if (home.isBindGateway)
                        {
                            UserInfo.Current.regionList.Add(home);
                        }
                    }
                    if(UserInfo.Current.regionList.Count== 0)
                    {
                        return "null";
                    }
                    //-------如果账号是首次登录
                    if (DB_ResidenceData.Instance.CurrentRegion == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID))
@@ -503,7 +525,7 @@
                                UserInfo.Current.SaveUserInfo();
                                Action action = () =>
                                {
                                    MainPage.GoUserPage();
                                    MainPage.GoUserPage(true);
                                };
                                new UI.PublicAssmebly().TipMsg(StringId.Tip, StringId.ResidenceDeletedSwitchToAnotherResidence, action);
                            });
@@ -553,11 +575,11 @@
        /// <summary>
        /// 获取刷新当前住宅的网关列表
        /// </summary>
        public void GetHomeGatewayList()
        public string GetHomeGatewayList()
        {
            try
            {
                if (string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID)) return;
                if (string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID)) return "";
                var nowhomeId = DB_ResidenceData.Instance.CurrentRegion.RegionID;
                var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = nowhomeId });
                var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetGatewayList, requestJson);
@@ -571,17 +593,9 @@
                            if (mHomeGatewayRes.Count > 0)
                            {
                                DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0];
                                if(mHomeGatewayRes[0].gatewayStatus)
                                {
                                    //DriverLayer.Control.Ins.IsRemote = true;
                                    DriverLayer.Control.Ins.GatewayOnline = true;
                                }
                                else
                                {
                                    DriverLayer.Control.Ins.GatewayOnline = false;
                                }
                                DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes[0].gatewayStatus;
                                DB_ResidenceData.Instance.SaveResidenceData();
                                return;
                                return revertObj.Code;
                            }
                        }
                        //其余情况清空网关信息
@@ -593,11 +607,34 @@
                {
                    //提示错误
                }
                return revertObj.Code;
            }
            catch
            {
                return "";
            }
        }
        /// <summary>
        /// 获取网关信息
        /// </summary>
        public string GetGatewayInfo()
        {
            if (DB_ResidenceData.Instance.HomeGateway == null)
                return StateCode.NETWORK_ERROR;
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId);
            var jsonString = HttpUtil.GetSignRequestJson(d);
            var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetGatewayInfo, jsonString);
            if (revertObj.Code == StateCode.SUCCESS)
            {
                var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<HomeGatewayInfo>(revertObj.Data.ToString());
                if (mHomeGatewayRes != null)
                {
                    DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes.gatewayStatus;
                }
            }
            return revertObj.Code;
        }
        /// <summary>
@@ -1752,6 +1789,56 @@
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDevcieList, requestJson);
        }
        /// <summary>
        /// 获取指定第三方品牌的绑定过的设备列表
        /// </summary>
        /// <param name="productPlatform"></param>
        /// <param name="productBrand"></param>
        /// <returns></returns>
        public ResponsePackNew Get3TyBrandBindDeviceList(string productPlatform, string productBrand)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("productPlatform", productPlatform);
            d.Add("productBrand", productBrand);
            d.Add("networkConfig", true);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDevcieList, requestJson);
        }
        /// <summary>
        /// 获取指定第三方品牌的设备列表
        /// </summary>
        /// <param name="productPlatform"></param>
        /// <param name="productBrand"></param>
        /// <returns></returns>
        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);
        }
        /// <summary>
        /// 获取设备详情
        /// </summary>
        /// <returns></returns>
        public ResponsePackNew GetDeviceInfo(string functionId)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("deviceIds", new List<string>() { functionId });
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDevcieInfoList, requestJson);
        }
        /// <summary>
        /// 获取设备详情列表
        /// </summary>
        /// <returns></returns>
@@ -1787,7 +1874,7 @@
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId);//DriverLayer.Control.Ins.GatewayId);
            d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway == null ? "0" : DB_ResidenceData.Instance.HomeGateway.gatewayId);//DriverLayer.Control.Ins.GatewayId);
            d.Add("actions", actionObjs);
            var requestJson = HttpUtil.GetSignRequestJson(d);
@@ -1802,7 +1889,7 @@
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("deviceId", function.deviceId);//DriverLayer.Control.Ins.GatewayId);
            d.Add("deviceId", function.deviceId);
            d.Add("name", function.name);
            d.Add("collect", function.collect);
            d.Add("roomIds", function.roomIds);
@@ -1810,6 +1897,22 @@
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson);
        }
        /// <summary>
        /// 更新设备绑定房间信息
        /// </summary>
        /// <returns></returns>
        public ResponsePackNew UpdataDevcieBindRoomInfo(Function function)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            d.Add("deviceId", function.deviceId);
            d.Add("roomIds", function.roomIds);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson);
        }
        /// <summary>
        /// 设备绑定房间
        /// </summary>
@@ -1908,6 +2011,21 @@
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson);
        }
        /// <summary>
        /// 获取场景详情列表
        /// </summary>
        /// <param name="seceneId">场景ID</param>
        /// <returns></returns>
        public ResponsePackNew GetSceneListInfo(List<string> seceneIds)
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("userSceneIds", seceneIds);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson);
        }
        /// <summary>
        /// 添加场景
        /// </summary>
@@ -2071,5 +2189,61 @@
        }
        #endregion
        #region Kaede --房间功能--------------------------
        /// <summary>
        /// 获取第三方品牌列表
        /// </summary>
        public ResponsePackNew Get3tyBrandList()
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            var requestJson = HttpUtil.GetSignRequestJson(d);
            var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetBrandList, requestJson);
            return pack;
        }
        /// <summary>
        /// 获取绑定的第三方品牌列表
        /// </summary>
        public ResponsePackNew Get3tyBindBrandList()
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetBindBrandList, requestJson);
            return pack;
        }
        #endregion
        #region 萤石云SDK相关接口
        /// <summary>
        /// 河东获取萤石云子账号token的接口
        /// </summary>
        public ResponsePackNew EZGetChildToken()
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            var requestJson = HttpUtil.GetSignRequestJson(d);
            return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_EZ_GetChildToken, requestJson);
        }
        #endregion
        #region 可视对讲
        /// <summary>
        /// 检查住宅是否绑定丰林,并获取门口机列表
        /// </summary>
        /// <returns></returns>
        public ResponsePackNew CheckFlVideo()
        {
            Dictionary<string, object> d = new Dictionary<string, object>();
            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID);
            var requestJson = HttpUtil.GetSignRequestJson(d);
            var pack = HttpUtil.RequestHttpsPostFroHome( NewAPI.API_POST_FL_Check, requestJson);
            return pack;
        }
        #endregion
    }
}