public ActionResult SSOPoolList()
 {
     List<SelectListItem> selectItem = new List<SelectListItem>()
     {
         new SelectListItem(){ Text="全部",Value="0",Selected=true },
         new SelectListItem(){ Text="已启用",Value=((int)Model.Enum.IsEnabledEnum.Enabled).ToString() },
         new SelectListItem(){ Text="未启用",Value=((int)Model.Enum.IsEnabledEnum.Disabled).ToString() }
     };
     ViewBag.Select = selectItem;
     ISSOPoolService service = new SSOPoolService();
     SSOPoolParam parameter = new SSOPoolParam()
     {
         PageIndex = DotNet.Utils.Untility.ConvertFactory.ToInt32(HttpUtility.UrlEncode(Request["page"]), 1),
         PageSize =12,
         IsEnabled = DotNet.Utils.Untility.ConvertFactory.ToInt32(HttpUtility.UrlEncode(Request["isEnabled"]), 0),
         PoolName = HttpUtility.HtmlEncode(Request["poolName"]),
         IsPaging = true,
         PoolId = 0
     };
     var model = service.GetPagingModel(parameter);
     return View(model);
 }
Beispiel #2
0
        /// <summary>
        /// 单点登录池分页
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public PagingModel<SSOPool> GetPaging(SSOPoolParam parameter)
        {
            PagingModel<SSOPool> pagingModel = new PagingModel<SSOPool>()
            {
                PageIndex = parameter.PageIndex,
                PageSize = parameter.PageSize
            };
            using (var connection = ConnectionFactory.GetMasterSql())
            {
                //跳过的页数
                int skip = (parameter.PageIndex - 1) * parameter.PageSize;
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(@" and DelFlag=@DelFlag ");
                #region where条件和参数
                DynamicParameters param = new DynamicParameters();
                param.Add("@DelFlag", (int)DelFlagEnum.Noraml);
                //按照池名称进行搜索
                if (!string.IsNullOrEmpty(parameter.PoolName))
                {
                    sb.AppendFormat(" and PoolName like @PoolName");
                    param.Add("@PoolName", string.Format("%{0}%", parameter.PoolName));
                }
                //按照池Id进行搜索
                if (parameter.PoolId > 0)
                {
                    sb.AppendFormat(" and PoolId=@PoolId");
                    param.Add("@PoolId", parameter.PoolId);
                }
                //按照域的名称来搜索
                if (Enum.IsDefined(typeof(IsEnabledEnum), parameter.IsEnabled))
                {
                    sb.AppendFormat(" and IsEnabled=@IsEnabled");
                    param.Add("@IsEnabled", parameter.IsEnabled);
                }

                #endregion
                string countSql = string.Format("Select count(*) from B_SSOPool where 1=1 {0}", sb.ToString());
                var totalCount = connection.ExecuteScalar<int>(countSql, param);
                pagingModel.TotalRecord = totalCount;

                string sql = string.Format("Select top {0} * from  (Select  row_number() over (order by PoolId) AS RowNumber,* from B_SSOPool ) as tb  where RowNumber>{1} {2}", parameter.PageSize, skip, sb.ToString());
                var query = connection.Query<SSOPool>(sql, param);
                pagingModel.Data = query.ToList();
            }
            return pagingModel;
        }
 /// <summary>
 /// 带分页的单点登录池
 /// </summary>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public PagingModel<SSOPool> GetPagingModel(SSOPoolParam parameter)
 {
     //过滤
     parameter.PoolName = DotNet.Utils.Untility.StringHelper.FilterHtml(parameter.PoolName);
     ISSOPoolDal ssoPoolDal = new SSOPoolDal();
     var pagingModel = ssoPoolDal.GetPaging(parameter);
     return pagingModel;
 }