using System;
using System.Collections.Generic;

namespace Stat.BLL
{
    /// <summary>
    /// 
    /// </summary>
    public class GatherServer
    {
        private static Stat.IDAL.IGatherServer dal = Stat.DALFactory.AbstractFactory.GetInstance().CreateGatherServer();
        /// <summary>
        /// 新增/删除/修改
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns>-1:存储过程执行失败,-2:存在相同的主键,Insert:返回插入自动ID,Update:返回更新记录数,Delete:返回删除记录数</returns>
        public static Int32 InsertUpdateDelete(Model.GatherServer model)
        {
            return dal.InsertUpdateDelete(model);
        }
        /// <summary>
        /// 获取 
        /// </summary>
        /// <returns></returns>
        public static IList<Model.GatherServer> Get(Model.GatherServer gatherModel, ref Model.PageInfo pageModel)
        {
            return dal.Get(gatherModel, ref pageModel);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Model.GatherServer Get(int id)
        {
            return dal.Get(id);
        }
        /// <summary>
        /// 获取一个 可用 开放申请的 统计服务器 ID
        /// </summary>
        /// <returns>0：没有</returns>
        public static Int32 Get_IsOpen_GathServerID()
        {
            Model.GatherServer gatherModel = new Stat.Model.GatherServer();
            gatherModel.IsOpen = 1;
            //
            Model.PageInfo pageModel = new Stat.Model.PageInfo();
            pageModel.PageIndex = 1;
            //
            IList<Model.GatherServer> list = Get(gatherModel, ref pageModel);
            //
            if (list != null && list.Count > 0)
            {
                return list[0].ID;
            }
            else
            {
                return 0;
            }
        }
    }
}
