using System;
using System.Collections;

namespace Core.Mes.ServerFrameWork
{
    /// <summary>
    /// ClsComponentBase 的摘要说明。
    /// </summary>

    /// <summary>
    /// 业务服务组件的统一接口，
    /// 只有实现该接口才能在服务端自动加载并公开给客户端调用，
    /// 如属服务端内部处理，不用公开给客户端的类，则无需实现本接口。
    /// </summary>
    /// 
    //[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
    public class IComponent :  IServerBase
    {
        public IComponent() { }

        /// <summary>
        /// 最大副本数，指该类在组件容器池中存在的最大副本数。
        /// 即在服务运行过程中，由于用户并发调用而可以创建的该类的最大实例数量。
        /// 当并发请求量超过该数量则需要排队等候。
        /// </summary>
        /// <returns>大于或等于最小副本数的整数</returns>
        public virtual int maxValue
        {
            get { return 1; }
        }

        /// <summary>
        /// 最小副本数，指在组件容器池中存在的最小副本数。
        /// 即在服务启动时自动加载的该类的实例数量，
        /// 和在运行过程中始终保留的最小实例数量。
        /// 默认为1。
        /// </summary>
        /// <returns>大于零的整数</returns>
        public virtual int minValue
        {
            get { return 1; }
        }

        public virtual string Description
        {
            get
            {
                return "业务组件"; ;
            }
        }
        public string DBName = "MesDB";

        private ArrayList _objects = null;
        public ArrayList OwnObjects
        {
            get { return _objects; }
            set { _objects = value; }
        }

        private Hashtable _dbManagerList = null;
        public Hashtable DBManagerList
        {
            get
            {
                return _dbManagerList;
            }
            set
            {
                _dbManagerList = value;
            }
        }
        private STMes.DBManager _dbManager;
        public STMes.DBManager DBManager
        {
            set { _dbManager = value; }
            get
            {
                if (_dbManager == null && DBManagerList != null && DBManagerList.Contains(DBName))
                    _dbManager = DBManagerList[DBName] as STMes.DBManager;

                return _dbManager;
            }
        }
        private Hashtable _htServerKeys = null;
        public Hashtable HTServiceKeys
        {
            get { return _htServerKeys; }
            set { _htServerKeys = value; }
        }
        string _callClassName = "";
        public string CallingClass
        {
            get { return _callClassName; }
            set { _callClassName = value; }
        }

        string _callMethod = "";
        public string CallingMethod
        {
            get { return _callMethod; }
            set { _callMethod = value; }
        }

        DateTime _callTime;
        public DateTime CallingMethodStartTime
        {
            get { return _callTime; }
            set { _callTime = value; }
        }

        private ServerConfigure _servConf = null;
        public ServerConfigure ServerConfig
        {
            get { return _servConf; }
            set { _servConf = value; }
        }
        public virtual void Dispose() { }
    }
}
