/// <summary>
        /// 获取电话号码 add by tangcy
        /// </summary>
        /// <param name="usename"> 用户姓名</param>
        /// <returns></returns>
        public DataSet GetAllUserMobileNo(string usename)
        {
            dal = new Tcs.Libary.DataAccess();
            dal.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString2"].ToString();
            dal.CreateConnection();
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("select MobileNo from Sys_Operator where UserName = '******'", usename);

            return dal.GetDataSet(sb.ToString());
        }
        public TN_DevDefine()
        {
            dal = new DataHelper.DataAccess();

            dal.ConnectionString = ConfigurationSettings.AppSettings["connectionString"];
        }
        public TN_NoteReciver()
        {
            dal = new DataHelper.DataAccess();

            dal.ConnectionString =ConfigurationSettings.AppSettings["connectionString"];
        }
        /// <summary>
        /// 分页DataSet
        /// </summary>
        /// <param name="coalCode">煤矿名称</param>
        /// <param name="queryWhere">查询条件</param>
        /// <param name="queryOrder">排序</param>
        /// <param name="startRowNo">起始编号</param>
        /// <param name="endRowNo">终止编号</param>
        /// <param name="rowCount">总行数</param>
        /// <returns>DataSet</returns>
        public DataSet GridViewAndPager(string coalCode,string queryWhere, string queryOrder, int startRowNo, int endRowNo, out int rowCount)
        {
            DataSet dst = new DataSet();
            //data access new
            DataHelper.DataAccess das = new DataHelper.DataAccess();

            das.ProviderName = "System.Data.SqlClient";
            if (string.IsNullOrEmpty(GetConnectionString(coalCode)))
            {
                rowCount = 0;
                return null;
            }
            else
            {

                //设置数据库连接字符串
                das.ConnectionString = GetConnectionString(coalCode);

                string queryString = BuildQuery(coalCode, queryWhere, queryOrder);
                rowCount = 0;
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("select * from ( {0} )", queryString);
                sb.AppendFormat(" as rel where RowNo>={0} and RowNo<={1} order by statsDate desc", startRowNo, endRowNo);

                StringBuilder sbCount = new StringBuilder();
                sbCount.AppendFormat("select count(*) from TN_MinuteData_{0}",coalCode);
                if (!string.IsNullOrEmpty(queryWhere))
                {
                    sbCount.AppendFormat(" where {0}",queryWhere);
                }
                try
                {
                    rowCount = Convert.ToInt32(das.ExecuteScalar(sbCount.ToString()));
                    dst = das.GetDataSet(sb.ToString());
                }
                catch (Exception ex)
                {
                    Tcs.Libary.Log.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 错误说明:分服务器不存在或分服务器配置错误");
                    Tcs.Libary.Log.Write("内容:" + ex.ToString());
                    Tcs.Libary.Log.Write("-------------------------------------------------");
                }

            }
            return dst;
        }
        public TN_AlarmRecodeClearUp()
        {
            dal = new DataHelper.DataAccess();

            dal.ConnectionString = ConfigurationSettings.AppSettings["connectionString"];
        }
        /// <summary>
        /// 获取平台中所有接收人员名称和编号
        /// </summary>
        /// <returns></returns>
        public DataSet GetAllUserName()
        {
            dal = new Tcs.Libary.DataAccess();
            dal.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString2"].ToString();
            dal.CreateConnection();
            StringBuilder sb = new StringBuilder();
            sb.Append("select UserName,UserCode from Sys_Operator");

            return dal.GetDataSet(sb.ToString());
        }
        /// <summary>
        /// 获取画图历史数据
        /// </summary>
        /// <param name="coalCode">煤矿编号</param>
        /// <param name="deviceCode">设备编号</param>
        /// <param name="queryWhere">查询条件</param>
        /// <param name="queryOrder">排序条件</param>
        /// <returns></returns>
        public DataSet GetChartData(string coalCode, string deviceCode, string queryWhere,string queryOrder)
        {
            //data access
            DataHelper.DataAccess das = new DataHelper.DataAccess();

            das.ProviderName = "System.Data.SqlClient";
            if (string.IsNullOrEmpty(GetConnectionString(coalCode)))
            {
                return null;
            }
            else
            {
                //设置数据库连接字符串
                das.ConnectionString = GetConnectionString(coalCode);

                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("select DevValue,RealTime from TN_PerData_{0}",coalCode);
                sb.AppendFormat(" where DevType = '模拟量' and DevCode='{0}'",deviceCode);
                if (!string.IsNullOrEmpty(queryWhere))
                {
                    sb.AppendFormat(" and {0}",queryWhere);
                }

                if (!string.IsNullOrEmpty(queryOrder))
                {
                    sb.AppendFormat(" ordery by {0}", queryOrder);
                }

                DataSet dst = das.GetDataSet(sb.ToString());
                //dal.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
                return dst;

            }
        }
        /// <summary>
        /// 由煤矿编号获取该煤矿所在分数据服务器的数据库连接字符串
        /// </summary>
        /// <param name="coalCode">煤矿编号</param>
        /// <returns>数据库连接字符串</returns>
        public string GetConnectionString(string coalCode)
        {
            // data access
            DataHelper.DataAccess das = new DataHelper.DataAccess();

            StringBuilder sb = new StringBuilder();
            sb.Append("select s.DBConfig from TN_Coals as c inner join TN_Servers as s on c.ServerCode = s.ServerCode");
            sb.AppendFormat(" where c.CoalCode = '{0}' and s.IsForbid='False'", coalCode);

            string dbConfig = String.Empty;
            string connection = String.Empty;
            try
            {
                dbConfig = Convert.ToString(das.ExecuteScalar(sb.ToString()));
            }
            catch (Exception ex)
            {
                Tcs.Libary.Log.Write("异常信息:" + ex);
                Tcs.Libary.Log.Write("说明:分服务器不存在或分服务器配置错误!");
            }
            finally
            {
                connection = string.IsNullOrEmpty(dbConfig) ? string.Empty : dbConfig;
            }

            return connection;
        }