public ListWorkflowInstancesRequest(int page, int pageSize = 50, string?workflowDefinitionId = default, WorkflowStatus?workflowStatus = default, OrderBy?orderBy = default, string?searchTerm = default)
 {
     Page                 = page;
     PageSize             = pageSize;
     WorkflowDefinitionId = workflowDefinitionId;
     WorkflowStatus       = workflowStatus;
     OrderBy              = orderBy;
     SearchTerm           = searchTerm;
 }
Example #2
0
        private async Task <ContentResponse> SubBrowseApiAsync(string id, ContentSource source, BrowseItemType browseType, ExtraDetails extra, OrderBy?orderBy = null, int?maxItems = null, int?page = null, string language = null, string country = null, string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = await FormatRequestParametersAsync(continuationToken, language, country);

            if (orderBy.HasValue)
            {
                requestParameters.Add("orderby", orderBy.ToString());
            }
            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }
            if (page.HasValue)
            {
                requestParameters.Add("page", page.ToString());
            }
            return(await GetWithRetryOnExpiredTokenAsync <ContentResponse>(
                       "/1/content/" + id + "/" + source + "/" + browseType + "/" + extra + "/browse",
                       new CancellationToken(false), requestParameters));
        }
Example #3
0
        private IEnumerable <CompletedEvent> GetOrderedCompletedEvents(IEnumerable <CompletedEvent> completedEvents, OrderBy?orderBy, OrderDirection?orderDirection)
        {
            switch (orderBy)
            {
            case OrderBy.PatientName:
                return(GetOrderedCompletedEventsByDirection(completedEvents, orderDirection, e => e.Period.Pathway.Patient.Name));

            case OrderBy.EventDescription:
                return(GetOrderedCompletedEventsByDirection(completedEvents, orderDirection, e => e.Name.Description));

            case OrderBy.Specialty:
                return(GetOrderedCompletedEventsByDirection(completedEvents, orderDirection, e => e.Clinician.Specialty.Name));

            case OrderBy.Clinician:
                return(GetOrderedCompletedEventsByDirection(completedEvents, orderDirection, e => e.Clinician.Name));

            case OrderBy.DaysInPeriod:
                return(GetOrderedCompletedEventsByDirection(completedEvents, orderDirection, e => e.Period.GetDaysSpentAt(_clock.Today)));

            case OrderBy.DaysRemainingInPeriod:
                return(GetOrderedCompletedEventsByDirection(completedEvents, orderDirection, e => e.Period.GetDaysRemainingAt(_clock.Today)));
            }
            return(completedEvents.ToArray());
        }
Example #4
0
        public async Task <ActionResult> Archieve([Range(2010, 2099)] int yyyy, [Range(1, 12)] int mm, [Range(1, 31)] int dd, [Optional] OrderBy?orderBy, int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15, string mode = nameof(Models.Entity.Post.ModifyDate))
        {
            page = Math.Max(1, page);
            if (!DateTime.TryParse(yyyy + "-" + mm + "-" + dd, out var date))
            {
                date = DateTime.Today;
            }

            var where = PostBaseWhere().And(p => p.Status == Status.Published);
            where     = mode switch
            {
                nameof(Models.Entity.Post.PostDate) => where.And(p => p.PostDate.Date == date),
                _ => where.And(p => p.ModifyDate.Date == date),
            };
            var queryable = PostService.GetQuery(where);
            var h24       = DateTime.Today.AddDays(-1);
            var posts     = orderBy switch
            {
                OrderBy.Trending => await queryable.OrderByDescending(p => p.PostVisitRecordStats.Where(e => e.Date >= h24).Sum(e => e.Count)).ToCachedPagedListAsync <Post, PostDto>(page, size, MapperConfig),
                _ => await queryable.OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync <Post, PostDto>(page, size, MapperConfig)
            };
            var viewModel = await GetIndexPageViewModel();

            viewModel.Posts             = posts;
            viewModel.PageParams        = new Pagination(page, size, posts.TotalCount, orderBy);
            viewModel.SidebarAds        = AdsService.GetsByWeightedPrice(2, AdvertiseType.SideBar, Request.Location());
            viewModel.ListAdvertisement = AdsService.GetByWeightedPrice(AdvertiseType.ListItem, Request.Location());
            PostService.SolvePostsCategory(posts.Data);
            foreach (var item in posts.Data)
            {
                item.ModifyDate = item.ModifyDate.ToTimeZone(HttpContext.Session.Get <string>(SessionKey.TimeZone));
            }

            return(View(viewModel));
        }
