初始化CRICS
This commit is contained in:
27
Service/Implement/AlarmSettingManager.cs
Normal file
27
Service/Implement/AlarmSettingManager.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class AlarmSettingManager : GenericManagerBase<AlarmSetting>, IAlarmSettingManager
|
||||
{
|
||||
public IList<AlarmSetting> LoadAll(char type)
|
||||
{
|
||||
return ((IAlarmSettingRepository)CurrentRepository).LoadAll(type).ToList();
|
||||
}
|
||||
|
||||
public AlarmSetting Get(int hotelID, string code)
|
||||
{
|
||||
return ((IAlarmSettingRepository)CurrentRepository).LoadAll().FirstOrDefault(r => r.HotelID == hotelID && r.Code == code);
|
||||
}
|
||||
|
||||
public AlarmSetting Get(int hotelID, char type, string code)
|
||||
{
|
||||
return ((IAlarmSettingRepository)CurrentRepository).Get(hotelID, type, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Service/Implement/AppHotelManager.cs
Normal file
12
Service/Implement/AppHotelManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class AppHotelManager : GenericManagerBase<AppHotel>, IAppHotelManager
|
||||
{
|
||||
}
|
||||
}
|
||||
23
Service/Implement/AppMenuManager.cs
Normal file
23
Service/Implement/AppMenuManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class AppMenuManager : GenericManagerBase<AppMenu>, IAppMenuManager
|
||||
{
|
||||
public IList<AppMenu> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IAppMenuRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
|
||||
public IList<AppMenu> LoadAll(int type, int hotelID)
|
||||
{
|
||||
return ((Dao.IAppMenuRepository)(this.CurrentRepository)).LoadAll(type, hotelID).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Service/Implement/AppRoomManager.cs
Normal file
29
Service/Implement/AppRoomManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class AppRoomManager : GenericManagerBase<AppRoom>, IAppRoomManager
|
||||
{
|
||||
public IList<AppRoom> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IAppRoomRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
|
||||
public bool isExistMac(string mac)
|
||||
{
|
||||
return ((Dao.IAppRoomRepository)(this.CurrentRepository)).isExistMac(mac);
|
||||
}
|
||||
|
||||
public AppRoom GetRoomNumber(string mac)
|
||||
{
|
||||
return ((Dao.IAppRoomRepository)(this.CurrentRepository)).GetRoomNumber(mac);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
32
Service/Implement/CarbonVIPManager.cs
Normal file
32
Service/Implement/CarbonVIPManager.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RestSharp;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class CarbonVIPManager: GenericManagerBase<CarbonScene>, ICarbonVIPMananger
|
||||
{
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(CarbonVIPManager));
|
||||
public int Add(CarbonScene test)
|
||||
{
|
||||
return ((Dao.ICarbonScene_SetRepository)(this.CurrentRepository)).Add(test);
|
||||
}
|
||||
|
||||
public new void Update(CarbonScene n)
|
||||
{
|
||||
((Dao.ICarbonScene_SetRepository)(this.CurrentRepository)).Update(n);
|
||||
}
|
||||
|
||||
|
||||
public CarbonScene GetByID(int hostid)
|
||||
{
|
||||
var CarbonVIP= ((Dao.ICarbonScene_SetRepository)(this.CurrentRepository)).GetDataBy(hostid);
|
||||
return CarbonVIP;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Service/Implement/CurtainControlManager.cs
Normal file
26
Service/Implement/CurtainControlManager.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class CurtainControlManager : ICurtainControlManager
|
||||
{
|
||||
public ICurtainControlReceiver CurtainControlReceiver { get; set; }
|
||||
|
||||
// <summary>
|
||||
/// 发送窗帘控制
|
||||
/// </summary>
|
||||
/// <param name="host">主机</param>
|
||||
/// <param name="CurtainId">窗帘id</param>
|
||||
/// <param name="ctrl">窗帘控制</param>
|
||||
public void SendCtrl(Host host, int CurtainId, CurtainCtrl ctrl)
|
||||
{
|
||||
CurtainControlReceiver.SendCtrl(host, CurtainId, ctrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Service/Implement/ECO_DetailManager.cs
Normal file
28
Service/Implement/ECO_DetailManager.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class ECO_DetailManager : GenericManagerBase<ECO_Detail>, IECO_RoomDetailManager
|
||||
{
|
||||
public int Add(ECO_Detail test)
|
||||
{
|
||||
return ((Dao.IECO_DetailRepository)(this.CurrentRepository)).Add(test);
|
||||
}
|
||||
|
||||
public new void Update(ECO_Detail n)
|
||||
{
|
||||
((Dao.IECO_DetailRepository)(this.CurrentRepository)).Update(n);
|
||||
}
|
||||
|
||||
public new void UpdateOrSave(ECO_Detail n)
|
||||
{
|
||||
((Dao.IECO_DetailRepository)(this.CurrentRepository)).SaveOrUpdate(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Service/Implement/ECO_SettingManager.cs
Normal file
79
Service/Implement/ECO_SettingManager.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RestSharp;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class ECO_SettingManager : GenericManagerBase<ECO_Setting>, IECO_SettingMananger
|
||||
{
|
||||
public int Add(ECO_Setting test)
|
||||
{
|
||||
return ((Dao.IECO_SettingRepository)(this.CurrentRepository)).Add(test);
|
||||
}
|
||||
|
||||
public new void Update(ECO_Setting n)
|
||||
{
|
||||
((Dao.IECO_SettingRepository)(this.CurrentRepository)).Update(n);
|
||||
}
|
||||
|
||||
public new void UpdateOrSave(ECO_Setting n)
|
||||
{
|
||||
((Dao.IECO_SettingRepository)(this.CurrentRepository)).SaveOrUpdate(n);
|
||||
}
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(ECO_SettingManager));
|
||||
|
||||
|
||||
public void ECO_Start_Mission(string hotelid, int start_hour, int start_minute, int end_hour, int end_minute, bool IsEnable)
|
||||
{
|
||||
var client1 = new RestClient(HostManager.Missionsys_Address);
|
||||
var request1 = new RestRequest("api/eco_execute", Method.POST);
|
||||
|
||||
logger.Error("启动ECO任务:" + "api/eco_execute");
|
||||
|
||||
|
||||
request1.AddParameter("hotelid", hotelid);
|
||||
request1.AddParameter("start_hour", start_hour);
|
||||
request1.AddParameter("start_minute", start_minute);
|
||||
request1.AddParameter("end_hour", end_hour);
|
||||
request1.AddParameter("end_minute", end_minute);
|
||||
request1.AddParameter("enable_trigger", IsEnable);
|
||||
|
||||
client1.ExecuteAsync(request1, (response) =>
|
||||
{
|
||||
string result = response.Content;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 什么时候重置
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="end_hour"></param>
|
||||
/// <param name="end_minute"></param>
|
||||
/// <param name="IsEnable"></param>
|
||||
public void ECO_Reset_Mission(string id, int end_hour, int end_minute, bool IsEnable)
|
||||
{
|
||||
var client1 = new RestClient(HostManager.Missionsys_Address);
|
||||
var request1 = new RestRequest("api/eco_reset", Method.POST);
|
||||
|
||||
logger.Error("ECO_Reset 任务重置:" + "api/eco_reset");
|
||||
|
||||
|
||||
request1.AddParameter("eco_reset_key", id);
|
||||
request1.AddParameter("hour", end_hour);
|
||||
request1.AddParameter("minute", end_minute);
|
||||
request1.AddParameter("enable_trigger", IsEnable);
|
||||
|
||||
client1.ExecuteAsync(request1, (response) =>
|
||||
{
|
||||
string result = response.Content;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Service/Implement/EnergyConsumptionStatisticsManager.cs
Normal file
30
Service/Implement/EnergyConsumptionStatisticsManager.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dao;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class EnergyConsumptionStatisticsManager : IEnergyConsumptionStatisticsManager
|
||||
{
|
||||
public IEnergyConsumptionStatisticsRepository CurrentRepository { get; set; }
|
||||
|
||||
public void StatisticHostModalEnergy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IList<string> LoadRoomNumbers()
|
||||
{
|
||||
return CurrentRepository.LoadRoomNumbers();
|
||||
}
|
||||
|
||||
public DataTable LoadModals(string roomNumber, DeviceType? deviceType)
|
||||
{
|
||||
return CurrentRepository.LoadModals(roomNumber, deviceType);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Service/Implement/FaultRecordsManager.cs
Normal file
21
Service/Implement/FaultRecordsManager.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class FaultRecordsManager : GenericManagerBase<FaultRecord>, IFaultRecordsManager
|
||||
{
|
||||
public IList<FaultRecord> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((Dao.IFaultRecordsRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
|
||||
public string GenerateFaultNumber()
|
||||
{
|
||||
return ((Dao.IFaultRecordsRepository)(this.CurrentRepository)).GenerateFaultNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Service/Implement/FaultTypeManager.cs
Normal file
40
Service/Implement/FaultTypeManager.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class FaultTypeManager : GenericManagerBase<FaultType>, IFaultTypeManager
|
||||
{
|
||||
public Dao.IFaultRecordsRepository FaultRecordsRepository { get; set; }
|
||||
|
||||
public IList<FaultType> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((Dao.IFaultTypeRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
|
||||
public FaultType Get(string code)
|
||||
{
|
||||
return ((Dao.IFaultTypeRepository)(this.CurrentRepository)).Get(code);
|
||||
}
|
||||
|
||||
public override void Delete(IList<object> idList)
|
||||
{
|
||||
if (idList != null && idList.Count > 0)
|
||||
{
|
||||
foreach (int id in idList)
|
||||
{
|
||||
if (FaultRecordsRepository.GetFaultsCount(id) > 0)
|
||||
{
|
||||
FaultType faultType = base.Get(id);
|
||||
throw new ApplicationException(String.Format("删除失败,请先清空类别为【{0}】的故障。", faultType.Name));
|
||||
}
|
||||
}
|
||||
|
||||
base.Delete(idList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
181
Service/Implement/GroupManager.cs
Normal file
181
Service/Implement/GroupManager.cs
Normal file
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dao;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class GroupManager : GenericManagerBase<Group>, IGroupManager
|
||||
{
|
||||
public ISysUserRepository SysUserRepository { get; set; }
|
||||
public IHostRepository HostRepository { get; set; }
|
||||
|
||||
public IList<Group> GetGroupList(Group group)
|
||||
{
|
||||
return ((IGroupRepository)CurrentRepository).GetGroupList(group);
|
||||
}
|
||||
|
||||
public IList<Group> GetGroupList(int hotelID)
|
||||
{
|
||||
return ((IGroupRepository)CurrentRepository).GetGroupList(hotelID);
|
||||
}
|
||||
|
||||
public override void Delete(object id)
|
||||
{
|
||||
Group group = CurrentRepository.Get(id);
|
||||
if (group != null)
|
||||
{
|
||||
if (SysUserRepository.GetByGroup(group).Count() > 0)
|
||||
{
|
||||
throw new ApplicationException("分组【" + group.Name + "】已分配给用户,不能删除!");
|
||||
}
|
||||
|
||||
if (HostRepository.GetByGroup(group).Count() > 0)
|
||||
{
|
||||
throw new ApplicationException("分组【" + group.Name + "】已分配给主机,不能删除!");
|
||||
}
|
||||
}
|
||||
base.Delete(id);
|
||||
}
|
||||
|
||||
public IList<object> CreateGroupTree(Group group, int hotelID)
|
||||
{
|
||||
return BuildGroupTree(CurrentRepository.LoadAll().Where(r => r.HotelID == hotelID).ToList(), group);
|
||||
}
|
||||
|
||||
public object CreateGroupTree2(Group group, int hotelID)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var groupMenu = ((IGroupRepository)CurrentRepository).GetGroupMenu(group.ID, hotelID);
|
||||
|
||||
return BuildGroupTree(groupMenu);
|
||||
}
|
||||
|
||||
public IList<object> CreateGroupTreeWithRoom(Group group, IList<Host> checkedHosts, int hotelID)
|
||||
{
|
||||
return BuildGroupTreeWithRoom(CurrentRepository.LoadAll().Where(r => r.HotelID == hotelID).ToList(), group, checkedHosts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按层级构造分组名称
|
||||
/// 例如:
|
||||
/// BLW-1栋-1层
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
public string BuildGroupName(Group group)
|
||||
{
|
||||
string name = "";
|
||||
while (group != null)
|
||||
{
|
||||
if (name == "")
|
||||
{
|
||||
name = group.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = group.Name + "-" + name;
|
||||
}
|
||||
group = group.Parent;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// 构造楼层树,用于 easyui-tree, easyui-combotree
|
||||
/// </summary>
|
||||
/// <param name="groups"></param>
|
||||
/// <param name="parent"></param>
|
||||
/// <returns></returns>
|
||||
private IList<object> BuildGroupTree(IList<Group> groups, Group parent)
|
||||
{
|
||||
IList<object> groupTree = new List<object>();
|
||||
IList<Group> subGroups = groups.Where(r => r.Parent == parent).OrderBy(o => o.Sort).ToList();
|
||||
foreach (Group group in subGroups)
|
||||
{
|
||||
IList<object> children = BuildGroupTree(groups, group);
|
||||
if (children.Count != 0)
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon", children = children });
|
||||
}
|
||||
else
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon" });
|
||||
}
|
||||
}
|
||||
|
||||
return groupTree;
|
||||
}
|
||||
|
||||
private object BuildGroupTree(GroupMenu groupMenu)
|
||||
{
|
||||
if (groupMenu == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (groupMenu.SubGroupMenus.Count <= 0)
|
||||
{
|
||||
return new { id = groupMenu.ID, text = groupMenu.Name, iconCls = "tree-node-no-icon" };
|
||||
}
|
||||
IList<object> children = new List<object>();
|
||||
foreach (GroupMenu subGroupMenu in groupMenu.SubGroupMenus)
|
||||
{
|
||||
var subGroupTree = BuildGroupTree(subGroupMenu);
|
||||
if (subGroupTree != null)
|
||||
{
|
||||
children.Add(subGroupTree);
|
||||
}
|
||||
}
|
||||
return new { id = groupMenu.ID, text = groupMenu.Name, iconCls = "tree-node-no-icon", children = children };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构造带房号的 easyui-tree 数据格式的分组树,房号附在其所属的结点之下
|
||||
/// 如果分支上的房号包含在 checkedHosts 则将其选中
|
||||
/// </summary>
|
||||
/// <param name="groups"></param>
|
||||
/// <param name="parent"></param>
|
||||
/// <param name="checkedHosts"></param>
|
||||
/// <returns></returns>
|
||||
private IList<object> BuildGroupTreeWithRoom(IList<Group> groups, Group parent, IList<Host> checkedHosts)
|
||||
{
|
||||
IList<object> groupTree = new List<object>();
|
||||
IList<Group> subGroups = groups.Where(r => r.Parent == parent).OrderBy(o => o.Sort).ToList();
|
||||
foreach (Group group in subGroups)
|
||||
{
|
||||
IList<object> children = BuildGroupTreeWithRoom(groups, group, checkedHosts);
|
||||
if (children.Count != 0)
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon", children = children, attributes = new { isHost = false, roomTypeID = 0 } });
|
||||
}
|
||||
else
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon", attributes = new { isHost = false, roomTypeID = 0 } });
|
||||
}
|
||||
}
|
||||
var hosts = HostRepository.GetByGroup(parent).OrderBy(r => r.RoomType.ID).ToList();
|
||||
foreach (Host host in hosts)
|
||||
{
|
||||
if (checkedHosts != null && checkedHosts.Contains(host))
|
||||
{
|
||||
groupTree.Add(new { id = host.ID, text = host.RoomNumber + "(" + host.RoomType.Name + ")", iconCls = "tree-node-no-icon", @checked = true, attributes = new { isHost = true, roomTypeID = host.RoomType.ID } });
|
||||
}
|
||||
else
|
||||
{
|
||||
groupTree.Add(new { id = host.ID, text = host.RoomNumber + "(" + host.RoomType.Name + ")", iconCls = "tree-node-no-icon", attributes = new { isHost = true, roomTypeID = host.RoomType.ID } });
|
||||
}
|
||||
}
|
||||
return groupTree;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
250
Service/Implement/HostAirManager.cs
Normal file
250
Service/Implement/HostAirManager.cs
Normal file
@@ -0,0 +1,250 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RCUHost;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostAirManager : GenericManagerBase<HostAir>, IHostAirManager
|
||||
{
|
||||
public IHostRepository HostRepository { get; set; }
|
||||
|
||||
public IHotelSeasonRepository HotelSeasonRepository { get; set; }
|
||||
|
||||
public IAirConditionStatusReceiver AirConditionStatusReceiver { get; set; }
|
||||
|
||||
public IList<HostAir> LoadByHostID(int hostID)
|
||||
{
|
||||
return ((IHostAirRepository)CurrentRepository).LoadByHostID(hostID).OrderBy(r => r.Modal.Sort).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 空调设置整体下发
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="host"></param>
|
||||
public void ApplyAirConditionSetting(HostAir entity, Host host)
|
||||
{
|
||||
AirConditionStatusReceiver.SendAirConditionSetting(entity, host);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 空调单个属性下发
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="airNo"></param>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="status"></param>
|
||||
/// <param name="seasonData">季节数据</param>
|
||||
public void SetAirProperty(Host host, int airNo, AirProperty property, int status, byte[] seasonData = null)
|
||||
{
|
||||
AirConditionStatusReceiver.SetAirProperty(host, airNo, property, status, seasonData);
|
||||
if (property == AirProperty.Season)
|
||||
{
|
||||
var result = HotelSeasonRepository.LoadByHotelID(host.SysHotel.ID);
|
||||
if (result == null)
|
||||
{
|
||||
result = new HotelSeason();
|
||||
}
|
||||
result.SysHotel = host.SysHotel;
|
||||
result.Month1 = (int)seasonData[0];
|
||||
result.Month2 = (int)seasonData[1];
|
||||
result.Month3 = (int)seasonData[2];
|
||||
result.Month4 = (int)seasonData[3];
|
||||
result.Month5 = (int)seasonData[4];
|
||||
result.Month6 = (int)seasonData[5];
|
||||
result.Month7 = (int)seasonData[6];
|
||||
result.Month8 = (int)seasonData[7];
|
||||
result.Month9 = (int)seasonData[8];
|
||||
result.Month10 = (int)seasonData[9];
|
||||
result.Month11 = (int)seasonData[10];
|
||||
result.Month12 = (int)seasonData[11];
|
||||
HotelSeasonRepository.SaveOrUpdate(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
var hostAir = Get(host.ID, airNo);
|
||||
if (hostAir != null)
|
||||
{
|
||||
switch (property)
|
||||
{
|
||||
case AirProperty.ColdHotMode:
|
||||
hostAir.ColdHotMode = status;
|
||||
break;
|
||||
case AirProperty.Mode:
|
||||
hostAir.Mode = status;
|
||||
break;
|
||||
case AirProperty.SettingTemp:
|
||||
hostAir.SettingTemp = status;
|
||||
break;
|
||||
case AirProperty.Speed:
|
||||
hostAir.Speed = status;
|
||||
break;
|
||||
case AirProperty.KeepTemp:
|
||||
hostAir.KeepTemp = status;
|
||||
break;
|
||||
case AirProperty.InitTemp:
|
||||
hostAir.InitTemp = status;
|
||||
break;
|
||||
case AirProperty.DeadTemp:
|
||||
hostAir.DeadTemp = status;
|
||||
break;
|
||||
case AirProperty.LowerTemp:
|
||||
hostAir.LowerTemp = status;
|
||||
break;
|
||||
case AirProperty.HighTemp:
|
||||
hostAir.HightTemp = status;
|
||||
break;
|
||||
case AirProperty.ColdDevition:
|
||||
hostAir.ColdDevition = status;
|
||||
break;
|
||||
case AirProperty.HotDevition:
|
||||
hostAir.HotDevition = status;
|
||||
break;
|
||||
case AirProperty.ColdHotSwitchDelayTime:
|
||||
hostAir.ColdHotSwitchDelayTime = status;
|
||||
break;
|
||||
case AirProperty.WelcomeTime:
|
||||
hostAir.WelcomeTime = status;
|
||||
break;
|
||||
case AirProperty.RelateDoorContact:
|
||||
hostAir.RelateDoorContact = (status != 0);
|
||||
break;
|
||||
case AirProperty.RelateRoomStatus:
|
||||
hostAir.RelateRoomStatus = (status != 0);
|
||||
break;
|
||||
case AirProperty.FanStop:
|
||||
hostAir.FanStop = (status != 0);
|
||||
break;
|
||||
case AirProperty.DisableFanHighSpeed:
|
||||
hostAir.DisableFanHighSpeed = (status != 0);
|
||||
break;
|
||||
|
||||
}
|
||||
CurrentRepository.Update(hostAir);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置空调补偿温度
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="airNo"></param>
|
||||
/// <param name="compensatoryTemp"></param>
|
||||
public void SetCompensatoryTemp(Host host, int airNo, float compensatoryTemp)
|
||||
{
|
||||
AirConditionStatusReceiver.SetCompensatoryTemp(host, airNo, compensatoryTemp);
|
||||
var hostAir = GetByModalTypeID(host.ID, airNo);
|
||||
if (hostAir != null)
|
||||
{
|
||||
hostAir.CompensatoryTemp = compensatoryTemp;
|
||||
CurrentRepository.Update(hostAir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置空调锁定温度
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="airNo"></param>
|
||||
/// <param name="isLock"></param>
|
||||
/// <param name="lockTemp"></param>
|
||||
public void SetLockTemp(Host host, int airNo, bool isLock, int lockTemp)
|
||||
{
|
||||
AirConditionStatusReceiver.SetLockTemp(host, airNo, isLock, lockTemp);
|
||||
var hostAir = GetByModalTypeID(host.ID, airNo);
|
||||
if (hostAir != null)
|
||||
{
|
||||
hostAir.IsLockTemp = isLock;
|
||||
hostAir.LockTemp = lockTemp;
|
||||
CurrentRepository.Update(hostAir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置空调睡眠模式
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="airNo"></param>
|
||||
/// <param name="sleepFlag"></param>
|
||||
/// <param name="SleepDevition"></param>
|
||||
/// <param name="sleepStartTime"></param>
|
||||
/// <param name="sleepEndTime"></param>
|
||||
public void SetSleepMode(Host host, int airNo, bool sleepFlag, int sleepDevition, string sleepStartTime, string sleepEndTime)
|
||||
{
|
||||
AirConditionStatusReceiver.SetSleepMode(host, airNo, sleepFlag, sleepDevition, sleepStartTime, sleepEndTime);
|
||||
var hostAir = GetByModalTypeID(host.ID, airNo);
|
||||
if (hostAir != null)
|
||||
{
|
||||
hostAir.SleepFlag = sleepFlag;
|
||||
hostAir.SleepDevition = sleepDevition;
|
||||
hostAir.SleepStartTime = sleepStartTime;
|
||||
hostAir.SleepEndTime = sleepEndTime;
|
||||
CurrentRepository.Update(hostAir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置空调定时设置
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="airNo"></param>
|
||||
/// <param name="timeFlag"></param>
|
||||
/// <param name="startTime1"></param>
|
||||
/// <param name="endTime1"></param>
|
||||
/// <param name="startTime2"></param>
|
||||
/// <param name="endTime2"></param>
|
||||
/// <param name="startTime3"></param>
|
||||
/// <param name="endTime3"></param>
|
||||
public void SetTimeSetting(Host host, int airNo, bool timeFlag, string startTime1, string endTime1, string startTime2, string endTime2, string startTime3, string endTime3)
|
||||
{
|
||||
AirConditionStatusReceiver.SetTimeSetting(host, airNo, timeFlag, startTime1, endTime1, startTime2, endTime2, startTime3, endTime3);
|
||||
var hostAir = GetByModalTypeID(host.ID, airNo);
|
||||
if (hostAir != null)
|
||||
{
|
||||
hostAir.TimeFlag = timeFlag;
|
||||
hostAir.TimeStartTime1 = startTime1;
|
||||
hostAir.TimeEndTime1 = endTime1;
|
||||
hostAir.TimeStartTime2 = startTime2;
|
||||
hostAir.TimeEndTime2 = endTime2;
|
||||
hostAir.TimeStartTime3 = startTime3;
|
||||
hostAir.TimeEndTime3 = endTime3;
|
||||
CurrentRepository.Update(hostAir);
|
||||
}
|
||||
}
|
||||
|
||||
#region Override Methods
|
||||
|
||||
public override void Update(HostAir entity)
|
||||
{
|
||||
base.Update(entity);
|
||||
|
||||
AirConditionStatusReceiver.SendAirConditionSetting(entity, HostRepository.Get(entity.HostID));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public HostAir Get(int hostID, int roomTypeAirId)
|
||||
{
|
||||
return CurrentRepository.LoadAll().OrderBy(r => r.Modal.Sort).FirstOrDefault(r => r.HostID == hostID && r.Modal.ID == roomTypeAirId);
|
||||
}
|
||||
|
||||
public HostAir GetByModalTypeID(int hostID, int modalTypeId)
|
||||
{
|
||||
return CurrentRepository.LoadAll().OrderBy(r => r.Modal.Sort).FirstOrDefault(r => r.HostID == hostID && r.Modal.ModalType.ID == modalTypeId);
|
||||
}
|
||||
|
||||
public void Delete(int hostID)
|
||||
{
|
||||
((IHostAirRepository)CurrentRepository).DeteleByHostID(hostID);
|
||||
}
|
||||
|
||||
public void Delete(int hostID, int roomTypeAirID)
|
||||
{
|
||||
((IHostAirRepository)CurrentRepository).DeteleByRoomTypeAirID(hostID, roomTypeAirID);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Service/Implement/HostAirRecordManager.cs
Normal file
17
Service/Implement/HostAirRecordManager.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostAirRecordManager : GenericManagerBase<HostAirRecord>, IHostAirRecordManager
|
||||
{
|
||||
public DataTable LoadHostAirRecords(out long total, int page, int rows, string order, string sort, string roomNumber, int airNo, string startTime, string endTime, string tempTypes, int hotelID)
|
||||
{
|
||||
return ((Dao.IHostAirRecordRepository)CurrentRepository).LoadHostAirRecords(out total, page, rows, order, sort, roomNumber, airNo, startTime, endTime, tempTypes, hotelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Service/Implement/HostFaultRecordsManager.cs
Normal file
23
Service/Implement/HostFaultRecordsManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostFaultRecordsManager : GenericManagerBase<HostFaultRecords>, IHostFaultRecordsManager
|
||||
{
|
||||
public IList<string> LoadRoomNumbers(int hotelID)
|
||||
{
|
||||
return ((Dao.IHostFaultRecordsRepository)CurrentRepository).LoadRoomNumbers(hotelID);
|
||||
}
|
||||
|
||||
public DataTable LoadHostFaultRecords(out long total, int page, int rows, string order, string sort, string roomNumber, string startTime, string endTime, DeviceType? deviceType, string modalIds, int hotelID)
|
||||
{
|
||||
return ((Dao.IHostFaultRecordsRepository)CurrentRepository).LoadHostFaultRecords(out total, page, rows, order, sort, roomNumber, startTime, endTime, deviceType, modalIds, hotelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Service/Implement/HostFaultsManager.cs
Normal file
33
Service/Implement/HostFaultsManager.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostFaultsManager : GenericManagerBase<HostFaults>, IHostFaultsManager
|
||||
{
|
||||
public IList<HostFaults> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((IHostFaultsRepository)CurrentRepository).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
|
||||
//public IList<object[]> LoadCurrentHostFault(int hostID)
|
||||
//{
|
||||
// return ((IHostFaultsRepository)CurrentRepository).LoadCurrentHostFault(hostID);
|
||||
//}
|
||||
|
||||
public IList<object[]> LoadHostFault(int hostID)
|
||||
{
|
||||
return ((IHostFaultsRepository)CurrentRepository).LoadHostFault(hostID);
|
||||
}
|
||||
|
||||
public void DeleteByAddress(string address, int roomTypeID)
|
||||
{
|
||||
((IHostFaultsRepository)CurrentRepository).DeleteByAddress(address, roomTypeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
1611
Service/Implement/HostManager.cs
Normal file
1611
Service/Implement/HostManager.cs
Normal file
File diff suppressed because it is too large
Load Diff
214
Service/Implement/HostModalManager.cs
Normal file
214
Service/Implement/HostModalManager.cs
Normal file
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RCUHost;
|
||||
using RCUHost.Protocols;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostModalManager : GenericManagerBase<HostModal>, IHostModalManager
|
||||
{
|
||||
public IDeviceControlReceiver DeviceControlReceiver { get; set; }
|
||||
public IHostRegisterReceiver HostRegisterReceiver { get; set; }
|
||||
|
||||
public HostModal Get(int hostID, int roomTypeModalId)
|
||||
{
|
||||
var QQQ = ((IHostModalRepository)CurrentRepository).Get(hostID, roomTypeModalId);
|
||||
if (QQQ != null)
|
||||
{
|
||||
StatusTran(hostID, QQQ.Modal.ModalAddress, QQQ);
|
||||
}
|
||||
return QQQ;
|
||||
}
|
||||
|
||||
public HostModal GetByModalAddress(int hostID, string modalAddress)
|
||||
{
|
||||
var QQQ = ((IHostModalRepository)CurrentRepository).Get(hostID, modalAddress);
|
||||
StatusTran(hostID, modalAddress, QQQ);
|
||||
return QQQ;
|
||||
}
|
||||
|
||||
public HostModal GetByModalName(int hostID, string name)
|
||||
{
|
||||
var QQQ = ((IHostModalRepository)CurrentRepository).LoadAll().Where(r => r.HostID == hostID && r.Modal != null && r.Modal.Name == name).FirstOrDefault();
|
||||
if (QQQ != null)
|
||||
{
|
||||
StatusTran(hostID, QQQ.Modal.ModalAddress, QQQ);
|
||||
}
|
||||
return QQQ;
|
||||
}
|
||||
|
||||
public IList<HostModal> Load(int hostID, DeviceType type)
|
||||
{
|
||||
var LLL = ((IHostModalRepository)CurrentRepository).LoadAll().Where(r => r.HostID == hostID && r.Modal != null && r.Modal.Type == type).ToList();
|
||||
foreach (var QQQ in LLL)
|
||||
{
|
||||
if (QQQ != null)
|
||||
{
|
||||
StatusTran(hostID, QQQ.Modal.ModalAddress, QQQ);
|
||||
}
|
||||
}
|
||||
return LLL;
|
||||
}
|
||||
|
||||
public IList<HostModal> LoadByHostID(int hostID)
|
||||
{
|
||||
var LLL = ((IHostModalRepository)CurrentRepository).LoadByHostID(hostID).ToList();
|
||||
foreach (var QQQ in LLL)
|
||||
{
|
||||
if (QQQ != null)
|
||||
{
|
||||
StatusTran(hostID, QQQ.Modal.ModalAddress, QQQ);
|
||||
}
|
||||
}
|
||||
return LLL;
|
||||
}
|
||||
|
||||
public IList<HostModal> LoadAllLight(int hostID)
|
||||
{
|
||||
var LLL = ((IHostModalRepository)CurrentRepository).LoadAll().Where(r => r.HostID == hostID && r.Modal != null && r.Modal.Name.Contains("灯")).OrderBy(r => r.Modal.Sort).ToList();
|
||||
foreach (var QQQ in LLL)
|
||||
{
|
||||
if (QQQ != null)
|
||||
{
|
||||
StatusTran(hostID, QQQ.Modal.ModalAddress, QQQ);
|
||||
}
|
||||
}
|
||||
return LLL;
|
||||
}
|
||||
|
||||
public void DeteleByHostID(int hostID)
|
||||
{
|
||||
((IHostModalRepository)CurrentRepository).DeteleByHostID(hostID);
|
||||
}
|
||||
|
||||
public void DeteleByRoomTypeModal(int hostID, int roomTypeModalID)
|
||||
{
|
||||
((IHostModalRepository)CurrentRepository).DeteleByRoomTypeModal(hostID, roomTypeModalID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向某个结点发送数据
|
||||
/// </summary>
|
||||
/// <param name="hostnumber"></param>
|
||||
/// <param name="mac"></param>
|
||||
/// <param name="Data"></param>
|
||||
public void SendData(string hostnumber, string mac, byte[] Data)
|
||||
{
|
||||
Tuple<string, string> t = new Tuple<string, string>(hostnumber, mac);
|
||||
System.Threading.Tasks.Task.Factory.StartNew((state) =>
|
||||
{
|
||||
Tuple<string, string> t1 = state as Tuple<string, string>;
|
||||
var host1 = t1.Item1;
|
||||
var mac1 = t1.Item2;
|
||||
HostRegisterReceiver.Send(hostnumber, mac);//发送命令
|
||||
}, t, System.Threading.CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
public void SetDevice(Host host, HostModal hostModal, int status, int brightness, int temperature, int fanSpeed, int mode, int valve)
|
||||
{
|
||||
Device device = new Device();
|
||||
device.Address = hostModal.Modal.ModalAddress;
|
||||
device.AddressType = AddressType.DeviceAddress;
|
||||
device.Type = hostModal.Modal.Type;
|
||||
device.Status = (byte)status;
|
||||
device.Brightness = (byte)brightness;
|
||||
device.Temperature = (byte)temperature;
|
||||
device.FanSpeed = (byte)fanSpeed;
|
||||
device.Mode = (byte)mode;
|
||||
device.Valve = (byte)valve;
|
||||
device.AirExecMode = (status << 14) + (mode << 12) + (fanSpeed << 10) + (valve << 8) + temperature;//空调执行方式和内容
|
||||
device.FloorHotExecMode = (status << 12) + (mode << 8) + (valve << 6) + temperature;//地暖执行方式和内容
|
||||
device.MusicExecMode = status + (brightness << 12) + (mode << 8);//背景音乐执行方式和内容
|
||||
//device.ColorTempExecMode = status + (brightness << 12) + (temperature << 8);//色温执行方式和内容
|
||||
|
||||
var t = new Tuple<Host, Device>(host, device);
|
||||
System.Threading.Tasks.Task.Factory.StartNew((state) =>
|
||||
{
|
||||
var t1 = state as Tuple<Host, Device>;
|
||||
var host1 = t1.Item1;
|
||||
var device1 = t1.Item2;
|
||||
DeviceControlReceiver.Send(host1, device1);//发送命令
|
||||
}, t, System.Threading.CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
|
||||
public void SetDevice_Repeat(string SingleKey, Host host, HostModal hostModal, int status, int brightness, int temperature, int fanSpeed, int mode, int valve)
|
||||
{
|
||||
Device device = new Device();
|
||||
device.Address = hostModal.Modal.ModalAddress;
|
||||
device.AddressType = AddressType.DeviceAddress;
|
||||
device.Type = hostModal.Modal.Type;
|
||||
device.Status = (byte)status;
|
||||
device.Brightness = (byte)brightness;
|
||||
device.Temperature = (byte)temperature;
|
||||
device.FanSpeed = (byte)fanSpeed;
|
||||
device.Mode = (byte)mode;
|
||||
device.Valve = (byte)valve;
|
||||
device.AirExecMode = (status << 14) + (mode << 12) + (fanSpeed << 10) + (valve << 8) + temperature;//空调执行方式和内容
|
||||
device.FloorHotExecMode = (status << 12) + (mode << 8) + (valve << 6) + temperature;//地暖执行方式和内容
|
||||
device.MusicExecMode = status + (brightness << 12) + (mode << 8);//背景音乐执行方式和内容
|
||||
//device.ColorTempExecMode = status + (brightness << 12) + (temperature << 8);//色温执行方式和内容
|
||||
|
||||
var t = new Tuple<Host, Device, string>(host, device, SingleKey);
|
||||
System.Threading.Tasks.Task.Factory.StartNew((state) =>
|
||||
{
|
||||
var t1 = state as Tuple<Host, Device, string>;
|
||||
var host1 = t1.Item1;
|
||||
var device1 = t1.Item2;
|
||||
var key = t1.Item3;
|
||||
DeviceControlReceiver.Send_Repeat(key, host1, device1);//发送命令
|
||||
}, t);
|
||||
}
|
||||
|
||||
public void UpdateHostModalStatus(Host host1, string modalAddress1, int status1)
|
||||
{
|
||||
var t = new Tuple<Host, string, int>(host1, modalAddress1, status1);
|
||||
System.Threading.Tasks.Task.Factory.StartNew((state) =>
|
||||
{
|
||||
var t1 = state as Tuple<Host, string, int>;
|
||||
var host = t1.Item1;
|
||||
var modalAddress = t1.Item2;
|
||||
var status = t1.Item3;
|
||||
HostModal hostModal = ((IHostModalRepository)CurrentRepository).Get(host.ID, modalAddress);
|
||||
if (hostModal != null)
|
||||
{
|
||||
Device device = new Device();
|
||||
device.Address = modalAddress;
|
||||
device.AddressType = AddressType.DeviceAddress;
|
||||
device.Type = hostModal.Modal.Type;
|
||||
device.Status = (byte)status;
|
||||
|
||||
DeviceControlReceiver.Send(host, device);
|
||||
}
|
||||
}, t, System.Threading.CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
|
||||
}
|
||||
|
||||
|
||||
private static void StatusTran(int hostID, string modalAddress, HostModal QQQ)
|
||||
{
|
||||
string KKey = CommonEntity.CacheKey.HostModalStatus_Prefix + "_" + hostID + "_" + modalAddress;
|
||||
var obj = Common.CSRedisCacheHelper.Get_Partition<CommonEntity.HostModal_Cache>(KKey);
|
||||
if (obj != null)
|
||||
{
|
||||
CommonEntity.HostModal_Cache hhh = obj as CommonEntity.HostModal_Cache;
|
||||
if (QQQ != null)
|
||||
{
|
||||
QQQ.Status = hhh.Status;
|
||||
QQQ.Brightness = hhh.Brightness;
|
||||
var H = hhh.AirConditionData;
|
||||
QQQ.CurrentTemp = H.CurrentTemp;
|
||||
QQQ.SettingTemp = H.SettingTemp;
|
||||
QQQ.FanSpeed = H.FanSpeed;
|
||||
QQQ.Valve = H.Valve;
|
||||
QQQ.Mode = H.Mode;
|
||||
QQQ.UpdateTime = H.UpdateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Service/Implement/HostModalRecordManager.cs
Normal file
38
Service/Implement/HostModalRecordManager.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostModalRecordManager : GenericManagerBase<HostModalRecord>, IHostModalRecordManager
|
||||
{
|
||||
public IList<HostModalRecord> LoadByHostID(int hostID, string modalAddress = "")
|
||||
{
|
||||
return ((Dao.IHostModalRecordRepository)CurrentRepository).LoadByHostID(hostID, modalAddress).ToList();
|
||||
}
|
||||
|
||||
public DataTable LoadHostModalRecords(out long total, int page, int rows, string order, string sort, string roomNumber, string deviceTypes, string deviceSubtypes, string startTime, string endTime, int hotelID)
|
||||
{
|
||||
CommonEntity.DataTongJi.InvokeCount("LoadHostModalRecords_");
|
||||
return ((Dao.IHostModalRecordRepository)CurrentRepository).LoadHostModalRecords(out total, page, rows, order, sort, roomNumber, deviceTypes, deviceSubtypes, startTime, endTime, hotelID);
|
||||
}
|
||||
|
||||
public IList<string> LoadRoomNumbers(int hotelID)
|
||||
{
|
||||
return ((Dao.IHostModalRecordRepository)CurrentRepository).LoadRoomNumbers(hotelID);
|
||||
}
|
||||
|
||||
public DataTable LoadModals(string roomNumber, int hotelID)
|
||||
{
|
||||
return ((Dao.IHostModalRecordRepository)CurrentRepository).LoadModals(roomNumber, hotelID);
|
||||
}
|
||||
|
||||
public HostModalRecord GetLastHostModalRecord(int hostId, int roomTypeModalId)
|
||||
{
|
||||
return ((Dao.IHostModalRecordRepository)CurrentRepository).GetLastHostModalRecord(hostId, roomTypeModalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Service/Implement/HostRCUManager.cs
Normal file
29
Service/Implement/HostRCUManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RCUHost;
|
||||
using RCUHost.Protocols;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostRCUManager : GenericManagerBase<HostRCU>, IHostRCUManager
|
||||
{
|
||||
public IQueryable<HostRCU> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((IHostRCURepository)CurrentRepository).LoadAllByPage(out total, page, rows, order, sort, hotelID);
|
||||
}
|
||||
|
||||
public HostRCU GetByHostID(int hostID)
|
||||
{
|
||||
return ((IHostRCURepository)CurrentRepository).GetByHostID(hostID);
|
||||
}
|
||||
|
||||
public List<HostRCU> LoadAll(int hotelID)
|
||||
{
|
||||
return ((IHostRCURepository)CurrentRepository).LoadAll(hotelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Service/Implement/HostRoomCardManager.cs
Normal file
74
Service/Implement/HostRoomCardManager.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using System.Data;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostRoomCardManager : GenericManagerBase<HostRoomCard>, IHostRoomCardManager
|
||||
{
|
||||
public IList<HostRoomCard> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID,
|
||||
string roomNumber, int roomCardTypeID, string cardNumber, string userName, DateTime startTime, DateTime endTime)
|
||||
{
|
||||
var list = CurrentRepository.LoadAll();
|
||||
|
||||
list = list.Where(r => r.RoomCard.HotelID == hotelID);
|
||||
if (!String.IsNullOrEmpty(roomNumber))
|
||||
{
|
||||
list = list.Where(r => r.RoomNumber == roomNumber);
|
||||
}
|
||||
if (roomCardTypeID > -1)
|
||||
{
|
||||
list = list.Where(r => r.RoomCard.ID == roomCardTypeID);
|
||||
}
|
||||
if (!String.IsNullOrEmpty(cardNumber))
|
||||
{
|
||||
list = list.Where(r => r.CardNumber == cardNumber);
|
||||
}
|
||||
if (!String.IsNullOrEmpty(userName))
|
||||
{
|
||||
list = list.Where(r => r.UserName == userName);
|
||||
}
|
||||
list = list.Where(r => r.InCardTime >= startTime && r.InCardTime <= endTime.AddDays(1));
|
||||
|
||||
total = list.Count();
|
||||
list = list.OrderBy(sort + " " + order);
|
||||
list = list.Skip((page - 1) * rows).Take(rows);
|
||||
|
||||
return list.ToList();
|
||||
}
|
||||
|
||||
public IList<HostRoomCard> LoadAll(int hotelID, string roomNumber, string userName)
|
||||
{
|
||||
var list = CurrentRepository.LoadAll();
|
||||
|
||||
list = list.Where(r => r.HostID == hotelID);
|
||||
|
||||
if (!String.IsNullOrEmpty(roomNumber))
|
||||
{
|
||||
list = list.Where(r => r.RoomNumber == roomNumber);
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(userName))
|
||||
{
|
||||
list = list.Where(r => r.UserName == userName);
|
||||
}
|
||||
|
||||
return list.ToList();
|
||||
}
|
||||
|
||||
public void DeleteAll(int hotelID)
|
||||
{
|
||||
((IHostRoomCardRepository)CurrentRepository).DeleteAll(hotelID);
|
||||
}
|
||||
|
||||
public DataTable LoadHostRoomCard(out long total, int page, int rows, string order, string sort, int hotelID, string cardType, string roomNumber, string userName, string cardNumber, string startDate,string endDate)
|
||||
{
|
||||
return ((IHostRoomCardRepository)CurrentRepository).LoadHostRoomCard(out total, page, rows, order, sort, hotelID, cardType, roomNumber, userName, cardNumber, startDate,endDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Service/Implement/HostSceneManager.cs
Normal file
39
Service/Implement/HostSceneManager.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RCUHost;
|
||||
using RCUHost.Protocols;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostSceneManager : GenericManagerBase<HostScene>, IHostSceneManager
|
||||
{
|
||||
public HostScene Get(int hostID, int roomTypeSceneId)
|
||||
{
|
||||
return CurrentRepository.LoadAll().FirstOrDefault(r => r.HostID == hostID && r.Scene != null && r.Scene.ID == roomTypeSceneId);
|
||||
}
|
||||
|
||||
public IList<HostScene> LoadByHostID(int hostID)
|
||||
{
|
||||
return ((IHostSceneRepository)CurrentRepository).LoadByHostID(hostID).ToList();
|
||||
}
|
||||
|
||||
public void DeteleByHostID(int hostID)
|
||||
{
|
||||
((IHostSceneRepository)CurrentRepository).DeteleByHostID(hostID);
|
||||
}
|
||||
|
||||
public void DeteleByRoomTypeScene(int roomTypeSceneID)
|
||||
{
|
||||
((IHostSceneRepository)CurrentRepository).DeteleByRoomTypeScene(roomTypeSceneID);
|
||||
}
|
||||
|
||||
public void DeteleByRoomTypeScene(int hostID, int roomTypeSceneID)
|
||||
{
|
||||
((IHostSceneRepository)CurrentRepository).DeteleByRoomTypeScene(hostID, roomTypeSceneID);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Service/Implement/HostTimingControlManager.cs
Normal file
17
Service/Implement/HostTimingControlManager.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostTimingControlManager : GenericManagerBase<HostTimingControl>, IHostTimingControlManager
|
||||
{
|
||||
public IList<HostTimingControl> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((IHostTimingControlRepository)(CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Service/Implement/HostUpdateManager.cs
Normal file
25
Service/Implement/HostUpdateManager.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostUpdateManager : GenericManagerBase<HostUpdate>, IHostUpdateManager
|
||||
{
|
||||
public IList<HostUpdate> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((Dao.IHostUpdateRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据酒店ID获取第一条记录
|
||||
/// </summary>
|
||||
/// <param name="hotelID"></param>
|
||||
/// <returns></returns>
|
||||
public HostUpdate Get(string md5, int hotelID)
|
||||
{
|
||||
return ((Dao.IHostUpdateRepository)(this.CurrentRepository)).Get(md5, hotelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Service/Implement/HostUpdateStatusManager.cs
Normal file
16
Service/Implement/HostUpdateStatusManager.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostUpdateStatusManager : GenericManagerBase<HostUpdateStatus>, IHostUpdateStatusManager
|
||||
{
|
||||
public IList<HostUpdateStatus> LoadAllByHostUpdate(HostUpdate hostUpdate)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.HostUpdate == hostUpdate).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Service/Implement/HostWordsReportManager.cs
Normal file
18
Service/Implement/HostWordsReportManager.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HostWordsReportManager : GenericManagerBase<HostWordsReport>, IHostWordsReportManager
|
||||
{
|
||||
public IList<HostWordsReport> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((Dao.IHostWordsReportRepository)CurrentRepository).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Service/Implement/HotelAirControlManager.cs
Normal file
23
Service/Implement/HotelAirControlManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HotelAirControlManager : GenericManagerBase<HotelAirControl>, IHotelAirControlManager
|
||||
{
|
||||
public IList<HotelAirControl> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IHotelAirControlRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
|
||||
public List<HotelAirControl> LoadByHotelID(int hotelID)
|
||||
{
|
||||
return ((Dao.IHotelAirControlRepository)(this.CurrentRepository)).LoadByHotelID(hotelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Service/Implement/HotelSeasonManager.cs
Normal file
23
Service/Implement/HotelSeasonManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class HotelSeasonManager : GenericManagerBase<HotelSeason>, IHotelSeasonManager
|
||||
{
|
||||
public IList<HotelSeason> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IHotelSeasonRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
|
||||
public HotelSeason LoadByHotelID(int hotelID)
|
||||
{
|
||||
return ((Dao.IHotelSeasonRepository)(this.CurrentRepository)).LoadByHotelID(hotelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Service/Implement/KongTiaoTimerManager.cs
Normal file
30
Service/Implement/KongTiaoTimerManager.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class KongTiaoTimerManager : GenericManagerBase<KongTiaoTimer>, IKongTiaoTimerManager
|
||||
{
|
||||
public new void Save(KongTiaoTimer test)
|
||||
{
|
||||
((Dao.IRoomAirConditionMissionRepository)(this.CurrentRepository)).Save(test);
|
||||
}
|
||||
|
||||
|
||||
public new void Update(KongTiaoTimer test)
|
||||
{
|
||||
((Dao.IRoomAirConditionMissionRepository)(this.CurrentRepository)).Update(test);
|
||||
}
|
||||
|
||||
|
||||
public List<KongTiaoTimer> Select()
|
||||
{
|
||||
return ((Dao.IRoomAirConditionMissionRepository)(this.CurrentRepository)).SelectNoExecuted();
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Service/Implement/LieECOManager.cs
Normal file
42
Service/Implement/LieECOManager.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RestSharp;
|
||||
using RCUHost;
|
||||
using RCUHost.Implement;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class LieECOManager : GenericManagerBase<LieECO>, ILieECOMananger
|
||||
{
|
||||
|
||||
|
||||
public int Add(LieECO test)
|
||||
{
|
||||
return ((Dao.ILieECORepository)(this.CurrentRepository)).Add(test);
|
||||
}
|
||||
|
||||
public new void Update(LieECO n)
|
||||
{
|
||||
((Dao.ILieECORepository)(this.CurrentRepository)).Update(n);
|
||||
}
|
||||
|
||||
public new void UpdateOrSave(LieECO n)
|
||||
{
|
||||
((Dao.ILieECORepository)(this.CurrentRepository)).SaveOrUpdate(n);
|
||||
}
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(LieECOManager));
|
||||
|
||||
|
||||
|
||||
|
||||
public LieECO GetData(string hotelcode)
|
||||
{
|
||||
return ((Dao.ILieECORepository)(this.CurrentRepository)).GetDataBy(hotelcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
194
Service/Implement/LightControlManager.cs
Normal file
194
Service/Implement/LightControlManager.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
using RCUHost.Protocols;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class LightControlManager : ILightControlManager
|
||||
{
|
||||
public IRoomTypeSceneModalManager RoomTypeSceneModalManager { get; set; }
|
||||
public IDeviceControlReceiver DeviceControlReceiver { get; set; }
|
||||
/// <summary>
|
||||
/// 下发场景
|
||||
/// </summary>
|
||||
/// <param name="host">主机</param>
|
||||
/// <param name="scene">场景</param>
|
||||
/// <param name="takeInverse">是否取反</param>
|
||||
public void ApplyScene(Host host, RoomTypeScene scene, bool takeInverse = false)
|
||||
{
|
||||
if (scene.Type == SceneType.Custom)
|
||||
{
|
||||
var sceneModals = RoomTypeSceneModalManager.LoadAll(scene);
|
||||
if (sceneModals.Count > 0)
|
||||
{
|
||||
var devices = new List<Device>();
|
||||
foreach (var sceneModal in sceneModals)
|
||||
{
|
||||
Device device = new Device();
|
||||
device.Address = sceneModal.Modal.ModalAddress;
|
||||
device.AddressType = AddressType.DeviceAddress;
|
||||
device.Type = sceneModal.Modal.Type;
|
||||
if (takeInverse)
|
||||
{
|
||||
switch (sceneModal.Modal.Type)
|
||||
{
|
||||
case DeviceType.Curtain:
|
||||
if (sceneModal.Status == 1 || sceneModal.Status == 2)
|
||||
{
|
||||
device.Status = 0x06;
|
||||
device.Brightness = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
device.Status = (byte)sceneModal.Status;
|
||||
device.Brightness = (byte)sceneModal.Brightness;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (sceneModal.Status == 1)
|
||||
{
|
||||
device.Status = 0x02;
|
||||
device.Brightness = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
device.Status = (byte)sceneModal.Status;
|
||||
device.Brightness = (byte)sceneModal.Brightness;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
device.Status = (byte)sceneModal.Status;
|
||||
device.Brightness = (byte)sceneModal.Brightness;
|
||||
device.Temperature = (byte)sceneModal.CurrentTemp;
|
||||
device.FanSpeed = (byte)sceneModal.FanSpeed;
|
||||
device.Mode = (byte)sceneModal.Mode;
|
||||
device.Valve = (byte)sceneModal.Valve;
|
||||
device.AirExecMode = (sceneModal.Status << 14) + (sceneModal.Mode << 12) + (sceneModal.FanSpeed << 10) + (sceneModal.Valve << 8) + sceneModal.CurrentTemp;//空调执行方式和内容
|
||||
device.FloorHotExecMode = (sceneModal.Status << 12) + (sceneModal.Mode << 8) + (sceneModal.Valve << 6) + sceneModal.CurrentTemp;//地暖执行方式和内容
|
||||
device.MusicExecMode = sceneModal.Status + (sceneModal.Brightness << 12) + (sceneModal.Mode << 8);//背景音乐执行方式和内容
|
||||
}
|
||||
devices.Add(device);
|
||||
}
|
||||
DeviceControlReceiver.Send(host, devices);
|
||||
}
|
||||
}
|
||||
else if (scene.Type == SceneType.Command)
|
||||
{
|
||||
Device device = new Device();
|
||||
device.Address = scene.GroupAddress;
|
||||
device.AddressType = AddressType.GroupAddress;
|
||||
device.Status = (byte)(takeInverse ? 0x02 : 0x01);
|
||||
DeviceControlReceiver.Send(host, device);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 控制所有灯开关和亮度
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
public void AllDeviceControl(Host host, List<Device> devices)
|
||||
{
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
DeviceControlReceiver.Send(host, devices);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下发场景
|
||||
/// </summary>
|
||||
/// <param name="host">主机</param>
|
||||
/// <param name="scene">场景</param>
|
||||
/// <param name="takeInverse">是否取反</param>
|
||||
public void ApplyScene_Repeat(string Key,Host host, RoomTypeScene scene, bool takeInverse = false)
|
||||
{
|
||||
if (scene.Type == SceneType.Custom)
|
||||
{
|
||||
var sceneModals = RoomTypeSceneModalManager.LoadAll(scene);
|
||||
if (sceneModals.Count > 0)
|
||||
{
|
||||
var devices = new List<Device>();
|
||||
foreach (var sceneModal in sceneModals)
|
||||
{
|
||||
Device device = new Device();
|
||||
device.Address = sceneModal.Modal.ModalAddress;
|
||||
device.AddressType = AddressType.DeviceAddress;
|
||||
device.Type = sceneModal.Modal.Type;
|
||||
if (takeInverse)
|
||||
{
|
||||
switch (sceneModal.Modal.Type)
|
||||
{
|
||||
case DeviceType.Curtain:
|
||||
if (sceneModal.Status == 1 || sceneModal.Status == 2)
|
||||
{
|
||||
device.Status = 0x06;
|
||||
device.Brightness = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
device.Status = (byte)sceneModal.Status;
|
||||
device.Brightness = (byte)sceneModal.Brightness;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (sceneModal.Status == 1)
|
||||
{
|
||||
device.Status = 0x02;
|
||||
device.Brightness = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
device.Status = (byte)sceneModal.Status;
|
||||
device.Brightness = (byte)sceneModal.Brightness;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
device.Status = (byte)sceneModal.Status;
|
||||
device.Brightness = (byte)sceneModal.Brightness;
|
||||
device.Temperature = (byte)sceneModal.CurrentTemp;
|
||||
device.FanSpeed = (byte)sceneModal.FanSpeed;
|
||||
device.Mode = (byte)sceneModal.Mode;
|
||||
device.Valve = (byte)sceneModal.Valve;
|
||||
device.AirExecMode = (sceneModal.Status << 14) + (sceneModal.Mode << 12) + (sceneModal.FanSpeed << 10) + (sceneModal.Valve << 8) + sceneModal.CurrentTemp;//空调执行方式和内容
|
||||
device.FloorHotExecMode = (sceneModal.Status << 12) + (sceneModal.Mode << 8) + (sceneModal.Valve << 6) + sceneModal.CurrentTemp;//地暖执行方式和内容
|
||||
device.MusicExecMode = sceneModal.Status + (sceneModal.Brightness << 12) + (sceneModal.Mode << 8);//背景音乐执行方式和内容
|
||||
}
|
||||
devices.Add(device);
|
||||
}
|
||||
DeviceControlReceiver.Send_Repeat(Key,host, devices);
|
||||
}
|
||||
}
|
||||
else if (scene.Type == SceneType.Command)
|
||||
{
|
||||
Device device = new Device();
|
||||
device.Address = scene.GroupAddress;
|
||||
device.AddressType = AddressType.GroupAddress;
|
||||
device.Status = (byte)(takeInverse ? 0x02 : 0x01);
|
||||
DeviceControlReceiver.Send_Repeat(Key, host, device);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重复发送
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="devices"></param>
|
||||
/// <param name="Key"></param>
|
||||
public void AllDeviceControl_Repeat(string Key,Host host, List<Device> devices)
|
||||
{
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
DeviceControlReceiver.Send_Repeat(Key,host, devices);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Service/Implement/ManualVisitManager.cs
Normal file
47
Service/Implement/ManualVisitManager.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class ManualVisitManager : GenericManagerBase<ManualVisit>, IManualVisitManager
|
||||
{
|
||||
public IList<ManualVisit> LoadAllByPage(out long total, int page, int rows, string order, string sort, DateTime? startDate, DateTime? endDate)
|
||||
{
|
||||
var list = CurrentRepository.LoadAll();
|
||||
if (startDate.HasValue && endDate.HasValue)
|
||||
{
|
||||
list = list.Where(r => r.CreatedDate >= startDate && r.CreatedDate <= endDate);
|
||||
}
|
||||
total = list.LongCount();
|
||||
list = list.OrderBy(sort + " " + order);
|
||||
list = list.Skip((page - 1) * rows).Take(rows);
|
||||
return list.ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 验证验证码是否正确
|
||||
/// </summary>
|
||||
/// <param name="phoneNumber"></param>
|
||||
/// <param name="validateCode"></param>
|
||||
/// <returns></returns>
|
||||
public bool ValidateCode(string phoneNumber, string validateCode)
|
||||
{
|
||||
ManualVisit item = CurrentRepository.LoadAll()
|
||||
.Where(r => r.PhoneNumber == phoneNumber && r.ValidateCode == validateCode)
|
||||
.OrderByDescending(r => r.ID)
|
||||
.FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Service/Implement/ModalTypeManager.cs
Normal file
12
Service/Implement/ModalTypeManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class ModalTypeManager : GenericManagerBase<ModalType>, IModalTypeManager
|
||||
{
|
||||
}
|
||||
}
|
||||
12
Service/Implement/ModelDetailManager.cs
Normal file
12
Service/Implement/ModelDetailManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class ModelDetailManager : GenericManagerBase<ModelDetail>, IModelDetailManager
|
||||
{
|
||||
}
|
||||
}
|
||||
55
Service/Implement/ModelManager.cs
Normal file
55
Service/Implement/ModelManager.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class ModelManager : GenericManagerBase<Model>, IModelManager
|
||||
{
|
||||
public IEnergySavingModeReceiver EnergySavingModeReceiver { get; set; }
|
||||
|
||||
public IList<Model> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IModelRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
|
||||
public Model GetByName(string name)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.Name == name).FirstOrDefault();
|
||||
}
|
||||
|
||||
public void ApplyModel(Model model, IList<Host> hosts, string user)
|
||||
{
|
||||
if(hosts.Count == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Host host in hosts)
|
||||
{
|
||||
EnergySavingModeReceiver.ApplyEnergySavingMode(model, host);
|
||||
}
|
||||
|
||||
model.ApplyDate = DateTime.Now;
|
||||
model.ApplyUser = user;
|
||||
model.Hosts = MergeHostIDs(model.Hosts, hosts.Select(r => r.ID).ToList());
|
||||
|
||||
CurrentRepository.Update(model);
|
||||
}
|
||||
|
||||
private string MergeHostIDs(string hostIDs1, IList<int> hostIDs2)
|
||||
{
|
||||
IList<int> hostIDs = new List<int>();
|
||||
|
||||
if (!String.IsNullOrEmpty(hostIDs1))
|
||||
{
|
||||
string[] ids = hostIDs1.Split(',');
|
||||
hostIDs = ids.Select(r => Convert.ToInt32(r)).ToList();
|
||||
}
|
||||
|
||||
return String.Join(",", hostIDs.Union(hostIDs2).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Service/Implement/MusicControlManager.cs
Normal file
25
Service/Implement/MusicControlManager.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class MusicControlManager : IMusicControlManager
|
||||
{
|
||||
public IMusicControlReceiver MusicControlReceiver { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发送音乐按键
|
||||
/// </summary>
|
||||
/// <param name="host">主机</param>
|
||||
/// <param name="key">按键</param>
|
||||
public void SendKey(Host host, MusicKey key)
|
||||
{
|
||||
MusicControlReceiver.SendKey(host, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Service/Implement/OverviewManager.cs
Normal file
75
Service/Implement/OverviewManager.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dao;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class OverviewManager : IOverviewManager
|
||||
{
|
||||
public IOverviewRepository CurrentRepository { get; set; }
|
||||
|
||||
//public IHostModalRecordRepository HostModalRecordRepository { get; set; }
|
||||
|
||||
public IRoomTypeModalRepository RoomTypeModalRepository { get; set; }
|
||||
|
||||
public object LoadRoomServiceState()
|
||||
{
|
||||
return CurrentRepository.LoadRoomServiceState();
|
||||
}
|
||||
|
||||
public object LoadRoomRentState(int hotelID)
|
||||
{
|
||||
return CurrentRepository.LoadRoomRentState(hotelID);
|
||||
}
|
||||
|
||||
public object LoadRoomState()
|
||||
{
|
||||
return CurrentRepository.LoadRoomState();
|
||||
}
|
||||
|
||||
public object LoadAirConditionState(int hotelID)
|
||||
{
|
||||
return CurrentRepository.LoadAirConditionState(hotelID);
|
||||
}
|
||||
|
||||
public DataTable LoadHostModalRecords(out long total, int page, int rows, string order, string sort, string roomNumber, string startTime, string endTime, DeviceType? deviceType, string modalIds, int hotelID)
|
||||
{
|
||||
CommonEntity.DataTongJi.InvokeCount("LoadHostModalRecords_");
|
||||
return CurrentRepository.LoadHostModalRecords(out total, page, rows, order, sort, roomNumber, startTime, endTime, deviceType, modalIds, hotelID);
|
||||
}
|
||||
|
||||
//定时上报异常记录
|
||||
public DataTable LoadHostAbnormalRecords(int type, int hotelID)
|
||||
{
|
||||
CommonEntity.DataTongJi.InvokeCount("LoadHostAbnormalRecords_");
|
||||
return CurrentRepository.LoadHostAbnormalRecords(type, hotelID);
|
||||
}
|
||||
|
||||
public DataSet LoadHostAbnormalRecordsAll(int type)
|
||||
{
|
||||
CommonEntity.DataTongJi.InvokeCount("LoadHostAbnormalRecordsAll_");
|
||||
//严重怀疑这里的代码有问题
|
||||
return CurrentRepository.LoadHostAbnormalRecordsAll(type);
|
||||
}
|
||||
|
||||
public object LoadDoorState(int hotelID)
|
||||
{
|
||||
return CurrentRepository.LoadDoorState(hotelID);
|
||||
}
|
||||
|
||||
|
||||
public object LoadSafeBoxState()
|
||||
{
|
||||
return CurrentRepository.LoadSafeBoxState();
|
||||
}
|
||||
|
||||
public DataTable LoadEnergyStatitics(string roomNumber, DateTimeUnit dateUnit, string startDate, string endDate, DeviceType? deviceType, string modalIds)
|
||||
{
|
||||
return CurrentRepository.LoadEnergyStatitics(roomNumber, dateUnit, startDate, endDate, deviceType, modalIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Service/Implement/PowerSupplyControlManager.cs
Normal file
25
Service/Implement/PowerSupplyControlManager.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class PowerSupplyControlManager : IPowerSupplyControlManager
|
||||
{
|
||||
public IPowerSupplyControlReceiver PowerSupplyControlReceiver { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发送主机电源控制
|
||||
/// </summary>
|
||||
/// <param name="host">主机</param>
|
||||
/// <param name="ctrl">电源控制</param>
|
||||
public void SendCtrl(Host host, PowerSupplyCtrl ctrl)
|
||||
{
|
||||
PowerSupplyControlReceiver.SendCtrl(host, ctrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Service/Implement/RoomCardManager.cs
Normal file
21
Service/Implement/RoomCardManager.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomCardManager : GenericManagerBase<RoomCard>, IRoomCardManager
|
||||
{
|
||||
public IList<RoomCard> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((Dao.IRoomCardRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
|
||||
public RoomCard GetByCarNumber(string cardNumber, int hotelID)
|
||||
{
|
||||
return ((Dao.IRoomCardRepository)(this.CurrentRepository)).GetByCarNumber(cardNumber, hotelID); //.LoadAll().FirstOrDefault(r => r.CardNumber == cardNumber && r.HotelID == hotelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Service/Implement/RoomCardTypeManager.cs
Normal file
12
Service/Implement/RoomCardTypeManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomCardTypeManager : GenericManagerBase<RoomCardType>, IRoomCardTypeManager
|
||||
{
|
||||
}
|
||||
}
|
||||
16
Service/Implement/RoomModalManager.cs
Normal file
16
Service/Implement/RoomModalManager.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomModalManager : GenericManagerBase<RoomModal>, IRoomModalManager
|
||||
{
|
||||
public IList<RoomModal> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IRoomModalRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Service/Implement/RoomNobodyLogManager.cs
Normal file
23
Service/Implement/RoomNobodyLogManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomNobodyLogManager : GenericManagerBase<RoomNobodyHowToLog>, IRoomNoBodyLogMananger
|
||||
{
|
||||
public new void Save(RoomNobodyHowToLog test)
|
||||
{
|
||||
((Dao.IRoomNoBodyHowToLogRepository)(this.CurrentRepository)).Save(test);
|
||||
}
|
||||
|
||||
public new void UpdateOrSave(RoomNobodyHowToLog n)
|
||||
{
|
||||
((Dao.IRoomNoBodyHowToLogRepository)(this.CurrentRepository)).SaveOrUpdate(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Service/Implement/RoomNobodyManager.cs
Normal file
28
Service/Implement/RoomNobodyManager.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomNobodyManager : GenericManagerBase<RoomNobodyHowTo>, IRoomNoBodyMananger
|
||||
{
|
||||
public int Add(RoomNobodyHowTo test)
|
||||
{
|
||||
return ((Dao.IRoomNoBodyHowToRepository)(this.CurrentRepository)).Add(test);
|
||||
}
|
||||
|
||||
public new void Update(RoomNobodyHowTo n)
|
||||
{
|
||||
((Dao.IRoomNoBodyHowToRepository)(this.CurrentRepository)).Update(n);
|
||||
}
|
||||
|
||||
public new void UpdateOrSave(RoomNobodyHowTo n)
|
||||
{
|
||||
((Dao.IRoomNoBodyHowToRepository)(this.CurrentRepository)).SaveOrUpdate(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
210
Service/Implement/RoomServiceManager.cs
Normal file
210
Service/Implement/RoomServiceManager.cs
Normal file
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Dao;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
using RCUHost.Protocols;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomServiceManager : GenericManagerBase<RoomService>, IRoomServiceManager
|
||||
{
|
||||
#region Fields
|
||||
|
||||
public ISysUserRepository SysUserRepository { get; set; }
|
||||
public IGroupRepository GroupRepository { get; set; }
|
||||
public IHostRepository HostRepository { get; set; }
|
||||
public IAlarmSettingRepository AlarmSettingRepository { get; set; }
|
||||
public IRoomTypeModalRepository RoomTypeModalRepository { get; set; }
|
||||
public IServiceReceiver ServiceReceiver { get; set; }
|
||||
public IHostFaultsRepository HostFaultsRepository { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public IList<RoomService> LoadAllByPage(out long total, int page, int rows, string order, string sort, string roomNumber, string startTime, string endTime, string[] services)
|
||||
{
|
||||
return ((Dao.IRoomServiceRepository)CurrentRepository).LoadAllByPage(out total, page, rows, order, sort, roomNumber, startTime, endTime, services);
|
||||
}
|
||||
|
||||
#region 服务
|
||||
|
||||
/// <summary>
|
||||
/// 加载客房当前服务
|
||||
/// </summary>
|
||||
/// <param name="hostId"></param>
|
||||
/// <returns></returns>
|
||||
public IList<RoomService> LoadCurrentRoomServices(int hostId)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.HostID == hostId && r.AlarmType == 'B' && r.Status).ToList();
|
||||
}
|
||||
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(RoomServiceManager));
|
||||
public DataTable LoadCurrentRoomServicesCount(int hotelID, string user)
|
||||
{
|
||||
CommonEntity.DataTongJi.InvokeCount("QueryCurrentRoomServiceStatistics_");
|
||||
SysUsers sysUser = SysUserRepository.Get(user);
|
||||
if (sysUser == null || sysUser.Group == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//logger.Error("hotelID is: "+hotelID+" groupid: "+sysUser.Group.ID+" "+DeviceType.ServiceInfo.ToString());
|
||||
if (sysUser.SysHotelGroup == null)
|
||||
{
|
||||
|
||||
return ((Dao.IRoomServiceRepository)CurrentRepository).LoadCurrentRoomServicesOrAbnormitiesCount(hotelID, sysUser.Group.ID, DeviceType.ServiceInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((Dao.IRoomServiceRepository)CurrentRepository).LoadCurrentRoomServicesOrAbnormitiesCount(hotelID, 0, DeviceType.ServiceInfo);//组用户获取本酒店所有
|
||||
}
|
||||
}
|
||||
|
||||
//public DataTable LoadCurrentRoomAbnormitiesCount(int hotelID, string user)
|
||||
//{
|
||||
// return ((Dao.IRoomServiceRepository)CurrentRepository).LoadCurrentRoomServicesOrAbnormitiesCount(hotelID, DeviceType.ServiceInfo);
|
||||
//}
|
||||
|
||||
public IList<object[]> LoadCurrentRoomServices(int hotelID, string user)
|
||||
{
|
||||
SysUsers sysUser = SysUserRepository.Get(user);
|
||||
if (sysUser == null || sysUser.Group == null)
|
||||
{
|
||||
return new List<object[]>();
|
||||
}
|
||||
//var sysUserHotel = SysUserHotelRepository.Get(sysUser.ID, hotelID);//获取当前用户所在酒店
|
||||
var currentGroup = GroupRepository.LoadAll().FirstOrDefault(r => r.HotelID == hotelID);//Get(sysUserHotel != null ? sysUserHotel.GroupID : 0);//获取当前用户所在酒店的楼层
|
||||
|
||||
IList<int> groupIDs = GroupRepository.GetGroupList(currentGroup).Select(r => r.ID).ToArray();
|
||||
if (groupIDs.Count == 0)
|
||||
{
|
||||
return new List<object[]>();
|
||||
}
|
||||
|
||||
return ((Dao.IRoomServiceRepository)CurrentRepository).LoadCurrentRoomServices(hotelID, groupIDs);
|
||||
}
|
||||
|
||||
public IList<object[]> LoadCurrentHostFaultStatistics(int hotelID, string user, int type)
|
||||
{
|
||||
SysUsers sysUser = SysUserRepository.Get(user);
|
||||
if (sysUser == null || sysUser.Group == null)
|
||||
{
|
||||
return new List<object[]>();
|
||||
}
|
||||
//var sysUserHotel = SysUserHotelRepository.Get(sysUser.ID, hotelID);//获取当前用户所在酒店
|
||||
var currentGroup = GroupRepository.LoadAll().FirstOrDefault(r => r.Parent == null && r.HotelID == hotelID);//Get(sysUserHotel != null ? sysUserHotel.GroupID : 0);//获取当前用户所在酒店的楼层
|
||||
IList<int> groupIDs = GroupRepository.GetGroupList(currentGroup).Select(r => r.ID).ToArray();
|
||||
if (groupIDs.Count == 0)
|
||||
{
|
||||
return new List<object[]>();
|
||||
}
|
||||
return HostFaultsRepository.LoadCurrentHostFaultStatistics(hotelID, groupIDs, type);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 异常
|
||||
|
||||
/// <summary>
|
||||
/// 加载客房当前异常
|
||||
/// </summary>
|
||||
/// <param name="hostId"></param>
|
||||
/// <returns></returns>
|
||||
public IList<RoomService> LoadCurrentRoomAbnormities(int hostId)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.HostID == hostId && r.AlarmType == 'C' && r.Status).ToList();
|
||||
}
|
||||
|
||||
public IList<object[]> LoadCurrentRoomAbnormities(int hotelID, string user)
|
||||
{
|
||||
SysUsers sysUser = SysUserRepository.Get(user);
|
||||
if (sysUser == null || sysUser.Group == null)
|
||||
{
|
||||
return new List<object[]>();
|
||||
}
|
||||
|
||||
IList<int> groupIDs = GroupRepository.GetGroupList(sysUser.Group).Select(r => r.ID).ToArray();
|
||||
if (groupIDs.Count == 0)
|
||||
{
|
||||
return new List<object[]>();
|
||||
}
|
||||
|
||||
return ((Dao.IRoomServiceRepository)CurrentRepository).LoadCurrentRoomAbnormities(hotelID, groupIDs);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetService(Host host, string alarmCode, int status)
|
||||
{
|
||||
var serviceSetting = AlarmSettingRepository.Get(host.SysHotel.ID, 'B', alarmCode);
|
||||
|
||||
if (serviceSetting != null)
|
||||
{
|
||||
ServiceReceiver.SetService(host, serviceSetting.ModalTypeID, status);
|
||||
|
||||
var service = ((Dao.IRoomServiceRepository)CurrentRepository).Get(host.ID, alarmCode);
|
||||
if (service != null)
|
||||
{
|
||||
service.Status = (status == 0 ? false : true);
|
||||
service.StartTime = DateTime.Now;
|
||||
CurrentRepository.Update(service);
|
||||
}
|
||||
|
||||
//设置连通房服务
|
||||
//if (host.IsConnectingRoom)
|
||||
//{
|
||||
// var hostList = HostRepository.GetConnectRoomHosts(host);
|
||||
|
||||
// foreach (var item in hostList)
|
||||
// {
|
||||
// ServiceReceiver.SetService(item, serviceSetting.ModalTypeID, status);
|
||||
|
||||
// service = ((Dao.IRoomServiceRepository)CurrentRepository).Get(host.ID, alarmCode);
|
||||
// if (service != null)
|
||||
// {
|
||||
// service.Status = (status == 0 ? false : true);
|
||||
// CurrentRepository.Update(service);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除服务
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="service"></param>
|
||||
/// <param name="user"></param>
|
||||
public void ClearRoomService(Host host, RoomService service, string user)
|
||||
{
|
||||
var serviceSetting = AlarmSettingRepository.LoadAll().FirstOrDefault(r => r.Code == service.AlarmCode);
|
||||
|
||||
if (serviceSetting != null)
|
||||
{
|
||||
ServiceReceiver.SetService(host, serviceSetting.ModalTypeID, 0);
|
||||
|
||||
//清除连通房服务
|
||||
//if (host.IsConnectingRoom)
|
||||
//{
|
||||
// var hostList = HostRepository.GetConnectRoomHosts(host);
|
||||
|
||||
// foreach (var item in hostList)
|
||||
// {
|
||||
// ServiceReceiver.SetService(item, serviceSetting.ModalTypeID, 0);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
service.Status = false;
|
||||
CurrentRepository.Update(service);
|
||||
}
|
||||
|
||||
public RoomService Get(int hostID, string alarmCode)
|
||||
{
|
||||
return ((Dao.IRoomServiceRepository)CurrentRepository).Get(hostID, alarmCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Service/Implement/RoomServiceRecordManager.cs
Normal file
16
Service/Implement/RoomServiceRecordManager.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomServiceRecordManager : GenericManagerBase<RoomServiceRecord>, IRoomServiceRecordManager
|
||||
{
|
||||
public IList<RoomServiceRecord> LoadAllByPage(out long total, int page, int rows, string order, string sort, string roomNumber, string startTime, string endTime, string[] services)
|
||||
{
|
||||
return ((Dao.IRoomServiceRecordRepository)CurrentRepository).LoadAllByPage(out total, page, rows, order, sort, roomNumber, startTime, endTime, services);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Service/Implement/RoomStatusAidManager.cs
Normal file
12
Service/Implement/RoomStatusAidManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomStatusAidManager : GenericManagerBase<RoomStatusAid>, IRoomStatusAidManager
|
||||
{
|
||||
}
|
||||
}
|
||||
12
Service/Implement/RoomStatusManager.cs
Normal file
12
Service/Implement/RoomStatusManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomStatusManager : GenericManagerBase<RoomStatus>, IRoomStatusManager
|
||||
{
|
||||
}
|
||||
}
|
||||
21
Service/Implement/RoomTypeAirManager.cs
Normal file
21
Service/Implement/RoomTypeAirManager.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeAirManager : GenericManagerBase<RoomTypeAir>, IRoomTypeAirManager
|
||||
{
|
||||
public IList<RoomTypeAir> LoadAll(RoomType roomType)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType == roomType).ToList();
|
||||
}
|
||||
|
||||
public RoomTypeAir Load(RoomType roomType, ModalType modalType)
|
||||
{
|
||||
return CurrentRepository.LoadAll().OrderBy(r => r.Sort).FirstOrDefault(r => r.RoomType == roomType && r.ModalType == modalType);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Service/Implement/RoomTypeChannelsManager.cs
Normal file
22
Service/Implement/RoomTypeChannelsManager.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeChannelsManager : GenericManagerBase<RoomTypeChannels>, IRoomTypeChannelsManager
|
||||
{
|
||||
public IList<RoomTypeChannels> LoadAllByPage(out long total, int page, int rows, string order, string sort, int roomTypeId)
|
||||
{
|
||||
return ((Dao.IRoomTypeChannelsRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, roomTypeId).ToList();
|
||||
}
|
||||
|
||||
public IList<RoomTypeChannels> LoadAll(int roomTypeId)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType.ID == roomTypeId).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
260
Service/Implement/RoomTypeManager.cs
Normal file
260
Service/Implement/RoomTypeManager.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeManager : GenericManagerBase<RoomType>, IRoomTypeManager
|
||||
{
|
||||
public IRoomTypeModalRepository RoomTypeModalRepository { get; set; }
|
||||
public IWXMenusRepository WXMenusRepository { get; set; }
|
||||
public IRoomTypeWXMenusRepository RoomTypeWXMenusRepository { get; set; }
|
||||
public IRoomTypeSceneRepository RoomTypeSceneRepository { get; set; }
|
||||
public IRoomTypeSceneModalRepository RoomTypeSceneModalRepository { get; set; }
|
||||
public IRoomTypeChannelsRepository RoomTypeChannelsRepository { get; set; }
|
||||
public IRoomTypeProgramFilesRepository RoomTypeProgramFilesRepository { get; set; }
|
||||
|
||||
public IList<RoomType> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((IRoomTypeRepository)(CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
|
||||
public RoomType GetByCode(string code, int hotelID)
|
||||
{
|
||||
return ((IRoomTypeRepository)(CurrentRepository)).LoadAll().Where(r => r.Code == code && r.HotelID == hotelID && r.IsDeleted != true).FirstOrDefault();
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存微信控制菜单
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
private void SaveRoomTypeWXMenus(RoomType entity)
|
||||
{
|
||||
var lists = WXMenusRepository.LoadAll();
|
||||
foreach (var list in lists)
|
||||
{
|
||||
RoomTypeWXMenusRepository.Save(new RoomTypeWXMenus
|
||||
{
|
||||
RoomType = entity,
|
||||
Code = list.Code,
|
||||
Name = list.Name,
|
||||
EName = list.EName,
|
||||
TWName = list.TWName,
|
||||
Class = list.Class,
|
||||
Sort = list.Sort,
|
||||
ActiveIndicator = true
|
||||
});
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存房型
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public override object Save(RoomType entity)
|
||||
{
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
object result = base.Save(entity);
|
||||
SaveRoomTypeWXMenus(entity);
|
||||
return result;
|
||||
}
|
||||
public override void Update(RoomType entity)
|
||||
{
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
base.Update(entity);
|
||||
}
|
||||
|
||||
public override void SaveOrUpdate(RoomType entity)
|
||||
{
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
base.SaveOrUpdate(entity);
|
||||
}
|
||||
/// <summary>
|
||||
/// 复制房型
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public bool Copy(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var roomType = ((IRoomTypeRepository)(CurrentRepository)).Get(id);
|
||||
if (roomType != null)
|
||||
{
|
||||
List<RoomType> list = ((IRoomTypeRepository)(CurrentRepository)).LoadAll().Where(r => r.HotelID == roomType.HotelID).ToList();
|
||||
string newCode = (Convert.ToInt32(list[list.Count - 1].Code) + 1).ToString();
|
||||
//复制房型
|
||||
RoomType newRoomType = new RoomType();
|
||||
newRoomType.ID = 0;
|
||||
newRoomType.HotelID = roomType.HotelID;
|
||||
newRoomType.Code = newCode;
|
||||
newRoomType.Name = roomType.Name + "-复制";
|
||||
newRoomType.HostName = newRoomType.Name;
|
||||
newRoomType.Default = false;
|
||||
newRoomType.Last_Modified_Time = DateTime.Now;
|
||||
base.Save(newRoomType);
|
||||
//复制微信菜单
|
||||
var roomTypeWXMenus = RoomTypeWXMenusRepository.LoadAll(id);
|
||||
foreach (RoomTypeWXMenus rtm in roomTypeWXMenus)
|
||||
{
|
||||
RoomTypeWXMenus newRoomTypeWXMenus = new RoomTypeWXMenus();
|
||||
newRoomTypeWXMenus.ID = 0;
|
||||
newRoomTypeWXMenus.RoomType = newRoomType;
|
||||
newRoomTypeWXMenus.Code = rtm.Code;
|
||||
newRoomTypeWXMenus.Name = rtm.Name;
|
||||
newRoomTypeWXMenus.EName = rtm.EName;
|
||||
newRoomTypeWXMenus.TWName = rtm.TWName;
|
||||
newRoomTypeWXMenus.Class = rtm.Class;
|
||||
newRoomTypeWXMenus.Sort = rtm.Sort;
|
||||
newRoomTypeWXMenus.ActiveIndicator = rtm.ActiveIndicator;
|
||||
newRoomTypeWXMenus.TakePower = rtm.TakePower;
|
||||
RoomTypeWXMenusRepository.Save(newRoomTypeWXMenus);
|
||||
}
|
||||
//复制房型回路
|
||||
var roomTypeModels = RoomTypeModalRepository.LoadAll().Where(r => r.RoomType == roomType).ToList();
|
||||
foreach (RoomTypeModal rtm in roomTypeModels)
|
||||
{
|
||||
RoomTypeModal newRoomTypeModal = new RoomTypeModal();
|
||||
newRoomTypeModal.ID = 0;
|
||||
newRoomTypeModal.RoomType = newRoomType;
|
||||
newRoomTypeModal.ModalAddress = rtm.ModalAddress;
|
||||
newRoomTypeModal.Outlet = rtm.Outlet;
|
||||
newRoomTypeModal.Name = rtm.Name;
|
||||
newRoomTypeModal.EnglishName = rtm.EnglishName;
|
||||
newRoomTypeModal.Power = rtm.Power;
|
||||
newRoomTypeModal.Type = rtm.Type;
|
||||
newRoomTypeModal.Subtype = rtm.Subtype;
|
||||
newRoomTypeModal.Default = rtm.Default;
|
||||
newRoomTypeModal.Sort = rtm.Sort;
|
||||
newRoomTypeModal.AppApply = rtm.AppApply;
|
||||
newRoomTypeModal.Color = rtm.Color;
|
||||
newRoomTypeModal.ActiveIndicator = rtm.ActiveIndicator;
|
||||
newRoomTypeModal.WXActiveIndicator = rtm.WXActiveIndicator;
|
||||
newRoomTypeModal.LowPower = rtm.LowPower;
|
||||
newRoomTypeModal.TWName = rtm.TWName;
|
||||
newRoomTypeModal.OfflineDisplay = rtm.OfflineDisplay;
|
||||
newRoomTypeModal.LowPowerDisplay = rtm.LowPowerDisplay;
|
||||
newRoomTypeModal.Beep = rtm.Beep;
|
||||
newRoomTypeModal.Abnormal = rtm.Abnormal;
|
||||
RoomTypeModalRepository.Save(newRoomTypeModal);
|
||||
}
|
||||
//复制房型场景
|
||||
var roomTypeScenes = RoomTypeSceneRepository.LoadAll(roomType);
|
||||
foreach (RoomTypeScene rts in roomTypeScenes)
|
||||
{
|
||||
RoomTypeScene newRoomTypeScene = new RoomTypeScene();
|
||||
newRoomTypeScene.ID = 0;
|
||||
newRoomTypeScene.RoomType = newRoomType;
|
||||
newRoomTypeScene.Type = rts.Type;
|
||||
newRoomTypeScene.Name = rts.Name;
|
||||
newRoomTypeScene.AppApply = rts.AppApply;
|
||||
newRoomTypeScene.EnglishName = rts.EnglishName;
|
||||
newRoomTypeScene.TWName = rts.TWName;
|
||||
newRoomTypeScene.GroupAddress = rts.GroupAddress;
|
||||
newRoomTypeScene.Icon = rts.Icon;
|
||||
newRoomTypeScene.Sort = rts.Sort;
|
||||
newRoomTypeScene.HotelID = rts.HotelID;
|
||||
newRoomTypeScene.ActiveIndicator = rts.ActiveIndicator;
|
||||
newRoomTypeScene.TakeInverse = rts.TakeInverse;
|
||||
newRoomTypeScene.AliasName = rts.AliasName;
|
||||
RoomTypeSceneRepository.Save(newRoomTypeScene);
|
||||
//复制房型场景回路
|
||||
var roomTypeSceneModals = RoomTypeSceneModalRepository.LoadAll(rts);
|
||||
foreach (RoomTypeSceneModal rtsm in roomTypeSceneModals)
|
||||
{
|
||||
RoomTypeSceneModal newRoomTypeSceneModal = new RoomTypeSceneModal();
|
||||
newRoomTypeSceneModal.ID = 0;
|
||||
newRoomTypeSceneModal.Scene = newRoomTypeScene;
|
||||
newRoomTypeSceneModal.Modal = RoomTypeModalRepository.LoadAll().Where(r => r.RoomType == newRoomType && r.ModalAddress == rtsm.Modal.ModalAddress).FirstOrDefault();
|
||||
newRoomTypeSceneModal.Status = rtsm.Status;
|
||||
newRoomTypeSceneModal.Brightness = rtsm.Brightness;
|
||||
newRoomTypeSceneModal.CurrentTemp = rtsm.CurrentTemp;
|
||||
newRoomTypeSceneModal.SettingTemp = rtsm.SettingTemp;
|
||||
newRoomTypeSceneModal.FanSpeed = rtsm.FanSpeed;
|
||||
newRoomTypeSceneModal.Mode = rtsm.Mode;
|
||||
newRoomTypeSceneModal.Valve = rtsm.Valve;
|
||||
RoomTypeSceneModalRepository.Save(newRoomTypeSceneModal);
|
||||
}
|
||||
}
|
||||
//复制房型电视频道
|
||||
var roomTypeChannels = RoomTypeChannelsRepository.LoadAll().Where(r => r.RoomType == roomType).ToList();
|
||||
foreach (RoomTypeChannels rtc in roomTypeChannels)
|
||||
{
|
||||
RoomTypeChannels newRoomTypeChannels = new RoomTypeChannels();
|
||||
newRoomTypeChannels.ID = 0;
|
||||
newRoomTypeChannels.RoomType = newRoomType;
|
||||
newRoomTypeChannels.Code = rtc.Code;
|
||||
newRoomTypeChannels.Name = rtc.Name;
|
||||
newRoomTypeChannels.Sort = rtc.Sort;
|
||||
RoomTypeChannelsRepository.Save(newRoomTypeChannels);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除房型
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
public override void Delete(object id)
|
||||
{
|
||||
//删除场景
|
||||
var roomTypeScenes = RoomTypeSceneRepository.LoadAll().Where(r => r.RoomType.ID == Convert.ToInt16(id)).ToList();
|
||||
foreach (RoomTypeScene rts in roomTypeScenes)
|
||||
{
|
||||
var roomTypeSceneModals = RoomTypeSceneModalRepository.LoadAll(rts);
|
||||
foreach (RoomTypeSceneModal rtsm in roomTypeSceneModals)
|
||||
{
|
||||
RoomTypeSceneModalRepository.Delete(rtsm.ID);
|
||||
}
|
||||
RoomTypeSceneRepository.Delete(rts.ID);
|
||||
}
|
||||
//删除微信菜单
|
||||
RoomTypeWXMenusRepository.DeleteByRoomTypeID(Convert.ToInt16(id));
|
||||
//删除电视频道
|
||||
RoomTypeChannelsRepository.DeleteByRoomTypeID(Convert.ToInt16(id));
|
||||
//删除程序文件
|
||||
//RoomTypeProgramFilesRepository.DeleteByRoomTypeID(Convert.ToInt16(id));
|
||||
//删除回路
|
||||
RoomTypeModalRepository.DeleteByRoomTypeID(Convert.ToInt16(id), -1);
|
||||
((IRoomTypeRepository)(this.CurrentRepository)).Delete(id);
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除房型(批量删除)
|
||||
/// </summary>
|
||||
/// <param name="idList"></param>
|
||||
public override void Delete(IList<object> idList)
|
||||
{
|
||||
foreach (int id in idList)
|
||||
{
|
||||
//删除场景
|
||||
IList<RoomTypeScene> roomTypeScenes = RoomTypeSceneRepository.LoadAll().Where(r => r.RoomType.ID == id).ToList();
|
||||
foreach (RoomTypeScene rts in roomTypeScenes)
|
||||
{
|
||||
IList<RoomTypeSceneModal> roomTypeSceneModals = RoomTypeSceneModalRepository.LoadAll(rts);
|
||||
foreach (RoomTypeSceneModal rtsm in roomTypeSceneModals)
|
||||
{
|
||||
RoomTypeSceneModalRepository.Delete(rtsm.ID);
|
||||
}
|
||||
RoomTypeSceneRepository.Delete(rts.ID);
|
||||
}
|
||||
//删除微信菜单
|
||||
RoomTypeWXMenusRepository.DeleteByRoomTypeID(id);
|
||||
//删除电视频道
|
||||
RoomTypeChannelsRepository.DeleteByRoomTypeID(id);
|
||||
//删除程序文件
|
||||
//RoomTypeProgramFilesRepository.DeleteByRoomTypeID(id);
|
||||
//删除回路
|
||||
RoomTypeModalRepository.DeleteByRoomTypeID(id, -1);
|
||||
}
|
||||
((IRoomTypeRepository)(this.CurrentRepository)).Delete(idList);
|
||||
}
|
||||
}
|
||||
}
|
||||
69
Service/Implement/RoomTypeModalManager.cs
Normal file
69
Service/Implement/RoomTypeModalManager.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeModalManager : GenericManagerBase<RoomTypeModal>, IRoomTypeModalManager
|
||||
{
|
||||
public IList<RoomTypeModal> LoadAllByPage(out long total, int page, int rows, string order, string sort, int roomTypeId)
|
||||
{
|
||||
return ((Dao.IRoomTypeModalRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, roomTypeId).ToList();
|
||||
}
|
||||
|
||||
public IList<RoomTypeModal> LoadAll(int? roomTypeId, int sourceType = -1)
|
||||
{
|
||||
if (sourceType == -1)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType != null && r.RoomType.ID == roomTypeId).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType != null && r.RoomType.ID == roomTypeId && r.SourceType == sourceType).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public IList<RoomTypeModal> LoadAll(RoomType roomType, int sourceType)
|
||||
{
|
||||
if (sourceType == -1)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType == roomType).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType == roomType && r.SourceType == sourceType).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public IList<RoomTypeModal> LoadAll(RoomType roomType, DeviceType deviceType, int sourceType)
|
||||
{
|
||||
if (sourceType == -1)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType == roomType && r.Type == deviceType).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.RoomType == roomType && r.Type == deviceType && r.SourceType == sourceType).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(RoomTypeModal roomTypeModal)
|
||||
{
|
||||
this.Delete(roomTypeModal.ID);
|
||||
}
|
||||
|
||||
public void DeleteByRoomTypeID(int roomTypeID, int sourceType)
|
||||
{
|
||||
((Dao.IRoomTypeModalRepository)(this.CurrentRepository)).DeleteByRoomTypeID(roomTypeID, sourceType);
|
||||
}
|
||||
|
||||
|
||||
public void DeleteByAddress(int roomTypeID, string address)
|
||||
{
|
||||
((Dao.IRoomTypeModalRepository)(this.CurrentRepository)).DeleteByAddress(roomTypeID, address);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Service/Implement/RoomTypeProgramFilesManager.cs
Normal file
16
Service/Implement/RoomTypeProgramFilesManager.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeProgramFilesManager : GenericManagerBase<RoomTypeProgramFiles>, IRoomTypeProgramFilesManager
|
||||
{
|
||||
public IList<RoomTypeProgramFiles> LoadAllByPage(out long total, int page, int rows, string order, string sort, int roomTypeID)
|
||||
{
|
||||
return ((Dao.IRoomTypeProgramFilesRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, roomTypeID).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
44
Service/Implement/RoomTypeSceneManager.cs
Normal file
44
Service/Implement/RoomTypeSceneManager.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeSceneManager : GenericManagerBase<RoomTypeScene>, IRoomTypeSceneManager
|
||||
{
|
||||
public IRoomTypeModalRepository RoomTypeModalRepository { get; set; }
|
||||
|
||||
public IList<RoomTypeScene> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID)
|
||||
{
|
||||
return ((IRoomTypeSceneRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID).ToList();
|
||||
}
|
||||
|
||||
public IList<RoomTypeScene> LoadAllByPage(out long total, int page, int rows, string order, string sort, int hotelID, int roomTypeId)
|
||||
{
|
||||
return ((IRoomTypeSceneRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, hotelID, roomTypeId).ToList();
|
||||
}
|
||||
|
||||
public IList<RoomTypeModal> LoadLights(RoomType roomType)
|
||||
{
|
||||
return RoomTypeModalRepository.LoadAll().Where(r => r.RoomType == roomType).ToList();// && (r.Type == DeviceType.Light || r.Type == DeviceType.LightDimmer)).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="roomType"></param>
|
||||
/// <param name="name">中文名,英文名和别名</param>
|
||||
/// <returns></returns>
|
||||
public RoomTypeScene Get(RoomType roomType, string name)
|
||||
{
|
||||
return CurrentRepository.LoadAll().FirstOrDefault(r => r.RoomType == roomType && (r.Name.Contains(name) || r.EnglishName.Contains(name) || r.AliasName.Contains(name)));
|
||||
}
|
||||
|
||||
public RoomTypeScene Get(RoomType roomType, int sceneID)
|
||||
{
|
||||
return CurrentRepository.LoadAll().FirstOrDefault(r => r.RoomType == roomType && r.ID == sceneID);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Service/Implement/RoomTypeSceneModalManager.cs
Normal file
29
Service/Implement/RoomTypeSceneModalManager.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeSceneModalManager : GenericManagerBase<RoomTypeSceneModal>, IRoomTypeSceneModalManager
|
||||
{
|
||||
public IList<RoomTypeSceneModal> LoadAll(RoomTypeScene scene)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.Scene != null && r.Scene == scene).ToList();
|
||||
}
|
||||
|
||||
public void DeleteByModal(RoomTypeModal modal)
|
||||
{
|
||||
if(modal != null)
|
||||
{
|
||||
var list = CurrentRepository.LoadAll().Where(r => r.Modal == modal);
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
CurrentRepository.Delete(item.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Service/Implement/RoomTypeWXMenusManager.cs
Normal file
23
Service/Implement/RoomTypeWXMenusManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class RoomTypeWXMenusManager : GenericManagerBase<RoomTypeWXMenus>, IRoomTypeWXMenusManager
|
||||
{
|
||||
public IList<RoomTypeWXMenus> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IRoomTypeWXMenusRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
|
||||
public IList<RoomTypeWXMenus> LoadAll(int roomTypeID)
|
||||
{
|
||||
return ((Dao.IRoomTypeWXMenusRepository)(this.CurrentRepository)).LoadAll(roomTypeID).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
65
Service/Implement/SearchHostManager.cs
Normal file
65
Service/Implement/SearchHostManager.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SearchHostManager : ISearchHostManager
|
||||
{
|
||||
public RCUHost.IHostSearchReceiver HostSearchReceiver { get; set; }
|
||||
|
||||
public Dao.IHostRepository HostRepository { get; set; }
|
||||
|
||||
public void Start(SearchHostResultHandler handler)
|
||||
{
|
||||
HostSearchReceiver.Start(handler);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
HostSearchReceiver.Start();
|
||||
}
|
||||
|
||||
public string User
|
||||
{
|
||||
get
|
||||
{
|
||||
return HostSearchReceiver.User;
|
||||
}
|
||||
set
|
||||
{
|
||||
HostSearchReceiver.User = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Searching
|
||||
{
|
||||
get { return HostSearchReceiver.Searching; }
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
HostSearchReceiver.Stop();
|
||||
}
|
||||
|
||||
public bool UpdateHost(SearchHost host, int hotelID)
|
||||
{
|
||||
var hostRepository = HostRepository.GetByMAC(host.MAC, hotelID);
|
||||
if (hostRepository != null)
|
||||
{
|
||||
hostRepository.SubnetMask = host.SubnetMask;
|
||||
hostRepository.Gateway = host.Gateway;
|
||||
hostRepository.Port = host.Port;
|
||||
hostRepository.Version = host.Version;
|
||||
hostRepository.ConfigVersion = host.ConfigVersion;
|
||||
|
||||
HostRepository.Update(hostRepository);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Service/Implement/SysActiveUserManager.cs
Normal file
16
Service/Implement/SysActiveUserManager.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysActiveUserManager : GenericManagerBase<SysActiveUser>, ISysActiveUserManager
|
||||
{
|
||||
public SysActiveUser Get(string account, string loginIp)
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => r.Account == account && r.LoginIP == loginIp).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Service/Implement/SysAuthorityManager.cs
Normal file
21
Service/Implement/SysAuthorityManager.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysAuthorityManager : GenericManagerBase<SysAuthority>, ISysAuthorityManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取权限
|
||||
/// </summary>
|
||||
/// <param name="parentId">父结点权限ID</param>
|
||||
/// <returns></returns>
|
||||
public IList<SysAuthority> GetAuthorities(int parentId)
|
||||
{
|
||||
return this.LoadAll().Where(r => r.ParentID == parentId).OrderBy(i => i.Sort).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
199
Service/Implement/SysHotelGroupManager.cs
Normal file
199
Service/Implement/SysHotelGroupManager.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dao;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysHotelGroupManager : GenericManagerBase<SysHotelGroup>, ISysHotelGroupManager
|
||||
{
|
||||
public ISysHotelRepository SysHotelRepository { get; set; }
|
||||
public ISysRoleRepository SysRoleRepository { get; set; }
|
||||
public ISysUserRepository SysUserRepository { get; set; }
|
||||
|
||||
public override object Save(SysHotelGroup entity)
|
||||
{
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
return base.Save(entity);
|
||||
}
|
||||
|
||||
public override void Update(SysHotelGroup entity)
|
||||
{
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
base.Update(entity);
|
||||
}
|
||||
|
||||
public override void SaveOrUpdate(SysHotelGroup entity)
|
||||
{
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
base.SaveOrUpdate(entity);
|
||||
}
|
||||
|
||||
public IList<SysHotelGroup> GetGroupList(SysHotelGroup group)
|
||||
{
|
||||
return ((ISysHotelGroupRepository)CurrentRepository).GetGroupList(group);
|
||||
}
|
||||
|
||||
public override void Delete(object id)
|
||||
{
|
||||
SysHotelGroup group = CurrentRepository.Get(id);
|
||||
if (group != null)
|
||||
{
|
||||
if (SysHotelRepository.GetByGroup(group).Count() > 0)
|
||||
{
|
||||
throw new ApplicationException("分组【" + group.Name + "】已分配有酒店,不能删除!");
|
||||
}
|
||||
if (SysRoleRepository.LoadAll().Where(r => r.SysHotelGroup == group).ToList().Count > 0)
|
||||
{
|
||||
throw new ApplicationException("分组【" + group.Name + "】已分配有组角色,不能删除!");
|
||||
}
|
||||
if (SysUserRepository.LoadAll().Where(r => r.SysHotelGroup == group).ToList().Count > 0)
|
||||
{
|
||||
throw new ApplicationException("分组【" + group.Name + "】已分配有组用户,不能删除!");
|
||||
}
|
||||
}
|
||||
((ISysHotelGroupRepository)CurrentRepository).Delete(id);
|
||||
}
|
||||
|
||||
public IList<object> CreateGroupTree(SysHotelGroup group)
|
||||
{
|
||||
IList<object> groupTree = new List<object>();
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon", children = BuildGroupTree(CurrentRepository.LoadAll().ToList(), group) });
|
||||
return groupTree;
|
||||
}
|
||||
|
||||
public object CreateGroupTree2(SysHotelGroup group)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var groupMenu = ((ISysHotelGroupRepository)CurrentRepository).GetGroupMenu(group.ID);
|
||||
return BuildGroupTree(groupMenu);
|
||||
}
|
||||
|
||||
public IList<object> CreateGroupTreeWithHotel(SysHotelGroup group, IList<SysHotel> checkedHotels)
|
||||
{
|
||||
var currentSysHotelGroups = CurrentRepository.LoadAll().ToList();
|
||||
return BuildGroupTreeWithHotel(currentSysHotelGroups, group, checkedHotels);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按层级构造分组名称
|
||||
/// 例如:
|
||||
/// BLW-1栋-1层
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <returns></returns>
|
||||
public string BuildGroupName(SysHotelGroup group)
|
||||
{
|
||||
string name = "";
|
||||
while (group != null)
|
||||
{
|
||||
if (name == "")
|
||||
{
|
||||
name = group.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = group.Name + "-" + name;
|
||||
}
|
||||
group = group.Parent;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// 构造楼层树,用于 easyui-tree, easyui-combotree
|
||||
/// </summary>
|
||||
/// <param name="groups"></param>
|
||||
/// <param name="parent"></param>
|
||||
/// <returns></returns>
|
||||
private IList<object> BuildGroupTree(IList<SysHotelGroup> groups, SysHotelGroup parent)
|
||||
{
|
||||
IList<object> groupTree = new List<object>();
|
||||
IList<SysHotelGroup> subGroups = groups.Where(r => r.Parent != null && r.Parent.ID == parent.ID).OrderBy(o => o.Sort).ToList();
|
||||
foreach (SysHotelGroup group in subGroups)
|
||||
{
|
||||
IList<object> children = BuildGroupTree(groups, group);
|
||||
if (children.Count == 0)
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon" });
|
||||
}
|
||||
else
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon", children = children });
|
||||
}
|
||||
}
|
||||
return groupTree;
|
||||
}
|
||||
|
||||
private object BuildGroupTree(GroupMenu groupMenu)
|
||||
{
|
||||
if (groupMenu == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (groupMenu.SubGroupMenus.Count <= 0)
|
||||
{
|
||||
//return new { id = groupMenu.ID, text = groupMenu.Name, iconCls = "tree-node-no-icon" };
|
||||
return new { ID = groupMenu.ID, Name = groupMenu.Name, Sort = groupMenu.Sort, iconCls = "tree-node-no-icon" };
|
||||
}
|
||||
IList<object> children = new List<object>();
|
||||
foreach (GroupMenu subGroupMenu in groupMenu.SubGroupMenus)
|
||||
{
|
||||
var subGroupTree = BuildGroupTree(subGroupMenu);
|
||||
if (subGroupTree != null)
|
||||
{
|
||||
children.Add(subGroupTree);
|
||||
}
|
||||
}
|
||||
//return new { id = groupMenu.ID, text = groupMenu.Name, iconCls = "tree-node-no-icon", children = children };
|
||||
return new { ID = groupMenu.ID, Name = groupMenu.Name, Sort = groupMenu.Sort, children = children, iconCls = "tree-node-no-icon" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构造带房号的 easyui-tree 数据格式的分组树,房号附在其所属的结点之下
|
||||
/// 如果分支上的房号包含在 checkedHosts 则将其选中
|
||||
/// </summary>
|
||||
/// <param name="groups"></param>
|
||||
/// <param name="parent"></param>
|
||||
/// <param name="checkedHosts"></param>
|
||||
/// <returns></returns>
|
||||
private IList<object> BuildGroupTreeWithHotel(IList<SysHotelGroup> groups, SysHotelGroup parent, IList<SysHotel> checkedHotels)
|
||||
{
|
||||
IList<object> groupTree = new List<object>();
|
||||
IList<SysHotelGroup> subGroups = groups.Where(r => r.Parent == parent).OrderBy(o => o.Sort).ToList();
|
||||
foreach (SysHotelGroup group in subGroups)
|
||||
{
|
||||
IList<object> children = BuildGroupTreeWithHotel(groups, group, checkedHotels);
|
||||
if (children.Count != 0)
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon", children = children, attributes = new { isHotel = false } });
|
||||
}
|
||||
else
|
||||
{
|
||||
groupTree.Add(new { id = group.ID, text = group.Name, iconCls = "tree-node-no-icon", attributes = new { isHotel = false } });
|
||||
}
|
||||
}
|
||||
var hotels = SysHotelRepository.GetByGroup(parent);
|
||||
foreach (SysHotel hotel in hotels)
|
||||
{
|
||||
if (checkedHotels != null && checkedHotels.Contains(hotel))
|
||||
{
|
||||
groupTree.Add(new { id = hotel.ID, text = hotel.Code + "-" + hotel.Name, iconCls = "tree-node-no-icon", @checked = true, attributes = new { isHotel = true } });
|
||||
}
|
||||
else
|
||||
{
|
||||
groupTree.Add(new { id = hotel.ID, text = hotel.Code + "-" + hotel.Name, iconCls = "tree-node-no-icon", attributes = new { isHotel = true } });
|
||||
}
|
||||
}
|
||||
return groupTree;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
166
Service/Implement/SysHotelManager.cs
Normal file
166
Service/Implement/SysHotelManager.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dao;
|
||||
using Domain;
|
||||
using Common;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysHotelManager : GenericManagerBase<SysHotel>, ISysHotelManager
|
||||
{
|
||||
public IGroupRepository GroupRepository { get; set; }
|
||||
public IRoomTypeManager RoomTypeManager { get; set; }
|
||||
public ISysUserManager SysUserManager { get; set; }
|
||||
public IHostManager HostManager { get; set; }
|
||||
public RCUHost.IHotelTimeReceiver HotelTimeReceiver { get; set; }
|
||||
|
||||
public IList<SysHotel> LoadAllByPage(out long total, int page, int rows, string order, string sort, string query, int? groupId)
|
||||
{
|
||||
return ((ISysHotelRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, query, groupId).ToList();
|
||||
}
|
||||
|
||||
public SysHotel GetByCode(string code)
|
||||
{
|
||||
return ((ISysHotelRepository)(this.CurrentRepository)).GetByCode(code);
|
||||
}
|
||||
|
||||
public SysHotel GetByCode(string code, DateTime date)
|
||||
{
|
||||
var entity = ((ISysHotelRepository)(this.CurrentRepository)).GetByCode(code);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entity.WXValidate != ComputePasswordHash(code, date))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public SysHotel GetByAssociatedAccount(string associatedAccount)
|
||||
{
|
||||
return ((ISysHotelRepository)(this.CurrentRepository)).GetByAssociatedAccount(associatedAccount);
|
||||
}
|
||||
|
||||
public SysHotel GetByDomainUrl(string domainUrl)
|
||||
{
|
||||
return ((ISysHotelRepository)(this.CurrentRepository)).GetByDomainUrl(domainUrl);
|
||||
}
|
||||
|
||||
public override object Save(SysHotel entity)
|
||||
{
|
||||
entity.WXValidate = ComputePasswordHash(entity.Code, entity.CreatedDate);
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
object result = base.Save(entity);
|
||||
//新增酒店时,需要新增酒店根楼层
|
||||
GroupRepository.Save(new Group { Parent = null, Name = entity.Name, Sort = 1, HotelID = entity.ID });
|
||||
//新增默认房型(同时新增房型时:新增微信菜单等)
|
||||
RoomTypeManager.Save(new RoomType { HotelID = entity.ID, Code = entity.Code + "01", Name = "默认房型", HostName = "默认房型", Default = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void Update(SysHotel entity)
|
||||
{
|
||||
entity.WXValidate = ComputePasswordHash(entity.Code, entity.CreatedDate);
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
base.Update(entity);
|
||||
}
|
||||
|
||||
public override void SaveOrUpdate(SysHotel entity)
|
||||
{
|
||||
entity.WXValidate = ComputePasswordHash(entity.Code, entity.CreatedDate);
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
base.SaveOrUpdate(entity);
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新白天起始时间并下发命令给主机
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
public void UpdateDayTime(SysHotel entity)
|
||||
{
|
||||
entity.WXValidate = ComputePasswordHash(entity.Code, entity.CreatedDate);
|
||||
base.Update(entity);
|
||||
IList<Host> hosts = HostManager.LoadAll().Where(r => r.SysHotel.ID == entity.ID).ToList();
|
||||
foreach (Host host in hosts)
|
||||
{
|
||||
if (Common.CSRedisCacheHelper.Contains(host.HostNumber, host.MAC))
|
||||
{
|
||||
HotelTimeReceiver.Send(host);//下发白天起始时间命令
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Delete(IList<object> idList)
|
||||
{
|
||||
foreach (int id in idList)
|
||||
{
|
||||
//删除楼层信息
|
||||
var groups = GroupRepository.LoadAll().Where(r => r.HotelID == id).OrderByDescending(r => r.ID);
|
||||
foreach (var l in groups)
|
||||
{
|
||||
GroupRepository.Delete(l.ID);
|
||||
}
|
||||
//删除房型
|
||||
var roomTypes = RoomTypeManager.LoadAll().Where(r => r.HotelID == id);
|
||||
foreach (var r in roomTypes)
|
||||
{
|
||||
RoomTypeManager.Delete(r.ID);
|
||||
}
|
||||
//删除酒店关联用户
|
||||
var users = SysUserManager.LoadAll().Where(r => r.HotelID == id);
|
||||
foreach (SysUsers user in users)
|
||||
{
|
||||
SysUserManager.Delete(user.ID);
|
||||
}
|
||||
}
|
||||
((ISysHotelRepository)(this.CurrentRepository)).Delete(idList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算密码 Hash值
|
||||
/// </summary>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
private string ComputePasswordHash(string code, DateTime createDate)
|
||||
{
|
||||
return HashCode(createDate.ToString("yyyy") + code.ToUpper() + createDate.ToString("MMdd"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取MD5值
|
||||
/// </summary>
|
||||
/// <param name="key">加密的字符串</param>
|
||||
/// <returns>返回MD5值</returns>
|
||||
private string HashCode(string key)
|
||||
{
|
||||
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(key, "MD5");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<CommonEntity.KongQi> GetNeedData()
|
||||
{
|
||||
return ((ISysHotelRepository)(this.CurrentRepository)).GetNeedData();
|
||||
}
|
||||
|
||||
|
||||
public List<CommonEntity.SomeDeviceExistsData> IsExistsSomeDeviceRoomModal(int id, string roomnum, string start_address, string end_address)
|
||||
{
|
||||
return ((ISysHotelRepository)(this.CurrentRepository)).IsExistsSomeDeviceRoomModal(id,roomnum,start_address,end_address);
|
||||
}
|
||||
|
||||
|
||||
public IList<SysHotel> LoadFCS_PushData()
|
||||
{
|
||||
return ((ISysHotelRepository)(this.CurrentRepository)).LoadAll().Where(A=>!A.IsDeleted&&A.FCSPushEnable).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Service/Implement/SysOauth2Manager.cs
Normal file
47
Service/Implement/SysOauth2Manager.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dao;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysOauth2Manager : GenericManagerBase<SysOauth2>, ISysOauth2Manager
|
||||
{
|
||||
public IList<SysOauth2> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((ISysOauth2Repository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据code获取最新的授权记录,如果授权记录已过期,则返回null
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public SysOauth2 Get(string code)
|
||||
{
|
||||
var sysOauth2 = ((ISysOauth2Repository)(this.CurrentRepository)).Get(code);
|
||||
if (null != sysOauth2)
|
||||
{
|
||||
if (sysOauth2.CreatedDate.AddSeconds(sysOauth2.ExpiresIn) < DateTime.Now)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return sysOauth2;
|
||||
}
|
||||
|
||||
public SysOauth2 GetByRefreshToken(string refreshToken)
|
||||
{
|
||||
return ((ISysOauth2Repository)(this.CurrentRepository)).GetByRefreshToken(refreshToken);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取小度token
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetXiaoDuToken()
|
||||
{
|
||||
return ((ISysOauth2Repository)(this.CurrentRepository)).GetXiaoDuToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Service/Implement/SysProvinceManager.cs
Normal file
35
Service/Implement/SysProvinceManager.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysProvinceManager : GenericManagerBase<SysProvince>, ISysProvinceManager
|
||||
{
|
||||
public Dao.ISysCityRepository SysCityRepository { get; set; }
|
||||
|
||||
public Dao.ISysCountyRepository SysCountyRepository { get; set; }
|
||||
|
||||
public IList<SysCity> LoadAllCity()
|
||||
{
|
||||
return SysCityRepository.LoadAll().ToList();
|
||||
}
|
||||
|
||||
public IList<SysCity> GetCity(string provinceCoe)
|
||||
{
|
||||
return SysCityRepository.LoadAll().Where(r => r.ProvinceCode == provinceCoe).ToList();
|
||||
}
|
||||
|
||||
public IList<SysCounty> LoadAllCounty()
|
||||
{
|
||||
return SysCountyRepository.LoadAll().ToList();
|
||||
}
|
||||
|
||||
public IList<SysCounty> GetCounty(string cityCoe)
|
||||
{
|
||||
return SysCountyRepository.LoadAll().Where(r => r.CityCode == cityCoe).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
99
Service/Implement/SysRoleManager.cs
Normal file
99
Service/Implement/SysRoleManager.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysRoleManager : GenericManagerBase<SysRole>, ISysRoleManager
|
||||
{
|
||||
public ISysUserRepository SysUserRepository { get; set; }
|
||||
|
||||
public ISysAuthorityRepository SysAuthorityRepository { get; set; }
|
||||
|
||||
public IList<SysRole> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.ISysRoleRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
|
||||
public SysRole Get(string name)
|
||||
{
|
||||
return ((Dao.ISysRoleRepository)(this.CurrentRepository)).Get(name);
|
||||
}
|
||||
|
||||
public override void Delete(IList<object> idList)
|
||||
{
|
||||
if (idList != null) {
|
||||
foreach (int roleId in idList.Cast<int>()) {
|
||||
if (!Deletable(roleId)) {
|
||||
throw new Exception("角色已分配给用户不能删除。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.Delete(idList);
|
||||
}
|
||||
|
||||
public override void Delete(object id)
|
||||
{
|
||||
if (!Deletable((int)id)) {
|
||||
throw new ApplicationException("角色已分配给用户不能删除。");
|
||||
}
|
||||
|
||||
base.Delete(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断角色是否可以删除。
|
||||
/// 如果一个角色已分配给用户,则此角色不可以被删除
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public bool Deletable(int roleId)
|
||||
{
|
||||
IList<SysUsers> users = SysUserRepository.GetByRole(roleId);
|
||||
if (users == null || users.Count == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SaveRoleAuthorities(int roleId, IList<int> authorityIdList)
|
||||
{
|
||||
SysRole role = CurrentRepository.Get(roleId);
|
||||
|
||||
if (role.Name == "超级管理员") {
|
||||
throw new ApplicationException("不能修改超级管理员的权限!");
|
||||
}
|
||||
|
||||
role.Authorities.Clear();
|
||||
|
||||
if (authorityIdList != null && authorityIdList.Count > 0)
|
||||
{
|
||||
foreach (int authorityId in authorityIdList)
|
||||
{
|
||||
role.Authorities.Add(SysAuthorityRepository.Get(authorityId));
|
||||
}
|
||||
}
|
||||
|
||||
this.Update(role);
|
||||
}
|
||||
|
||||
|
||||
public IList<SysAuthority> GetAuthorities(SysRole role)
|
||||
{
|
||||
IList<SysAuthority> list = new List<SysAuthority>();
|
||||
|
||||
var roleEntity = ((Dao.ISysRoleRepository)(this.CurrentRepository)).LoadAll().FirstOrDefault(r => r == role);
|
||||
|
||||
if (roleEntity != null)
|
||||
{
|
||||
list = roleEntity.Authorities;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Service/Implement/SysSettingManager.cs
Normal file
34
Service/Implement/SysSettingManager.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysSettingManager : GenericManagerBase<SysSetting>, ISysSettingManager
|
||||
{
|
||||
public SysSetting Get(string name)
|
||||
{
|
||||
return ((ISysSettingRepository)CurrentRepository).Get(name);
|
||||
}
|
||||
|
||||
public string GetValue(string name)
|
||||
{
|
||||
var setting = ((ISysSettingRepository)CurrentRepository).Get(name);
|
||||
|
||||
return (setting != null && setting.Value != null) ? setting.Value : String.Empty;
|
||||
}
|
||||
|
||||
public void SetValue(string name, string value)
|
||||
{
|
||||
SysSetting setting = ((ISysSettingRepository)CurrentRepository).Get(name);
|
||||
if (setting != null)
|
||||
{
|
||||
setting.Value = value;
|
||||
CurrentRepository.Update(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Service/Implement/SysSystemLogsManager.cs
Normal file
43
Service/Implement/SysSystemLogsManager.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysSystemLogsManager : GenericManagerBase<SysSystemLogs>, ISysSystemLogsManager
|
||||
{
|
||||
public ISysSystemLogsRepository SysSystemLogsRepository { get; set; }
|
||||
|
||||
public IList<SysSystemLogs> LoadAllByPage(out long total, int page, int rows, string order, string sort, int? authorityId, DateTime? startDate, DateTime? endDate, string keyword, int currentHotelID)
|
||||
{
|
||||
var list = CurrentRepository.LoadAll().Where(r => r.Detail.Contains(keyword) && r.HotelID == currentHotelID);
|
||||
|
||||
if (authorityId.HasValue)
|
||||
{
|
||||
list = list.Where(r => r.AuthorityID == authorityId);
|
||||
}
|
||||
|
||||
if (startDate.HasValue && endDate.HasValue)
|
||||
{
|
||||
list = list.Where(r => r.Time >= startDate && r.Time <= endDate);
|
||||
}
|
||||
|
||||
total = list.LongCount();
|
||||
|
||||
list = list.OrderBy(sort + " " + order);
|
||||
|
||||
list = list.Skip((page - 1) * rows).Take(rows);
|
||||
|
||||
return list.ToList();
|
||||
}
|
||||
|
||||
public void DeleteAll(int currentHotelID)
|
||||
{
|
||||
Delete(LoadAll().Where(r => r.HotelID == currentHotelID).Select(r => r.ID as object).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
133
Service/Implement/SysUserManager.cs
Normal file
133
Service/Implement/SysUserManager.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class SysUserManager : GenericManagerBase<SysUsers>, ISysUserManager
|
||||
{
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(SysUserManager));
|
||||
|
||||
public IList<SysUsers> LoadAllByPage(out long total, int page, int rows, string order, string sort, int type, int? groupId, int? hotelID)
|
||||
{
|
||||
//var list = CurrentRepository.LoadAll();
|
||||
////list = list.Where("Account != @0", "admin");
|
||||
//if (groupId.HasValue && groupId != 1)
|
||||
//{
|
||||
// list = list.Where(r => r.Group != null && r.Group.ID == groupId);
|
||||
//}
|
||||
//total = list.LongCount();
|
||||
//list = list.OrderBy(sort + " " + order);
|
||||
////list = list.Skip((page - 1) * rows).Take(rows);
|
||||
//return list.ToList();
|
||||
return ((ISysUserRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort, type, groupId, hotelID).ToList();
|
||||
}
|
||||
|
||||
public SysUsers Get(string account)
|
||||
{
|
||||
return ((Dao.ISysUserRepository)(this.CurrentRepository)).Get(account);
|
||||
}
|
||||
|
||||
public SysUsers Get(string account, string password)
|
||||
{
|
||||
var entity = ((Dao.ISysUserRepository)(this.CurrentRepository)).Get(account);
|
||||
if (entity != null)
|
||||
{
|
||||
if (entity.Password != ComputePasswordHash(password, entity))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public int GetCount()
|
||||
{
|
||||
return CurrentRepository.LoadAll().Where(r => !r.IsDeleted).Count();
|
||||
}
|
||||
|
||||
public override object Save(SysUsers entity)
|
||||
{
|
||||
entity.Password = ComputePasswordHash("123456", entity);
|
||||
entity.Password2 = "123456";
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
return base.Save(entity);
|
||||
|
||||
//if (entity.Hotels != null && entity.Hotels.Count > 0)
|
||||
//{
|
||||
// var userHotel = SysUserHotelRepository.Get(entity.ID, entity.Hotels[0].ID);
|
||||
// if (userHotel == null)
|
||||
// {
|
||||
// userHotel = new SysUserHotel();
|
||||
// }
|
||||
// userHotel.UserID = entity.ID;
|
||||
// userHotel.HotelID = entity.Hotels[0].ID;
|
||||
// userHotel.GroupID = entity.Group.ID;
|
||||
// SysUserHotelRepository.SaveOrUpdate(userHotel);
|
||||
//}
|
||||
|
||||
//return result;
|
||||
}
|
||||
|
||||
public void Update(SysUsers entity, string password)
|
||||
{
|
||||
entity.Password = ComputePasswordHash(password, entity);
|
||||
entity.Password2 = password;
|
||||
entity.Last_Modified_Time = DateTime.Now;//标识有更新
|
||||
base.Update(entity);
|
||||
}
|
||||
|
||||
public bool HasAuthority(string account, int authorityId)
|
||||
{
|
||||
SysUsers user = Get(account);
|
||||
if (user == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (user.Account == "admin")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (user.Role == null || user.Role.Authorities == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (user.Role.Authorities.Count(r => r.ID == authorityId) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// 计算密码 Hash值
|
||||
/// </summary>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
private string ComputePasswordHash(string password, SysUsers entity)
|
||||
{
|
||||
return HashCode(entity.Account.ToUpper() + password + entity.CreatedDate.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取MD5值
|
||||
/// </summary>
|
||||
/// <param name="key">加密的字符串</param>
|
||||
/// <returns>返回MD5值</returns>
|
||||
private string HashCode(string key)
|
||||
{
|
||||
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(key, "MD5");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
48
Service/Implement/TFTP_SettingManager.cs
Normal file
48
Service/Implement/TFTP_SettingManager.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
using RestSharp;
|
||||
using RCUHost;
|
||||
using RCUHost.Implement;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class TFTP_SettingManager : GenericManagerBase<TFTP_Set>, ITFTP_SettingMananger
|
||||
{
|
||||
|
||||
|
||||
public int Add(TFTP_Set test)
|
||||
{
|
||||
return ((Dao.ITFTP_SetRepository)(this.CurrentRepository)).Add(test);
|
||||
}
|
||||
|
||||
public new void Update(TFTP_Set n)
|
||||
{
|
||||
((Dao.ITFTP_SetRepository)(this.CurrentRepository)).Update(n);
|
||||
}
|
||||
|
||||
public new void UpdateOrSave(TFTP_Set n)
|
||||
{
|
||||
((Dao.ITFTP_SetRepository)(this.CurrentRepository)).SaveOrUpdate(n);
|
||||
}
|
||||
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(TFTP_SettingManager));
|
||||
|
||||
|
||||
|
||||
|
||||
public TFTP_Set GetData(int hotelid, int hostid)
|
||||
{
|
||||
return ((Dao.ITFTP_SetRepository)(this.CurrentRepository)).GetDataBy(hotelid,hostid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
18
Service/Implement/TestManager.cs
Normal file
18
Service/Implement/TestManager.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class TestManager : GenericManagerBase<Test>, ITestManager
|
||||
{
|
||||
public new void Save(Test test)
|
||||
{
|
||||
((Dao.ITestRepository)(this.CurrentRepository)).Save(test);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Service/Implement/TvControlManager.cs
Normal file
25
Service/Implement/TvControlManager.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class TvControlManager : ITvControlManager
|
||||
{
|
||||
public ITVControlReceiver TVControlReceiver { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发送电视按键
|
||||
/// </summary>
|
||||
/// <param name="host">主机</param>
|
||||
/// <param name="key">按键</param>
|
||||
public void SendKey(Host host,TvKey key)
|
||||
{
|
||||
TVControlReceiver.SendKey(host, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Service/Implement/UnlockControlManager.cs
Normal file
20
Service/Implement/UnlockControlManager.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using RCUHost;
|
||||
using RCUHost.Protocols;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class UnlockControlManager : IUnlockControlManager
|
||||
{
|
||||
public IUnlockControlReceiver UnlockControlReceiver { get; set; }
|
||||
|
||||
public void Send(Host host)
|
||||
{
|
||||
UnlockControlReceiver.Send(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Service/Implement/WXMenusManager.cs
Normal file
18
Service/Implement/WXMenusManager.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic;
|
||||
using System.Text;
|
||||
using Domain;
|
||||
using Dao;
|
||||
|
||||
namespace Service.Implement
|
||||
{
|
||||
public class WXMenusManager : GenericManagerBase<WXMenus>, IWXMenusManager
|
||||
{
|
||||
public IList<WXMenus> LoadAllByPage(out long total, int page, int rows, string order, string sort)
|
||||
{
|
||||
return ((Dao.IWXMenusRepository)(this.CurrentRepository)).LoadAllByPage(out total, page, rows, order, sort).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user