初始化CRICS
This commit is contained in:
75
RCUHost/TimingHelper/Common.cs
Normal file
75
RCUHost/TimingHelper/Common.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using CommonEntity;
|
||||
using RestSharp;
|
||||
using Common;
|
||||
using System.Configuration;
|
||||
using Domain;
|
||||
using Dao.Implement;
|
||||
|
||||
namespace RCUHost.TimingHelper
|
||||
{
|
||||
public class Common
|
||||
{
|
||||
|
||||
//public static Host GetByHostNumber(string hostno)
|
||||
//{
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.Append("HostNumber_");
|
||||
// sb.Append(hostno);
|
||||
// string Key = sb.ToString();
|
||||
// object HOSTNO = MemoryCacheHelper.Get(Key);
|
||||
|
||||
// Host host = null;
|
||||
// if (HOSTNO == null)
|
||||
// {
|
||||
// host = HostRepository.GetByHostNumber(hostno);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// host = (Host)HOSTNO;
|
||||
// }
|
||||
// return host;
|
||||
//}
|
||||
|
||||
public static readonly string debug_log_report_url = ConfigurationManager.AppSettings["debug_log_report_url"];
|
||||
public static readonly string debug_log_report_mqtt_topic = ConfigurationManager.AppSettings["debug_log_report_mqtt_topic"];
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(Common));
|
||||
|
||||
public static 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 dataHex)
|
||||
{
|
||||
string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
MonitorLog mm = new MonitorLog();
|
||||
mm.HotelCode = hotel_code;
|
||||
mm.HostID = host_id;
|
||||
mm.HostNumber = hostnumber;
|
||||
mm.RoomNo = roomnumber;
|
||||
|
||||
mm.LanIP = lan_ip;
|
||||
mm.LanPort = lan_port;
|
||||
mm.WWW_IP = WWW_IP;
|
||||
mm.WWW_Port = WWW_Port;
|
||||
|
||||
mm.MAC = mac;
|
||||
mm.SendOrReceive = "Receive";
|
||||
mm.CommandType = MyCommandType;
|
||||
mm.Data = dataHex;
|
||||
mm.CreateTime = ti;
|
||||
|
||||
|
||||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(mm);
|
||||
var client1 = new RestClient(debug_log_report_url);
|
||||
var request1 = new RestRequest("/", Method.POST);
|
||||
|
||||
//注意方法是POST
|
||||
//两个参数名字必须是 topic 和payload ,区分大小写的
|
||||
request1.AddParameter("topic", debug_log_report_mqtt_topic);
|
||||
request1.AddParameter("payload", str);
|
||||
|
||||
|
||||
client1.ExecuteAsync(request1, (response) => { });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user