Example #5
0
        public async Task <XCommasResponse <SmartTrade[]> > GetSmartTradesAsync(int?accountId = null, string pair = null, SmartTradeType?type = null, SmartTradeStatus?status = null, OrderBy?orderBy = null, OrderDirection?orderDirection = null, int?page = null, int?perPage = null)
        {
            var param = new Dictionary <string, string>();

            if (accountId.HasValue)
            {
                param.Add("accountId", accountId.Value.ToString());
            }
            AddIfHasValue(param, "pair", pair);
            AddIfHasValue(param, "type", type?.GetEnumMemberAttrValue());
            AddIfHasValue(param, "status", status?.GetEnumMemberAttrValue());
            AddIfHasValue(param, "order_by", orderBy?.GetEnumMemberAttrValue());
            AddIfHasValue(param, "order_direction", orderDirection?.GetEnumMemberAttrValue());
            AddIfHasValue(param, "page", page.ToString());
            AddIfHasValue(param, "per_page", perPage.ToString());

            var qString = BuildQueryString(param);
            var path    = $"{BaseAddress}/v2/smart_trades{qString}";

            using (var request = XCommasRequest.Get(path).Force(UserMode).Sign(this))
            {
                return(await this.GetResponse <SmartTrade[]>(request).ConfigureAwait(false));
            }
        }
Example #6
0
        /// <summary>
        /// Gets products by an artist.
        /// </summary>
        /// <param name="id">The artist id.</param>
        /// <param name="category">The category.</param>
        /// <param name="orderBy">The field to sort the items by.</param>
        /// <param name="sortOrder">The sort order of the items to fetch.</param>
        /// <param name="startIndex">The zero-based start index to fetch items from (e.g. to get the second page of 10 items, pass in 10).</param>
        /// <param name="itemsPerPage">The number of items to fetch.</param>
        /// <returns>
        /// A ListResponse containing Products or an Error
        /// </returns>
        public Task <ListResponse <Product> > GetArtistProductsAsync(string id, Category?category = null, OrderBy?orderBy = null, SortOrder?sortOrder = null, int startIndex = MusicClient.DefaultStartIndex, int itemsPerPage = MusicClient.DefaultItemsPerPage)
        {
            var cmd = this.CreateCommand <ArtistProductsCommand>();

            cmd.ArtistId     = id;
            cmd.Category     = category;
            cmd.OrderBy      = orderBy;
            cmd.SortOrder    = sortOrder;
            cmd.StartIndex   = startIndex;
            cmd.ItemsPerPage = itemsPerPage;
            return(cmd.InvokeAsync());
        }
Example #7
0
        /// <summary>
        /// Searches Nokia Music
        /// </summary>
        /// <param name="searchTerm">Optional search term.</param>
        /// <param name="category">Optional category.</param>
        /// <param name="genreId">Optional genre id</param>
        /// <param name="orderBy">The field to sort the items by.</param>
        /// <param name="sortOrder">The sort order of the items to fetch.</param>
        /// <param name="startIndex">The zero-based start index to fetch items from (e.g. to get the second page of 10 items, pass in 10).</param>
        /// <param name="itemsPerPage">The number of items to fetch.</param>
        /// <param name="requestId">Id of the request.</param>
        /// <remarks>A searchTerm or genreId should be supplied</remarks>
        /// <returns>A ListResponse containing MusicItems or an Error</returns>
        public Task <ListResponse <MusicItem> > SearchAsync(string searchTerm = null, Category?category = null, string genreId = null, OrderBy?orderBy = null, SortOrder?sortOrder = null, int startIndex = MusicClient.DefaultStartIndex, int itemsPerPage = MusicClient.DefaultItemsPerPage, Guid?requestId = null)
        {
            var cmd = this.CreateCommand <SearchCommand>();

            cmd.SearchTerm   = searchTerm;
            cmd.Category     = category;
            cmd.GenreId      = genreId;
            cmd.OrderBy      = orderBy;
            cmd.SortOrder    = sortOrder;
            cmd.StartIndex   = startIndex;
            cmd.ItemsPerPage = itemsPerPage;

            this.SetRequestId(cmd, requestId);

            return(cmd.InvokeAsync());
        }
        public static ServiceProviderGridVm GetServiceProviderGridVm(int?pageNumber, int?pageSize, ServiceProviderGridSortByOption?sortBy, OrderBy?orderBy, ServiceProviderGridFilter filter)
        {
            ServiceProviderGridVm serviceProviderGrid = new ServiceProviderGridVm();
            int totalCount;
            List <ServiceProvider> serviceProviders = ServiceProviderBc.Instance.GetAll(pageNumber, pageSize, sortBy, orderBy, filter, out totalCount);

            serviceProviderGrid.List = serviceProviders.MapToServiceProviderForGridVmList();
            if (pageNumber.HasValue)
            {
                serviceProviderGrid.PageNumber = pageNumber.Value;
            }
            if (pageSize.HasValue)
            {
                serviceProviderGrid.PageSize = pageSize.Value;
            }
            serviceProviderGrid.SortBy     = sortBy;
            serviceProviderGrid.OrderBy    = orderBy;
            serviceProviderGrid.TotalCount = totalCount;
            serviceProviderGrid.GridUrl    = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "ServiceProvider",
                Action     = "Grid"
            });
            serviceProviderGrid.JsonGridUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "ServiceProvider",
                Action     = "JsonGrid"
            });
            serviceProviderGrid.ChangePackageTypeUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "ServiceProvider",
                Action     = "ChangePackageType"
            });
            serviceProviderGrid.ChangeSeniorHousingAndCareCategoriesUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "ServiceProvider",
                Action     = "ChangeSeniorHousingAndCareCategories"
            });
            serviceProviderGrid.ChangeFeatureDatesUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "ServiceProvider",
                Action     = "ChangeFeatureDates"
            });
            serviceProviderGrid.ChangePublishDatesUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "ServiceProvider",
                Action     = "ChangePublishDates"
            });
            serviceProviderGrid.Filter = filter.MapToFilterForServiceProviderGridVm();
            return(serviceProviderGrid);
        }
