using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Estsh.Web.Util;
using System.Data;
using Estsh.Web.Dal;
using System.Collections;
using Estsh.Web.Models;
using System.IO;
using System.Text;
namespace Estsh.Core.Services
{
public class EnergyDefineService
{
/***************************************************************************
*
* 能源看板定义
* Noah
*
*****************************************************************************/
private EnergyDefineDal dal = new EnergyDefineDal(RemotingProxyProvider._remotingProxy);
///
/// 根据分页条件获取分页菜单数据
///
///
///
///
///
///
public Hashtable getEnergyListByPage(String device_name, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
string strWhere = " 1=1 ";
if (!string.IsNullOrEmpty(device_name))
{
strWhere = " device_name LIKE '%" + device_name.Trim() + "%' ";
}
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += sort + " ";
}
else
{
orderBy += " seq ";
}
result = dal.getEnergyListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
return result;
}
///
/// 获取分页总数量
///
///
///
public int getMenuCount(String menuName)
{
if (menuName != null && !menuName.Trim().Equals(""))
{
menuName = " device_name like '%" + menuName.Trim() + "%'";
}
else
{
menuName = "";
}
return dal.getCountWhere(menuName);
}
///
/// 保存菜单数据
///
///
///
public int saveEnergy(Hashtable htParams)
{
return dal.saveEnergy(htParams);
}
///
/// 更新菜单数据
///
///
///
public int updateEnergy(Hashtable htParams)
{
return dal.updateEnergy(htParams);
}
///
/// 查看菜单详情
///
///
///
public Hashtable getEnergyDetail(String device_id)
{
device_id = " device_id = " + device_id;
DataTable dt = dal.getEnergyDetail(device_id, "");
Hashtable result = new Hashtable();
result.Add("device_id", dt.Rows[0]["device_id"]);
result.Add("device_name", dt.Rows[0]["device_name"]);
result.Add("target_value", dt.Rows[0]["target_value"]);
result.Add("seq", dt.Rows[0]["seq"]);
return result;
}
///
/// 删除菜单
///
///
///
public int deleteMenu(String ids)
{
String[] idArray = ids.Split(',');
int count = 0;
foreach (String id in idArray)
{
if (!"".Equals(id))
{
count += this.dal.deleteMenu(id);
}
}
return count;
}
}
}