Files
Web_CRICS_Server_VS2010_Prod/Common/TVOperation.cs
2025-12-11 09:17:16 +08:00

102 lines
3.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace Common
{
/// <summary>
/// 与第三方TV云端对接将语音文字上报
/// </summary>
public static class TVOperation
{
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(TVOperation));
//private static readonly string _iptvURL = "http://iot.gooorun.com:8282/uis/smartVoiceSkill/commonSmartPreInterceptor";
//http://192.168.1.210:8888/epg/api/audioControl/control
//private static readonly string _tclURL = "";
//private static readonly string _tclAppKey = "4a4b4c125608";
//private static readonly string _tclAppSecret = "4a4b4c125608";
/// <summary>
/// 远程控制IPTV
/// </summary>
/// <param name="tvControlToken"></param>
/// <param name="tvControlUrl">控制地址</param>
/// <param name="hotelCode"></param>
/// <param name="roomNumber"></param>
/// <param name="value"></param>
public static bool ReportIPTV(string tvControlToken, string tvControlUrl, string hotelCode, string roomNumber, string value)
{
if (!string.IsNullOrEmpty(tvControlUrl))
{
try
{
if (string.IsNullOrEmpty(tvControlToken))
{
tvControlToken = "DEFAULT_TOKEN";
}
IPTVPostData postData = new IPTVPostData()
{
token = tvControlToken,
hotelId = "",//hotelCode
roomId = roomNumber,
value = value
};
string param = Newtonsoft.Json.JsonConvert.SerializeObject(postData);
string result = HttpWebRequestHelper.PostWebRequest(tvControlUrl, param);
IPTVPostDataResult returnResult = JsonConvert.DeserializeObject<IPTVPostDataResult>(result);
if (returnResult.retCode == "1")
{
return true;
}
logger.Error(string.Format("酒店({0})客房({1})调用iptv接口({2})失败:{3}", hotelCode, roomNumber, tvControlUrl, returnResult.retMsg));
return false;
}
catch (Exception ex)
{
logger.Error(string.Format("酒店({0})客房({1})调用iptv接口({2})失败:{3}", hotelCode, roomNumber, tvControlUrl, ex));
return false;
}
}
logger.Error(string.Format("酒店({0})客房({1})调用iptv接口({2})失败", hotelCode, roomNumber, tvControlUrl));
return false;
}
}
/// <summary>
/// 发送数据
/// </summary>
internal class IPTVPostData
{
/// <summary>
/// 机顶盒序列号
/// </summary>
public string token { get; set; }
/// <summary>
/// 酒店ID
/// </summary>
public string hotelId { get; set; }
/// <summary>
/// 房间ID
/// </summary>
public string roomId { get; set; }
/// <summary>
/// 用户语句
/// </summary>
public string value { get; set; }
}
/// <summary>
/// 返回
/// </summary>
internal class IPTVPostDataResult
{
/// <summary>
/// 返回码
/// </summary>
public string retCode { get; set; }
/// <summary>
/// 返回描述
/// </summary>
public string retMsg { get; set; }
}
}