Example #9
0
        /// <summary>
        /// Gets products by an artist.
        /// </summary>
        /// <param name="id">The artist id.</param>
        /// <param name="category">The category.</param>
        /// <param name="orderBy">The field to sort the items by.</param>
        /// <param name="sortOrder">The sort order of the items.</param>
        /// <param name="startIndex">The zero-based start index to fetch items from (e.g. to get the second page of 10 items, pass in 10).</param>
        /// <param name="itemsPerPage">The number of items to fetch.</param>
        /// <param name="cancellationToken">The cancellation token to cancel operation</param>
        /// <returns>
        /// A ListResponse containing Products or an Error
        /// </returns>
        public async Task <ListResponse <Product> > GetArtistProductsAsync(string id, Category?category = null, OrderBy?orderBy = null, SortOrder?sortOrder = null, int startIndex = MusicClient.DefaultStartIndex, int itemsPerPage = MusicClient.DefaultItemsPerPage, CancellationToken?cancellationToken = null)
        {
            var cmd = this.CreateCommand <ArtistProductsCommand>();

            cmd.ArtistId     = id;
            cmd.Category     = category;
            cmd.OrderBy      = orderBy;
            cmd.SortOrder    = sortOrder;
            cmd.StartIndex   = startIndex;
            cmd.ItemsPerPage = itemsPerPage;
            return(await cmd.ExecuteAsync(cancellationToken).ConfigureAwait(false));
        }
        public static CommunityForGridVm GetLastCommunityForGrid(int?pageNumber, int?pageSize, CommunityGridSortByOption?sortBy, OrderBy?orderBy, CommunityGridFilter filter)
        {
            int totalCount;

            return(CommunityBc.Instance.GetAll(pageNumber * pageSize, 1, sortBy, orderBy, filter, out totalCount).FirstOrDefault().MapToCommunityForGridVm());
        }
        public static CommunityGridVm GetCommunityGridVm(int?pageNumber, int?pageSize, CommunityGridSortByOption?sortBy, OrderBy?orderBy, CommunityGridFilter filter)
        {
            CommunityGridVm communityGrid = new CommunityGridVm();

            communityGrid.IsAdmin = true;
            int totalCount;
            List <Community> communities = CommunityBc.Instance.GetAll(pageNumber, pageSize, sortBy, orderBy, filter, out totalCount);

            communityGrid.List = communities.MapToCommunityForGridVmList();
            if (pageNumber.HasValue)
            {
                communityGrid.PageNumber = pageNumber.Value;
            }
            if (pageSize.HasValue)
            {
                communityGrid.PageSize = pageSize.Value;
            }
            communityGrid.TotalCount = totalCount;
            communityGrid.SortBy     = sortBy;
            communityGrid.OrderBy    = orderBy;
            communityGrid.GridUrl    = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "Grid"
            });
            communityGrid.JsonGridUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "JsonGrid"
            });
            communityGrid.ChangeListingTypeStateUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "ChangeListingTypeState"
            });
            communityGrid.ChangePackageTypeUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "ChangePackageType"
            });
            communityGrid.ChangeSeniorHousingAndCareCategoriesUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "ChangeSeniorHousingAndCareCategories"
            });
            communityGrid.ChangeShowcaseDatesUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "ChangeShowcaseDates"
            });
            communityGrid.ChangePublishDatesUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "ChangePublishDates"
            });
            communityGrid.DeleteCommunityUrl = MSLivingChoices.Mvc.Uipc.Legacy.MslcUrlBuilder.GetRouteUrl("iList", new
            {
                Controller = "Community",
                Action     = "Delete"
            });
            communityGrid.Filter = filter.MapToFilterForCommunityGridVm();
            return(communityGrid);
        }
Example #12
0
        public List <Community> GetAll(List <Book> books, int?pageNumber, int?pageSize, CommunityGridSortByOption?sortBy, OrderBy?orderBy, CommunityGridFilter filter, out int totalCount)
        {
            pageNumber = pageNumber ?? ConfigurationManager.Instance.DefaultGridPageNumber;
            pageSize   = pageSize ?? ConfigurationManager.Instance.DefaultGridPageSize;
            GetCommunityGridCommand command = new GetCommunityGridCommand(books, pageNumber.Value, pageSize.Value, sortBy, orderBy, filter);

            command.Execute();
            totalCount = command.GetTotalCount();
            return(command.CommandResult);
        }
