Esempio n. 1
0
        /// <summary>
        /// 将查询实体转换为Where语句
        /// <param name="query">查询实体</param>
        /// <returns>获取Where语句,不包含Where</returns>
        /// </summary>
        public string DBServerInfoQueryToSQLWhere(DBServerInfoQuery query)
        {
            StringBuilder sbWhere = new StringBuilder(" 1=1 ");

            if (query.Status != null)
            {
                sbWhere.Append(" AND Status= ").Append(query.Status.Value);
            }
            if (!string.IsNullOrEmpty(query.Account))
            {
                sbWhere.AppendFormat(" AND Account='{0}'", WKT.Common.Security.SecurityUtils.SafeSqlString(query.Account));
            }
            if (!string.IsNullOrEmpty(query.ServerIP))
            {
                sbWhere.AppendFormat(" AND ServerIP='{0}'", WKT.Common.Security.SecurityUtils.SafeSqlString(query.ServerIP));
            }
            if (sbWhere.ToString() == " 1=1 ")
            {
                return(string.Empty);
            }
            else
            {
                return(sbWhere.ToString());
            }
        }
Esempio n. 2
0
        public List <DBServerInfoEntity> GetDBServerInfoList(DBServerInfoQuery query)
        {
            List <DBServerInfoEntity> list           = new List <DBServerInfoEntity>();
            StringBuilder             sqlCommandText = new StringBuilder();

            sqlCommandText.Append("SELECT DBServerID,ServerIP,Port,Account,Pwd,Note,Status,AddDate FROM dbo.DBServerInfo WITH(NOLOCK)");
            string whereSQL = DBServerInfoQueryToSQLWhere(query);
            string orderBy  = DBServerInfoQueryToSQLOrder(query);

            if (!string.IsNullOrEmpty(whereSQL))
            {
                sqlCommandText.Append(" WHERE " + whereSQL);
            }
            if (!string.IsNullOrEmpty(orderBy))
            {
                sqlCommandText.Append(" ORDER BY " + orderBy);
            }
            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                list = MakeDBServerInfoList(dr);
            }
            return(list);
        }
Esempio n. 3
0
        public Pager <DBServerInfoEntity> GetDBServerInfoPageList(DBServerInfoQuery query)
        {
            int     recordCount = 0;
            string  whereSQL    = DBServerInfoQueryToSQLWhere(query);
            string  orderBy     = DBServerInfoQueryToSQLOrder(query);
            DataSet ds          = db.GetPagingData("DBServerInfo", "DBServerID,ServerIP,Port,Account,Pwd,Note,Status,AddDate", orderBy, whereSQL, query.CurrentPage, query.PageSize, out recordCount);
            Pager <DBServerInfoEntity> pager = new Pager <DBServerInfoEntity>();

            if (ds != null && ds.Tables.Count > 0)
            {
                pager.ItemList = MakeDBServerInfoList(ds.Tables[0]);
            }
            pager.CurrentPage  = query.CurrentPage;
            pager.PageSize     = query.PageSize;
            pager.TotalRecords = recordCount;
            return(pager);
        }
Esempio n. 4
0
 /// <summary>
 /// 获取所有符合查询条件的数据
 /// </summary>
 /// <param name="dBServerInfoQuery">DBServerInfoQuery查询实体对象</param>
 /// <returns>List<DBServerInfoEntity></returns>
 public List <DBServerInfoEntity> GetDBServerInfoList(DBServerInfoQuery dBServerInfoQuery)
 {
     return(DBServerInfoBusProvider.GetDBServerInfoList(dBServerInfoQuery));
 }
Esempio n. 5
0
 /// <summary>
 /// 分页获取符合查询条件的数据
 /// </summary>
 /// <param name="dBServerInfoQuery">DBServerInfoQuery查询实体对象</param>
 /// <returns>Pager<DBServerInfoEntity></returns>
 public Pager <DBServerInfoEntity> GetDBServerInfoPageList(DBServerInfoQuery dBServerInfoQuery)
 {
     return(DBServerInfoDataAccess.Instance.GetDBServerInfoPageList(dBServerInfoQuery));
 }
Esempio n. 6
0
 /// <summary>
 /// 将查询实体转换为Order语句
 /// <param name="query">查询实体</param>
 /// <returns>获取Order语句,不包含Order</returns>
 /// </summary>
 public string DBServerInfoQueryToSQLOrder(DBServerInfoQuery query)
 {
     return(" DBServerID DESC");
 }