有重复了,删除重复
This commit is contained in:
@@ -526,42 +526,42 @@ namespace UI.Controllers
|
||||
/// <param name="requestData"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
[HttpPost]
|
||||
public async Task<string> SetRCUService(RCUCurtainRequest requestData)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
// 1. 序列化请求对象为JSON
|
||||
string jsonString = JsonConvert.SerializeObject(requestData);
|
||||
//[HttpPost]
|
||||
//public async Task<string> SetRCUService(RCUCurtainRequest requestData)
|
||||
//{
|
||||
// using (var client = new HttpClient())
|
||||
// {
|
||||
// // 1. 序列化请求对象为JSON
|
||||
// string jsonString = JsonConvert.SerializeObject(requestData);
|
||||
|
||||
// 2. 正确编码JSON字符串
|
||||
string encodedJson = Uri.EscapeDataString(jsonString);
|
||||
// // 2. 正确编码JSON字符串
|
||||
// string encodedJson = Uri.EscapeDataString(jsonString);
|
||||
|
||||
// 3. 构建完整的GET请求URL
|
||||
string apiUrl = $"{baseUrl}SetRCUService?jsonData={encodedJson}";
|
||||
// // 3. 构建完整的GET请求URL
|
||||
// string apiUrl = $"{baseUrl}SetRCUService?jsonData={encodedJson}";
|
||||
|
||||
try
|
||||
{
|
||||
// 4. 发送GET请求
|
||||
var response = await client.GetAsync(apiUrl);
|
||||
// try
|
||||
// {
|
||||
// // 4. 发送GET请求
|
||||
// var response = await client.GetAsync(apiUrl);
|
||||
|
||||
// 5. 处理响应
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
throw new Exception($"服务信息控制失败: HTTP {response.StatusCode} - {errorContent}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"请求发送失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
// // 5. 处理响应
|
||||
// if (response.IsSuccessStatusCode)
|
||||
// {
|
||||
// return await response.Content.ReadAsStringAsync();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var errorContent = await response.Content.ReadAsStringAsync();
|
||||
// throw new Exception($"服务信息控制失败: HTTP {response.StatusCode} - {errorContent}");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// throw new Exception($"请求发送失败: {ex.Message}");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 设备信息类
|
||||
|
||||
Reference in New Issue
Block a user