/// <summary>
 /// 获取所有符合查询条件的数据
 /// </summary>
 /// <param name="dBServerInfoQuery">DBServerInfoQuery查询实体对象</param>
 /// <returns>List<DBServerInfoEntity></returns>
 public List<DBServerInfoEntity> GetDBServerInfoList(DBServerInfoQuery dBServerInfoQuery)
 {
     return DBServerInfoDataAccess.Instance.GetDBServerInfoList(dBServerInfoQuery);
 }
 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;
 }
 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;
 }
 /// <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();
     }
 }
 /// <summary>
 /// 将查询实体转换为Order语句
 /// <param name="query">查询实体</param>
 /// <returns>获取Order语句,不包含Order</returns>
 /// </summary>
 public string DBServerInfoQueryToSQLOrder(DBServerInfoQuery query)
 {
     return " DBServerID DESC";
 }
Esempio n. 6
0
 /// <summary>
 /// 分页获取符合查询条件的数据
 /// </summary>
 /// <param name="dBServerInfoQuery">DBServerInfoQuery查询实体对象</param>
 /// <returns>Pager<DBServerInfoEntity></returns>
 public Pager<DBServerInfoEntity> GetDBServerInfoPageList(DBServerInfoQuery dBServerInfoQuery)
 {
     return DBServerInfoBusProvider.GetDBServerInfoPageList(dBServerInfoQuery);
 }
Esempio n. 7
0
 public ActionResult IndexAjax(DBServerInfoQuery queryEntity)
 {
     if (!Request.IsAjaxRequest())
     {
         return Content("{\"result\":\"error\",\"msg\":\"非法访问\"}");
     }
     else
     {
         IDBServerInfoService dbServerService = ServiceContainer.Instance.Container.Resolve<IDBServerInfoService>();
         queryEntity.CurrentPage = queryEntity.CurrentPage + 1;
         WKT.Model.Pager<DBServerInfoEntity> dbServerPagerList = dbServerService.GetDBServerInfoPageList(queryEntity);
         if (dbServerPagerList != null)
         {
             return Content("{\"result\":\"success\",\"msg\":\"成功\",\"data\":" + JsonConvert.SerializeObject(dbServerPagerList) + "}");
         }
         else
         {
             return Content("{\"result\":\"error\",\"msg\":\"系统出现异常,请稍后再试\"}");
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            ViewBag.TotalCount = 0;
            IDBServerInfoService dbServerService = ServiceContainer.Instance.Container.Resolve<IDBServerInfoService>();
            DBServerInfoQuery queryEntity = new DBServerInfoQuery();
            queryEntity.CurrentPage = 1;
            Pager<DBServerInfoEntity> pagerDBServerList = dbServerService.GetDBServerInfoPageList(queryEntity);
            IList<DBServerInfoEntity> listServer = new List<DBServerInfoEntity>();
            if (pagerDBServerList != null)
            {
                listServer = pagerDBServerList.ItemList;
                ViewBag.TotalCount = pagerDBServerList.TotalRecords;
            }

            return View(listServer);
        }