在Server层定义WaterLevelSetServer和WaterLevelRecordServer两个子类,分别继承DeviceSetServer和DeviceRecordServer。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMOS.DAL.Device;
using SMOS.Model.Device; namespace SMOS.Server.Impl.Device
{
public class WaterLevelSetServer:DeviceSetServer
{
private WaterLevelSetDao WaterLevelSetDao = new WaterLevelSetDao();
/// <summary>
/// 查询水位计设置信息
/// </summary>
/// <param name="deviceID">水位计设置信息</param>
/// <returns>设备信息</returns>
public override object GetDeviceSetInfo(int deviceID)
{
return WaterLevelSetDao.GetWaterLevelSetInfo(deviceID);
} /// <summary>
/// 查询所有水位计设备信息
/// </summary>
/// <returns>设备列表</returns>
public override IList<object> GetAllDeviceSetInfo()
{
return WaterLevelSetDao.GetAllWaterLevelSetInfo().ToList<Object>();
}
/// <summary>
/// 增加水位计设置
/// </summary>
/// <param name="DeviceSetInfo"></param>
/// <returns>操作记录数</returns>
public override int AddDeviceSetInfo(object waterLevelSetInfo)
{
WaterLevelSetInfo entity = waterLevelSetInfo as WaterLevelSetInfo;
if (entity == null)
{
throw new Exception("水位计设置信息不能为空!");
}
WaterLevelSetInfo dbInfo = WaterLevelSetDao.GetWaterLevelSetInfo(entity.DeviceID);
if (dbInfo != null)
{
//throw new Exception("该水位计设备设置信息已存在!");
return WaterLevelSetDao.ModifyWaterLevelSetInfo(entity);
}
else
{
return WaterLevelSetDao.AddWaterLevelSetInfo(waterLevelSetInfo as WaterLevelSetInfo);
} }
/// <summary>
/// 修改水位计设置
/// </summary>
/// <param name="deviceSetInfo"></param>
/// <returns>操作记录</returns>
public override int ModifyDeviceSetInfo(object waterLevelSetInfo)
{
return WaterLevelSetDao.ModifyWaterLevelSetInfo(waterLevelSetInfo as WaterLevelSetInfo);
}
/// <summary>
/// 删除水位计设置
/// </summary>
/// <param name="deviceSetInfo"></param>
/// <returns>操作记录</returns>
public override int DelDeviceSetInfo(object waterLevelSetInfo)
{
return WaterLevelSetDao.DelWaterLevelSetInfo(waterLevelSetInfo as WaterLevelSetInfo);
}
}
}
DeviceSetServer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMOS.IServer.Device; namespace SMOS.Server.Impl.Device
{
public abstract class DeviceSetServer:IDeviceSetServer
{
public abstract object GetDeviceSetInfo(int deviceID); public abstract IList<object> GetAllDeviceSetInfo(); public abstract int AddDeviceSetInfo(object deviceSetInfo); public abstract int ModifyDeviceSetInfo(object deviceSetInfo); public abstract int DelDeviceSetInfo(object deviceSetInfo);
}
}
若需转载请标明出处或链接http://www.cnblogs.com/EaIE099/,本人初入职场,对编程也是一个菜鸟,只想把自己所学点滴记录下来,如有不合理的地方希望各位高手多多指点,非常感谢!