初始化
This commit is contained in:
45
Common/HttpSend.cs
Normal file
45
Common/HttpSend.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualBasic;
|
||||
using RestSharp;
|
||||
|
||||
namespace LogCap.Common
|
||||
{
|
||||
public class HttpSend
|
||||
{
|
||||
|
||||
public static readonly string debug_log_report_url = ReadConfig.Instance.get_debug_log_report_url;
|
||||
public static readonly string debug_log_report_mqtt_topic = ReadConfig.Instance.get_debug_log_report_mqtt_topic;
|
||||
|
||||
public static RestClient client1 = new RestClient(debug_log_report_url);
|
||||
public static async void SendLog(string MyCommandType, long hotel_code, int host_id, string roomnumber, string hostnumber, string WWW_IP, int WWW_Port, string lan_ip, int lan_port, string mac, string send_or_receive, string dataHex)
|
||||
{
|
||||
try
|
||||
{
|
||||
string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
string mm = "";
|
||||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(mm);
|
||||
//Console.WriteLine("发送MQTT的数据为:" + str);
|
||||
var request1 = new RestRequest("/", Method.Post);
|
||||
|
||||
//注意方法是POST
|
||||
//两个参数名字必须是 topic 和payload ,区分大小写的
|
||||
//Console.WriteLine("Topic: " + debug_log_report_mqtt_topic);
|
||||
request1.AddParameter("topic", debug_log_report_mqtt_topic);
|
||||
request1.AddParameter("payload", str);
|
||||
|
||||
await HttpSend.client1.ExecuteAsync(request1);
|
||||
Console.WriteLine("当前时间为:" + ti+" Data: "+dataHex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("发送MQTT数据出错:" + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user