Example #13
0
 public GetCommunityGridCommand(List <Book> books, int pageNumber, int pageSize, CommunityGridSortByOption?sortBy, OrderBy?orderBy, CommunityGridFilter filter)
 {
     base.StoredProcedureName = AdminStoredProcedures.SpGetCommunityGridWithPaging;
     this._books      = books;
     this._pageNumber = pageNumber;
     this._pageSize   = pageSize;
     this._sortBy     = sortBy;
     this._orderBy    = orderBy;
     this._filter     = filter;
 }
Example #14
0
        private async Task <ContentResponse> BrowseApiAsync(
            MediaNamespace mediaNamespace,
            ContentSource source,
            ItemType type,
            string genre             = null,
            string mood              = null,
            string activity          = null,
            OrderBy?orderBy          = null,
            int?maxItems             = null,
            int?page                 = null,
            string country           = null,
            string language          = null,
            string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = await FormatRequestParametersAsync(continuationToken, language, country);

            if (genre != null)
            {
                requestParameters.Add("genre", genre);
            }

            if (mood != null)
            {
                requestParameters.Add("mood", genre);
            }

            if (activity != null)
            {
                requestParameters.Add("activity", genre);
            }

            if (orderBy.HasValue)
            {
                requestParameters.Add("orderby", orderBy.ToString());
            }

            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }

            if (page.HasValue)
            {
                requestParameters.Add("page", page.ToString());
            }

            if (_userTokenManager?.UserIsSignedIn == true)
            {
                return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                           headers => GetAsync <ContentResponse>(
                               Hostname,
                               $"/1/content/{mediaNamespace}/{source}/{type}/browse",
                               new CancellationToken(false),
                               requestParameters,
                               headers)));
            }
            else
            {
                Dictionary <string, string> requestHeaders = await FormatRequestHeadersAsync(null);

                return(await GetAsync <ContentResponse>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/{source}/{type}/browse",
                           new CancellationToken(false),
                           requestParameters,
                           requestHeaders));
            }
        }
Example #15
0
 /// <summary>
 /// Sort the result by the <paramref name="column"/> in descending order.
 /// </summary>
 /// <param name="column">The column name.</param>
 /// <returns>The <see cref="ThenOrderByBuilder"/>.</returns>
 public ThenOrderByBuilder ByDescending(string column)
 {
     OrderBy = new OrderBy(Table, column, SortDirection.Descending);
     return(new ThenOrderByBuilder(Table, OrderBy));
 }
Example #16
0
        /// <summary>
        /// Searches for tracks with a Beats per Minute range.
        /// </summary>
        /// <param name="minBpm">The minimum BPM.</param>
        /// <param name="maxBpm">The maximum BPM.</param>
        /// <param name="genreId">The genre identifier.</param>
        /// <param name="orderBy">The order by.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="startIndex">The start index.</param>
        /// <param name="itemsPerPage">The items per page.</param>
        /// <param name="requestId">The request identifier.</param>
        /// <param name="cancellationToken">The cancellation token to cancel operation</param>
        /// <returns>
        /// A list of tracks
        /// </returns>
        public async Task <ListResponse <MusicItem> > SearchBpmAsync(int minBpm, int maxBpm, string genreId = null, OrderBy?orderBy = null, SortOrder?sortOrder = null, int startIndex = MusicClient.DefaultStartIndex, int itemsPerPage = MusicClient.DefaultItemsPerPage, Guid?requestId = null, CancellationToken?cancellationToken = null)
        {
            var cmd = this.CreateCommand <SearchCommand>();

            cmd.MinBpm       = minBpm;
            cmd.MaxBpm       = maxBpm;
            cmd.Category     = Category.Track;
            cmd.GenreId      = genreId;
            cmd.OrderBy      = orderBy;
            cmd.SortOrder    = sortOrder;
            cmd.StartIndex   = startIndex;
            cmd.ItemsPerPage = itemsPerPage;

            this.SetRequestId(cmd, requestId);

            return(await cmd.ExecuteAsync(cancellationToken).ConfigureAwait(false));
        }
Example #17
0
        /// <summary> Gets all issues for the specified project. </summary>
        /// <param name="projectId"> The ID of the project. </param>
        /// <param name="state"> Limit the results to the specified state. (opened/closed) </param>
        /// <param name="labels"> Limit the results to only issues with the specified labels. </param>
        /// <param name="milestone"> Limit the results to only issues for the specified milestone. </param>
        /// <param name="orderBy"> Order the results by created_at or updated_at. Default is created_at. </param>
        /// <param name="sort"> Sort results in ascending or descending order. (asc/desc) </param>
        /// <returns> A <see cref="PaginatedResult{Issue}" /> representing the results of the request. </returns>
        public async Task <PaginatedResult <Issue> > GetByProject(uint projectId, IssueState?state = null,
                                                                  string[] labels = null, string milestone = null, OrderBy?orderBy = null, SortOrder?sort = null)
        {
            var stateValue = state != null?Enum.GetName(typeof(IssueState), state)?.ToLower() : null;

            var orderByValue = orderBy?.GetDescription();
            var sortValue    = sort != null?Enum.GetName(typeof(SortOrder), sort)?.ToLower() : null;

            var request = RequestFactory.Create("projects/{projectId}/issues", Method.Get);

            request.AddUrlSegment("projectId", projectId);
            request.AddParameterIfNotNull("state", stateValue);
            request.AddParameterIfNotNull("labels", labels.ToCommaSeparated());
            request.AddParameterIfNotNull("milestone", milestone);
            request.AddParameterIfNotNull("order_by", orderByValue);
            request.AddParameterIfNotNull("sort", sortValue);

            return(await request.ExecutePaginated <Issue>());
        }
