private void CargaDatos(string sortExpression, SortDirection sortDirection) { ulong blockNumber = Convert.ToUInt64(ViewState["blockNumber"]); MainService.SearchParameter searchParameter = new MainService.SearchParameter() { BlockNumber = blockNumber }; List <MainService.TransactionDomain> items = items = mainService.GetTransactionsByBlockNumber(searchParameter).ToList <MainService.TransactionDomain>(); if (sortExpression != "") { if (ViewState["e.SortDirection"] == null) { ViewState["e.SortDirection"] = sortDirection.ToString(); } string sortDir = ViewState["e.SortDirection"].ToString(); items = Helpers.Util.OrderByField(items.AsQueryable(), sortExpression, sortDir == "Ascending").ToList(); } lblResultActivity.InnerText = "Result of transactions. Transactions found: " + items.Count; gdvTransactions.DataSource = items; gdvTransactions.DataBind(); }
public List <ClearanceStock> GetClearanceStock(int recFrom, int recTo, string orderByField, SortDirection direction, string product_code = null, string description = null, string range = null) { return(conn.Query <ClearanceStock>( $@"WITH results AS (SELECT [price_list],[product_code],[long_description], [range], exvat_price,[price],[freestock], ROW_NUMBER() OVER (ORDER BY {orderByField} {direction.ToString()}) AS RowNum FROM dbo.mpclearancestock WITH (NOLOCK) WHERE (@product_code IS NULL OR product_code LIKE @product_code) AND (@description IS NULL OR long_description LIKE @description) AND (@range IS NULL OR range LIKE @range) ) SELECT * FROM results WHERE RowNum BETWEEN @recFrom AND @recTo" , new { recFrom, recTo, product_code = !string.IsNullOrEmpty(product_code) ? $"%{product_code}%" : null, description = !string.IsNullOrEmpty(description) ? $"%{description}%" : null, range = !string.IsNullOrEmpty(range) ? $"%{range}%" : null } ).ToList()); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <ProjectStepInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <ProjectStepInfo> list = new List <ProjectStepInfo>(); Query q = ProjectStep.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); ProjectStepCollection collection = new ProjectStepCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (ProjectStep projectStep in collection) { ProjectStepInfo projectStepInfo = new ProjectStepInfo(); LoadFromDAL(projectStepInfo, projectStep); list.Add(projectStepInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <FileApplyInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <FileApplyInfo> list = new List <FileApplyInfo>(); Query q = FileApply.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); FileApplyCollection collection = new FileApplyCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (FileApply fileApply in collection) { FileApplyInfo fileApplyInfo = new FileApplyInfo(); LoadFromDAL(fileApplyInfo, fileApply); list.Add(fileApplyInfo); } pRecordCount = q.GetRecordCount(); return(list); }
// ReSharper restore NonLocalizedString // ReSharper disable NonLocalizedString public void WriteXml(XmlWriter writer) { if (Name != null) { writer.WriteAttributeString("name", Name); } if (Caption != null) { writer.WriteAttributeString("caption", Caption); } if (Format != null) { writer.WriteAttributeString("format", Format); } if (Hidden) { writer.WriteAttributeString("hidden", "true"); } if (SortIndex != null) { writer.WriteAttributeString("sortindex", SortIndex.ToString()); } if (SortDirection != null) { writer.WriteAttributeString("sortdirection", SortDirection.ToString()); } if (Total != TotalOperation.GroupBy) { writer.WriteAttributeString("total", Total.ToString()); } }
public static MvcHtmlString SortExpressionLink( this HtmlHelper helper, string title, string sortExpression, SortDirection direction = SortDirection.Ascending, object htmlAttributes = null) { var a = new TagBuilder("a"); if (htmlAttributes != null) { // get the attributes IDictionary <string, object> attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes) as IDictionary <string, object>; // set the attributes a.MergeAttributes(attributes); } var i = new TagBuilder("i"); i.MergeAttribute("class", "indicator"); a.AddCssClass("sort-expression-link"); a.MergeAttribute("title", title); a.MergeAttribute("href", "#" + sortExpression); a.MergeAttribute("data-sort-expression", sortExpression); a.MergeAttribute("data-sort-direction", direction.ToString()); a.InnerHtml = title + i.ToString(TagRenderMode.Normal); return (MvcHtmlString.Create(a.ToString(TagRenderMode.Normal))); }
AudibleQueryBuilder IAudibleQueryBuilder.WithSearchRankSelect( AudibleQueryField searchRankSelectField, SortDirection searchRankSelectDirection) { if (_searchRankSelectField != null) { throw new InvalidOperationException( $"The searchRankSelectField cannot be set to {searchRankSelectField.ToString().ToLower().SQuote()} " + $"because the instance of {nameof(AudibleQueryBuilder).SQuote()} already has the " + $"searchRankSelectField {_searchRankSelectField.ToString().ToLower().SQuote()}."); } _searchRankSelectField = searchRankSelectField; if (_searchRankSelectDirection != null) { throw new InvalidOperationException( $"The searchRankSelectDirection cannot be set to " + $"{searchRankSelectDirection.ToString().ToLower().Quote()} because the instance of " + $"{nameof(AudibleQueryBuilder).SQuote()} already has the searchRankSelectDirection " + $"{_searchRankSelectDirection.ToString().ToLower().SQuote()}."); } _searchRankSelectDirection = searchRankSelectDirection; return(this); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <ContractTypeInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <ContractTypeInfo> list = new List <ContractTypeInfo>(); Query q = ContractType.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); ContractTypeCollection collection = new ContractTypeCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (ContractType contractType in collection) { ContractTypeInfo contractTypeInfo = new ContractTypeInfo(); LoadFromDAL(contractTypeInfo, contractType); list.Add(contractTypeInfo); } pRecordCount = q.GetRecordCount(); return(list); }
ArchiveQueryBuilder IArchiveQueryBuilder.WithSort( ArchiveQueryField sortField, SortDirection sortDirection) { if (_sortField != null) { throw new InvalidOperationException( $"The sortField cannot be set to {sortField.ToString().ToLower().Quote()} because the " + $"instance of {nameof(ArchiveQueryBuilder).SQuote()} already has the sortField " + $"{_sortField.ToString().ToLower().SQuote()}."); } _sortField = sortField; if (_sortDirection != null) { throw new InvalidOperationException( $"The sortDirection cannot be set to {sortDirection.ToString().ToLower().Quote()} because the " + $"instance of {nameof(ArchiveQueryBuilder).SQuote()} already has the sortDirection " + $"{_sortDirection.ToString().ToLower().SQuote()}."); } _sortDirection = sortDirection; return(this); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <TaskInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <TaskInfo> list = new List <TaskInfo>(); Query q = Task.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); TaskCollection collection = new TaskCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Task task in collection) { TaskInfo taskInfo = new TaskInfo(); LoadFromDAL(taskInfo, task); list.Add(taskInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <WorkToolSumInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <WorkToolSumInfo> list = new List <WorkToolSumInfo>(); Query q = WorkToolSum.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); WorkToolSumCollection collection = new WorkToolSumCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (WorkToolSum workToolSum in collection) { WorkToolSumInfo workToolSumInfo = new WorkToolSumInfo(); LoadFromDAL(workToolSumInfo, workToolSum); list.Add(workToolSumInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <MainWorkSheetInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <MainWorkSheetInfo> list = new List <MainWorkSheetInfo>(); Query q = MainWorkSheet.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); MainWorkSheetCollection collection = new MainWorkSheetCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (MainWorkSheet mainWorkSheet in collection) { MainWorkSheetInfo mainWorkSheetInfo = new MainWorkSheetInfo(); LoadFromDAL(mainWorkSheetInfo, mainWorkSheet); list.Add(mainWorkSheetInfo); } pRecordCount = q.GetRecordCount(); return(list); }
public static long[] DoRank <T> (SortDirection direction, RCVector <T> vector) where T : IComparable <T> { long[] indices = new long[vector.Count]; for (long i = 0; i < indices.Length; ++i) { indices[i] = i; } RankState <T> state = new RankState <T> (vector); Comparison <long> comparison; switch (direction) { case SortDirection.asc: comparison = new Comparison <long> (state.Asc); break; case SortDirection.desc: comparison = new Comparison <long> (state.Desc); break; case SortDirection.absasc: comparison = new Comparison <long> (state.AbsAsc); break; case SortDirection.absdesc: comparison = new Comparison <long> (state.AbsDesc); break; default: throw new Exception("Unknown SortDirection: " + direction.ToString()); } Array.Sort(indices, comparison); return(indices); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <EvaluateLevelInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <EvaluateLevelInfo> list = new List <EvaluateLevelInfo>(); Query q = EvaluateLevel.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); EvaluateLevelCollection collection = new EvaluateLevelCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (EvaluateLevel evaluateLevel in collection) { EvaluateLevelInfo evaluateLevelInfo = new EvaluateLevelInfo(); LoadFromDAL(evaluateLevelInfo, evaluateLevel); list.Add(evaluateLevelInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// Create sort arrows. /// </summary> /// <param name="sortedCell"></param> protected virtual void CreateSortArrows(TableCell sortedCell) { // Add the appropriate arrow image and apply the appropriate state, depending on whether we're // sorting the results in ascending or descending order TableItemStyle sortStyle = null; string imgUrl = null; SortDirection sortDirection = (SortDirection)ViewState["SortDirection"]; if (sortDirection == SortDirection.Ascending) { imgUrl = this.ArrowUpImageUrlInternal; sortStyle = _sortAscendingStyle; } else { imgUrl = this.ArrowDownImageUrlInternal; sortStyle = _sortDescendingStyle; } Image arrow = new Image(); arrow.ImageUrl = imgUrl; arrow.ToolTip = sortDirection.ToString(); // arrow.BorderStyle = BorderStyle.None; sortedCell.Controls.Add(arrow); sortedCell.Attributes.Add("noWrap", "true"); if (sortStyle != null) { sortedCell.MergeStyle(sortStyle); } }
/// <summary> /// Enumerates the files in a given folder. /// </summary> /// <param name="folderPath">A listed folder path started with a shared folder.</param> /// <param name="offset">Optional. Specify how many files are skipped before beginning to return listed files.</param> /// <param name="limit">Optional. Number of files requested. 0 indicates to list all files with a given folder.</param> /// <param name="sortBy">Optional. Specify which file information to sort on. Default: name.</param> /// <param name="sortDirection">Optional. Specify to sort ascending or descending</param> /// <param name="globPattern">Optional. Given glob pattern(s) to find files whose names and extensions /// match a case-insensitive glob pattern.Note: /// 1. If the pattern doesn’t contain any glob syntax (? and *), * /// of glob syntax will be added at begin and end of the string automatically /// for partially matching the pattern. /// 2. You can use ”,” to separate multiple glob patterns.</param> /// <param name="fileType">Optional. “file”: only enumerate regular files; “dir”: only enumerate folders; “all” enumerate regular files and folders</param> /// <param name="gotoPath">Optional. Folder path started with a shared folder. Return all files /// and sub-folders within folder_path path until goto_path path recursively.</param> /// <param name="additionalInfo">Optional. Additional requested file information.</param> /// <returns>The list of files in the given Folder Path.</returns> public async Task <FsListResponse> ListFilesInFolderAsync(string folderPath, int offset = 0, int limit = 0, FileInformationSortValues sortBy = FileInformationSortValues.Name, SortDirection sortDirection = SortDirection.Asc, string globPattern = "", FileType fileType = FileType.All, string gotoPath = "", IEnumerable <FileStationAdditionalInfoValues> additionalInfo = null) { var requestParameters = new RequestParameters { { "folder_path", folderPath }, { "offset", offset.ToString() }, { "limit", limit.ToString() }, { "sort_by", sortBy.ToString().ToLower() }, { "pattern", globPattern }, { "filetype", fileType.ToString().ToLower() }, }; if (!string.IsNullOrEmpty(globPattern)) { requestParameters.Add("sort_direction", sortDirection.ToString().ToLower()); } if (!string.IsNullOrEmpty(gotoPath)) { requestParameters.Add("goto_path", gotoPath); } if (additionalInfo != null) { requestParameters.Add("additional", string.Join(",", additionalInfo).ToLower()); } return(await _operationProvider.PerformOperationAsync <FsListResponse>(requestParameters)); }
public static MvcHtmlString SortExpressionLink( this HtmlHelper helper, string title, string sortExpression, SortDirection direction = SortDirection.Ascending, object htmlAttributes = null) { var a = new TagBuilder("a"); if (htmlAttributes != null) { // get the attributes IDictionary<string, object> attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes) as IDictionary<string, object>; // set the attributes a.MergeAttributes(attributes); } var i = new TagBuilder("i"); i.MergeAttribute("class", "indicator"); a.AddCssClass("sort-expression-link"); a.MergeAttribute("title", title); a.MergeAttribute("href", "#" + sortExpression); a.MergeAttribute("data-sort-expression", sortExpression); a.MergeAttribute("data-sort-direction", direction.ToString()); a.InnerHtml = title + i.ToString(TagRenderMode.Normal); return MvcHtmlString.Create(a.ToString(TagRenderMode.Normal)); }
private void CargaDatos(string sortExpression, SortDirection sortDirection) { Int64?FiltroFechaDesde = ViewState["FiltroFechaDesde"] == null ? (Int64?)null : Convert.ToInt64(ViewState["FiltroFechaDesde"]); if (String.IsNullOrEmpty(txtEDN.Text)) { lblStatus.Text = "Address is a mandatory field"; return; } MainService.SearchParameter searchParameter = new MainService.SearchParameter() { Any = txtEDN.Text, From = (ulong)FiltroFechaDesde }; List <MainService.ENSHistoryDomain> items = HttpContext.Current.Cache[ConstantsHelper.cacheKeyActivity] as List <MainService.ENSHistoryDomain>; string hexAddr = "N/A"; if (items == null) { items = mainService.GetHistoryAny(searchParameter).ToList <MainService.ENSHistoryDomain>(); hexAddr = items.First().Address; if (items != null & items.First().NumberOfTransactions > 0) { HttpContext.Current.Cache.Insert(ConstantsHelper.cacheKeyActivity, items, null, DateTime.Now.AddMinutes(180), TimeSpan.Zero); } else if (items != null & items.First().NumberOfTransactions == 0) { lblStatus.Text = "Address does not exist."; return; } else if (items != null & items.First().NumberOfTransactions == -1) { lblStatus.Text = "It seems domain does not exist: " + txtEDN.Text; return; } else if (items != null & items.First().NumberOfTransactions == -2) { lblStatus.Text = "No records found for " + txtEDN.Text + " / Hex Address: " + hexAddr; return; } } if (sortExpression != "") { if (ViewState["e.SortDirection"] == null) { ViewState["e.SortDirection"] = sortDirection.ToString(); } string sortDir = ViewState["e.SortDirection"].ToString(); items = Helpers.Util.OrderByField(items.AsQueryable(), sortExpression, sortDir == "Ascending").ToList(); } lblResultActivity.InnerText = "Result of activity. Results returned: " + items.Count + " for hex address: " + hexAddr; gdvActivity.DataSource = items; gdvActivity.DataBind(); }
public void OnPostSortBy(SortBy sortby, SortDirection sortDirection) { ClearValidationState(); SortByColumn = sortby.ToString(); SortByState = sortDirection.ToString(); SortByDirectionIcon = GetSortDirectionIcon(SortByState); RefreshPage(); }
protected void grvDocumentoAluno_Sorting(object sender, GridViewSortEventArgs e) { GridView grid = (GridView)sender; if (!string.IsNullOrEmpty(e.SortExpression)) { Dictionary <string, string> filtros = __SessionWEB.BuscaRealizada.Filtros; SortDirection sortDirection = VS_SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending; if (filtros.ContainsKey("VS_Ordenacao")) { filtros["VS_Ordenacao"] = e.SortExpression; } else { filtros.Add("VS_Ordenacao", e.SortExpression); } if (filtros.ContainsKey("VS_SortDirection")) { filtros["VS_SortDirection"] = sortDirection.ToString(); } else { filtros.Add("VS_SortDirection", sortDirection.ToString()); } __SessionWEB.BuscaRealizada = new BuscaGestao { PaginaBusca = PaginaGestao.DocumentosAluno , Filtros = filtros }; } try { Pesquisar(grid.PageIndex); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar os alunos.", UtilBO.TipoMensagem.Erro); } }
/// <summary> /// Gets a list of users subscribed to a specified channel, sorted by the date when they subscribed. /// Https://dev.twitch.tv/docs/v5/reference/channels/#get-channel-subscribers /// </summary> /// <param name="_channelId">Channel Id</param> /// <param name="_pagination">Pagination info <see cref="Helpers.Pagination"/></param> /// <param name="_direction">Sort direction <see cref="Enums.SortDirection"/></param> /// <returns></returns> public async Task <dynamic> GetChannelSubscribers(string _channelId, Pagination _pagination, SortDirection _direction = SortDirection.asc) { var request = httpHelperClient.CreateHttpRequest($"kraken/channels/{_channelId}/subscriptions", HttpMethod.Get); httpHelperClient.AddQueryString(request, _pagination); httpHelperClient.AddQueryString(request, "direction", _direction.ToString()); return(await httpHelperClient.ExecuteRequest(request)); }
protected void grvAluno_Sorting(object sender, GridViewSortEventArgs e) { GridView grid = (GridView)sender; if (!string.IsNullOrEmpty(e.SortExpression)) { Dictionary <string, string> filtros = __SessionWEB.BuscaRealizada.Filtros; SortDirection sortDirection = VS_SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending; if (filtros.ContainsKey("VS_Ordenacao")) { filtros["VS_Ordenacao"] = e.SortExpression; } else { filtros.Add("VS_Ordenacao", e.SortExpression); } if (filtros.ContainsKey("VS_SortDirection")) { filtros["VS_SortDirection"] = sortDirection.ToString(); } else { filtros.Add("VS_SortDirection", sortDirection.ToString()); } __SessionWEB.BuscaRealizada = new BuscaGestao { PaginaBusca = PaginaGestao.JustificativaAbonoFalta , Filtros = filtros }; } try { Pesquisar(grid.PageIndex); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage(CustomResource.GetGlobalResourceObject("Classe", "JustificativaAbonoFalta.Mensagem.Erro"), UtilBO.TipoMensagem.Erro); } }
/// <summary> /// Gets a list of all channels followed by a specified user, sorted by the date when they started following each channel. /// Https://dev.twitch.tv/docs/v5/reference/users/#get-user-follows /// </summary> /// <param name="_userId">User Id</param> /// <param name="_pagination">Pagination info <see cref="Helpers.Pagination"/></param> /// <param name="_direction">Sort direction <see cref="Enums.SortDirection"/></param> /// <param name="_sortKey">Sort key <see cref="Enums.SortKey"/></param> /// <returns></returns> public async Task <dynamic> GetUserFollowedChannels(string _userId, Pagination _pagination, SortDirection _direction = SortDirection.desc, SortKey _sortKey = SortKey.created_at) { var request = httpHelperClient.CreateHttpRequest($"kraken/users/{_userId}/follows/channels", HttpMethod.Get); httpHelperClient.AddQueryString(request, _pagination); httpHelperClient.AddQueryString(request, "direction", _direction.ToString()); httpHelperClient.AddQueryString(request, "sortby", _sortKey.ToString()); return(await httpHelperClient.ExecuteRequest(request)); }
public object ToValues(int?page) => new { page = page ?? Page, sort_field = SortField.ToString().ToLowerInvariant(), sort_direction = SortDirection.ToString().ToLowerInvariant(), q = Search, tags = Tags, version = Version, };
/// <summary> /// Used to query current and historical PagerDuty incidents over a date range /// </summary> /// <param name="since">Start date</param> /// <param name="until">End date</param> /// <param name="fields">Specify which fields return, all fields return by default</param> /// <param name="status">Returns only the incidents currently in the passed status(es). Valid status options are triggered, acknowledged, and resolved</param> /// <param name="incident_key">Returns only the incidents with the passed de-duplication key</param> /// <param name="service">Returns only the incidents associated with the passed service(s). This expects one or more service IDs. Separate multiple ids by a comma</param> /// <param name="assigned_to_user">Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs. </param> /// <param name="sort_by">Which field to sort by</param> /// <param name="sort_direction">Sort direction (default is asc)</param> /// <param name="offSet">The offset of the first incident record returned</param> /// <param name="limit">The number of incidents returned.</param> /// <returns></returns> public IncidentsResponse GetIncidents(IncidentFilter filters, IncidentSortBy sort_by, SortDirection sort_direction, int offSet, int limit) { var client = this.GetClient("/v1/incidents"); var req = this.GetRequest(); if (filters.ReturnAll) { req.AddParameter("date_range", "all"); } else { req.AddParameter("since", filters.since.ToString("s")); req.AddParameter("until", filters.until.ToString("s")); } if (!String.IsNullOrEmpty(filters.fields)) { req.AddParameter("fields", filters.fields); } if (!String.IsNullOrEmpty(filters.status)) { req.AddParameter("status", filters.fields); } if (!String.IsNullOrEmpty(filters.incident_key)) { req.AddParameter("incident_key", filters.incident_key); } if (!String.IsNullOrEmpty(filters.service)) { req.AddParameter("service", filters.service); } if (!String.IsNullOrEmpty(filters.assigned_to_user)) { req.AddParameter("assigned_to_user", filters.assigned_to_user); } if (sort_by != IncidentSortBy.unspecified) { req.AddParameter("sort_by", sort_by.ToString() + ":" + sort_direction.ToString()); } req.AddParameter("offset", offSet); req.AddParameter("limit", limit); var resp = client.Execute <IncidentsResponse>(req); if (resp.Data == null) { throw new PagerDutyAPIException(resp); } return(resp.Data); }
void Page_Load(object sender, EventArgs e) { grdSecuredActionLocations.CurrentSortDirection = _sortDir.ToString(); grdSecuredActionLocations.CurrentSortExpression = _sortExpr; List <SecuredActionLocation> usage = GetData(); grdSecuredActionLocations.DataSource = usage; grdSecuredActionLocations.DataBind(); }
protected override object SaveControlState() { RegisterHiddenField("View", View.ToString()); RegisterHiddenField("Sort", Sort.ToString()); RegisterHiddenField("SortDirection", SortDirection.ToString()); RegisterHiddenField("ShowInGroups", ShowInGroups ? "true" : "false"); RegisterHiddenField("Directory", FileManagerController.EncodeURIComponent(CurrentDirectory.FileManagerPath)); RegisterHiddenField("SelectedItems", ""); return(new object [] { base.SaveControlState() }); }
public override void RenderBeginTag(HtmlTextWriter writer) { if (!String.IsNullOrEmpty(SortExpression)) { writer.AddAttribute("data-sorting-default-expression", Convert.ToBase64String(Encoding.UTF8.GetBytes(SortExpression))); } writer.AddAttribute("data-sorting-default-direction", SortDirection.ToString().ToLower()); base.RenderBeginTag(writer); }
public IList <GroupBE> Groups_GetByQuery(string groupNameFilter, uint?serviceIdFilter, SortDirection sortDir, GroupsSortField sortField, uint?offset, uint?limit, out uint totalCount, out uint queryCount) { List <GroupBE> result = new List <GroupBE>(); StringBuilder query = new StringBuilder(); if (groupNameFilter != null) { groupNameFilter = "%" + DataCommand.MakeSqlSafe(groupNameFilter) + "%"; } string sortFieldString = null; GROUPS_SORT_FIELD_MAPPING.TryGetValue(sortField, out sortFieldString); if ((sortFieldString ?? string.Empty).StartsWith("roles.")) { query.Append(@" left join roles on groups.group_role_id = roles.role_id"); } if ((sortFieldString ?? string.Empty).StartsWith("services.")) { query.AppendFormat(@" left join services on groups.group_service_id = services.service_id"); } if (!string.IsNullOrEmpty(groupNameFilter) || serviceIdFilter != null) { query.Append(" where (1=1)"); if (serviceIdFilter != null) { query.AppendFormat(" AND group_service_id = {0}", serviceIdFilter.Value); } if (!string.IsNullOrEmpty(groupNameFilter)) { query.AppendFormat(" AND group_name like '{0}'", groupNameFilter); } } if (!string.IsNullOrEmpty(sortFieldString)) { query.AppendFormat(" order by {0} ", sortFieldString); if (sortDir != SortDirection.UNDEFINED) { query.Append(sortDir.ToString()); } } return(Groups_GetInternal(query.ToString(), "Groups_GetByQuery", true, limit, offset, out totalCount, out queryCount)); }
protected void GridSorting(object sender, GridViewSortEventArgs e) { _sortDir = e.SortDirection; _sortExpr = e.SortExpression; grdSecuredActionLocations.CurrentSortExpression = _sortExpr; grdSecuredActionLocations.CurrentSortDirection = _sortDir.ToString(); List <SecuredActionLocation> usage = GetData(); usage.Sort(DoSort); grdSecuredActionLocations.DataBind(); }
protected void _grvAluno_Sorting(object sender, GridViewSortEventArgs e) { GridView grid = ((GridView)(sender)); if (!string.IsNullOrEmpty(e.SortExpression)) { Dictionary <string, string> filtros = __SessionWEB.BuscaRealizada.Filtros; SortDirection sortDirection = VS_SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending; if (filtros.ContainsKey("VS_Ordenacao")) { filtros["VS_Ordenacao"] = e.SortExpression; } else { filtros.Add("VS_Ordenacao", e.SortExpression); } if (filtros.ContainsKey("VS_SortDirection")) { filtros["VS_SortDirection"] = sortDirection.ToString(); } else { filtros.Add("VS_SortDirection", sortDirection.ToString()); } __SessionWEB.BuscaRealizada = new BuscaGestao { PaginaBusca = PaginaGestao.Alunos , Filtros = filtros }; } _Pesquisar(grid.PageIndex, false); }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<ProductTypeInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< ProductTypeInfo> list = new List< ProductTypeInfo>(); Query q = ProductType .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); ProductTypeCollection collection=new ProductTypeCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (ProductType productType in collection) { ProductTypeInfo productTypeInfo = new ProductTypeInfo(); LoadFromDAL(productTypeInfo, productType); list.Add(productTypeInfo); } pRecordCount=q.GetRecordCount(); return list; }
protected void GridSorting(object sender, GridViewSortEventArgs e) { _sortDir = e.SortDirection; _sortExpr = e.SortExpression; grdSecuredActionLocations.CurrentSortExpression = _sortExpr; grdSecuredActionLocations.CurrentSortDirection = _sortDir.ToString(); List<SecuredActionLocation> usage = GetData(); usage.Sort(DoSort); grdSecuredActionLocations.DataBind(); }
public static XDoc GetCommentXml(IList<CommentBE> comments, bool collection, string suffix, bool? includeParentInfo, uint? offset, SortDirection? sortDir, XDoc doc, XUri commentCollectionUri, uint? totalCount) { bool requiresEnd = false; if(collection) { string rootCommentsNode = string.IsNullOrEmpty(suffix) ? "comments" : "comments." + suffix; if(doc == null) { doc = new XDoc(rootCommentsNode); } else { doc.Start(rootCommentsNode); requiresEnd = true; } if((offset ?? 0) > 0) { doc.Attr("offset", offset.Value); } if((sortDir ?? SortDirection.UNDEFINED) != SortDirection.UNDEFINED) { doc.Attr("sort", sortDir.ToString().ToLowerInvariant()); } doc.Attr("count", comments.Count); if(totalCount != null) { doc.Attr("totalcount", totalCount.Value); } } else { doc = XDoc.Empty; } if(commentCollectionUri != null) { doc.Attr("href", commentCollectionUri); } foreach(CommentBE c in comments) { doc = AppendCommentXml(doc, c, suffix, includeParentInfo); } if(requiresEnd) { doc.End(); } return doc; }
/// <summary> /// Generates user reputation object /// </summary> /// <param name="creator"></param> /// <param name="modClass"></param> /// <param name="userId"></param> /// <returns></returns> public static UserReputationList GetUserReputationList(IDnaDataReaderCreator creator, int modClassId, int modStatus, int days, int startIndex, int itemsPerPage, SortBy sortBy, SortDirection sortDirection) { UserReputationList userRepList = new UserReputationList() { days = days, modClassId = modClassId, modStatus = modStatus, startIndex = startIndex, itemsPerPage = itemsPerPage, sortBy = sortBy, sortDirection = sortDirection }; using (IDnaDataReader dataReader = creator.CreateDnaDataReader("getuserreputationlist")) { dataReader.AddParameter("modClassId", modClassId); dataReader.AddParameter("modStatus", modStatus); dataReader.AddParameter("startIndex", startIndex); dataReader.AddParameter("itemsPerPage", itemsPerPage); dataReader.AddParameter("days", days); dataReader.AddParameter("sortby", sortBy.ToString()); dataReader.AddParameter("sortdirection", sortDirection.ToString()); dataReader.Execute(); while(dataReader.Read()) { var userRep = new UserReputation(); userRep.UserId = dataReader.GetInt32NullAsZero("userid"); userRep.ModClass = ModerationClassListCache.GetObject().ModClassList.FirstOrDefault(x => x.ClassId == dataReader.GetInt32NullAsZero("modclassid")); userRep.CurrentStatus = (ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("currentstatus"); userRep.ReputationDeterminedStatus = (ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("ReputationDeterminedStatus"); userRep.ReputationScore = dataReader.GetInt16("accumulativescore"); userRep.LastUpdated = new DateElement(dataReader.GetDateTime("lastupdated")); userRep.UserName = dataReader.GetStringNullAsEmpty("UserName"); userRepList.Users.Add(userRep); userRepList.totalItems = dataReader.GetInt32NullAsZero("total"); } } return userRepList; }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<EvaluateLevelInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< EvaluateLevelInfo> list = new List< EvaluateLevelInfo>(); Query q = EvaluateLevel .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); EvaluateLevelCollection collection=new EvaluateLevelCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (EvaluateLevel evaluateLevel in collection) { EvaluateLevelInfo evaluateLevelInfo = new EvaluateLevelInfo(); LoadFromDAL(evaluateLevelInfo, evaluateLevel); list.Add(evaluateLevelInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<CarApplyInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< CarApplyInfo> list = new List< CarApplyInfo>(); Query q = CarApply .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); CarApplyCollection collection=new CarApplyCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (CarApply carApply in collection) { CarApplyInfo carApplyInfo = new CarApplyInfo(); LoadFromDAL(carApplyInfo, carApply); list.Add(carApplyInfo); } pRecordCount=q.GetRecordCount(); return list; }
public IList<ServiceBE> Services_GetByQuery(string serviceType, SortDirection sortDir, ServicesSortField sortField, uint? offset, uint? limit, out uint totalCount, out uint queryCount) { IList<ServiceBE> services = null; uint totalCountTemp = 0; uint queryCountTemp = 0; StringBuilder whereQuery = new StringBuilder(" where 1=1"); if(!string.IsNullOrEmpty(serviceType)) { whereQuery.AppendFormat(" AND service_type = '{0}'", DataCommand.MakeSqlSafe(serviceType)); } StringBuilder sortLimitQuery = new StringBuilder(); string sortFieldString = null; //Sort by id if no sort specified. if(sortField == ServicesSortField.UNDEFINED) { sortField = ServicesSortField.ID; } if(SERVICES_SORT_FIELD_MAPPING.TryGetValue(sortField, out sortFieldString)) { sortLimitQuery.AppendFormat(" order by {0} ", sortFieldString); if(sortDir != SortDirection.UNDEFINED) { sortLimitQuery.Append(sortDir.ToString()); } } if(limit != null || offset != null) { sortLimitQuery.AppendFormat(" limit {0} offset {1}", limit ?? int.MaxValue, offset ?? 0); } string query = string.Format(@" /* Services_GetByQuery */ select * from services {0} {1}; select service_config.* from service_config join ( select service_id from services {0} {1} ) s on service_config.service_id = s.service_id; select service_prefs.* from service_prefs join ( select service_id from services {0} {1} ) s on service_prefs.service_id = s.service_id; select count(*) as totalcount from services; select count(*) as querycount from services {0}; ", whereQuery, sortLimitQuery); Catalog.NewQuery(query) .Execute(delegate(IDataReader dr) { services = Services_Populate(dr); if(dr.NextResult() && dr.Read()) { totalCountTemp = DbUtils.Convert.To<uint>(dr["totalcount"], 0); } if(dr.NextResult() && dr.Read()) { queryCountTemp = DbUtils.Convert.To<uint>(dr["querycount"], 0); } }); totalCount = totalCountTemp; queryCount = queryCountTemp; return services == null ? new List<ServiceBE>() : services; }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<MonthInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< MonthInfo> list = new List< MonthInfo>(); Query q = Month .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); MonthCollection collection=new MonthCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Month month in collection) { MonthInfo monthInfo = new MonthInfo(); LoadFromDAL(monthInfo, month); list.Add(monthInfo); } pRecordCount=q.GetRecordCount(); return list; }
public virtual void Group(DataSorterCollection groupers, SortDirection direction) { this.Call("group", new JRawValue(groupers.Serialize()), direction.ToString().ToLowerInvariant()); }
private string ConvertSortDirectionToSql(SortDirection sortDirection) { string newSortDirection = String.Empty; string[] sortData = Session["sortExpression"].ToString().Trim().Split(' '); if (Session["NewSort"].ToString() == "true") { if (sortDirection.ToString() == sortData[0]) { Session["sortExpression"] = "Descending"; newSortDirection = "DESC"; } else { Session["sortExpression"] = "Ascending"; newSortDirection = "ASC"; } } else { if (sortDirection.ToString() == sortData[0]) { Session["sortExpression"] = "Ascending"; newSortDirection = "ASC"; } else { Session["sortExpression"] = "Descending"; newSortDirection = "DESC"; } } return newSortDirection; }
private string GetOrderByClause(SortBy sortBy, SortDirection sortDirection, string articleAlias) { if (sortBy == SortBy.None) { return String.Empty; } else { switch (sortBy) { case SortBy.DateCreated: case SortBy.DateModified: case SortBy.DateOnline: case SortBy.Title: return String.Format("order by {0}.{1} {2}", articleAlias, sortBy.ToString(), sortDirection.ToString()); case SortBy.Category: return String.Format("order by {0}.Category.Title {1}", articleAlias, sortDirection.ToString()); case SortBy.CreatedBy: return String.Format("order by {0}.CreatedBy.UserName {1}", articleAlias, sortDirection.ToString()); case SortBy.ModifiedBy: return String.Format("order by {0}.ModifiedBy.UserName {1}", articleAlias, sortDirection.ToString()); default: return String.Empty; } } }
public IList<GroupBE> Groups_GetByQuery(string groupNameFilter, uint? serviceIdFilter, SortDirection sortDir, GroupsSortField sortField, uint? offset, uint? limit, out uint totalCount, out uint queryCount) { List<GroupBE> result = new List<GroupBE>(); StringBuilder query = new StringBuilder(); if (groupNameFilter != null) { groupNameFilter = "%" + DataCommand.MakeSqlSafe(groupNameFilter) + "%"; } string sortFieldString = null; GROUPS_SORT_FIELD_MAPPING.TryGetValue(sortField, out sortFieldString); if ((sortFieldString ?? string.Empty).StartsWith("roles.")) { query.Append(@" left join roles on groups.group_role_id = roles.role_id"); } if ((sortFieldString ?? string.Empty).StartsWith("services.")) { query.AppendFormat(@" left join services on groups.group_service_id = services.service_id"); } if (!string.IsNullOrEmpty(groupNameFilter) || serviceIdFilter != null) { query.Append(" where (1=1)"); if (serviceIdFilter != null) { query.AppendFormat(" AND group_service_id = {0}", serviceIdFilter.Value); } if (!string.IsNullOrEmpty(groupNameFilter)) { query.AppendFormat(" AND group_name like '{0}'", groupNameFilter); } } if (!string.IsNullOrEmpty(sortFieldString)) { query.AppendFormat(" order by {0} ", sortFieldString); if (sortDir != SortDirection.UNDEFINED) { query.Append(sortDir.ToString()); } } return Groups_GetInternal(query.ToString(), "Groups_GetByQuery", true, limit, offset, out totalCount, out queryCount); }
/// <summary> /// Used to query current and historical PagerDuty incidents over a date range /// </summary> /// <param name="since">Start date</param> /// <param name="until">End date</param> /// <param name="fields">Specify which fields return, all fields return by default</param> /// <param name="status">Returns only the incidents currently in the passed status(es). Valid status options are triggered, acknowledged, and resolved</param> /// <param name="incident_key">Returns only the incidents with the passed de-duplication key</param> /// <param name="service">Returns only the incidents associated with the passed service(s). This expects one or more service IDs. Separate multiple ids by a comma</param> /// <param name="assigned_to_user">Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs. </param> /// <param name="sort_by">Which field to sort by</param> /// <param name="sort_direction">Sort direction (default is asc)</param> /// <param name="offSet">The offset of the first incident record returned</param> /// <param name="limit">The number of incidents returned.</param> /// <returns></returns> public IncidentsResponse GetIncidents(IncidentFilter filters, IncidentSortBy sort_by, SortDirection sort_direction, int offSet, int limit) { var client = this.GetClient("/v1/incidents"); var req = this.GetRequest(); if (filters.ReturnAll) { req.AddParameter("date_range", "all"); } else { req.AddParameter("since", filters.since.ToString("s")); req.AddParameter("until", filters.until.ToString("s")); } if (!String.IsNullOrEmpty(filters.fields)) { req.AddParameter("fields", filters.fields); } if (!String.IsNullOrEmpty(filters.status)) { req.AddParameter("status", filters.fields); } if (!String.IsNullOrEmpty(filters.incident_key)) { req.AddParameter("incident_key", filters.incident_key); } if (!String.IsNullOrEmpty(filters.service)) { req.AddParameter("service", filters.service); } if (!String.IsNullOrEmpty(filters.assigned_to_user)) { req.AddParameter("assigned_to_user", filters.assigned_to_user); } if (sort_by != IncidentSortBy.unspecified) { req.AddParameter("sort_by", sort_by.ToString() + ":" + sort_direction.ToString()); } req.AddParameter("offset", offSet); req.AddParameter("limit", limit); var resp = client.Execute<IncidentsResponse>(req); if (resp.Data == null) { throw new PagerDutyAPIException(resp); } return resp.Data; }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<BusinessExpInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< BusinessExpInfo> list = new List< BusinessExpInfo>(); Query q = BusinessExp .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); BusinessExpCollection collection=new BusinessExpCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (BusinessExp businessExp in collection) { BusinessExpInfo businessExpInfo = new BusinessExpInfo(); LoadFromDAL(businessExpInfo, businessExp); list.Add(businessExpInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<FilePermissionInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< FilePermissionInfo> list = new List< FilePermissionInfo>(); Query q = FilePermission .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); FilePermissionCollection collection=new FilePermissionCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (FilePermission filePermission in collection) { FilePermissionInfo filePermissionInfo = new FilePermissionInfo(); LoadFromDAL(filePermissionInfo, filePermission); list.Add(filePermissionInfo); } pRecordCount=q.GetRecordCount(); return list; }
///<summary> ///Takes a GridView object and attaches a suitable sort artist to the headerrow cells of any sortable columns ///</summary> ///<param name="gridView">The <see cref="System.Web.UI.WebControls.GridView" /> object whose headerrow cells are to be managed</param> ///<param name="defaultSortExpression">The default sort expression of the GridView data as <see cref="System.String" /></param> ///<param name="defaultSortDirection">The default sort direction of the GridView data as <see cref="System.Web.UI.WebControls.SortDirection" /></param> ///<param name="sortImagesFolder">The folder where the sort images are stored as <see cref="System.String" />. The sort images must be named sort_ascending.gif, sort_descending.gif and sort_unsorted.gif.</param> ///<param name="viewState">The page ViewState object that will allow tracking of the current sortorder. Only used when the sort has been performed using <see cref="William.Model.Entity.EntitySorter(Of T)" /></param> ///<param name="throwEmtpyDataException">If true an error is thrown if the gridview contains no data</param> ///<remarks>Must be run from within the PreRender event of the GridView so that the HeaderRow cells are created</remarks> public static void CreateSortArrows(System.Web.UI.WebControls.GridView gridView, string defaultSortExpression, SortDirection defaultSortDirection, string sortImagesFolder, StateBag viewState, bool throwEmtpyDataException) { // Check to see if the GridView contains rows of data. If there is no data throw an exception or exit the subroutine if (gridView.Rows.Count == 0) if (throwEmtpyDataException) throw new Exception(string.Format("The GridView \"{0}\" has no data.{1}Please ensure that you check the GridView has rows of data before running the CreateSortArrows shared method.", gridView.ID, Environment.NewLine)); else return; // Check to see that the GridView has been created before working with the HeaderRow cells // Although the RowCreated event fires after every row is created the actual GridView is // not created until after all rows have been created if (gridView.HeaderRow == null) throw new Exception(string.Format("The GridView \"{0}\" has not yet been created.{1}Please check that you are running the CreateSortArrows shared method from within the GridView's PreRender event handler.", gridView.ID, Environment.NewLine)); // Enumerate the columns and create the arrows for each sortable column foreach(DataControlField dcf in gridView.Columns) { if (!string.IsNullOrEmpty(dcf.SortExpression)) { string sortDirection = string.Empty; // Work out which arrow is to be used for this column. If viewstate is passed in // use William.Model.Data.EntitySorter's custom tracking, otherwise use the properties of the gridview if (viewState != null) { if (dcf.SortExpression == (string)viewState["EntitySortProperty"]) sortDirection = ((SortDirection)viewState["EntitySortDirection"]).ToString(); else if (string.IsNullOrEmpty((string)viewState["EntitySortProperty"]) && dcf.SortExpression == defaultSortExpression) { sortDirection = defaultSortDirection.ToString(); viewState["EntitySortProperty"] = defaultSortExpression; viewState["EntitySortDirection"] = defaultSortDirection; } else sortDirection = "Unsorted"; } else { if (dcf.SortExpression == gridView.SortExpression) sortDirection = gridView.SortDirection.ToString(); else if (string.IsNullOrEmpty(gridView.SortExpression) && dcf.SortExpression == defaultSortExpression) sortDirection = defaultSortDirection.ToString(); else sortDirection = "Unsorted"; } Image sortImage = new Image(); sortImage.ImageUrl = string.Format(sortImagesFolder + "sort_{0}.gif", sortDirection.ToLower()); sortImage.AlternateText = string.Format("Sort Order: {0}", sortDirection); sortImage.ToolTip = string.Format("Sort Order: {0}", sortDirection); sortImage.Style.Add("margin-left", "5px"); gridView.HeaderRow.Cells[gridView.Columns.IndexOf(dcf)].Controls.Add(sortImage); } } } // CreateSortArrows
public IEnumerable<UserBE> Users_GetByQuery(string usernamefilter, string realnamefilter, string usernameemailfilter, string rolefilter, bool? activatedfilter, uint? groupId, uint? serviceIdFilter, bool? seatFilter, SortDirection sortDir, UsersSortField sortField, uint? offset, uint? limit, out uint totalCount, out uint queryCount) { List<UserBE> users = new List<UserBE>(); uint totalCountTemp = 0; uint queryCountTemp = 0; StringBuilder joinQuery = new StringBuilder(); string sortFieldString; USERS_SORT_FIELD_MAPPING.TryGetValue(sortField, out sortFieldString); if(!string.IsNullOrEmpty(rolefilter) || (sortFieldString ?? string.Empty).StartsWith("roles.")) { joinQuery.Append(@" left join roles on users.user_role_id = roles.role_id"); } if((sortFieldString ?? string.Empty).StartsWith("services.")) { joinQuery.AppendFormat(@" left join services on users.user_service_id = services.service_id"); } if(groupId != null) { joinQuery.AppendFormat(@" join groups on groups.group_id = {0} join user_groups on user_groups.group_id = groups.group_id", groupId.Value); } StringBuilder whereQuery = new StringBuilder(" where 1=1"); if(groupId != null) { whereQuery.AppendFormat(" AND users.user_id = user_groups.user_id"); } if(!string.IsNullOrEmpty(usernamefilter) && !string.IsNullOrEmpty(realnamefilter)) { whereQuery.AppendFormat(" AND (user_name like '{0}%' OR user_real_name like '{1}%')", DataCommand.MakeSqlSafe(usernamefilter), DataCommand.MakeSqlSafe(realnamefilter)); } else if(!string.IsNullOrEmpty(usernamefilter)) { whereQuery.AppendFormat(" AND user_name like '{0}%'", DataCommand.MakeSqlSafe(usernamefilter)); } else if(!string.IsNullOrEmpty(realnamefilter)) { whereQuery.AppendFormat(" AND user_real_name like '{0}%'", DataCommand.MakeSqlSafe(realnamefilter)); } if(!string.IsNullOrEmpty(usernameemailfilter)) { whereQuery.AppendFormat(" AND (user_name like '{0}%' OR user_email like '{0}%')", DataCommand.MakeSqlSafe(usernameemailfilter)); } if(activatedfilter != null) { whereQuery.AppendFormat(" AND user_active = {0}", activatedfilter.Value ? "1" : "0"); } if(!string.IsNullOrEmpty(rolefilter)) { whereQuery.AppendFormat(" AND role_name = '{0}'", DataCommand.MakeSqlSafe(rolefilter)); } if(serviceIdFilter != null) { whereQuery.AppendFormat(" AND user_service_id = {0}", serviceIdFilter.Value); } if(seatFilter != null) { whereQuery.AppendFormat(" AND user_seat = {0}", seatFilter.Value ? 1 : 0); } StringBuilder sortLimitQuery = new StringBuilder(); if(!string.IsNullOrEmpty(sortFieldString)) { sortLimitQuery.AppendFormat(" order by {0} ", sortFieldString); if(sortDir != SortDirection.UNDEFINED) { sortLimitQuery.Append(sortDir.ToString()); } } if(limit != null || offset != null) { sortLimitQuery.AppendFormat(" limit {0} offset {1}", limit ?? int.MaxValue, offset ?? 0); } string query = string.Format(@" /* Users_GetByQuery */ select * from users {0} {1} {2}; select count(*) as totalcount from users {0} {3}; select count(*) as querycount from users {0} {1};", joinQuery, whereQuery, sortLimitQuery, groupId == null ? string.Empty : "where users.user_id = user_groups.user_id"); Catalog.NewQuery(query) .Execute(delegate(IDataReader dr) { while(dr.Read()) { UserBE u = Users_Populate(dr); users.Add(u); } if(dr.NextResult() && dr.Read()) { totalCountTemp = DbUtils.Convert.To<uint>(dr["totalcount"], 0); } if(dr.NextResult() && dr.Read()) { queryCountTemp = DbUtils.Convert.To<uint>(dr["querycount"], 0); } }); totalCount = totalCountTemp; queryCount = queryCountTemp; return users; }
public virtual void Group(string field, SortDirection direction) { this.Call("group", field, direction.ToString().ToLowerInvariant()); }
public IList<CommentBE> Comments_GetByPage(PageBE page, CommentFilter searchStatus, bool includePageDescendants, uint? postedByUserId, SortDirection datePostedSortDir, uint? offset, uint? limit, out uint totalComments) { List<CommentBE> comments = new List<CommentBE>(); uint totalCommentsTemp = 0; string joins = string.Empty; if(includePageDescendants) { joins = "JOIN pages \n\tON comments.cmnt_page_id = pages.page_id"; } string whereClauses = "\n 1=1"; switch(searchStatus) { case CommentFilter.DELETED: whereClauses += "\n AND cmnt_delete_date is not null"; break; case CommentFilter.NONDELETED: whereClauses += "\n AND cmnt_delete_date is null"; break; } if(includePageDescendants) { whereClauses += @" AND( ( (( ?TITLE = '' AND pages.page_title != '') OR (LEFT(pages.page_title, CHAR_LENGTH(?TITLE) + 1) = CONCAT(?TITLE, '/') AND SUBSTRING(pages.page_title, CHAR_LENGTH(?TITLE) + 2, 1) != '/')) AND pages.page_namespace = ?NS AND pages.page_is_redirect = 0 ) OR pages.page_id = ?PAGEID)"; } else { whereClauses += "\n AND cmnt_page_id = ?PAGEID"; } if(postedByUserId != null) { whereClauses += "\n AND cmnt_poster_user_id = ?POSTERID"; } string orderby = string.Empty; if(datePostedSortDir != SortDirection.UNDEFINED) { orderby = string.Format("ORDER BY cmnt_create_date {0}, cmnt_id {0}", datePostedSortDir.ToString()); } List<uint> userids = new List<uint>(); string query = string.Format(@" /* Comments_GetByPage */ SELECT SQL_CALC_FOUND_ROWS comments.* FROM comments {0} WHERE {1} {2} LIMIT ?COUNT OFFSET ?OFFSET; select found_rows() as totalcomments;" , joins, whereClauses, orderby); Catalog.NewQuery(query) .With("PAGEID", page.ID) .With("TITLE", page.Title.AsUnprefixedDbPath()) .With("NS", (int)page.Title.Namespace) .With("POSTERID", postedByUserId) .With("COUNT", limit ?? UInt32.MaxValue) .With("OFFSET", offset ?? 0) .Execute(delegate(IDataReader dr) { while(dr.Read()) { CommentBE c = Comments_Populate(dr); if(c.DeleterUserId != null) { userids.Add(c.DeleterUserId ?? 0); } if(c.LastEditUserId != null) { userids.Add(c.LastEditUserId ?? 0); } userids.Add(c.PosterUserId); comments.Add(c); } if(dr.NextResult() && dr.Read()) { totalCommentsTemp = DbUtils.Convert.To<uint>(dr["totalcomments"]) ?? 0; } }); totalComments = totalCommentsTemp; return comments; }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<WeekSumInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< WeekSumInfo> list = new List< WeekSumInfo>(); Query q = WeekSum .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); WeekSumCollection collection=new WeekSumCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (WeekSum weekSum in collection) { WeekSumInfo weekSumInfo = new WeekSumInfo(); LoadFromDAL(weekSumInfo, weekSum); list.Add(weekSumInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<ActionMasterInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< ActionMasterInfo> list = new List< ActionMasterInfo>(); Query q = ActionMaster .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); ActionMasterCollection collection=new ActionMasterCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (ActionMaster actionMaster in collection) { ActionMasterInfo actionMasterInfo = new ActionMasterInfo(); LoadFromDAL(actionMasterInfo, actionMaster); list.Add(actionMasterInfo); } pRecordCount=q.GetRecordCount(); return list; }