/// <summary> /// 获取符何指定过滤器条件的主题列表 /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="dispayNumber">提取条数</param> /// <returns></returns> protected override List<FullThemeView> GetFullThemes(ThemesFilter filter, ThemeSortOption sort, int dispayNumber) { List<FullThemeView> themes; string cacheKey = BuildCacheKey("GetFullThemes", filter.ToString(), sort.ToString(), dispayNumber); if (_enableCache == false) { themes = base.GetFullThemes(filter, sort, dispayNumber); _enableCache = true; } else { if (CacheHelper.Contains(cacheKey)) { themes = CacheHelper.Get<List<FullThemeView>>(cacheKey); } else { themes = base.GetFullThemes(filter, sort, dispayNumber); CacheHelper.Set<List<FullThemeView>>(cacheKey, themes, _cacheTime); } } return themes; }
/// <summary> /// 获取符何指定过滤器条件的主题列表 /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="pageIndex">显示的页码,从1开始计数</param> /// <param name="pageSize">每页显示的记录数</param> /// <param name="recordCount">总记录数(ref)</param> /// <returns></returns> protected override List<SimpleThemeView> GetSimpleThemes(ThemesFilter filter, ThemeSortOption sort, int pageIndex, int pageSize, ref int recordCount) { List<SimpleThemeView> themes; string cacheKey = BuildCacheKey("GetSimpleThemes", filter.ToString(), sort.ToString(), pageIndex, pageSize); string cacheKeyOfRecordCount = BuildCacheKey("GetSimpleThemes", filter.ToString(), sort.ToString(), pageSize); if (_enableCache == false) { themes = base.GetSimpleThemes(filter, sort, pageIndex, pageSize, ref recordCount); _enableCache = true; } else { if (CacheHelper.Contains(cacheKeyOfRecordCount)) { recordCount = CacheHelper.Get<int>(cacheKeyOfRecordCount); } if (CacheHelper.Contains(cacheKey)) { themes = CacheHelper.Get<List<SimpleThemeView>>(cacheKey); } else { themes = base.GetSimpleThemes(filter, sort, pageIndex, pageSize, ref recordCount); CacheHelper.Set<List<SimpleThemeView>>(cacheKey, themes, _cacheTime); CacheHelper.Set<int>(cacheKeyOfRecordCount, recordCount, _cacheTime); } } return themes; }
/// <summary> /// 获取符何指定过滤器条件的主题列表 /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="dispayNumber">提取条数</param> /// <returns></returns> protected List<SimpleThemeView> GetSimpleThemes(ThemesFilter filter, ThemeSortOption sort, int dispayNumber) { return GetSimpleThemes(GetDataViewName(filter, sort), filter.ToString(), GetSortExpression(sort), dispayNumber); }
/// <summary> /// 获取符何指定过滤器条件的主题列表 /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="pageIndex">显示的页码,从1开始计数</param> /// <param name="pageSize">每页显示的记录数</param> /// <param name="recordCount">总记录数(ref)</param> /// <returns></returns> protected virtual List<SimpleThemeView> GetSimpleThemes(ThemesFilter filter, ThemeSortOption sort, int pageIndex, int pageSize, ref int recordCount) { SqlParameter[] parameters = new SqlParameter[] { SqlParameterHelper.BuildParameter("@RecordNum",SqlDbType.Int, 4, ParameterDirection.InputOutput, recordCount), SqlParameterHelper.BuildInputParameter("@SelectList",SqlDbType.NVarChar,2000, SIMPLE_THEME_FIELDS), SqlParameterHelper.BuildInputParameter("@TableSource",SqlDbType.NVarChar,300, GetDataViewName(filter, sort)), SqlParameterHelper.BuildInputParameter("@SearchCondition",SqlDbType.NVarChar,2000, filter.ToString()), SqlParameterHelper.BuildInputParameter("@OrderExpression",SqlDbType.NVarChar,1000, GetSortExpression(sort)), SqlParameterHelper.BuildInputParameter("@PageSize",SqlDbType.Int,4,pageSize), SqlParameterHelper.BuildInputParameter("@PageIndex",SqlDbType.Int,4,pageIndex) }; List<SimpleThemeView> themes = new List<SimpleThemeView>(); using (IDataReader dataReader = SqlHelper.ExecuteReader(_connectionProvider.GetReadConnectionString(), CommandType.StoredProcedure, "PR_GetDataByPageIndex", parameters)) { while (dataReader.Read()) { themes.Add(BindSimpleThemeView(dataReader)); } } recordCount = Convert.ToInt32(parameters[0].Value); return themes; }
/// <summary> /// 获取符何指定过滤器条件的主题列表 /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="dispayNumber">提取条数</param> /// <returns></returns> protected virtual List<FullThemeView> GetFullThemes(ThemesFilter filter, ThemeSortOption sort, int dispayNumber) { List<FullThemeView> themes = new List<FullThemeView>(); string sortExpression = GetSortExpression(sort); string cmdText = string.Format("SELECT top {3} * FROM {0} Where {1} {2}" , GetDataViewName(filter, sort) , filter.ToString() , sortExpression.Length > 0 ? " ORDER BY " + sortExpression : "" , dispayNumber ); using (IDataReader reader = SqlHelper.ExecuteReader(_connectionProvider.GetReadConnectionString(), CommandType.Text, cmdText)) { while (reader.Read()) { themes.Add(BindFullThemeView(reader)); } } return themes; }
/// <summary> /// 根据过滤器和排序条件获取对应的视图名称 /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序</param> /// <returns></returns> protected virtual string GetDataViewName(ThemesFilter filter, ThemeSortOption sort) { if (filter.TagIds.Count > 0 || sort == ThemeSortOption.TagSort) { return VIEW_TAGTHEME; } return VIEW_THEME; }
/// <summary> /// 根据过滤器获取所有主题(完整实体) /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="pageIndex">显示的页码,从1开始计数</param> /// <param name="pageSize">每页显示的记录数</param> /// <param name="recordCount">总记录数(ref)</param> /// <returns></returns> public List<FullThemeView> GetFullThemesByFilter(ThemesFilter filter, ThemeSortOption sort, int pageIndex, int pageSize, ref int recordCount) { return GetFullThemes(filter, sort, pageIndex, pageSize, ref recordCount); }
} /// <summary> /// 根据多种组合的标签名称获取主题列表 /// </summary> /// <param name="tags">组合的标签列表</param> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="pageIndex">显示的页码,从1开始计数</param> /// <param name="pageSize">每页显示的记录数</param> /// <param name="recordCount">总记录数(ref)</param> /// <returns></returns> public List<SimpleThemeView> GetThemesByMultiTags(List<List<string>> tags, ThemesFilter filter, ThemeSortOption sort, int pageIndex, int pageSize, ref int recordCount) { if (tags.Count > 0) { StringBuilder sbInnerSql = new StringBuilder(); for (int i = 0; i < tags.Count; i++) { if (i > 0) { sbInnerSql.Append(" INNER JOIN "); } sbInnerSql.AppendFormat("(SELECT ThemeId FROM dbo.View_TagTheme WHERE 1=1 {0} GROUP BY ThemeId) T{1}", SqlConditionBuilder.GetMultiQueryValues("TagName", tags[i]), i+1); if (i > 0) { sbInnerSql.AppendFormat(" ON T{0}.ThemeId = T{1}.ThemeId", i, i+1); } } string searchCondition = string.Format("{0} AND ThemeId in (SELECT T1.ThemeId FROM {1})", filter.ToString(), sbInnerSql.ToString()); SqlParameter[] parameters = new SqlParameter[] { SqlParameterHelper.BuildParameter("@RecordNum",SqlDbType.Int, 4, ParameterDirection.InputOutput, recordCount), SqlParameterHelper.BuildInputParameter("@SelectList",SqlDbType.VarChar,2000, SIMPLE_THEME_FIELDS), SqlParameterHelper.BuildInputParameter("@TableSource",SqlDbType.VarChar,300, "View_Theme"), SqlParameterHelper.BuildInputParameter("@SearchCondition",SqlDbType.VarChar,2000, searchCondition), SqlParameterHelper.BuildInputParameter("@OrderExpression",SqlDbType.VarChar,1000, GetSortExpression(sort)), SqlParameterHelper.BuildInputParameter("@PageSize",SqlDbType.Int,4,pageSize), SqlParameterHelper.BuildInputParameter("@PageIndex",SqlDbType.Int,4,pageIndex) }; List<SimpleThemeView> themes = new List<SimpleThemeView>(); using (IDataReader dataReader = SqlHelper.ExecuteReader(_connectionProvider.GetReadConnectionString(), CommandType.StoredProcedure, "PR_GetDataByPageIndex", parameters)) { while (dataReader.Read()) { themes.Add(BindSimpleThemeView(dataReader)); } } recordCount = Convert.ToInt32(parameters[0].Value); return themes; }
} /// <summary> /// 根据过滤器获取所有主题 /// </summary> /// <param name="filter">过滤器</param> /// <param name="sort">排序方式</param> /// <param name="displayNumber">显示条数</param> /// <returns></returns> public List<SimpleThemeView> GetThemesByFilter(ThemesFilter filter, ThemeSortOption sort, int displayNumber) {