98 lines
4.0 KiB
C#
98 lines
4.0 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using RestSharp;
|
|||
|
|
using System.Net;
|
|||
|
|
using Common;
|
|||
|
|
|
|||
|
|
namespace CommonEntity
|
|||
|
|
{
|
|||
|
|
public class SkyWorth
|
|||
|
|
{
|
|||
|
|
private static readonly string BaseUrl = "http://localhost:9000/";
|
|||
|
|
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(SkyWorth));
|
|||
|
|
public static void Invoke(string hotelcode, string roomnum, string authCode, int cmd_no)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string R_ID = System.Guid.NewGuid().ToString("N");
|
|||
|
|
|
|||
|
|
string tiA = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
|||
|
|
Dictionary<string, string> RequestData = new Dictionary<string, string>();
|
|||
|
|
RequestData.Add("HotelCode", hotelcode);
|
|||
|
|
RequestData.Add("RoomNumber", roomnum);
|
|||
|
|
RequestData.Add("RequestId", R_ID);
|
|||
|
|
|
|||
|
|
var R_cmd = new Dictionary<string, string>();
|
|||
|
|
R_cmd.Add("room", roomnum);
|
|||
|
|
R_cmd.Add("event", cmd_no.ToString());
|
|||
|
|
R_cmd.Add("authCode", authCode);
|
|||
|
|
|
|||
|
|
var cmdstr = Newtonsoft.Json.JsonConvert.SerializeObject(R_cmd);
|
|||
|
|
RequestData.Add("RequestCmd", cmdstr);
|
|||
|
|
RequestData.Add("RequestTime", tiA);
|
|||
|
|
//LogRecorrd.WebAPI_DataSend(RequestData, "api/skyworth");
|
|||
|
|
|
|||
|
|
|
|||
|
|
var client1 = new RestClient(BaseUrl);
|
|||
|
|
var request1 = new RestRequest("api/skyworth", Method.POST);
|
|||
|
|
|
|||
|
|
request1.AddParameter("room", roomnum);
|
|||
|
|
request1.AddParameter("event", cmd_no);
|
|||
|
|
request1.AddParameter("authCode", authCode);
|
|||
|
|
|
|||
|
|
logger.Error("调用子创维电视:数据为:" + authCode + " RoomNUM" + roomnum);
|
|||
|
|
|
|||
|
|
|
|||
|
|
Interface3Log w1 = new Interface3Log();
|
|||
|
|
w1.HotelCode = hotelcode;
|
|||
|
|
w1.RoomNumber = roomnum;
|
|||
|
|
w1.TriggerTime = DateTime.Now;
|
|||
|
|
w1.ActionData = new HttpActionData() { RequestData = Newtonsoft.Json.JsonConvert.SerializeObject(RequestData) };
|
|||
|
|
w1.CommandType = ChangLiangValue.SkyWorth;
|
|||
|
|
|
|||
|
|
var q1 = Newtonsoft.Json.JsonConvert.SerializeObject(w1);
|
|||
|
|
CSRedisCacheHelper.Publish(CacheKey.InvokeHttpInterface, q1);
|
|||
|
|
|
|||
|
|
|
|||
|
|
client1.ExecuteAsync(request1, (QQQ) =>
|
|||
|
|
{
|
|||
|
|
HttpStatusCode HHH = QQQ.StatusCode;
|
|||
|
|
string FHS = QQQ.Content;
|
|||
|
|
|
|||
|
|
logger.Error("调用创维电视,结果为:" + FHS);
|
|||
|
|
|
|||
|
|
//string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
|||
|
|
//Dictionary<string, string> ResponseData = new Dictionary<string, string>();
|
|||
|
|
//ResponseData.Add("HotelCode", hotelcode);
|
|||
|
|
//ResponseData.Add("RoomNumber", roomnum);
|
|||
|
|
//ResponseData.Add("RequestId", R_ID);
|
|||
|
|
//ResponseData.Add("ResponseMsg", FHS);
|
|||
|
|
//ResponseData.Add("ResponseTime", ti);
|
|||
|
|
//LogRecorrd.WebAPI_DataSend(ResponseData, "api/skyworth");
|
|||
|
|
|
|||
|
|
Interface3Log ww = new Interface3Log();
|
|||
|
|
ww.HotelCode = hotelcode;
|
|||
|
|
ww.RoomNumber = roomnum;
|
|||
|
|
ww.TriggerTime = DateTime.Now;
|
|||
|
|
ww.ActionData = new HttpActionData() { ResponseData = FHS };
|
|||
|
|
ww.CommandType = ChangLiangValue.SkyWorth;
|
|||
|
|
|
|||
|
|
var qq = Newtonsoft.Json.JsonConvert.SerializeObject(ww);
|
|||
|
|
CSRedisCacheHelper.Publish(CacheKey.InvokeHttpInterface, qq);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
logger.Error("创维电视前台叫出问题了:" + ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public class iotVoiceData
|
|||
|
|
{
|
|||
|
|
public string room { get; set; }
|
|||
|
|
public string @event { get; set; }
|
|||
|
|
}
|
|||
|
|
}
|