Example #18
0
        public async Task <IActionResult> Handle(
            [FromQuery(Name = "workflow")] string?workflowDefinitionId = default,
            [FromQuery(Name = "status")] WorkflowStatus?workflowStatus = default,
            [FromQuery] string?correlationId = default,
            [FromQuery] OrderBy?orderBy      = default,
            [FromQuery] string?searchTerm    = default,
            int page     = 0,
            int pageSize = 25,
            CancellationToken cancellationToken = default)
        {
            _stopwatch.Restart();
            var specification = Specification <WorkflowInstance> .Identity;

            if (!string.IsNullOrWhiteSpace(workflowDefinitionId))
            {
                specification = specification.WithWorkflowDefinition(workflowDefinitionId);
            }

            if (!string.IsNullOrWhiteSpace(correlationId))
            {
                specification = specification.WithCorrelationId(correlationId);
            }

            if (workflowStatus != null)
            {
                specification = specification.WithStatus(workflowStatus.Value);
            }

            if (!string.IsNullOrWhiteSpace(searchTerm))
            {
                specification = specification.WithSearchTerm(searchTerm);
            }

            var tenantId = await _tenantAccessor.GetTenantIdAsync(cancellationToken);

            specification = specification.And(new TenantSpecification <WorkflowInstance>(tenantId));

            var orderBySpecification = default(OrderBy <WorkflowInstance>);

            if (orderBy != null)
            {
                orderBySpecification = orderBy switch
                {
                    OrderBy.Started => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.CreatedAt),
                    OrderBy.LastExecuted => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.LastExecutedAt !),
                    OrderBy.Finished => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.FinishedAt !),
                    _ => OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.FinishedAt !)
                };
            }

            var totalCount = await _workflowInstanceStore.CountAsync(specification, cancellationToken : cancellationToken);

            var paging            = Paging.Page(page, pageSize);
            var workflowInstances = await _workflowInstanceStore.FindManyAsync(specification, orderBySpecification, paging, cancellationToken).ToList();

            var items = _mapper.Map <ICollection <WorkflowInstanceSummaryModel> >(workflowInstances);

            _stopwatch.Stop();
            _logger.LogDebug("Handle took {TimeElapsed}", _stopwatch.Elapsed);
            var model = new PagedList <WorkflowInstanceSummaryModel>(items, page, pageSize, totalCount);

            return(Json(model, _contentSerializer.GetSettings()));
        }
    }
Example #19
0
        /// <summary>
        /// Gets products by an artist.
        /// </summary>
        /// <param name="artist">The artist.</param>
        /// <param name="category">The category.</param>
        /// <param name="orderBy">The field to sort the items by.</param>
        /// <param name="sortOrder">The sort order of the items to fetch.</param>
        /// <param name="startIndex">The zero-based start index to fetch items from (e.g. to get the second page of 10 items, pass in 10).</param>
        /// <param name="itemsPerPage">The number of items to fetch.</param>
        /// <returns>
        /// A ListResponse containing Products or an Error
        /// </returns>
        /// <exception cref="System.ArgumentNullException">artist;Artist cannot be null</exception>
        public Task <ListResponse <Product> > GetArtistProductsAsync(Artist artist, Category?category = null, OrderBy?orderBy = null, SortOrder?sortOrder = null, int startIndex = MusicClient.DefaultStartIndex, int itemsPerPage = MusicClient.DefaultItemsPerPage)
        {
            if (artist == null)
            {
                throw new ArgumentNullException("artist", "Artist cannot be null");
            }

            return(this.GetArtistProductsAsync(artist.Id, category, orderBy, sortOrder, startIndex, itemsPerPage));
        }
