| | |
| | | /// <returns></returns> |
| | | public string UpdataUserHeadImage(string fileName) |
| | | { |
| | | FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); |
| | | byte[] bytes = new byte[fs.Length]; |
| | | fs.Read(bytes, 0, bytes.Length); |
| | | byte[] bytes = Shared.IO.FileUtils.ReadFile(fileName); |
| | | var revertObj = HttpUtil.RequestHttpsUpload(RestSharp.Method.POST, NewAPI.API_POST_Head_Upload, bytes); |
| | | return revertObj.Code; |
| | | } |
| | |
| | | /// </summary> |
| | | public string GetHomePager(HomeTypeEnum homeType = HomeTypeEnum.ALL) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new GetHomeListObj() { homeType = homeType.ToString() }); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetHomeListObj() { homeType = homeType.ToString() }); |
| | | var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Gethomepager, requestJson); |
| | | if (resultObj.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | } |
| | | DB_ResidenceData.residenceData.SaveResidenceData(); |
| | | UserInfo.Current.SaveUserInfo(); |
| | | |
| | | //刷新一次住宅网关 |
| | | GetHomeGatewayList(); |
| | | } |
| | | |
| | | } |
| | |
| | | requestObj.Address = editName; |
| | | } |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Home_UpdateHome, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取刷新当前住宅网关接口 |
| | | /// 获取刷新当前住宅的网关列表 |
| | | /// </summary> |
| | | public void GetHomeGatewayList() |
| | | { |
| | | if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.residecenInfo.RegionID)) return; |
| | | var nowhomeId = DB_ResidenceData.residenceData.residecenInfo.RegionID; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeIdObj() { homeId = nowhomeId }); |
| | | var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetGatewayList, requestJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | try |
| | | { |
| | | var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomeGatewayInfo>>(revertObj.Data.ToString()); |
| | | if (nowhomeId == DB_ResidenceData.residenceData.residecenInfo.RegionID) |
| | | if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.residecenInfo.RegionID)) return; |
| | | var nowhomeId = DB_ResidenceData.residenceData.residecenInfo.RegionID; |
| | | var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = nowhomeId }); |
| | | var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetGatewayList, requestJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | | if (mHomeGatewayRes != null) |
| | | var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomeGatewayInfo>>(revertObj.Data.ToString()); |
| | | if (nowhomeId == DB_ResidenceData.residenceData.residecenInfo.RegionID) |
| | | { |
| | | if (mHomeGatewayRes.Count > 0) |
| | | if (mHomeGatewayRes != null) |
| | | { |
| | | DB_ResidenceData.residenceData.residenceGatewayMAC = mHomeGatewayRes[0].mac; |
| | | if (mHomeGatewayRes.Count > 0) |
| | | { |
| | | DB_ResidenceData.residenceData.HomeGateway = mHomeGatewayRes[0]; |
| | | DB_ResidenceData.residenceData.SaveResidenceData(); |
| | | return; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | DB_ResidenceData.residenceData.residenceGatewayMAC = ""; |
| | | |
| | | } |
| | | //其余情况清空网关信息 |
| | | DB_ResidenceData.residenceData.HomeGateway = null; |
| | | DB_ResidenceData.residenceData.SaveResidenceData(); |
| | | } |
| | | |
| | | if (mHomeGatewayRes != null) |
| | | { |
| | | //Utlis.WriteLine ("获得当前住宅网关个数:" + mHomeGatewayRes.content.Count); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //提示错误 |
| | | } |
| | | } |
| | | else |
| | | catch |
| | | { |
| | | //提示错误 |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetResidenceMemberAccount() |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID }); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID }); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_FindAll, requestJson); |
| | | } |
| | | |
| | |
| | | childAccountId = subaccount.childAccountId, |
| | | homeId = subaccount.homeId |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Delete, requestJson); |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew EditSubAccountNickName(string nickName, string childAccountId) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new UpdateChildNickNameObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildNickNameObj() |
| | | { |
| | | homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, |
| | | childAccountId = childAccountId, |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew ChangeCreateSceneState(bool isAllow, string childAccountId) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new UpdateChildAllowCreateSceneObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildAllowCreateSceneObj() |
| | | { |
| | | homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, |
| | | childAccountId = childAccountId, |
| | |
| | | }); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Update, requestJson); |
| | | } |
| | | |
| | | #region 新数据分享 |
| | | /// <summary> |
| | | /// 添加分享 |
| | | /// </summary> |
| | | /// <param name="addShareObj"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew AddShare(AddShareObj addShareObj) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(addShareObj); |
| | | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Share_Add, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除分享 |
| | | /// </summary> |
| | | /// <param name="deleteShareObj"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew DeleteShare(DeleteShareObj deleteShareObj) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(deleteShareObj); |
| | | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Share_Delete, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取分享 |
| | | /// </summary> |
| | | /// <param name="addShareObj"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetShare(GetShareObj getShareObj) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(getShareObj); |
| | | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Share_Delete, requestJson); |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 获取住宅下子账号的共享数据列表 |
| | |
| | | //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | //return RequestHttps($"{severAddress}/ZigbeeDataShare/GetShareDataBySubAccount", jsonString, true); |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeShareFindAll() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new HomeShareFindAll() |
| | | { |
| | | homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, |
| | | childAccountId = childAccountId |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew DeleteShareData(ShareData shareData) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new ShareFileDownObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new ShareFileDownObj() |
| | | { |
| | | homeId = shareData.homeId, |
| | | homeShareId = shareData.id |
| | |
| | | { |
| | | //添加子账号 |
| | | var requestObj = new ChildAddObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, account = subAccount, nickName = nickName }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Add, requestJson); |
| | | |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new GetMqttRemoteInfoObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetMqttRemoteInfoObj() |
| | | { |
| | | attachClientId = attachClientId, |
| | | homeType = HomeTypeEnum.BUSPRO.ToString() |
| | |
| | | #if __IOS__ |
| | | deviceType = PhoneDeviceType.IOS.ToString(); |
| | | #endif |
| | | //是否生成模式 |
| | | //是否生产模式 |
| | | bool isProduce = true; |
| | | #if DEBUG |
| | | isProduce = false; |
| | | #endif |
| | | |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushDeviceToken)) return false; |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushDeviceToken)) { |
| | | Utlis.WriteLine("PushDeviceToken 为空"); |
| | | return false; |
| | | } |
| | | |
| | | var mAddpushinfoObj = new AddpushinfoObj() |
| | | { |
| | |
| | | deviceName = OnAppConfig.Instance.PhoneName, |
| | | deviceType = deviceType, |
| | | produce = isProduce, |
| | | |
| | | }; |
| | | |
| | | var mAddpushinfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(mAddpushinfoObj); |
| | | //var mAddpushinfoJson = HttpUtil.GetSignRequestJson(mAddpushinfoObj); |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_AddToken, mAddpushinfoJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | { |
| | | OnAppConfig.Instance.PushId = pushId; |
| | | OnAppConfig.Instance.SaveUserConfig(); |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | Utlis.WriteLine("AddToken 成功"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("AddToken 失败"); |
| | | //Utlis.WriteLine("AddToken 失败"); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查询推送信息列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew PushSerivceGetpushmessagelist() |
| | | public ResponsePackNew PushSerivceGetPushmessagelist() |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new GetMessageListObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetMessageListObj() |
| | | { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | }); |
| | |
| | | { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() |
| | | { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | }); |
| | |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushIdObj() { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | }); |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() |
| | | { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | }); |
| | |
| | | |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushMsgIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushMsgIdObj() |
| | | { |
| | | msgId = msgId |
| | | }); |
| | |
| | | |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushMsgIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushMsgIdObj() |
| | | { |
| | | msgId = msgId |
| | | }); |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 注册推送 |
| | | /// </summary> |
| | | public void RegisteredPush() |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var success = PushSerivceAddPushInfo(); |
| | | if (success) |
| | | { |
| | | Utlis.WriteLine("推送注册成功"); |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("推送注册失败"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 注销推送 |
| | | /// </summary> |
| | | public void SignOutPush() |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var success = PushSerivceSignOut(); |
| | | if (success) |
| | | { |
| | | Utlis.WriteLine("推送注销成功"); |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("推送注销失败"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 检测更新 |
| | |
| | | #if __IOS__ |
| | | requestObj.DeviceType = PhoneDeviceType.IOS.ToString(); |
| | | #endif |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_CheckAppVersion, requestJson); |
| | | } |
| | | |
| | |
| | | #if __IOS__ |
| | | requestObj.DeviceType = PhoneDeviceType.IOS.ToString(); |
| | | #endif |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetAppVersion, requestJson); |
| | | } |
| | | |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region mqtt远程连接(旧) |
| | | /// <summary> |
| | | /// 请求Mqtt数据 |
| | | /// </summary> |
| | | /// <param name="dataStringJson">请求的参数.</param> |
| | | public ResponsePack RequestMqttInfo(string dataStringJson) |
| | | { |
| | | ResponsePack revertObj = null; |
| | | |
| | | var webClient = new WebClient(); |
| | | #region |
| | | webClient.Headers.Add("CONTENT-TYPE", "application/json"); |
| | | var url = "https://global.hdlcontrol.com/ProposedProductionApi/EmqMqtt/GetConnMqttInfo"; |
| | | |
| | | byte[] bytes = null; |
| | | try |
| | | { |
| | | bytes = webClient.UploadData(url, Encoding.UTF8.GetBytes(dataStringJson)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.Message); |
| | | revertObj = new ResponsePack() { StateCode = "Net_Error" }; |
| | | } |
| | | |
| | | string responseString = null; |
| | | if (bytes != null) |
| | | { |
| | | responseString = Encoding.UTF8.GetString(bytes); |
| | | } |
| | | |
| | | if (responseString != null) |
| | | { |
| | | try |
| | | { |
| | | revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(responseString); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.ToString()); |
| | | } |
| | | } |
| | | return revertObj; |
| | | #endregion |
| | | } |
| | | #endregion |
| | | |
| | | #region 备份部分 |
| | | ///// <summary> |
| | |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("gatewayId", DB_ResidenceData.residenceData.HomeGateway.id); |
| | | //d.Add("roomId", DB_ResidenceData.residenceData.residecenInfo.RegionID);//可控参数,当需要分页获取,怎么知道分页总数 |
| | | //d.Add("searchType", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | //d.Add("pageSize", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | //d.Add("pageNo", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_GetDevcieList, requestJson); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDevcieList, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 获取设备详情列表 |
| | |
| | | d.Add("deviceIds", functionIds); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_GetDevcieInfoList, requestJson); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDevcieInfoList, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 控制设备 |
| | |
| | | d.Add("actions", actionObjs); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_ControlDevice, requestJson); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_ControlDevice, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 设备绑定房间 |
| | |
| | | d.Add("roomIds", new List<string>() { roomId}); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_BindDeviceToRoom, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_BindDeviceToRoom, requestJson).Code; |
| | | } |
| | | /// <summary> |
| | | /// 设备解绑房间 |
| | |
| | | d.Add("roomIds", new List<string>() { roomId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_UnbindDeviceToRoom, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_UnbindDeviceToRoom, requestJson).Code; |
| | | } |
| | | /// <summary> |
| | | /// 设备名称修改 |
| | |
| | | d.Add("name", deviceName); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_EditDeviceName, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDeviceName, requestJson).Code; |
| | | } |
| | | /// <summary> |
| | | /// 收藏设备 |
| | |
| | | d.Add("deviceId",new List<string>() { deviceId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_CollectDevice, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CollectDevice, requestJson).Code; |
| | | } |
| | | /// <summary> |
| | | /// 取消收藏设备 |
| | |
| | | d.Add("deviceId", new List<string>() { deviceId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_CancelCollectDevice, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CancelCollectDevice, requestJson).Code; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | } |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_GetSecneList, requestJson); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneList, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 获取场景详情 |
| | |
| | | d.Add("userSceneIds",new List<string>() { seceneId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_GetSecneList, requestJson); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneList, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 添加场景 |
| | |
| | | d.Add("scenes", new List<Scene>() { scene }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_EditSecne, requestJson); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditSecne, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 编辑场景 |
| | |
| | | d.Add("scenes", new List<Scene>() { scene }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_EditSecne, requestJson); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditSecne, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 删除场景 |
| | |
| | | d.Add("userSceneIds", new List<string>() { userSceneId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_DeleteSecne, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DeleteSecne, requestJson).Code; |
| | | } |
| | | /// <summary> |
| | | /// 执行场景 |
| | |
| | | d.Add("userSceneIds", new List<string>() { userSceneId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_ExecuteSecne, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_ExecuteSecne, requestJson).Code; |
| | | } |
| | | /// <summary> |
| | | /// 收藏场景 |
| | |
| | | d.Add("userSceneIds", new List<string>() { userSceneId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_CollectScene, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CollectScene, requestJson).Code; |
| | | } |
| | | /// <summary> |
| | | /// 取消收藏场景 |
| | |
| | | d.Add("userSceneIds", new List<string>() { userSceneId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_CancelCollectScene, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CancelCollectScene, requestJson).Code; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | /// <summary> |
| | | /// 获取房间列表 |
| | | /// </summary> |
| | | /// <param name="GetType">获取类型:ROOM\FLOOR;不输入返回全部</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetRoomList() |
| | | public ResponsePackNew GetRoomList(string GetType = "All") |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | |
| | | if (GetType != "All") |
| | | { |
| | | d.Add("roomType", GetType); |
| | | } |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_GetRoomList, requestJson); |
| | | var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetRoomList, requestJson); |
| | | var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SpatialInfo>>(pack.Data.ToString()); |
| | | if (revData != null) |
| | | { |
| | | foreach (var spatial in revData) |
| | | { |
| | | spatial.UpdateSpatialInfoData(); |
| | | } |
| | | } |
| | | return pack; |
| | | } |
| | | /// <summary> |
| | | /// 添加房间 |
| | | /// 添加房间\楼层 |
| | | /// 楼层也属于房间 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew AddRoom(List<Room> rooms) |
| | | public ResponsePackNew AddRoom(List<SpatialInfo> rooms) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | foreach(var room in rooms) |
| | | { |
| | | Dictionary<string, string> d1 = new Dictionary<string, string>(); |
| | | d1.Add("roomName", room.name); |
| | | d1.Add("roomType", "ROOM"); |
| | | //d1. |
| | | } |
| | | d.Add("rooms", rooms); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.Api_Post_AddRoom, requestJson); |
| | | var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_AddRoom, requestJson); |
| | | var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SpatialInfo>>(pack.Data.ToString()); |
| | | if (revData != null) |
| | | { |
| | | foreach (var spatial in revData) |
| | | { |
| | | spatial.UpdateSpatialInfoData(); |
| | | } |
| | | } |
| | | return pack; |
| | | } |
| | | /// <summary> |
| | | /// 添加楼层 |
| | | /// 修改房间信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew AddFloor() |
| | | public ResponsePackNew UpdateRoom(List<SpatialInfo> rooms) |
| | | { |
| | | return null; |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("rooms", rooms); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_UpdateRoom, requestJson); |
| | | var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SpatialInfo>>(pack.Data.ToString()); |
| | | if (revData != null) |
| | | { |
| | | foreach (var spatial in revData) |
| | | { |
| | | spatial.UpdateSpatialInfoData(); |
| | | } |
| | | } |
| | | return pack; |
| | | } |
| | | /// <summary> |
| | | /// 删除房间 |
| | | /// </summary> |
| | | /// <param name="roomIds"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew DeleteRoom(List<string> roomIds) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("ids", roomIds); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DelRoom, requestJson); |
| | | return pack; |
| | | } |
| | | |
| | | #endregion |