有恶意请求,增加恶意请求的拦截
如题
This commit is contained in:
Binary file not shown.
@@ -51,7 +51,7 @@ namespace Common
|
||||
string result = HttpWebRequestHelper.PostWebRequest(url, param);
|
||||
if (resp.code.Equals("1003"))
|
||||
{
|
||||
logger.Error(resp.roomNumber + " Params:"+param+" Result:" + result);
|
||||
logger.Error(resp.roomNumber + " Params:" + param + " Result:" + result);
|
||||
}
|
||||
XuanZhuResult returnResult = JsonConvert.DeserializeObject<XuanZhuResult>(result);
|
||||
//if (returnResult.retCode == "0")//0代表成功 其他代表失败
|
||||
@@ -64,6 +64,8 @@ namespace Common
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Key = "HttpRequest_" + resp.code + "_" + resp.roomNumber;
|
||||
MemoryCacheHelper.Set(Key, 1, DateTimeOffset.Now.AddMinutes(10));
|
||||
logger.Error(string.Format("酒店({0})客房({1})调用设备状态或异常推送接口({2})失败:{3},数据:{4}", resp.code, resp.roomNumber, url, ex.Message, param));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace CommonEntity
|
||||
f.RoomNUMBER = roomno;
|
||||
string fsa = Newtonsoft.Json.JsonConvert.SerializeObject(f);
|
||||
//这个是 供轮循的时候调用使用
|
||||
CSRedisCacheHelper.HMSet(3, 60 * 24, CacheKey.FCSOrder, fsa);
|
||||
CSRedisCacheHelper.HMSet(3, 60 * 24, CacheKey.FCSOrder, Guid.NewGuid().ToString("N"), fsa);
|
||||
|
||||
//这个是供 取消订单的时候使用的
|
||||
//这个只 支持 取消 清理
|
||||
@@ -401,7 +401,7 @@ namespace CommonEntity
|
||||
}
|
||||
SSLXieYi();
|
||||
|
||||
string RUrl = string.Format("/job/order/{0}/cancelled", OrderId);
|
||||
string RUrl = string.Format("/api-secure/job/order/{0}/cancelled", OrderId);
|
||||
var client1 = new RestClient(FCSLoginUrl);
|
||||
var request1 = new RestRequest(RUrl, Method.POST);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using RestSharp;
|
||||
using System.Net;
|
||||
using Common;
|
||||
|
||||
namespace CommonEntity
|
||||
{
|
||||
@@ -29,16 +30,17 @@ namespace CommonEntity
|
||||
ServicePointManager.SecurityProtocol = A | B | C | D | E;
|
||||
var client1 = new RestClient(Url);
|
||||
var request1 = new RestRequest("", Method.POST);
|
||||
var jsa= Newtonsoft.Json.JsonConvert.SerializeObject(obj);
|
||||
//var jsa= Newtonsoft.Json.JsonConvert.SerializeObject(obj);
|
||||
request1.AddJsonBody(obj);
|
||||
var QQQ = client1.Execute(request1);
|
||||
HttpStatusCode HHH = QQQ.StatusCode;
|
||||
string fanhuizhi = QQQ.Content;
|
||||
|
||||
return fanhuizhi;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//string Key = "HttpRequest_" + resp.code + "_" + resp.roomNumber;
|
||||
//MemoryCacheHelper.Set(Key, 1, DateTimeOffset.Now.AddMinutes(10));
|
||||
logger.Error("Fault Push Error:" + ex.Message);
|
||||
logger.Error("Fault Push Error:" + ex.StackTrace);
|
||||
return ex.Message;
|
||||
|
||||
@@ -220,20 +220,63 @@ namespace ConsoleApplication2
|
||||
public struct Tiao
|
||||
{
|
||||
public string Nsa { get; set; }
|
||||
|
||||
|
||||
}
|
||||
public static void Data()
|
||||
{
|
||||
XuanZhuResponse resp = new XuanZhuResponse();
|
||||
resp.code = "1085";
|
||||
resp.roomNumber = "1001";
|
||||
resp.address = "";
|
||||
resp.name = "";
|
||||
resp.status = 1;
|
||||
if (resp.status == 1)
|
||||
{
|
||||
resp.brightness = 0;
|
||||
resp.currentTemp = 25;
|
||||
resp.settingTemp = 25;
|
||||
resp.mode = 1;
|
||||
resp.fanSpeed = 1;
|
||||
resp.valve = 0;
|
||||
}
|
||||
MyHttp.SendHttpData("http://f-xcx.blv-oa.com/rcu/report", resp);
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string uuawer= string.Concat("h","eeeelll");
|
||||
Data();
|
||||
Console.ReadLine();
|
||||
string uuawer = string.Concat("h", "eeeelll");
|
||||
|
||||
string QQQQSSS = File.ReadAllText("3.txt", Encoding.UTF8);
|
||||
var FFF = JsonConvert.DeserializeObject<FCS_Response>(QQQQSSS);
|
||||
|
||||
JObject jsonObject = JObject.Parse(QQQQSSS);
|
||||
var error = jsonObject.SelectToken("error");
|
||||
JObject jsonObject = JObject.Parse(QQQQSSS);
|
||||
var error = jsonObject.SelectToken("error");
|
||||
var JJJ = FFF.data.FirstOrDefault();
|
||||
|
||||
string orderuuid = JJJ.job_uuid;
|
||||
if (JJJ != null)
|
||||
{
|
||||
string orderuuid = JJJ.job_uuid;
|
||||
FCS_OrderData f = new FCS_OrderData();
|
||||
f.OrderUUID = orderuuid;
|
||||
f.PropertyID = "";
|
||||
f.ItemType = "Clean";
|
||||
f.OrderNo = JJJ.job_no;
|
||||
f.ItemUUID = "";
|
||||
f.LocationUUID = "";
|
||||
f.HotelCode = "";
|
||||
f.RoomNUMBER = "";
|
||||
string fsa = Newtonsoft.Json.JsonConvert.SerializeObject(f);
|
||||
//这个是 供轮循的时候调用使用
|
||||
CSRedisCacheHelper.HMSet(3, 60 * 24, CacheKey.FCSOrder, "aaa", fsa);
|
||||
|
||||
//这个是供 取消订单的时候使用的
|
||||
//这个只 支持 取消 清理
|
||||
//logger.Error("记录入循环:"+orderuuid);
|
||||
CSRedisCacheHelper.Set_PartitionWithTime(CacheKey.FCSRoom_Mapping_Order + "_" + "", orderuuid, 24 * 60, 3);
|
||||
}
|
||||
|
||||
//string orderuuid = JJJ.job_uuid;
|
||||
|
||||
AskRoomStatusChangedReceiver h = new AskRoomStatusChangedReceiver();
|
||||
RoomStatus vv = new RoomStatus();
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace RCUHost.Implement
|
||||
{
|
||||
logger.Error("Host Server启动失败,端口:3339");
|
||||
Close();
|
||||
throw ex;//不能去掉,否则重启iis服务,通讯服务不会再次启动
|
||||
//throw ex;//不能去掉,否则重启iis服务,通讯服务不会再次启动
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -728,41 +728,30 @@ namespace RCUHost.Implement
|
||||
if (list.Count > 0 && hostModals.Count > 0)
|
||||
{
|
||||
System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
|
||||
Host pa = new Host();
|
||||
pa.HostNumber = host.HostNumber;
|
||||
pa.MAC = host.MAC;
|
||||
foreach (HotelAirControl item in list)
|
||||
{
|
||||
foreach (System.Reflection.PropertyInfo prop in properties)//遍历属性
|
||||
{
|
||||
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节,则发送命令给rcu设置空调
|
||||
{
|
||||
var VA = new Tuple<List<HostModal>, HotelAirControl, Host>(hostModals, item, pa);
|
||||
Task.Factory.StartNew((state) =>
|
||||
{
|
||||
var UUU = state as Tuple<List<HostModal>, HotelAirControl, Host>;
|
||||
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
|
||||
var D1 = UUU.Item1;
|
||||
var D2 = UUU.Item2;
|
||||
var D3 = UUU.Item3;
|
||||
foreach (HostModal hostModal1 in D1)
|
||||
{
|
||||
Device device1 = new Device();
|
||||
device1.Address = hostModal1.Modal.ModalAddress;
|
||||
device1.AddressType = AddressType.DeviceAddress;
|
||||
device1.Type = DeviceType.AirConditioner;
|
||||
device1.Status = (byte)D2.Status;
|
||||
device1.Brightness = 0;
|
||||
device1.Temperature = (byte)D2.SettingTemp;
|
||||
device1.FanSpeed = (byte)D2.FanSpeed;
|
||||
device1.Mode = (byte)D2.Mode;
|
||||
device1.Valve = 0;
|
||||
device1.AirExecMode = (D2.Status << 14) + (D2.Mode << 12) + (D2.FanSpeed << 10) + (0 << 8) + D2.SettingTemp;//空调执行方式和内容
|
||||
//这里只需要host的mac和number或者 ip
|
||||
DeviceControlReceiver.Send(D3, device1);
|
||||
}
|
||||
}, VA);
|
||||
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
var D2 = item;
|
||||
foreach (HostModal hostModal1 in hostModals)
|
||||
{
|
||||
Device device1 = new Device();
|
||||
device1.Address = hostModal1.Modal.ModalAddress;
|
||||
device1.AddressType = AddressType.DeviceAddress;
|
||||
device1.Type = DeviceType.AirConditioner;
|
||||
device1.Status = (byte)D2.Status;
|
||||
device1.Brightness = 0;
|
||||
device1.Temperature = (byte)D2.SettingTemp;
|
||||
device1.FanSpeed = (byte)D2.FanSpeed;
|
||||
device1.Mode = (byte)D2.Mode;
|
||||
device1.Valve = 0;
|
||||
device1.AirExecMode = (D2.Status << 14) + (D2.Mode << 12) + (D2.FanSpeed << 10) + (0 << 8) + D2.SettingTemp;//空调执行方式和内容
|
||||
//这里只需要host的mac和number或者 ip
|
||||
DeviceControlReceiver.Send(host, device1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1350,7 +1339,8 @@ namespace RCUHost.Implement
|
||||
string mns = Newtonsoft.Json.JsonConvert.SerializeObject(resp);
|
||||
CSRedisCacheHelper.Publish("redis-action-data", mns);
|
||||
|
||||
XuanZhuOperation.ReportService(ttt.Item1.SysHotel.DeviceStatusPushURL, resp1);
|
||||
//XuanZhuOperation.ReportService(ttt.Item1.SysHotel.DeviceStatusPushURL, resp1);
|
||||
MyHttp.SendHttpData(ttt.Item1.SysHotel.DeviceStatusPushURL, resp);
|
||||
}, tup);
|
||||
}
|
||||
#endregion
|
||||
@@ -1483,7 +1473,9 @@ namespace RCUHost.Implement
|
||||
resp1.address = "054000001";
|
||||
resp1.name = "碳达人";
|
||||
resp1.status = ttt.Item2;
|
||||
XuanZhuOperation.ReportService(ttt.Item1.SysHotel.DeviceStatusPushURL, resp1);
|
||||
//XuanZhuOperation.ReportService(ttt.Item1.SysHotel.DeviceStatusPushURL, resp1);
|
||||
|
||||
MyHttp.SendHttpData(ttt.Item1.SysHotel.DeviceStatusPushURL, resp1);
|
||||
}, tup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1135,41 +1135,31 @@ namespace RCUHost.Implement
|
||||
if (list.Count > 0 && hostModals.Count > 0)
|
||||
{
|
||||
System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
|
||||
Host pa = new Host();
|
||||
pa.HostNumber = host.HostNumber;
|
||||
pa.MAC = host.MAC;
|
||||
foreach (HotelAirControl item in list)
|
||||
{
|
||||
foreach (System.Reflection.PropertyInfo prop in properties)//遍历属性
|
||||
{
|
||||
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节,则发送命令给rcu设置空调
|
||||
{
|
||||
var VA = new Tuple<List<HostModal>,HotelAirControl,Host>(hostModals,item,pa);
|
||||
Task.Factory.StartNew((state) =>
|
||||
{
|
||||
var UUU =state as Tuple<List<HostModal>, HotelAirControl,Host>;
|
||||
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
|
||||
var D1 = UUU.Item1;
|
||||
var D2 = UUU.Item2;
|
||||
var D3 = UUU.Item3;
|
||||
foreach (HostModal hostModal1 in D1)
|
||||
{
|
||||
Device device1 = new Device();
|
||||
device1.Address = hostModal1.Modal.ModalAddress;
|
||||
device1.AddressType = AddressType.DeviceAddress;
|
||||
device1.Type = DeviceType.AirConditioner;
|
||||
device1.Status = (byte)D2.Status;
|
||||
device1.Brightness = 0;
|
||||
device1.Temperature = (byte)D2.SettingTemp;
|
||||
device1.FanSpeed = (byte)D2.FanSpeed;
|
||||
device1.Mode = (byte)D2.Mode;
|
||||
device1.Valve = 0;
|
||||
device1.AirExecMode = (D2.Status << 14) + (D2.Mode << 12) + (D2.FanSpeed << 10) + (0 << 8) + D2.SettingTemp;//空调执行方式和内容
|
||||
//这里只需要host的mac和number或者 ip
|
||||
DeviceControlReceiver.Send(D3, device1);
|
||||
}
|
||||
},VA);
|
||||
var D2 = item;
|
||||
foreach (HostModal hostModal1 in hostModals)
|
||||
{
|
||||
Device device1 = new Device();
|
||||
device1.Address = hostModal1.Modal.ModalAddress;
|
||||
device1.AddressType = AddressType.DeviceAddress;
|
||||
device1.Type = DeviceType.AirConditioner;
|
||||
device1.Status = (byte)D2.Status;
|
||||
device1.Brightness = 0;
|
||||
device1.Temperature = (byte)D2.SettingTemp;
|
||||
device1.FanSpeed = (byte)D2.FanSpeed;
|
||||
device1.Mode = (byte)D2.Mode;
|
||||
device1.Valve = 0;
|
||||
device1.AirExecMode = (D2.Status << 14) + (D2.Mode << 12) + (D2.FanSpeed << 10) + (0 << 8) + D2.SettingTemp;//空调执行方式和内容
|
||||
//这里只需要host的mac和number或者 ip
|
||||
DeviceControlReceiver.Send(host, device1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1862,8 +1852,18 @@ namespace RCUHost.Implement
|
||||
resp.fanSpeed = 0;
|
||||
resp.valve = 0;
|
||||
}
|
||||
//MyHttp.SendHttpData(ttt.Item1.SysHotel.DeviceStatusPushURL, resp);
|
||||
XuanZhuOperation.ReportService(ttt.Item1.SysHotel.DeviceStatusPushURL, resp);
|
||||
|
||||
MyHttp.SendHttpData(ttt.Item1.SysHotel.DeviceStatusPushURL, resp);
|
||||
//string Key = "HttpRequest_" + resp.code + "_" + resp.roomNumber;
|
||||
//var Data = MemoryCacheHelper.Get(Key);
|
||||
//if (Data != null)
|
||||
//{
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// //XuanZhuOperation.ReportService(ttt.Item1.SysHotel.DeviceStatusPushURL, resp);
|
||||
//}
|
||||
}, tup);
|
||||
}
|
||||
#endregion
|
||||
@@ -1871,7 +1871,8 @@ namespace RCUHost.Implement
|
||||
else
|
||||
{
|
||||
string NoKey = CacheKey.HostModalStatus_BoolFilterPrefix + "_" + host.ID + "_" + device.Value.Address;
|
||||
CSRedisCacheHelper.Set_PartitionWithTime<int>(NoKey, 1, 10);
|
||||
var expiredata = new Random().Next(10, 50);
|
||||
CSRedisCacheHelper.Set_PartitionWithTime<int>(NoKey, 1, expiredata);
|
||||
//logger.Error("内存和数据库都不见这条数据:" + KKey);
|
||||
}
|
||||
#endregion
|
||||
@@ -2240,7 +2241,8 @@ namespace RCUHost.Implement
|
||||
faultType = fault.Value.Type,
|
||||
faultData = fault.Value.Data
|
||||
};
|
||||
XuanZhuOperation.ReportService(host.FaultPushURL, resp);
|
||||
//XuanZhuOperation.ReportService(host.FaultPushURL, resp);
|
||||
MyHttp.SendHttpData(host.FaultPushURL, resp);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,277 +537,285 @@ namespace Service.Implement
|
||||
/// <param name="wxValidate"></param>
|
||||
public void ChangeRoomStatus(Host host, RoomStatus roomStatus, string wxValidate)
|
||||
{
|
||||
logger.Error("触发状态ID:" + roomStatus.ID);
|
||||
RoomStatusChangedReceiver.SendRoomStatus(host, roomStatus);
|
||||
host.RoomStatus = roomStatus;
|
||||
|
||||
Host host_takeout = null;
|
||||
string Key = CacheKey.HostInfo_Key_HostNumber + "_" + host.HostNumber;
|
||||
object obj = MemoryCacheHelper.Get(Key);
|
||||
if (obj != null)
|
||||
try
|
||||
{
|
||||
host_takeout = (Host)obj;
|
||||
host_takeout.RoomStatus = roomStatus;
|
||||
}
|
||||
logger.Error("触发状态ID:" + roomStatus.ID);
|
||||
RoomStatusChangedReceiver.SendRoomStatus(host, roomStatus);
|
||||
host.RoomStatus = roomStatus;
|
||||
|
||||
if (!string.IsNullOrEmpty(wxValidate))
|
||||
{
|
||||
host.WXValidate = wxValidate;
|
||||
}
|
||||
CurrentRepository.Update(host);
|
||||
|
||||
|
||||
#region 语言重置
|
||||
|
||||
if (roomStatus.ID == 2 || roomStatus.ID == 8)//开房和退房时重置
|
||||
{
|
||||
if (!string.IsNullOrEmpty(host.XiaoDuCUID))
|
||||
Host host_takeout = null;
|
||||
string Key = CacheKey.HostInfo_Key_HostNumber + "_" + host.HostNumber;
|
||||
object obj = MemoryCacheHelper.Get(Key);
|
||||
if (obj != null)
|
||||
{
|
||||
string accessToken = SysOauth2Repository.GetXiaoDuToken();
|
||||
if (!string.IsNullOrEmpty(accessToken) && host.SysHotel.IsPowerOffResetXiaoDu)
|
||||
host_takeout = (Host)obj;
|
||||
host_takeout.RoomStatus = roomStatus;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(wxValidate))
|
||||
{
|
||||
host.WXValidate = wxValidate;
|
||||
}
|
||||
CurrentRepository.Update(host);
|
||||
|
||||
|
||||
#region 语言重置
|
||||
|
||||
if (roomStatus.ID == 2 || roomStatus.ID == 8)//开房和退房时重置
|
||||
{
|
||||
if (!string.IsNullOrEmpty(host.XiaoDuCUID))
|
||||
{
|
||||
string accessToken = SysOauth2Repository.GetXiaoDuToken();
|
||||
if (!string.IsNullOrEmpty(accessToken) && host.SysHotel.IsPowerOffResetXiaoDu)
|
||||
{
|
||||
System.Threading.Tasks.Task.Factory.StartNew(() =>
|
||||
{
|
||||
foreach (string cuid in host.XiaoDuCUID.Split(','))//多个小度英文逗号隔开
|
||||
{
|
||||
XiaoDuOperation.PostWebRequestToXiaoDu(accessToken, cuid, new XiaoDuParamJson() { method = "reset" }, host.SysHotel.Code, host.RoomNumber);//重置小度
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(host.TianMaoCUID))
|
||||
{
|
||||
System.Threading.Tasks.Task.Factory.StartNew(() =>
|
||||
{
|
||||
foreach (string cuid in host.XiaoDuCUID.Split(','))//多个小度英文逗号隔开
|
||||
foreach (string cuid in host.TianMaoCUID.Split(','))//多个英文逗号隔开
|
||||
{
|
||||
XiaoDuOperation.PostWebRequestToXiaoDu(accessToken, cuid, new XiaoDuParamJson() { method = "reset" }, host.SysHotel.Code, host.RoomNumber);//重置小度
|
||||
TianMaoOperation.PostWebRequestToTianMao("CheckoutWithAK",
|
||||
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1] }), host.SysHotel.Code, host.RoomNumber);//重置天猫精灵
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(host.TianMaoCUID))
|
||||
{
|
||||
System.Threading.Tasks.Task.Factory.StartNew(() =>
|
||||
{
|
||||
foreach (string cuid in host.TianMaoCUID.Split(','))//多个英文逗号隔开
|
||||
{
|
||||
TianMaoOperation.PostWebRequestToTianMao("CheckoutWithAK",
|
||||
Newtonsoft.Json.JsonConvert.SerializeObject(new { HotelId = cuid.Split('&')[0], RoomNo = cuid.Split('&')[1] }), host.SysHotel.Code, host.RoomNumber);//重置天猫精灵
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
if (roomStatus.ID == 8)
|
||||
{
|
||||
#region 退房后空调控制
|
||||
HotelSeason hotelSeason = HotelSeasonRepository.LoadByHotelID(host.SysHotel.ID);//获取该酒店下季节设置记录
|
||||
if (hotelSeason != null)
|
||||
{
|
||||
//条件:1出租后,2取电后,3断电后
|
||||
List<HotelAirControl> list = HotelAirControlRepository.LoadAll(host.SysHotel.ID, 4, true);
|
||||
List<HostModal> hostModals = HostModalRepository.LoadByHostID(host.ID).Where(r => r.Modal.Type == DeviceType.AirConditioner && r.Modal.ActiveIndicator).ToList();//获取启用的空调回路
|
||||
if (list.Count > 0 && hostModals.Count > 0)
|
||||
{
|
||||
System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
|
||||
foreach (HotelAirControl item in list)
|
||||
{
|
||||
foreach (System.Reflection.PropertyInfo prop in properties)//遍历属性
|
||||
{
|
||||
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节,则发送命令给rcu设置空调
|
||||
{
|
||||
#region 备用方案
|
||||
//var TTT = new Tuple<Host, HotelAirControl, List<HostModal>>(host, item, hostModals);
|
||||
//Task.Factory.StartNew((state) =>
|
||||
// {
|
||||
// System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
|
||||
// Tuple<Host, HotelAirControl, List<HostModal>> NNN = state as Tuple<Host, HotelAirControl, List<HostModal>>;
|
||||
|
||||
// var QQ0 = NNN.Item1;
|
||||
// var QQ1 = NNN.Item2;
|
||||
// var QQ2 = NNN.Item3;
|
||||
// foreach (HostModal hostModal in QQ2)
|
||||
// {
|
||||
// HostModalManager.SetDevice(QQ0, hostModal, QQ1.Status, 0, QQ1.SettingTemp, QQ1.FanSpeed, QQ1.Mode, 0);//0表示不变
|
||||
// }
|
||||
// }, TTT);
|
||||
#endregion
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
//这段代码在生产环境中不管用,很奇怪
|
||||
string KeyMission = System.Guid.NewGuid().ToString("N");
|
||||
MissonData m = new MissonData()
|
||||
{
|
||||
hostnumber = host.HostNumber,
|
||||
mac = host.MAC,
|
||||
};
|
||||
|
||||
m.HostModalList = new List<Tuple<string, DeviceType>>();
|
||||
foreach (HostModal hostModal in hostModals)
|
||||
{
|
||||
var t = new Tuple<string, DeviceType>(hostModal.Modal.ModalAddress, hostModal.Modal.Type);
|
||||
m.HostModalList.Add(t);
|
||||
}
|
||||
m.Status = item.Status;
|
||||
m.SettingTemp = item.SettingTemp;
|
||||
m.FanSpeed = item.FanSpeed;
|
||||
m.Mode = item.Mode;
|
||||
string MKey = "TuiFang_" + KeyMission;
|
||||
CSRedisCacheHelper.Set_Partition<MissonData>(MKey, m, 1);
|
||||
|
||||
DelayExe_Task(host, item.DelayTime, MKey);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
if (roomStatus.ID == 2)
|
||||
{
|
||||
#region 出租后空调处理
|
||||
//阿宝
|
||||
//空调 在10分钟无人入住的情况之下,就关闭
|
||||
//启动 一个任务
|
||||
|
||||
#region 阿宝添加的
|
||||
int currenthotelid = host.SysHotel.ID;
|
||||
RoomNobodyHowTo nnn = RoomNoBodyMananger.LoadAll().FirstOrDefault(A => A.CurrentHotelID == currenthotelid);
|
||||
if (nnn != null)
|
||||
{
|
||||
if (!nnn.How.Equals("without"))
|
||||
{
|
||||
string Code = host.SysHotel.Code;
|
||||
string RoomNo = host.RoomNumber;
|
||||
DateTime CreateDate = host.SysHotel.CreatedDate;
|
||||
string CD = CreateDate.ToString("yyyy-MM-dd");
|
||||
int hotel_id = host.SysHotel.ID;
|
||||
int host_id = host.ID;
|
||||
string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
int delaytime = nnn.DelayTime;
|
||||
int sustain = 20;
|
||||
string MissionKey = System.Guid.NewGuid().ToString("N");
|
||||
DateTime starttime = DateTime.Now.AddMinutes(delaytime);
|
||||
DateTime endtime = starttime.AddMinutes(sustain);
|
||||
|
||||
//创建一条任务 插 入数据库
|
||||
KongTiaoTimer k = new KongTiaoTimer();
|
||||
k.HotelID = hotel_id;
|
||||
k.HostID = host_id;
|
||||
k.HotelCode = Code;
|
||||
k.RoomNo = RoomNo;
|
||||
k.MissonKey = MissionKey;
|
||||
k.IsCancel = 0;
|
||||
k.CreateTime = ti;
|
||||
k.StartTime = starttime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
k.EndTime = endtime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
k.CreateDate = CD;
|
||||
|
||||
//string HotelCode, string RoomNo, int host_id,int hotel_id
|
||||
|
||||
MissionRequestData mm = new MissionRequestData();
|
||||
|
||||
mm.DelayTimer = delaytime;
|
||||
mm.KT = k;
|
||||
//mm.HotelCode = Code;
|
||||
//mm.RoomNo = RoomNo;
|
||||
//mm.HotelID = hotel_id;
|
||||
//mm.HostID = host_id;
|
||||
//mm.CreateDate = CD;
|
||||
|
||||
string jsstr = Newtonsoft.Json.JsonConvert.SerializeObject(mm);
|
||||
//k.JsonData = jsstr;
|
||||
k.MissonKey = MissionKey;
|
||||
KongTiaoManager.Save(k);
|
||||
|
||||
//给 任务管理系统 发送消息
|
||||
var client1 = new RestClient(Missionsys_Address);
|
||||
var request1 = new RestRequest("api/index", Method.POST);
|
||||
|
||||
logger.Error("任务管理系统发送了数据:" + Missionsys_Address + "API/Index");
|
||||
//GetRequest ggg = new GetRequest() { creatDate = DateTime.Now.ToString("yyyy-mm-dd"), roomNumber = RoomNo, code = Code };
|
||||
|
||||
|
||||
request1.AddParameter("jsonData", jsstr);
|
||||
|
||||
client1.ExecuteAsync(request1, (response) => { });
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
HotelSeason hotelSeason = HotelSeasonRepository.LoadByHotelID(host.SysHotel.ID);//获取该酒店下季节设置记录
|
||||
if (hotelSeason != null)
|
||||
if (roomStatus.ID == 8)
|
||||
{
|
||||
List<HotelAirControl> list = HotelAirControlRepository.LoadAll(host.SysHotel.ID, 1, true);
|
||||
List<HostModal> hostModals = HostModalRepository.LoadByHostID(host.ID).Where(r => r.Modal.Type == DeviceType.AirConditioner && r.Modal.ActiveIndicator).ToList();//获取启用的空调回路
|
||||
if (list.Count > 0 && hostModals.Count > 0)
|
||||
#region 退房后空调控制
|
||||
HotelSeason hotelSeason = HotelSeasonRepository.LoadByHotelID(host.SysHotel.ID);//获取该酒店下季节设置记录
|
||||
if (hotelSeason != null)
|
||||
{
|
||||
System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
|
||||
foreach (HotelAirControl item in list)
|
||||
//条件:1出租后,2取电后,3断电后
|
||||
List<HotelAirControl> list = HotelAirControlRepository.LoadAll(host.SysHotel.ID, 4, true);
|
||||
List<HostModal> hostModals = HostModalRepository.LoadByHostID(host.ID).Where(r => r.Modal.Type == DeviceType.AirConditioner && r.Modal.ActiveIndicator).ToList();//获取启用的空调回路
|
||||
if (list.Count > 0 && hostModals.Count > 0)
|
||||
{
|
||||
foreach (System.Reflection.PropertyInfo prop in properties)//遍历属性
|
||||
System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
|
||||
foreach (HotelAirControl item in list)
|
||||
{
|
||||
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节,则发送命令给rcu设置空调
|
||||
foreach (System.Reflection.PropertyInfo prop in properties)//遍历属性
|
||||
{
|
||||
var TTT = new Tuple<Host, HotelAirControl, List<HostModal>>(host, item, hostModals);
|
||||
Task.Factory.StartNew((state) =>
|
||||
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节,则发送命令给rcu设置空调
|
||||
{
|
||||
#region 备用方案
|
||||
//var TTT = new Tuple<Host, HotelAirControl, List<HostModal>>(host, item, hostModals);
|
||||
//Task.Factory.StartNew((state) =>
|
||||
// {
|
||||
// System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
|
||||
// Tuple<Host, HotelAirControl, List<HostModal>> NNN = state as Tuple<Host, HotelAirControl, List<HostModal>>;
|
||||
|
||||
// var QQ0 = NNN.Item1;
|
||||
// var QQ1 = NNN.Item2;
|
||||
// var QQ2 = NNN.Item3;
|
||||
// foreach (HostModal hostModal in QQ2)
|
||||
// {
|
||||
// HostModalManager.SetDevice(QQ0, hostModal, QQ1.Status, 0, QQ1.SettingTemp, QQ1.FanSpeed, QQ1.Mode, 0);//0表示不变
|
||||
// }
|
||||
// }, TTT);
|
||||
#endregion
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
|
||||
Tuple<Host, HotelAirControl, List<HostModal>> NNN = state as Tuple<Host, HotelAirControl, List<HostModal>>;
|
||||
|
||||
var QQ0 = NNN.Item1;
|
||||
var QQ1 = NNN.Item2;
|
||||
var QQ2 = NNN.Item3;
|
||||
foreach (HostModal hostModal in QQ2)
|
||||
//这段代码在生产环境中不管用,很奇怪
|
||||
string KeyMission = System.Guid.NewGuid().ToString("N");
|
||||
MissonData m = new MissonData()
|
||||
{
|
||||
//host 只需要hostnumber和mac
|
||||
//hostmodal只需要 address //和type
|
||||
//device.Address = hostModal.Modal.ModalAddress;
|
||||
//device.Type = hostModal.Modal.Type;
|
||||
HostModalManager.SetDevice(QQ0, hostModal, QQ1.Status, 0, QQ1.SettingTemp, QQ1.FanSpeed, QQ1.Mode, 0);//0表示不变
|
||||
hostnumber = host.HostNumber,
|
||||
mac = host.MAC,
|
||||
};
|
||||
|
||||
m.HostModalList = new List<Tuple<string, DeviceType>>();
|
||||
foreach (HostModal hostModal in hostModals)
|
||||
{
|
||||
var t = new Tuple<string, DeviceType>(hostModal.Modal.ModalAddress, hostModal.Modal.Type);
|
||||
m.HostModalList.Add(t);
|
||||
}
|
||||
}, TTT);
|
||||
try
|
||||
{
|
||||
//这段代码在生产环境中不管用,很奇怪
|
||||
//string KeyMission = System.Guid.NewGuid().ToString("N");
|
||||
m.Status = item.Status;
|
||||
m.SettingTemp = item.SettingTemp;
|
||||
m.FanSpeed = item.FanSpeed;
|
||||
m.Mode = item.Mode;
|
||||
string MKey = "TuiFang_" + KeyMission;
|
||||
CSRedisCacheHelper.Set_Partition<MissonData>(MKey, m, 1);
|
||||
|
||||
//MissonData m = new MissonData()
|
||||
//{
|
||||
// hostnumber = host.HostNumber,
|
||||
// mac = host.MAC,
|
||||
//};
|
||||
|
||||
//m.HostModalList = new List<Tuple<string, DeviceType>>();
|
||||
//foreach (HostModal hostModal in hostModals)
|
||||
//{
|
||||
// var t = new Tuple<string, DeviceType>(hostModal.Modal.ModalAddress, hostModal.Modal.Type);
|
||||
// m.HostModalList.Add(t);
|
||||
//}
|
||||
//m.Status = item.Status;
|
||||
//m.SettingTemp = item.SettingTemp;
|
||||
//m.FanSpeed = item.FanSpeed;
|
||||
//m.Mode = item.Mode;
|
||||
//string MKey = "Mission_" + KeyMission;
|
||||
//CSRedisCacheHelper.Set_Partition<MissonData>(MKey, m, 1);
|
||||
|
||||
//DelayExe_Task(host, item.DelayTime, KeyMission);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
DelayExe_Task(host, item.DelayTime, MKey);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (roomStatus.ID == 2)
|
||||
{
|
||||
#region 出租后空调处理
|
||||
//阿宝
|
||||
//空调 在10分钟无人入住的情况之下,就关闭
|
||||
//启动 一个任务
|
||||
|
||||
#region 阿宝添加的
|
||||
int currenthotelid = host.SysHotel.ID;
|
||||
RoomNobodyHowTo nnn = RoomNoBodyMananger.LoadAll().FirstOrDefault(A => A.CurrentHotelID == currenthotelid);
|
||||
if (nnn != null)
|
||||
{
|
||||
if (!nnn.How.Equals("without"))
|
||||
{
|
||||
string Code = host.SysHotel.Code;
|
||||
string RoomNo = host.RoomNumber;
|
||||
DateTime CreateDate = host.SysHotel.CreatedDate;
|
||||
string CD = CreateDate.ToString("yyyy-MM-dd");
|
||||
int hotel_id = host.SysHotel.ID;
|
||||
int host_id = host.ID;
|
||||
string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
int delaytime = nnn.DelayTime;
|
||||
int sustain = 20;
|
||||
string MissionKey = System.Guid.NewGuid().ToString("N");
|
||||
DateTime starttime = DateTime.Now.AddMinutes(delaytime);
|
||||
DateTime endtime = starttime.AddMinutes(sustain);
|
||||
|
||||
//创建一条任务 插 入数据库
|
||||
KongTiaoTimer k = new KongTiaoTimer();
|
||||
k.HotelID = hotel_id;
|
||||
k.HostID = host_id;
|
||||
k.HotelCode = Code;
|
||||
k.RoomNo = RoomNo;
|
||||
k.MissonKey = MissionKey;
|
||||
k.IsCancel = 0;
|
||||
k.CreateTime = ti;
|
||||
k.StartTime = starttime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
k.EndTime = endtime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
k.CreateDate = CD;
|
||||
|
||||
//string HotelCode, string RoomNo, int host_id,int hotel_id
|
||||
|
||||
MissionRequestData mm = new MissionRequestData();
|
||||
|
||||
mm.DelayTimer = delaytime;
|
||||
mm.KT = k;
|
||||
//mm.HotelCode = Code;
|
||||
//mm.RoomNo = RoomNo;
|
||||
//mm.HotelID = hotel_id;
|
||||
//mm.HostID = host_id;
|
||||
//mm.CreateDate = CD;
|
||||
|
||||
string jsstr = Newtonsoft.Json.JsonConvert.SerializeObject(mm);
|
||||
//k.JsonData = jsstr;
|
||||
k.MissonKey = MissionKey;
|
||||
KongTiaoManager.Save(k);
|
||||
|
||||
//给 任务管理系统 发送消息
|
||||
var client1 = new RestClient(Missionsys_Address);
|
||||
var request1 = new RestRequest("api/index", Method.POST);
|
||||
|
||||
logger.Error("任务管理系统发送了数据:" + Missionsys_Address + "API/Index");
|
||||
//GetRequest ggg = new GetRequest() { creatDate = DateTime.Now.ToString("yyyy-mm-dd"), roomNumber = RoomNo, code = Code };
|
||||
|
||||
|
||||
request1.AddParameter("jsonData", jsstr);
|
||||
|
||||
client1.ExecuteAsync(request1, (response) => { });
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
HotelSeason hotelSeason = HotelSeasonRepository.LoadByHotelID(host.SysHotel.ID);//获取该酒店下季节设置记录
|
||||
if (hotelSeason != null)
|
||||
{
|
||||
List<HotelAirControl> list = HotelAirControlRepository.LoadAll(host.SysHotel.ID, 1, true);
|
||||
List<HostModal> hostModals = HostModalRepository.LoadByHostID(host.ID).Where(r => r.Modal.Type == DeviceType.AirConditioner && r.Modal.ActiveIndicator).ToList();//获取启用的空调回路
|
||||
if (list.Count > 0 && hostModals.Count > 0)
|
||||
{
|
||||
System.Reflection.PropertyInfo[] properties = typeof(HotelSeason).GetProperties();//获取所有属性
|
||||
foreach (HotelAirControl item in list)
|
||||
{
|
||||
foreach (System.Reflection.PropertyInfo prop in properties)//遍历属性
|
||||
{
|
||||
if (prop.Name == "Month" + DateTime.Now.Month.ToString() && Convert.ToInt16(prop.GetValue(hotelSeason, null)) == item.Season)//当前月份所属该季节,则发送命令给rcu设置空调
|
||||
{
|
||||
var TTT = new Tuple<Host, HotelAirControl, List<HostModal>>(host, item, hostModals);
|
||||
Task.Factory.StartNew((state) =>
|
||||
{
|
||||
System.Threading.Thread.Sleep(item.DelayTime * 1000);//延迟执行
|
||||
|
||||
Tuple<Host, HotelAirControl, List<HostModal>> NNN = state as Tuple<Host, HotelAirControl, List<HostModal>>;
|
||||
|
||||
var QQ0 = NNN.Item1;
|
||||
var QQ1 = NNN.Item2;
|
||||
var QQ2 = NNN.Item3;
|
||||
foreach (HostModal hostModal in QQ2)
|
||||
{
|
||||
//host 只需要hostnumber和mac
|
||||
//hostmodal只需要 address //和type
|
||||
//device.Address = hostModal.Modal.ModalAddress;
|
||||
//device.Type = hostModal.Modal.Type;
|
||||
HostModalManager.SetDevice(QQ0, hostModal, QQ1.Status, 0, QQ1.SettingTemp, QQ1.FanSpeed, QQ1.Mode, 0);//0表示不变
|
||||
}
|
||||
}, TTT);
|
||||
try
|
||||
{
|
||||
//这段代码在生产环境中不管用,很奇怪
|
||||
//string KeyMission = System.Guid.NewGuid().ToString("N");
|
||||
|
||||
//MissonData m = new MissonData()
|
||||
//{
|
||||
// hostnumber = host.HostNumber,
|
||||
// mac = host.MAC,
|
||||
//};
|
||||
|
||||
//m.HostModalList = new List<Tuple<string, DeviceType>>();
|
||||
//foreach (HostModal hostModal in hostModals)
|
||||
//{
|
||||
// var t = new Tuple<string, DeviceType>(hostModal.Modal.ModalAddress, hostModal.Modal.Type);
|
||||
// m.HostModalList.Add(t);
|
||||
//}
|
||||
//m.Status = item.Status;
|
||||
//m.SettingTemp = item.SettingTemp;
|
||||
//m.FanSpeed = item.FanSpeed;
|
||||
//m.Mode = item.Mode;
|
||||
//string MKey = "Mission_" + KeyMission;
|
||||
//CSRedisCacheHelper.Set_Partition<MissonData>(MKey, m, 1);
|
||||
|
||||
//DelayExe_Task(host, item.DelayTime, KeyMission);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
public class MissonData
|
||||
@@ -1116,7 +1124,7 @@ namespace Service.Implement
|
||||
public static readonly string Missionsys_Address = ConfigurationManager.AppSettings["missionsys_address"];
|
||||
public static readonly string Currentsys_address = ConfigurationManager.AppSettings["currentsys_address"];
|
||||
|
||||
public void TimerECO(string hotelcode,int sheng_jiang_value)
|
||||
public void TimerECO(string hotelcode, int sheng_jiang_value)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -81,7 +81,18 @@ namespace WebSite.Controllers
|
||||
/// <returns></returns>
|
||||
private Host CheckRoomNumber(string code, string creatDate, ref string msg, ref int hotelID, string roomNumber = "")
|
||||
{
|
||||
SysHotel sysHotel = SysHotelManager.GetByCode(code, Convert.ToDateTime(creatDate));
|
||||
string Key = "GetHotelInfo_" + code + "_" + creatDate;
|
||||
var Obj = MemoryCacheHelper.Get(Key);
|
||||
SysHotel sysHotel = null;
|
||||
if (Obj == null)
|
||||
{
|
||||
sysHotel = SysHotelManager.GetByCode(code, Convert.ToDateTime(creatDate));
|
||||
MemoryCacheHelper.SlideSet(Key, sysHotel, new TimeSpan(0, 5, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
sysHotel = Obj as SysHotel;
|
||||
}
|
||||
if (sysHotel == null)
|
||||
{
|
||||
msg = "酒店未知";
|
||||
@@ -91,7 +102,19 @@ namespace WebSite.Controllers
|
||||
hotelID = sysHotel.ID;
|
||||
if (!string.IsNullOrEmpty(roomNumber))
|
||||
{
|
||||
Host host = HostManager.GetByRoomNumber(roomNumber, sysHotel.ID);
|
||||
Host host = null;
|
||||
string Key1 = "QueryHostInfo_" + roomNumber + "_" + sysHotel.ID;
|
||||
var ooo = MemoryCacheHelper.Get(Key1);
|
||||
if (ooo != null)
|
||||
{
|
||||
host = ooo as Host;
|
||||
}
|
||||
else
|
||||
{
|
||||
host = HostManager.GetByRoomNumber(roomNumber, sysHotel.ID);
|
||||
MemoryCacheHelper.SlideSet(Key1, host, new TimeSpan(0, 5, 0));
|
||||
}
|
||||
|
||||
if (host == null)
|
||||
{
|
||||
msg = "房号[" + roomNumber + "]不存在";
|
||||
@@ -3411,117 +3434,118 @@ namespace WebSite.Controllers
|
||||
[HttpPost()]
|
||||
public ActionResult GetAirDetectListPost()
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
//Task.Factory.StartNew(() =>
|
||||
// {
|
||||
// });
|
||||
|
||||
try
|
||||
{
|
||||
List<KongQi> listdata = GetPrepareData();
|
||||
|
||||
var QQQ = listdata.GroupBy(A => new { A.HotelID, A.HotelCode, A.RoomNumber, A.CreatDate });
|
||||
|
||||
foreach (var itemKey in QQQ)
|
||||
{
|
||||
try
|
||||
var item = itemKey.Key;
|
||||
string roomNumber = item.RoomNumber;
|
||||
string code = item.HotelCode;
|
||||
string createDate = item.CreatDate;
|
||||
DateTime dts = DateTime.Parse(createDate);
|
||||
string cd = dts.ToString("yyyy-MM-dd");
|
||||
|
||||
Host host = CheckRoomNumber(code, cd, ref msg, ref hotelID, roomNumber);
|
||||
if (host == null)
|
||||
{
|
||||
List<KongQi> listdata = GetPrepareData();
|
||||
logger.Error("host not exists hotelcode: " + code + " createDate: " + cd + " roomnumber: " + roomNumber);
|
||||
continue;
|
||||
//return Json(new { IsSuccess = false, Result = msg }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
if (host != null)
|
||||
{
|
||||
var hostModals = HostModalManager.Load(host.ID, DeviceType.AirDetect).Where(r => r.Modal.WXActiveIndicator);
|
||||
|
||||
var QQQ = listdata.GroupBy(A => new { A.HotelID, A.HotelCode, A.RoomNumber, A.CreatDate });
|
||||
TimeSpan ts = DateTime.Now.ToLocalTime() - new DateTime(1970, 1, 1, 8, 0, 0, 0, DateTimeKind.Utc);
|
||||
string current_timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();
|
||||
|
||||
foreach (var itemKey in QQQ)
|
||||
KongQiReport re = new KongQiReport();
|
||||
re.hotel_code = code;
|
||||
re.room_no = roomNumber;
|
||||
re.time = current_timestamp;
|
||||
|
||||
string md5key = Tools.MD5Encrypt(baojing_airreport_key);
|
||||
//hotel_code=酒店编码&time=时间戳&key=密钥
|
||||
string sss = string.Format("hotel_code={0}&time={1}&key={2}", code, current_timestamp, md5key);
|
||||
|
||||
//logger.Error("sss is: " + sss);
|
||||
string sign = Tools.MD5Encrypt(sss).ToLower();
|
||||
re.sign = sign;
|
||||
foreach (HostModal modal in hostModals)
|
||||
{
|
||||
var item = itemKey.Key;
|
||||
string roomNumber = item.RoomNumber;
|
||||
string code = item.HotelCode;
|
||||
string createDate = item.CreatDate;
|
||||
DateTime dts = DateTime.Parse(createDate);
|
||||
string cd = dts.ToString("yyyy-MM-dd");
|
||||
//string Name = ReturnNameByLanguage(modal.Modal.Name, modal.Modal.EnglishName, modal.Modal.TWName);
|
||||
string ModalAddress = modal.Modal.ModalAddress;
|
||||
|
||||
Host host = CheckRoomNumber(code, cd, ref msg, ref hotelID, roomNumber);
|
||||
if (host == null)
|
||||
string status = modal.Brightness.ToString();
|
||||
string KKey = CacheKey.HostModalStatus_Prefix + "_" + host.ID + "_" + ModalAddress;
|
||||
var obj = CSRedisCacheHelper.Get_Partition<HostModal_Cache>(KKey);
|
||||
if (obj != null)
|
||||
{
|
||||
logger.Error("host not exists hotelcode: " + code + " createDate: " + cd + " roomnumber: " + roomNumber);
|
||||
continue;
|
||||
//return Json(new { IsSuccess = false, Result = msg }, JsonRequestBehavior.AllowGet);
|
||||
HostModal_Cache hhh = obj as HostModal_Cache;
|
||||
status = hhh.Brightness.ToString();
|
||||
}
|
||||
if (host != null)
|
||||
|
||||
switch (ModalAddress)
|
||||
{
|
||||
var hostModals = HostModalManager.Load(host.ID, DeviceType.AirDetect).Where(r => r.Modal.WXActiveIndicator);
|
||||
case "009000001"://CO2浓度 ppm
|
||||
re.co2 = status;
|
||||
break;
|
||||
case "009000002"://甲醛浓度 ug/m3 实际显示单位为mg/M3
|
||||
re.methanal = status;
|
||||
break;
|
||||
case "009000003"://TVOC浓度 ug/m3 实际显示单位为mg/M3
|
||||
re.tvoc = status;
|
||||
break;
|
||||
case "009000004"://PM2.5浓度 ug/m3
|
||||
re.pm25 = status;
|
||||
break;
|
||||
case "009000005"://PM10浓度 ug/m3
|
||||
re.pm10 = status;
|
||||
break;
|
||||
case "009000006"://温度 度
|
||||
re.temperature = status;
|
||||
break;
|
||||
case "009000007"://湿度 %RH
|
||||
re.humidness = status;
|
||||
break;
|
||||
|
||||
TimeSpan ts = DateTime.Now.ToLocalTime() - new DateTime(1970, 1, 1, 8, 0, 0, 0, DateTimeKind.Utc);
|
||||
string current_timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();
|
||||
|
||||
KongQiReport re = new KongQiReport();
|
||||
re.hotel_code = code;
|
||||
re.room_no = roomNumber;
|
||||
re.time = current_timestamp;
|
||||
|
||||
string md5key = Tools.MD5Encrypt(baojing_airreport_key);
|
||||
//hotel_code=酒店编码&time=时间戳&key=密钥
|
||||
string sss = string.Format("hotel_code={0}&time={1}&key={2}", code, current_timestamp, md5key);
|
||||
|
||||
//logger.Error("sss is: " + sss);
|
||||
string sign = Tools.MD5Encrypt(sss).ToLower();
|
||||
re.sign = sign;
|
||||
foreach (HostModal modal in hostModals)
|
||||
{
|
||||
//string Name = ReturnNameByLanguage(modal.Modal.Name, modal.Modal.EnglishName, modal.Modal.TWName);
|
||||
string ModalAddress = modal.Modal.ModalAddress;
|
||||
|
||||
string status = modal.Brightness.ToString();
|
||||
string KKey = CacheKey.HostModalStatus_Prefix + "_" + host.ID + "_" + ModalAddress;
|
||||
var obj = CSRedisCacheHelper.Get_Partition<HostModal_Cache>(KKey);
|
||||
if (obj != null)
|
||||
{
|
||||
HostModal_Cache hhh = obj as HostModal_Cache;
|
||||
status = hhh.Brightness.ToString();
|
||||
}
|
||||
|
||||
switch (ModalAddress)
|
||||
{
|
||||
case "009000001"://CO2浓度 ppm
|
||||
re.co2 = status;
|
||||
break;
|
||||
case "009000002"://甲醛浓度 ug/m3 实际显示单位为mg/M3
|
||||
re.methanal = status;
|
||||
break;
|
||||
case "009000003"://TVOC浓度 ug/m3 实际显示单位为mg/M3
|
||||
re.tvoc = status;
|
||||
break;
|
||||
case "009000004"://PM2.5浓度 ug/m3
|
||||
re.pm25 = status;
|
||||
break;
|
||||
case "009000005"://PM10浓度 ug/m3
|
||||
re.pm10 = status;
|
||||
break;
|
||||
case "009000006"://温度 度
|
||||
re.temperature = status;
|
||||
break;
|
||||
case "009000007"://湿度 %RH
|
||||
re.humidness = status;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//list{Name(名称),ModalAddress(回路 地址),Brightness, Status(对应值)}
|
||||
var client1 = new RestClient(AirReport_Address);
|
||||
var request1 = new RestRequest("/rcu/v1/air", Method.POST);
|
||||
request1.RequestFormat = DataFormat.Json;
|
||||
|
||||
//string json = Newtonsoft.Json.JsonConvert.SerializeObject(re);
|
||||
//logger.Error("空气质量送了数据:" + AirReport_Address+" data: "+json);
|
||||
|
||||
request1.AddJsonBody(re);
|
||||
|
||||
client1.ExecuteAsync(request1, (response) =>
|
||||
{
|
||||
string result = response.Content;
|
||||
//logger.Error("空气质量返回了:"+result);
|
||||
});
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//list{Name(名称),ModalAddress(回路 地址),Brightness, Status(对应值)}
|
||||
var client1 = new RestClient(AirReport_Address);
|
||||
var request1 = new RestRequest("/rcu/v1/air", Method.POST);
|
||||
request1.RequestFormat = DataFormat.Json;
|
||||
|
||||
//string json = Newtonsoft.Json.JsonConvert.SerializeObject(re);
|
||||
//logger.Error("空气质量送了数据:" + AirReport_Address+" data: "+json);
|
||||
|
||||
request1.AddJsonBody(re);
|
||||
|
||||
client1.ExecuteAsync(request1, (response) =>
|
||||
{
|
||||
string result = response.Content;
|
||||
//logger.Error("空气质量返回了:"+result);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.Message + ex.StackTrace);
|
||||
//return Json(new { IsSuccess = false, Result = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.Message + ex.StackTrace);
|
||||
//return Json(new { IsSuccess = false, Result = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new { IsSuccess = true, Result = "sucess" }, JsonRequestBehavior.AllowGet);
|
||||
|
||||
}
|
||||
@@ -3754,7 +3778,7 @@ namespace WebSite.Controllers
|
||||
});
|
||||
}
|
||||
var QQQ = result.ToList();
|
||||
QQQ.Sort();
|
||||
//QQQ.Sort();
|
||||
return Json(new { total = result.Count, rows = QQQ });
|
||||
|
||||
//var statusList = HostUpdateStatusManager.LoadAll().Where(r => r.HostUpdate.ID == hostUpdateID).Select(r => new { id = r.ID, hostID = r.Host.ID, status = r.Status });
|
||||
@@ -4137,18 +4161,24 @@ namespace WebSite.Controllers
|
||||
var QQQ = client1.Execute(request1);
|
||||
string ddd = QQQ.Content;
|
||||
var FFFA = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOrderResponse>(ddd);
|
||||
var D1 = FFFA.data.FirstOrDefault(A => A["item_uuid"].Equals(CleanUUID));
|
||||
if (D1 != null)
|
||||
if (!string.IsNullOrEmpty(CleanUUID))
|
||||
{
|
||||
string V = "";
|
||||
D1.TryGetValue("job_status", out V);
|
||||
if (V.Equals("cancelled"))
|
||||
if (FFFA != null && FFFA.data != null && FFFA.data.Count > 0)
|
||||
{
|
||||
Host host = new Host();
|
||||
host.HostNumber = HostNUMBER;
|
||||
HostModal s = new HostModal();
|
||||
s.Modal = new RoomTypeModal() { ModalAddress = "004000003", Type = DeviceType.ServiceInfo };
|
||||
HostModalManager.SetDevice(host, s, 0, 0);
|
||||
var D1 = FFFA.data.FirstOrDefault(A => A["item_uuid"].Equals(CleanUUID));
|
||||
if (D1 != null)
|
||||
{
|
||||
string V = "";
|
||||
D1.TryGetValue("job_status", out V);
|
||||
if (V.Equals("cancelled"))
|
||||
{
|
||||
Host host = new Host();
|
||||
host.HostNumber = HostNUMBER;
|
||||
HostModal s = new HostModal();
|
||||
s.Modal = new RoomTypeModal() { ModalAddress = "004000003", Type = DeviceType.ServiceInfo };
|
||||
HostModalManager.SetDevice(host, s, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5118,6 +5148,7 @@ namespace WebSite.Controllers
|
||||
long jishu_error = Interlocked.Read(ref MvcApplication.UDPServerErrorCount);
|
||||
if (jishu_error >= 3)
|
||||
{
|
||||
logger.Error("重启了UDP服务器");
|
||||
Interlocked.Exchange(ref MvcApplication.UDPServerErrorCount, 0);
|
||||
var hostServer = (IHostServer)MvcApplication.cxt.GetObject("RCUHost.HostServer");
|
||||
hostServer.Start();
|
||||
|
||||
@@ -117,11 +117,12 @@ namespace WebSite.Controllers
|
||||
public ActionResult LogOn()
|
||||
{
|
||||
string result = "";
|
||||
if (!Common.MyDes.Validate(ref result))
|
||||
{
|
||||
ViewData["Msg"] = result;
|
||||
return View("License");
|
||||
}
|
||||
//这个是公网没有必要再验证证书了
|
||||
//if (!Common.MyDes.Validate(ref result))
|
||||
//{
|
||||
// ViewData["Msg"] = result;
|
||||
// return View("License");
|
||||
//}
|
||||
if (Request.Cookies["Account"] != null)
|
||||
{
|
||||
ViewData["Account"] = HttpUtility.UrlDecode(Request.Cookies["Account"].Value);
|
||||
|
||||
@@ -1541,7 +1541,7 @@ namespace WebSite.Controllers
|
||||
bool bsa = hostModal.Modal.Type == DeviceType.AirConditioner;
|
||||
string KKKey = System.Guid.NewGuid().ToString("N");
|
||||
|
||||
bool wendu1 = KongTiaoControlName.Equals("IncrementTemperatureRequest") || KongTiaoControlName.Equals("IncrementTemperatureRequest")||KongTiaoControlName.Equals("SetTemperatureRequest");
|
||||
bool wendu1 = KongTiaoControlName.Equals("IncrementTemperatureRequest") || KongTiaoControlName.Equals("IncrementTemperatureRequest") || KongTiaoControlName.Equals("SetTemperatureRequest");
|
||||
bool fengsu1 = KongTiaoControlName.Equals("SetFanSpeedRequest") || KongTiaoControlName.Equals("IncrementFanSpeedRequest") || KongTiaoControlName.Equals("DecrementFanSpeedRequest");
|
||||
bool moshi1 = KongTiaoControlName.Equals("SetModeRequest");
|
||||
//特殊酒店
|
||||
@@ -6291,7 +6291,9 @@ namespace WebSite.Controllers
|
||||
resp.status = 1;
|
||||
string nnn = Newtonsoft.Json.JsonConvert.SerializeObject(resp);
|
||||
logger.Error("投诉信息给宝镜推送: " + nnn);
|
||||
XuanZhuOperation.ReportService(ttt.Item3, resp);
|
||||
//XuanZhuOperation.ReportService(ttt.Item3, resp);
|
||||
|
||||
MyHttp.SendHttpData(ttt.Item3, resp);
|
||||
}, tup);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ namespace WebSite
|
||||
}
|
||||
protected override void Application_Start(object sender, EventArgs e)
|
||||
{
|
||||
logger.Error("Web重启了");
|
||||
// 在应用程序启动时调用
|
||||
PreHot();
|
||||
log4net.Config.XmlConfigurator.Configure();//初始化log4net
|
||||
@@ -279,16 +280,17 @@ namespace WebSite
|
||||
{
|
||||
try
|
||||
{
|
||||
hostServer.Close();
|
||||
System.Threading.Thread.Sleep(5000);
|
||||
System.Net.WebRequest request = System.Net.WebRequest.Create(currentUrl);
|
||||
System.Net.WebResponse response = request.GetResponse();
|
||||
logger.Error("系统重启Web服务");
|
||||
response.Close();
|
||||
//hostServer.Close();
|
||||
//System.Threading.Thread.Sleep(5000);
|
||||
//System.Net.WebRequest request = System.Net.WebRequest.Create(currentUrl);
|
||||
//System.Net.WebResponse response = request.GetResponse();
|
||||
//logger.Error("系统重启Web服务");
|
||||
//response.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
logger.Error("重启原因为:" + ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -696,10 +698,10 @@ namespace WebSite
|
||||
_client.UpdateCheckInOrOutRecord(dr["Code"].ToString(), Convert.ToInt64(dr["ID"]), flag);//更新已同步状态
|
||||
|
||||
string RoomNUM = dr["RoomNumber"].ToString();
|
||||
var T = new Tuple<int, string,RoomStatus>(hotelID,RoomNUM,roomStatus);
|
||||
var T = new Tuple<int, string, RoomStatus>(hotelID, RoomNUM, roomStatus);
|
||||
Task.Factory.StartNew((state) =>
|
||||
{
|
||||
var T1 = state as Tuple<int, string,RoomStatus>;
|
||||
var T1 = state as Tuple<int, string, RoomStatus>;
|
||||
Host host = HostManager.GetByRoomNumber(T1.Item2, T1.Item1);
|
||||
if (host != null)
|
||||
{
|
||||
@@ -711,7 +713,7 @@ namespace WebSite
|
||||
ddd.Status = T1.Item3;
|
||||
CSRedisCacheHelper.Set_PartitionWithForever<RoomStatusRequest>(Key, ddd);
|
||||
}
|
||||
},T);
|
||||
}, T);
|
||||
}
|
||||
/// <summary>
|
||||
/// 定时上报主机异常记录
|
||||
@@ -737,13 +739,119 @@ namespace WebSite
|
||||
resp.status = 2;
|
||||
resp.faultType = 1;
|
||||
resp.faultData = 1;
|
||||
XuanZhuOperation.ReportService(hotel.FaultPushURL, resp);
|
||||
//XuanZhuOperation.ReportService(hotel.FaultPushURL, resp);
|
||||
|
||||
MyHttp.SendHttpData(hotel.FaultPushURL, resp);
|
||||
}
|
||||
}
|
||||
logger.Error(string.Format("定时上报酒店({0})主机异常记录", hotel.Code));
|
||||
}
|
||||
}, System.Threading.CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
|
||||
protected void Application_Error(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Exception ex = Server.GetLastError();
|
||||
logger.Error("IIS:" + ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error("IIS Exception:" + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// 存储恶意IP和请求频率
|
||||
private static ConcurrentDictionary<string, RequestInfo> _ipRequests = new ConcurrentDictionary<string, RequestInfo>();
|
||||
protected void Application_BeginRequest(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ip = Request.UserHostAddress;
|
||||
var url = Request.Url.AbsolutePath.ToLower();
|
||||
|
||||
// 定义要拦截的路径模式
|
||||
var maliciousPatterns = new[]
|
||||
{
|
||||
@".*\.git/*",
|
||||
@"^/sdk",
|
||||
@"^/HNAP1",
|
||||
@"^/evox",
|
||||
@"^/nmaplowercheck",
|
||||
@"^/phpmyadmin",
|
||||
@"^/admin",
|
||||
@"^/wp-login",
|
||||
@"^/shell",
|
||||
@"^/cmd",
|
||||
@".*\.php$",
|
||||
@".*\.asp$",
|
||||
@".*\.git/credentials"
|
||||
//@".*\.aspx$"
|
||||
};
|
||||
|
||||
// 检查是否为恶意路径
|
||||
if (maliciousPatterns.Any(pattern => System.Text.RegularExpressions.Regex.IsMatch(url, pattern)))
|
||||
{
|
||||
LogMaliciousRequest(ip, url);
|
||||
Response.StatusCode = 403;
|
||||
//Response.End();
|
||||
Context.ApplicationInstance.CompleteRequest();
|
||||
return;
|
||||
}
|
||||
// 频率限制(可选)
|
||||
if (IsMaliciousRequestRate(ip))
|
||||
{
|
||||
Response.StatusCode = 429; // Too Many Requests
|
||||
Context.ApplicationInstance.CompleteRequest();
|
||||
//Response.End();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error("恶意请求出错了:" + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void LogMaliciousRequest(string ip, string url)
|
||||
{
|
||||
logger.Error("恶意IP:" + ip + " URL:" + url);
|
||||
}
|
||||
|
||||
private bool IsMaliciousRequestRate(string ip)
|
||||
{
|
||||
// 简单的频率检查逻辑
|
||||
var now = DateTime.UtcNow;
|
||||
var info = _ipRequests.GetOrAdd(ip, _ => new RequestInfo());
|
||||
|
||||
lock (info)
|
||||
{
|
||||
info.RequestCount++;
|
||||
info.LastRequest = now;
|
||||
|
||||
// 如果1分钟内超过100次请求,认为是恶意请求
|
||||
if (info.RequestCount > 100 && (now - info.FirstRequest).TotalMinutes < 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private class RequestInfo
|
||||
{
|
||||
public RequestInfo()
|
||||
{
|
||||
this.FirstRequest = DateTime.UtcNow;
|
||||
}
|
||||
public int RequestCount { get; set; }
|
||||
public DateTime FirstRequest { get; set; }
|
||||
public DateTime LastRequest { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前登录帐号
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user