Example #20
0
        /// <summary>
        /// 获取页面视图模型
        /// </summary>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="orderBy"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        private IndexPageViewModel GetIndexPageViewModel(int page, int size, OrderBy?orderBy, UserInfoOutputDto user)
        {
            var postsQuery  = PostService.GetQuery <PostOutputDto>(p => (p.Status == Status.Pended || user.IsAdmin));                                                                             //准备文章的查询
            var notices     = NoticeService.GetPagesFromCache <DateTime, NoticeOutputDto>(1, 5, out int _, n => (n.Status == Status.Display || user.IsAdmin), n => n.ModifyDate, false).ToList(); //加载前5条公告
            var cats        = CategoryService.GetQueryFromCache <string, CategoryOutputDto>(c => c.Status == Status.Available, c => c.Name).ToList();                                             //加载分类目录
            var hotSearches = RedisHelper.Get <List <KeywordsRankOutputDto> >("SearchRank:Week").Take(10).ToList();                                                                               //热词统计
            Expression <Func <PostOutputDto, double> > order = p => p.TotalViewCount;

            switch (new Random().Next() % 3)
            {
            case 1:
                order = p => p.VoteUpCount;
                break;

            case 2:
                order = p => p.AverageViewCount;
                break;
            }
            var hot6Post = postsQuery.OrderByDescending(order).Skip(0).Take(5).Cacheable().ToList();                                                                                                                          //热门文章
            var newdic   = new Dictionary <string, int>();                                                                                                                                                                    //标签云最终结果
            var tagdic   = postsQuery.Where(p => !string.IsNullOrEmpty(p.Label)).Select(p => p.Label).Cacheable().AsEnumerable().SelectMany(s => s.Split(',', ',')).GroupBy(s => s).ToDictionary(g => g.Key, g => g.Count()); //统计标签

            if (tagdic.Any())
            {
                int min = tagdic.Values.Min();
                tagdic.ForEach(kv =>
                {
                    var fontsize = (int)Math.Floor(kv.Value * 1.0 / (min * 1.0) + 12.0);
                    newdic.Add(kv.Key, fontsize >= 36 ? 36 : fontsize);
                });
            }
            IList <PostOutputDto> posts;

            switch (orderBy) //文章排序
            {
            case OrderBy.CommentCount:
                posts = postsQuery.Where(p => !p.IsFixedTop).OrderByDescending(p => p.CommentCount).Skip(size * (page - 1)).Take(size).Cacheable().ToList();
                break;

            case OrderBy.PostDate:
                posts = postsQuery.Where(p => !p.IsFixedTop).OrderByDescending(p => p.PostDate).Skip(size * (page - 1)).Take(size).Cacheable().ToList();
                break;

            case OrderBy.ViewCount:
                posts = postsQuery.Where(p => !p.IsFixedTop).OrderByDescending(p => p.TotalViewCount).Skip(size * (page - 1)).Take(size).Cacheable().ToList();
                break;

            case OrderBy.VoteCount:
                posts = postsQuery.Where(p => !p.IsFixedTop).OrderByDescending(p => p.VoteUpCount).Skip(size * (page - 1)).Take(size).Cacheable().ToList();
                break;

            case OrderBy.AverageViewCount:
                posts = postsQuery.Where(p => !p.IsFixedTop).OrderByDescending(p => p.AverageViewCount).Skip(size * (page - 1)).Take(size).Cacheable().ToList();
                break;

            default:
                posts = postsQuery.Where(p => !p.IsFixedTop).OrderByDescending(p => p.ModifyDate).Skip(size * (page - 1)).Take(size).Cacheable().ToList();
                break;
            }
            if (page == 1)
            {
                posts = postsQuery.Where(p => p.IsFixedTop).OrderByDescending(p => p.ModifyDate).AsEnumerable().Union(posts).ToList();
            }
            return(new IndexPageViewModel()
            {
                Categories = cats,
                HotSearch = hotSearches,
                Notices = notices,
                Posts = posts,
                Tags = newdic,
                Top6Post = hot6Post,
                PostsQueryable = postsQuery,
                SidebarAds = AdsService.GetsByWeightedPrice(2, AdvertiseType.SideBar),
                ListAdvertisement = AdsService.GetByWeightedPrice(AdvertiseType.PostList)
            });
        }
        public List <Community> GetAll(int?pageNumber, int?pageSize, CommunityGridSortByOption?sortBy, OrderBy?orderBy, CommunityGridFilter filter, out int totalCount)
        {
            List <Book> books = new List <Book>();

            if (!AccountBc.Instance.IsUserInRole(UmsRoles.Admin))
            {
                books = AccountBc.Instance.GetBooks().ConvertAll <Book>((Publication p) => new Book()
                {
                    Id = new long?((long)p.Id)
                });
            }
            else
            {
                books.Add(new Book()
                {
                    Id = new long?((long)-1)
                });
            }
            return(this._communityDac.GetAll(books, pageNumber, pageSize, sortBy, orderBy, filter, out totalCount));
        }
