初始化CRICS
This commit is contained in:
144
Common/XuanZhuOperation.cs
Normal file
144
Common/XuanZhuOperation.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
|
||||
namespace Common
|
||||
{
|
||||
/// <summary>
|
||||
/// 与第三方选住云端对接:将相关服务信息推送过去
|
||||
/// </summary>
|
||||
public static class XuanZhuOperation
|
||||
{
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(XuanZhuOperation));
|
||||
//private static readonly string _postURL = "http://111.231.106.196:19230/hogood/report";
|
||||
//###
|
||||
//POST http://111.231.106.196:19230/hogood/report
|
||||
//Content-Type: application/json; charset=UTF-8
|
||||
//{
|
||||
// "code": "1094",//酒店编码
|
||||
// "roomNumber": "8888",//房号
|
||||
// "address": "001001001",//回路地址
|
||||
// "name": "廊灯",//回路名称
|
||||
// "status":"1" //状态:1开,2关
|
||||
//}
|
||||
//### 返回
|
||||
//{
|
||||
// "retCode": 1, //0代表成功 其他代表失败
|
||||
// "retMsg": "[003]非法访问",
|
||||
// "retData": null
|
||||
//}
|
||||
//###
|
||||
/// <summary>
|
||||
/// 上报设备或服务状态信息
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="resp"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ReportService(string url, XuanZhuResponse resp)
|
||||
{
|
||||
string param = Newtonsoft.Json.JsonConvert.SerializeObject(resp);
|
||||
try
|
||||
{
|
||||
var A = (SecurityProtocolType)48;
|
||||
var B = (SecurityProtocolType)192;
|
||||
var C = (SecurityProtocolType)768;
|
||||
var D = (SecurityProtocolType)3072;
|
||||
var E = (SecurityProtocolType)12288;
|
||||
ServicePointManager.SecurityProtocol = A | B | C | D | E;
|
||||
string result = HttpWebRequestHelper.PostWebRequest(url, param);
|
||||
if (resp.code.Equals("1003"))
|
||||
{
|
||||
logger.Error(resp.roomNumber + " Params:"+param+" Result:" + result);
|
||||
}
|
||||
XuanZhuResult returnResult = JsonConvert.DeserializeObject<XuanZhuResult>(result);
|
||||
//if (returnResult.retCode == "0")//0代表成功 其他代表失败
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
//logger.Error(string.Format("酒店({0})客房({1})调用设备状态推送接口({2})结果:{3}", hotelCode, roomNumber, url, returnResult.retMsg));
|
||||
//return false;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(string.Format("酒店({0})客房({1})调用设备状态或异常推送接口({2})失败:{3},数据:{4}", resp.code, resp.roomNumber, url, ex.Message, param));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class XuanZhuResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 酒店编码
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
/// 房号
|
||||
/// </summary>
|
||||
public string roomNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 回路地址
|
||||
/// </summary>
|
||||
public string address { get; set; }
|
||||
/// <summary>
|
||||
/// 回路名称
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int status { get; set; }
|
||||
/// <summary>
|
||||
/// 异常类型
|
||||
/// </summary>
|
||||
public int faultType { get; set; }
|
||||
/// <summary>
|
||||
/// 异常值
|
||||
/// </summary>
|
||||
public int faultData { get; set; }
|
||||
/// <summary>
|
||||
/// 亮度
|
||||
/// </summary>
|
||||
public int brightness { get; set; }
|
||||
/// <summary>
|
||||
/// 当前温度
|
||||
/// </summary>
|
||||
public int currentTemp { get; set; }
|
||||
/// <summary>
|
||||
/// 设定温度
|
||||
/// </summary>
|
||||
public int settingTemp { get; set; }
|
||||
/// <summary>
|
||||
/// 风速
|
||||
/// </summary>
|
||||
public int fanSpeed { get; set; }
|
||||
/// <summary>
|
||||
/// 模式
|
||||
/// </summary>
|
||||
public int mode { get; set; }
|
||||
/// <summary>
|
||||
/// 阀门
|
||||
/// </summary>
|
||||
public int valve { get; set; }
|
||||
}
|
||||
|
||||
internal class XuanZhuResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回码
|
||||
/// </summary>
|
||||
public string retCode { get; set; }
|
||||
/// <summary>
|
||||
/// 返回描述
|
||||
/// </summary>
|
||||
public string retMsg { get; set; }
|
||||
/// <summary>
|
||||
/// 返回描述
|
||||
/// </summary>
|
||||
public string retData { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user