159 lines
8.2 KiB
C#
159 lines
8.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Collections.Specialized;
|
|||
|
|
using System.Configuration;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Data.SqlClient;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
|
|||
|
|
namespace Common
|
|||
|
|
{
|
|||
|
|
public sealed class SyncRoomStatus
|
|||
|
|
{
|
|||
|
|
//private static object _lock = new object();
|
|||
|
|
///// <summary>
|
|||
|
|
///// 重置回路当天开启时长
|
|||
|
|
///// </summary>
|
|||
|
|
//public static void SyncRoomStatus(string codes)
|
|||
|
|
//{
|
|||
|
|
// //using (IDbConnection connection = new SqlConnection(AppUtils.GetConnectingString()))
|
|||
|
|
// //using (IDbCommand command = connection.CreateCommand())
|
|||
|
|
// //{
|
|||
|
|
// // connection.Open();
|
|||
|
|
// // //command.CommandType = CommandType.Text;
|
|||
|
|
// // //command.CommandText = "UPDATE tb_HostModal SET [Time]=0,UpdateTime=GETDATE()";
|
|||
|
|
// // command.CommandType = CommandType.StoredProcedure;
|
|||
|
|
// // command.CommandText = "UpdateHostModalRecords";
|
|||
|
|
// // command.ExecuteNonQuery();
|
|||
|
|
// //}
|
|||
|
|
|
|||
|
|
// lock (_lock)
|
|||
|
|
// {
|
|||
|
|
// foreach (string code in codes.Split(','))//遍历多家酒店需要与PMS同步房态
|
|||
|
|
// {
|
|||
|
|
// //DataTable dtHotel = _client.GetHotelByCode(code);
|
|||
|
|
// DataSet ds = _client.GetCheckInOrOutRecord(code);
|
|||
|
|
// if (ds != null && ds.Tables.Count > 2)
|
|||
|
|
// {
|
|||
|
|
// int hotelID = Convert.ToInt16(ds.Tables[3].Rows[0]["HotelID"].ToString());//与PMS同步接口所配置的HotelID
|
|||
|
|
// using (IDbConnection connection = new SqlConnection(AppUtils.GetConnectingString()))
|
|||
|
|
// using (IDbCommand command = connection.CreateCommand())
|
|||
|
|
// {
|
|||
|
|
// connection.Open();
|
|||
|
|
// command.CommandType = System.Data.CommandType.Text;
|
|||
|
|
// //新开房记录
|
|||
|
|
// foreach (DataRow dr in ds.Tables[0].Rows)
|
|||
|
|
// {
|
|||
|
|
// //更新RICS房态(出租:2)
|
|||
|
|
// SyncRoomStatus(hotelID, command, dr, 2, 0);
|
|||
|
|
// }
|
|||
|
|
// //新退房记录
|
|||
|
|
// foreach (DataRow dr in ds.Tables[1].Rows)
|
|||
|
|
// {
|
|||
|
|
// //更新RICS房态(退房:8)
|
|||
|
|
// SyncRoomStatus(hotelID, command, dr, 8, 1);
|
|||
|
|
// }
|
|||
|
|
// //新待租记录
|
|||
|
|
// foreach (DataRow dr in ds.Tables[2].Rows)
|
|||
|
|
// {
|
|||
|
|
// //更新RICS房态(待租:4)
|
|||
|
|
// SyncRoomStatus(hotelID, command, dr, 4, 2);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// //判断已插卡取电但尚未开房5分钟后,上报报警数据给金天鹅PMS
|
|||
|
|
// //Group group = GroupManager.Load(21);
|
|||
|
|
// //IList<Host> hosts = HostManager.LoadAll(group);
|
|||
|
|
// //foreach (Host host in hosts)
|
|||
|
|
// //{
|
|||
|
|
// // IList<HostRoomCard> hostRoomCards = HostRoomCardManager.LoadAll(host.RoomNumber, "");
|
|||
|
|
// // if (hostRoomCards != null && hostRoomCards.Count > 0)
|
|||
|
|
// // {
|
|||
|
|
// // XmlDocument xmlDoc = new XmlDocument();
|
|||
|
|
// // xmlDoc.LoadXml(_client1.GethHotelcode("宝来客控对接酒店"));
|
|||
|
|
// // XmlElement element = xmlDoc.DocumentElement;
|
|||
|
|
// // string hotelCode = element.GetElementsByTagName("Body")[0].ChildNodes[0].ChildNodes[0].InnerText;//"HOTEL1489374686";
|
|||
|
|
// // xmlDoc = new XmlDocument();
|
|||
|
|
// // XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");//创建类型声明节点
|
|||
|
|
// // xmlDoc.AppendChild(node);
|
|||
|
|
// // XmlNode root = xmlDoc.CreateElement("request");
|
|||
|
|
// // xmlDoc.AppendChild(root);
|
|||
|
|
// // XmlNode card = xmlDoc.CreateElement("Alarm");
|
|||
|
|
// // root.AppendChild(card);
|
|||
|
|
// // XmlNode data = xmlDoc.CreateNode(XmlNodeType.Element, "hotelCode", null);
|
|||
|
|
// // data.InnerText = hotelCode;//酒店代码
|
|||
|
|
// // card.AppendChild(data);
|
|||
|
|
// // data = xmlDoc.CreateNode(XmlNodeType.Element, "roomno", null);
|
|||
|
|
// // data.InnerText = host.RoomNumber;//房间号
|
|||
|
|
// // card.AppendChild(data);
|
|||
|
|
// // data = xmlDoc.CreateNode(XmlNodeType.Element, "remark", null);
|
|||
|
|
// // data.InnerText = "";//备注
|
|||
|
|
// // card.AppendChild(data);
|
|||
|
|
// // data = xmlDoc.CreateNode(XmlNodeType.Element, "state", null);
|
|||
|
|
|
|||
|
|
// // HostRoomCard hostRoomCard = hostRoomCards[hostRoomCards.Count - 1];
|
|||
|
|
|
|||
|
|
// // if (host.RoomStatus.ID != 2 && host.RoomCard != null)
|
|||
|
|
// // {
|
|||
|
|
// // if ((hostRoomCard.IsAlarm == null || hostRoomCard.IsAlarm == false) &&
|
|||
|
|
// // Convert.ToDateTime(hostRoomCard.InCardTime).AddMinutes(5) <= DateTime.Now)
|
|||
|
|
// // {
|
|||
|
|
// // data.InnerText = "1";//报警
|
|||
|
|
// // card.AppendChild(data);
|
|||
|
|
// // data = xmlDoc.CreateNode(XmlNodeType.Element, "key", null);
|
|||
|
|
// // data.InnerText = "Wide_Third";//授权码
|
|||
|
|
// // card.AppendChild(data);
|
|||
|
|
// // //string result = _client1.send(xmlDoc.InnerXml);
|
|||
|
|
// // logger.Error(xmlDoc.InnerXml);//result + Environment.NewLine +
|
|||
|
|
|
|||
|
|
// // hostRoomCard.IsAlarm = true;
|
|||
|
|
// // HostRoomCardManager.Update(hostRoomCard);
|
|||
|
|
// // }
|
|||
|
|
// // }
|
|||
|
|
// // else if (hostRoomCard.IsAlarm == true)
|
|||
|
|
// // {
|
|||
|
|
// // data.InnerText = "0";//取消报警
|
|||
|
|
// // card.AppendChild(data);
|
|||
|
|
// // data = xmlDoc.CreateNode(XmlNodeType.Element, "key", null);
|
|||
|
|
// // data.InnerText = "Wide_Third";//授权码
|
|||
|
|
// // card.AppendChild(data);
|
|||
|
|
// // //string result = _client1.send(xmlDoc.InnerXml);
|
|||
|
|
// // logger.Error(xmlDoc.InnerXml);//result + Environment.NewLine +
|
|||
|
|
|
|||
|
|
// // hostRoomCard.IsAlarm = false;
|
|||
|
|
// // HostRoomCardManager.Update(hostRoomCard);
|
|||
|
|
// // }
|
|||
|
|
// // }
|
|||
|
|
// //}
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
///// <summary>
|
|||
|
|
///// 同步房态
|
|||
|
|
///// </summary>
|
|||
|
|
///// <param name="hotelID">酒店ID</param>
|
|||
|
|
///// <param name="command"></param>
|
|||
|
|
///// <param name="dr"></param>
|
|||
|
|
///// <param name="roomStatusID">房态ID</param>
|
|||
|
|
///// <param name="flag">更新字段标记</param>
|
|||
|
|
//private static void SyncRoomStatus(int hotelID, IDbCommand command, DataRow dr, int roomStatusID, int flag)
|
|||
|
|
//{
|
|||
|
|
// _client.UpdateCheckInOrOutRecord(dr["Code"].ToString(), Convert.ToInt64(dr["ID"]), flag);//更新已同步状态
|
|||
|
|
|
|||
|
|
// string sql = "select id from tb_Hosts where HotelID=" + hotelID + " + and RoomNumber='" + dr["RoomNumber"].ToString() + "'";
|
|||
|
|
// command.CommandText = sql;
|
|||
|
|
// using (IDataReader reader = command.ExecuteReader())
|
|||
|
|
// {
|
|||
|
|
// reader.Read();
|
|||
|
|
// if (reader[0] != null)
|
|||
|
|
// {
|
|||
|
|
// Host host = HostManager.Get(reader[0]);
|
|||
|
|
// RoomStatus roomStatus = RoomStatusManager.Get(roomStatusID);
|
|||
|
|
// HostManager.ChangeRoomStatus(host, roomStatus);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
}
|