Example #22
0
        /// <summary>
        /// Searches for items
        /// </summary>
        /// <typeparam name="T">The type to return</typeparam>
        /// <param name="searchTerm">The search term.</param>
        /// <param name="genreId">The genre to filter the results by.</param>
        /// <param name="id">An artist or product id.</param>
        /// <param name="category">The category to filter the results by.</param>
        /// <param name="location">The location to filter the results by.</param>
        /// <param name="maxdistance">The max distance from the location to to filter the results by.</param>
        /// <param name="orderBy">The field to sort the items by.</param>
        /// <param name="sortOrder">The sort order of the items to fetch.</param>
        /// <param name="startIndex">The zero-based start index to fetch items from (e.g. to get the second page of 10 items, pass in 10).</param>
        /// <param name="itemsPerPage">The number of items to fetch.</param>
        /// <param name="converter">The object creation method to use</param>
        /// <param name="callback">The callback to use when the API call has completed</param>
        protected void InternalSearch <T>(string searchTerm, string genreId, string id, Category?category, string location, string maxdistance, OrderBy?orderBy, SortOrder?sortOrder, int startIndex, int itemsPerPage, JTokenConversionDelegate <T> converter, Action <ListResponse <T> > callback)
        {
            // Build querystring parameters...
            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(PagingStartIndex, startIndex.ToString(CultureInfo.InvariantCulture)),
                new KeyValuePair <string, string>(PagingItemsPerPage, itemsPerPage.ToString(CultureInfo.InvariantCulture))
            };

            if (!string.IsNullOrEmpty(searchTerm))
            {
                parameters.Add(new KeyValuePair <string, string>(ParamSearchTerm, searchTerm));
            }

            if (!string.IsNullOrEmpty(genreId))
            {
                parameters.Add(new KeyValuePair <string, string>(ParamGenre, genreId));
            }

            if (!string.IsNullOrEmpty(id))
            {
                parameters.Add(new KeyValuePair <string, string>(ParamId, id));
            }

            if (category != null && category.Value != Types.Category.Unknown)
            {
                parameters.Add(new KeyValuePair <string, string>(ParamCategory, category.Value.ToString().ToLowerInvariant()));
            }

            if (orderBy != null && orderBy.HasValue)
            {
                parameters.Add(new KeyValuePair <string, string>(ParamOrderBy, orderBy.Value.ToString().ToLowerInvariant()));
            }

            if (sortOrder != null && sortOrder.HasValue)
            {
                parameters.Add(new KeyValuePair <string, string>(ParamSortOrder, sortOrder.Value.ToString().ToLowerInvariant()));
            }

            if (!string.IsNullOrEmpty(location))
            {
                parameters.Add(new KeyValuePair <string, string>(ParamLocation, location));
            }

            if (!string.IsNullOrEmpty(maxdistance))
            {
                parameters.Add(new KeyValuePair <string, string>(ParamMaxDistance, maxdistance));
            }

            this.RequestHandler.SendRequestAsync(
                this,
                this.ClientSettings,
                parameters,
                new JsonResponseCallback(rawResult => this.ListItemResponseHandler <T>(rawResult, ArrayNameItems, converter, callback)));
        }
Example #23
0
 public XCommasResponse <SmartTrade[]> GetSmartTrades(int?accountId = null, string pair = null, SmartTradeType?type = null, SmartTradeStatus?status = null, OrderBy?orderBy = null, OrderDirection?orderDirection = null, int?page = null, int?perPage = null) => this.GetSmartTradesAsync(accountId, pair, type, status, orderBy, orderDirection, page, perPage).Result;
Example #24
0
        private static RestAPIResponse Push(DataSiftClient client, string command)
        {
            RestAPIResponse response = null;

            OrderDirection tmpOrderDir;
            OrderDirection?orderDir = null;
            OrderBy        tmpOrderBy;
            OrderBy?       orderBy = null;

            if (Enum.TryParse(_argsParser.GetParameter <string>("order_dir"), out tmpOrderDir))
            {
                orderDir = tmpOrderDir;
            }

            if (Enum.TryParse(_argsParser.GetParameter <string>("order_by"), out tmpOrderBy))
            {
                orderBy = tmpOrderBy;
            }

            switch (command)
            {
            case "validate":
                response = client.Push.Validate(_argsParser.GetParameter <string>("output_type"),
                                                _argsParser.GetParameter <ExpandoObject>("output_params"));
                break;

            case "create":
                PushStatus statusTemp;
                PushStatus?status = null;

                if (Enum.TryParse(_argsParser.GetParameter <string>("initial_status"), out statusTemp))
                {
                    status = statusTemp;
                }

                response = client.Push.Create(_argsParser.GetParameter <string>("name"), _argsParser.GetParameter <string>("output_type"),
                                              _argsParser.GetParameter <ExpandoObject>("output_params"), hash: _argsParser.GetParameter <string>("hash"), historicsId: _argsParser.GetParameter <string>("historics_id"),
                                              initialStatus: status, start: _argsParser.GetParameter <DateTimeOffset?>("start"), end: _argsParser.GetParameter <DateTimeOffset?>("end"));
                break;

            case "update":
                if (_argsParser.Contains("output_params"))
                {
                    response = client.Push.Update(_argsParser.GetParameter <string>("id"), _argsParser.GetParameter <ExpandoObject>("output_params"), name: _argsParser.GetParameter <string>("name"));
                }
                else
                {
                    response = client.Push.Update(_argsParser.GetParameter <string>("id"), name: _argsParser.GetParameter <string>("name"));
                }
                break;

            case "pause":
                response = client.Push.Pause(_argsParser.GetParameter <string>("id"));
                break;

            case "resume":
                response = client.Push.Resume(_argsParser.GetParameter <string>("id"));
                break;

            case "delete":
                response = client.Push.Delete(_argsParser.GetParameter <string>("id"));
                break;

            case "stop":
                response = client.Push.Stop(_argsParser.GetParameter <string>("id"));
                break;

            case "log":
                response = client.Push.Log(_argsParser.GetParameter <string>("id"), _argsParser.GetParameter <int?>("page"),
                                           _argsParser.GetParameter <int?>("per_page"), orderDir);

                break;

            case "get":
                response = client.Push.Get(id: _argsParser.GetParameter <string>("id"), hash: _argsParser.GetParameter <string>("hash"),
                                           historicsId: _argsParser.GetParameter <string>("historics_id"), page: _argsParser.GetParameter <int?>("page"),
                                           perPage: _argsParser.GetParameter <int?>("per_page"), orderBy: orderBy, orderDirection: orderDir, includeFinished: _argsParser.GetParameter <bool?>("include_finished"));
                break;

            default:
                throw new ApplicationException("Unrecognised command: " + command);
            }

            return(response);
        }
Example #25
0
 public Task <ContentResponse> BrowseAsync(Namespace mediaNamespace, ContentSource source, ItemType type,
                                           string genre   = null, OrderBy?orderBy = null, int?maxItems = null, int?page = null, string language = null,
                                           string country = null)
 {
     return(BrowseApiAsync(mediaNamespace, source, type, genre, orderBy, maxItems, page, language, country));
 }
Example #26
0
        public static IQueryable<T> SortBy<T>(this IQueryable<T> query, string attributeName, OrderBy? orderBy)
        {
            Type type = typeof(T);
            ParameterExpression param = Expression.Parameter(type, "x");
            Type lambdaType = type.GetProperty(attributeName).PropertyType;

            MethodCallExpression expression = Expression.Call(typeof(Queryable),
                GetOrderByMethodName(orderBy),
                new Type[] {type, lambdaType},
                query.Expression,
                Expression.Lambda(Expression.Property(param, type.GetProperty(attributeName)), param));
            return query.Provider.CreateQuery<T>(expression);
        }
Example #27
0
 public Task <ContentResponse> SubBrowseAsync(string id, ContentSource source, BrowseItemType browseType, ExtraDetails extra, OrderBy?orderBy = null, int?maxItems = null, int?page = null, string language = null, string country = null)
 {
     return(SubBrowseApiAsync(id, source, browseType, extra, orderBy, maxItems, page, language, country));
 }
Example #28
0
        public static IQueryable<T> SortBy<T>(this IQueryable<T> query, Expression<Func<T, object>> attribute, OrderBy? orderBy)
        {
            Type type = typeof(T);
            ParameterExpression param = Expression.Parameter(type, "x");
            var body = attribute.Body as MemberExpression;
            Type lambdaType = type.GetProperty(body.Member.Name).PropertyType;

            MethodCallExpression expression = Expression.Call(typeof(Queryable), 
                                                GetOrderByMethodName(orderBy),
                                                new Type[] { type, lambdaType},
                                                query.Expression,
                                                Expression.Lambda(Expression.Property(param, type.GetProperty(body.Member.Name)), param));
            return query.Provider.CreateQuery<T>(expression);            
        }
Example #29
0
        public CurrentOrderSummaryReport listCurrentOrders(ISet <String> betIds, ISet <String> marketIds, OrderProjection?orderProjection = null, TimeRange placedDateRange = null, OrderBy?orderBy = null, SortDir?sortDir = null, int?fromRecord = null, int?recordCount = null)
        {
            var args = new Dictionary <string, object>();

            args[BET_IDS]           = betIds;
            args[MARKET_IDS]        = marketIds;
            args[ORDER_PROJECTION]  = orderProjection;
            args[PLACED_DATE_RANGE] = placedDateRange;
            args[ORDER_BY]          = orderBy;
            args[SORT_DIR]          = sortDir;
            args[FROM_RECORD]       = fromRecord;
            args[RECORD_COUNT]      = recordCount;

            return(Invoke <CurrentOrderSummaryReport>(LIST_CURRENT_ORDERS_METHOD, args));
        }
Example #30
0
        public void ReturnTheCollectionOfArticlesOrderedByAscending_WhenUserIdIsEmptyAndOrderIsAscendingOrNull(OrderBy?order)
        {
            // Arrange
            IQueryable <Article> expectedArticles = new List <Article>()
            {
                new Article()
                {
                    CreatedOn = DateTime.UtcNow
                },
                new Article()
                {
                    CreatedOn = DateTime.Now
                }
            }.OrderBy(x => x.CreatedOn)
            .AsQueryable();

            this.dbSetWrapperMock.Setup(x => x.All).Returns(expectedArticles);

            // Act
            IQueryable <Article> actualArticles = this.service.GetAllOrderedByCreatedOn(order, string.Empty);

            // Assert
            CollectionAssert.AreEqual(expectedArticles, actualArticles);
        }