Exemple #1
0
        public List <Models.Watch> GetStoreWatches(int storeId, SortBy?sortBy, int?pageNumber, int?pageSize, out int count)
        {
            Store store = storeRepository.Get().Where(s => s.Id == storeId).Include(s => s.StoreBookmarks).FirstOrDefault();

            if (store == null)
            {
                throw new NotFoundException("فروشگاه");
            }

            IQueryable <Models.Watch> result = watchRepository.Get().Where(w => w.User_Id == store.User_Id).Include(w => w.Brand);

            if (sortBy == SortBy.Popularity)
            {
                result = result.OrderByDescending(w => w.WatchBookmarks.Count);
            }

            count = result.Count();

            if (pageNumber.HasValue && pageSize.HasValue)
            {
                result = result.Skip((pageNumber.Value - 1) * pageSize.Value).Take(pageSize.Value);
            }
            else
            {
                result = result.Take(10);
            }

            return(result.ToList());
        }
Exemple #2
0
        public ActionResult ListOperation(int containerId, ListOperation operation, SortBy?sortBy, SortDirection?sortByDirection, PagerParameters pagerParameters)
        {
            var items = _containerService.GetContentItems(containerId, VersionOptions.Latest).Select(x => x.As <ContainablePart>());

            switch (operation)
            {
            case ViewModels.ListOperation.Reverse:
                _containerService.Reverse(items);
                _services.Notifier.Success(T("The list has been reversed."));
                break;

            case ViewModels.ListOperation.Shuffle:
                _containerService.Shuffle(items);
                _services.Notifier.Success(T("The list has been shuffled."));
                break;

            case ViewModels.ListOperation.Sort:
                _containerService.Sort(items, sortBy.GetValueOrDefault(), sortByDirection.GetValueOrDefault());
                _services.Notifier.Success(T("The list has been sorted."));
                break;

            default:
                _services.Notifier.Error(T("Please select an operation to perform on the list."));
                break;
            }

            return(RedirectToAction("List", new { containerId, page = pagerParameters.Page, pageSize = pagerParameters.PageSize }));
        }
Exemple #3
0
        /// <inheritdoc/>
        public async Task <IListResult <Room> > GetRoomsAsync(int max       = 100, string teamId  = "",
                                                              RoomType?type = null, SortBy?sortBy = null)
        {
            var roomParams = new List <KeyValuePair <string, string> >();

            if (max != 100)
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(max), max.ToString()));
            }

            if (!string.IsNullOrEmpty(teamId))
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(teamId), teamId));
            }

            if (type != null)
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(type), type.ToString().ToLower()));
            }

            if (sortBy != null)
            {
                roomParams.Add(new KeyValuePair <string, string>(nameof(sortBy), sortBy.ToString().ToLower()));
            }

            var path = await GetPathWithQueryAsync(WxTeamsConstants.RoomsUrl, roomParams);

            return(await TeamsClient.GetResultsAsync <Room>(path));
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            SortBy?by = value as SortBy?;

            if (!by.HasValue)
            {
                return(null);
            }
            switch (by.Value)
            {
            case SortBy.Place:
                return("Nazwa miejsca");

            case SortBy.City:
                return("Miasto");

            case SortBy.Price:
                return("Cena");

            case SortBy.StartDate:
                return("Data rozpoczęcia");

            case SortBy.EndDate:
                return("Data zakończenia");

            case SortBy.VacanciesNumber:
                return("Liczba wolnych miejsc");

            case SortBy.PublishDate:
                return("Data opublikowania");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #5
0
        public string GetEnumValue(SortBy?sortBy)
        {
            switch (sortBy)
            {
            case SortBy.None:
            case null:
                return("None");

            case SortBy.PriceFromLowToHigh:
                return("Price from low to high");

            case SortBy.PriceFromHighToLow:
                return("Price from high to low");

            case SortBy.NameFromAtoZ:
                return("From A to Z");

            case SortBy.NameFromZtoA:
                return("From Z to A");

            case SortBy.ByDate:
                return("By Date (New First)");

            case SortBy.Discount:
                return("Discount");

            default:
                return(sortBy.ToString());
            }
        }
Exemple #6
0
        /// <summary>
        /// 日志首页,列表页
        /// </summary>
        /// <returns></returns>
        public virtual ActionResult Home(int pageSize = 8, int pageIndex = 1, SortBy?sortBy = null)
        {
            var input = new GetBlogsInput
            {
                PageSize  = pageSize,
                PageIndex = pageIndex,
                SortBy    = sortBy
            };
            var list = _blogService.GetBlogs(input);

            return(View(list));
        }
        public ActionResult Index(SortBy?sortBy)
        {
            string uid   = Request.Cookies["user"]?["userId"];
            var    prods = DataAccessor.GetAllProducts(uid).ToClientProducts();

            switch (sortBy)
            {
            case SortBy.Date:
                prods = prods.OrderByDescending(p => p.UploadingDate);
                break;

            case SortBy.Title:
                prods = prods.OrderBy(p => p.Title);
                break;

            default: break;
            }
            return(View("Index", prods));
        }
        public static KeyValuePair <string, string> SortParameter(this BaseRequestModel baseRequestModel, SortBy?sortBy, SortDirection direction)
        {
            if (IsNullableObject(sortBy))
            {
                return(NullKeyValuePair());
            }

            string sort = sortBy.ToString();

            if (direction == SortDirection.Descending)
            {
                sort = "-" + sort;
            }

            return(new KeyValuePair <string, string>("sort", sort));
        }
        public CatalogViewModel GetItems(int?currentPage, int?itemsPerPage, string currentBrand, SortBy?sortBy)
        {
            var filter = new FilterViewModel
            {
                FilterByBrand = new FilterByBrandViewModel
                {
                    Brands       = GetBrands(),
                    CurrentBrand = GetBrands().Contains(currentBrand) ? currentBrand : "All"
                },
                SortingBy = sortBy
            };

            var catalogFilter = new CatalogFilterViewModel
            {
                Filter     = filter,
                Pagination = new PaginationViewModel
                {
                    CurrentPage  = currentPage ?? 1,
                    ItemsPerPage = itemsPerPage ?? 4,
                    TotalItems   = GetTotalItems(filter)
                }
            };

            var catalogItems = GetCatalogItems(catalogFilter);

            var viewmodel = new CatalogViewModel
            {
                CatalogItems = catalogItems,
                Filter       = catalogFilter
            };

            return(viewmodel);
        }
        private static string GetQuery(List <FolderFilter> filters, int?limit, int?offset, SortBy?sortBy, SortOrder?sortOrder)
        {
            var uri = new UriBuilder(SkyDriveBaseUrl + SkyDriveConstants.GetFiles);

            var filterString = ParseFilters(filters);

            uri.SetQueryParam(SkyDriveConstants.Filters, filterString);

            if (limit.HasValue)
            {
                uri.SetQueryParam(LiveSdkConstants.Limit, limit.Value.ToString());
            }

            if (offset.HasValue)
            {
                uri.SetQueryParam(LiveSdkConstants.Offset, offset.Value.ToString());
            }

            if (sortBy.HasValue)
            {
                uri.SetQueryParam(SkyDriveConstants.SortBy, sortBy.ToString().ToLower());
            }

            if (sortOrder.HasValue)
            {
                uri.SetQueryParam(SkyDriveConstants.SortOrder, sortBy.ToString().ToLower());
            }

            return(uri.Query);
        }
Exemple #11
0
 public IList <WebTVEpisodeBasic> GetTVEpisodesBasicForTVShowByRange(int?provider, string id, int start, int end, SortBy?sort = SortBy.TVEpisodeNumber, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllEpisodesBasic().AsQueryable().Where(p => p.ShowId == id).SortMediaItemList(sort, order, SortBy.TVEpisodeNumber).TakeRange(start, end - start).Finalize(provider, ProviderType.TVShow));
 }
Exemple #12
0
 public Task <List <Player> > GetGamePlayersAsync(SortBy?sortBy = null, OrderBy?orderBy = null, int?startingAt = null, int?numberToRetrieve = null, DateTime?startDate = null, DateTime?endDate = null, string platform = null)
 {
     throw new NotImplementedException();
 }
Exemple #13
0
 public IList <WebTVSeasonBasic> GetTVSeasonsBasicForTVShow(int?provider, string id, SortBy?sort = SortBy.TVSeasonNumber, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllSeasonsBasic().AsQueryable().Where(x => x.ShowId == id).SortMediaItemList(sort, order, SortBy.TVSeasonNumber).Finalize(provider, ProviderType.TVShow));
 }
Exemple #14
0
        public static IEnumerable <CatalogItem> SortByFilter(this IEnumerable <CatalogItem> source, SortBy?sortBy)
        {
            switch (sortBy)
            {
            case SortBy.None:
            case null:
                return(source.OrderBy(i => i.Id));

            case SortBy.NameFromAtoZ:
                return(source.OrderBy(i => i.Name));

            case SortBy.NameFromZtoA:
                return(source.OrderByDescending(i => i.Name));

            case SortBy.PriceFromLowToHigh:
                return(source.OrderBy(i => i.Price));

            case SortBy.PriceFromHighToLow:
                return(source.OrderByDescending(i => i.Price));

            case SortBy.ByDate:
                return(source.OrderByDescending(i => i.CreatedinUtc));

            default: return(source.OrderBy(i => i.Id));
            }
        }
Exemple #15
0
 public IList <WebTVEpisodeBasic> GetAllTVEpisodesBasic(int?provider, SortBy?sort = SortBy.TVEpisodeNumber, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllEpisodesBasic().AsQueryable().SortMediaItemList(sort, order, SortBy.TVEpisodeNumber).Finalize(provider, ProviderType.TVShow));
 }
Exemple #16
0
        public IList <WebFilesystemItem> GetFileSystemFilesAndFoldersByRange(int?provider, string id, int start, int end, SortBy?sort = SortBy.Title, OrderBy?order = OrderBy.Asc)
        {
            var listA = FileSystemLibraries[provider].GetFilesListing(id).AsQueryable().Select(x => x.ToWebFilesystemItem());
            var listB = FileSystemLibraries[provider].GetFoldersListing(id).AsQueryable().Select(x => x.ToWebFilesystemItem());

            return(listA.Concat(listB).SortMediaItemList(sort, order).TakeRange(start, end).Finalize(provider, ProviderType.Filesystem).ToList());
        }
Exemple #17
0
 public IList <WebFileBasic> GetFileSystemFilesByRange(int?provider, string id, int start, int end, SortBy?sort = SortBy.Title, OrderBy?order = OrderBy.Asc)
 {
     return(FileSystemLibraries[provider].GetFilesListing(id).AsQueryable().SortMediaItemList(sort, order).TakeRange(start, end).Finalize(provider, ProviderType.Filesystem).ToList());
 }
Exemple #18
0
 public IList <WebFolderBasic> GetAllFileSystemFolders(int?provider, string id, SortBy?sort = SortBy.Title, OrderBy?order = OrderBy.Asc)
 {
     return(FileSystemLibraries[provider].GetFoldersListing(id).AsQueryable().SortMediaItemList(sort, order).Finalize(provider, ProviderType.Filesystem).ToList());
 }
Exemple #19
0
 public IList <WebDriveBasic> GetAllFileSystemDrives(int?provider, SortBy?sort = SortBy.Title, OrderBy?order = OrderBy.Asc)
 {
     return(FileSystemLibraries[provider].GetDriveListing().AsQueryable().SortMediaItemList(sort, order).Finalize(provider, ProviderType.Filesystem).ToList());
 }
Exemple #20
0
 public IList <WebActor> GetTVShowActorsByRange(int?provider, int start, int end, SortBy?sort = SortBy.Name, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllTVShowsBasic().AsQueryable().SelectMany(x => x.Actors).Distinct().SortMediaItemList(sort, order, SortBy.Name).TakeRange(start, end).Finalize(provider, ProviderType.TVShow));
 }
Exemple #21
0
 public IList <WebTVEpisodeDetailed> GetTVEpisodesDetailedForSeason(int?provider, string id, SortBy?sort = SortBy.TVEpisodeNumber, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllEpisodesDetailed().AsQueryable().Where(p => p.SeasonId == id).SortMediaItemList(sort, order, SortBy.TVEpisodeNumber).Finalize(provider, ProviderType.TVShow));
 }
Exemple #22
0
        public static async Task <int> Generate(SortBy?groupSortBy, SortBy?userSortBy, string?csvOutdir, CancellationToken cancellationToken = default)
        {
            var(users, loadUsersErrMsg) = await Users.LoadUsersAsync(cancellationToken);

            if (loadUsersErrMsg is not null)
            {
                Console.WriteLine(loadUsersErrMsg);
                return(1);
            }

            var(loadedNodes, loadNodesErrMsg) = await Nodes.LoadNodesAsync(cancellationToken);

            if (loadNodesErrMsg is not null)
            {
                Console.WriteLine(loadNodesErrMsg);
                return(1);
            }
            using var nodes = loadedNodes;

            var(settings, loadSettingsErrMsg) = await Settings.LoadSettingsAsync(cancellationToken);

            if (loadSettingsErrMsg is not null)
            {
                Console.WriteLine(loadSettingsErrMsg);
                return(1);
            }

            // collect data
            var totalBytesUsed      = nodes.Groups.Select(x => x.Value.BytesUsed).Aggregate(0UL, (x, y) => x + y);
            var totalBytesRemaining = nodes.Groups.All(x => x.Value.DataLimitInBytes > 0UL)
                ? nodes.Groups.Select(x => x.Value.BytesRemaining).Aggregate(0UL, (x, y) => x + y)
                : 0UL;

            var recordsByGroup = nodes.GetDataUsageByGroup();
            var recordsByUser  = users.GetDataUsageByUser();

            // calculate column width
            var maxGroupNameLength = recordsByGroup.Select(x => x.group.Length)
                                     .DefaultIfEmpty()
                                     .Max();
            var groupNameFieldWidth = maxGroupNameLength > 5 ? maxGroupNameLength + 2 : 7;
            var maxUsernameLength   = recordsByUser.Select(x => x.username.Length)
                                      .DefaultIfEmpty()
                                      .Max();
            var usernameFieldWidth = maxUsernameLength > 4 ? maxUsernameLength + 2 : 6;

            // sort
            var groupSortByInEffect = groupSortBy ?? settings.GroupDataUsageDefaultSortBy;

            recordsByGroup = groupSortByInEffect switch
            {
                SortBy.DefaultAscending => recordsByGroup,
                SortBy.DefaultDescending => recordsByGroup.Reverse(),
                SortBy.NameAscending => recordsByGroup.OrderBy(x => x.group),
                SortBy.NameDescending => recordsByGroup.OrderByDescending(x => x.group),
                SortBy.DataUsedAscending => recordsByGroup.OrderBy(x => x.bytesUsed),
                SortBy.DataUsedDescending => recordsByGroup.OrderByDescending(x => x.bytesUsed),
                SortBy.DataRemainingAscending => recordsByGroup.OrderBy(x => x.bytesRemaining),
                SortBy.DataRemainingDescending => recordsByGroup.OrderByDescending(x => x.bytesRemaining),
                _ => throw new NotImplementedException("This sort method is not implemented!"),
            };

            var userSortByInEffect = userSortBy ?? settings.UserDataUsageDefaultSortBy;

            recordsByUser = userSortByInEffect switch
            {
                SortBy.DefaultAscending => recordsByUser,
                SortBy.DefaultDescending => recordsByUser.Reverse(),
                SortBy.NameAscending => recordsByUser.OrderBy(x => x.username),
                SortBy.NameDescending => recordsByUser.OrderByDescending(x => x.username),
                SortBy.DataUsedAscending => recordsByUser.OrderBy(x => x.bytesUsed),
                SortBy.DataUsedDescending => recordsByUser.OrderByDescending(x => x.bytesUsed),
                SortBy.DataRemainingAscending => recordsByUser.OrderBy(x => x.bytesRemaining),
                SortBy.DataRemainingDescending => recordsByUser.OrderByDescending(x => x.bytesRemaining),
                _ => throw new NotImplementedException("This sort method is not implemented!"),
            };

            // total
            Console.WriteLine("In the last 30 days:");
            Console.WriteLine();

            if (totalBytesUsed != 0UL)
            {
                Console.WriteLine($"{"Total data used",-24}{InteractionHelper.HumanReadableDataString1024(totalBytesUsed)}");
            }

            if (totalBytesRemaining != 0UL)
            {
                Console.WriteLine($"{"Total data remaining",-24}{InteractionHelper.HumanReadableDataString1024(totalBytesRemaining)}");
            }

            Console.WriteLine();

            // by group
            Console.WriteLine("Data usage by group");

            if (recordsByGroup.All(x => x.bytesRemaining == 0UL)) // Omit data remaining column if no data.
            {
                ConsoleHelper.PrintTableBorder(groupNameFieldWidth, 11);
                Console.WriteLine($"|{"Group".PadRight(groupNameFieldWidth)}|{"Data Used",11}|");
                ConsoleHelper.PrintTableBorder(groupNameFieldWidth, 11);

                foreach (var(group, bytesUsed, _) in recordsByGroup)
                {
                    Console.Write($"|{group.PadRight(groupNameFieldWidth)}|");

                    if (bytesUsed != 0UL)
                    {
                        Console.WriteLine($"{InteractionHelper.HumanReadableDataString1024(bytesUsed),11}|");
                    }
                    else
                    {
                        Console.WriteLine($"{string.Empty,11}|");
                    }
                }

                ConsoleHelper.PrintTableBorder(groupNameFieldWidth, 11);
            }
            else
            {
                ConsoleHelper.PrintTableBorder(groupNameFieldWidth, 11, 16);
                Console.WriteLine($"|{"Group".PadRight(groupNameFieldWidth)}|{"Data Used",11}|{"Data Remaining",16}|");
                ConsoleHelper.PrintTableBorder(groupNameFieldWidth, 11, 16);

                foreach (var(group, bytesUsed, bytesRemaining) in recordsByGroup)
                {
                    Console.Write($"|{group.PadRight(groupNameFieldWidth)}|");

                    if (bytesUsed != 0UL)
                    {
                        Console.Write($"{InteractionHelper.HumanReadableDataString1024(bytesUsed),11}|");
                    }
                    else
                    {
                        Console.Write($"{string.Empty,11}|");
                    }

                    if (bytesRemaining != 0UL)
                    {
                        Console.WriteLine($"{InteractionHelper.HumanReadableDataString1024(bytesRemaining),16}|");
                    }
                    else
                    {
                        Console.WriteLine($"{string.Empty,16}|");
                    }
                }

                ConsoleHelper.PrintTableBorder(groupNameFieldWidth, 11, 16);
            }

            Console.WriteLine();

            // by user
            Console.WriteLine("Data usage by user");

            if (recordsByUser.All(x => x.bytesRemaining == 0UL)) // Omit data remaining column if no data.
            {
                ConsoleHelper.PrintTableBorder(usernameFieldWidth, 11);
                Console.WriteLine($"|{"User".PadRight(usernameFieldWidth)}|{"Data Used",11}|");
                ConsoleHelper.PrintTableBorder(usernameFieldWidth, 11);

                foreach (var(username, bytesUsed, _) in recordsByUser)
                {
                    Console.Write($"|{username.PadRight(usernameFieldWidth)}|");

                    if (bytesUsed != 0UL)
                    {
                        Console.WriteLine($"{InteractionHelper.HumanReadableDataString1024(bytesUsed),11}|");
                    }
                    else
                    {
                        Console.WriteLine($"{string.Empty,11}|");
                    }
                }

                ConsoleHelper.PrintTableBorder(usernameFieldWidth, 11);
            }
            else
            {
                ConsoleHelper.PrintTableBorder(usernameFieldWidth, 11, 16);
                Console.WriteLine($"|{"User".PadRight(usernameFieldWidth)}|{"Data Used",11}|{"Data Remaining",16}|");
                ConsoleHelper.PrintTableBorder(usernameFieldWidth, 11, 16);

                foreach (var(username, bytesUsed, bytesRemaining) in recordsByUser)
                {
                    Console.Write($"|{username.PadRight(usernameFieldWidth)}|");

                    if (bytesUsed != 0UL)
                    {
                        Console.Write($"{InteractionHelper.HumanReadableDataString1024(bytesUsed),11}|");
                    }
                    else
                    {
                        Console.Write($"{string.Empty,11}|");
                    }

                    if (bytesRemaining != 0UL)
                    {
                        Console.WriteLine($"{InteractionHelper.HumanReadableDataString1024(bytesRemaining),16}|");
                    }
                    else
                    {
                        Console.WriteLine($"{string.Empty,16}|");
                    }
                }

                ConsoleHelper.PrintTableBorder(usernameFieldWidth, 11, 16);
            }

            // CSV
            if (!string.IsNullOrEmpty(csvOutdir))
            {
                var(dataUsageByGroup, dataUsageByUser) = ReportHelper.GenerateDataUsageCSV(recordsByGroup, recordsByUser);

                try
                {
                    _ = Directory.CreateDirectory(csvOutdir);

                    var writeDataUsageByGroupTask = File.WriteAllTextAsync($"{csvOutdir}/data-usage-by-group.csv", dataUsageByGroup, cancellationToken);
                    var writeDataUsageByUserTask  = File.WriteAllTextAsync($"{csvOutdir}/data-usage-by-user.csv", dataUsageByUser, cancellationToken);

                    await Task.WhenAll(writeDataUsageByGroupTask, writeDataUsageByUserTask);

                    Console.WriteLine();
                    Console.WriteLine($"Written to {csvOutdir}/data-usage-by-group.csv");
                    Console.WriteLine($"Written to {csvOutdir}/data-usage-by-user.csv");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error when saving CSV: {ex.Message}");
                }
            }

            return(0);
        }
Exemple #23
0
 public IList <WebGenre> GetTVShowGenresByRange(int?provider, int start, int end, SortBy?sort = SortBy.Title, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllGenres().AsQueryable().SortMediaItemList(sort, order).TakeRange(start, end).Finalize(provider, ProviderType.TVShow));
 }
Exemple #24
0
 public IList <WebTVShowDetailed> GetTVShowsDetailedByRange(int?provider, int start, int end, string genre = null, string actor = null, SortBy?sort = SortBy.Title, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllTVShowsDetailed().AsQueryable().CommonFilter(genre, actor).SortMediaItemList(sort, order).TakeRange(start, end).Finalize(provider, ProviderType.TVShow));
 }
        public static async Task <int> GetDataUsage(string group, SortBy?sortBy, CancellationToken cancellationToken = default)
        {
            var(loadedNodes, loadNodesErrMsg) = await Nodes.LoadNodesAsync(cancellationToken);

            if (loadNodesErrMsg is not null)
            {
                Console.WriteLine(loadNodesErrMsg);
                return(1);
            }
            using var nodes = loadedNodes;

            var(settings, loadSettingsErrMsg) = await Settings.LoadSettingsAsync(cancellationToken);

            if (loadSettingsErrMsg is not null)
            {
                Console.WriteLine(loadSettingsErrMsg);
                return(1);
            }

            var records = nodes.GetGroupDataUsage(group);

            if (records is null)
            {
                Console.WriteLine($"Error: group {group} doesn't exist.");
                return(-2);
            }

            var maxNameLength = records.Select(x => x.username.Length)
                                .DefaultIfEmpty()
                                .Max();
            var nameFieldWidth = maxNameLength > 4 ? maxNameLength + 2 : 6;

            var sortByInEffect = settings.GroupDataUsageDefaultSortBy;

            if (sortBy is SortBy currentRunSortBy)
            {
                sortByInEffect = currentRunSortBy;
            }
            switch (sortByInEffect)
            {
            case SortBy.DefaultAscending:
                break;

            case SortBy.DefaultDescending:
                records.Reverse();
                break;

            case SortBy.NameAscending:
                records = records.OrderBy(x => x.username).ToList();
                break;

            case SortBy.NameDescending:
                records = records.OrderByDescending(x => x.username).ToList();
                break;

            case SortBy.DataUsedAscending:
                records = records.OrderBy(x => x.bytesUsed).ToList();
                break;

            case SortBy.DataUsedDescending:
                records = records.OrderByDescending(x => x.bytesUsed).ToList();
                break;

            case SortBy.DataRemainingAscending:
                records = records.OrderBy(x => x.bytesRemaining).ToList();
                break;

            case SortBy.DataRemainingDescending:
                records = records.OrderByDescending(x => x.bytesRemaining).ToList();
                break;
            }

            Console.WriteLine($"{"Group",-16}{group,-32}");

            if (nodes.Groups.TryGetValue(group, out var targetGroup))
            {
                Console.WriteLine($"{"Data used",-16}{InteractionHelper.HumanReadableDataString1024(targetGroup.BytesUsed),-32}");
                if (targetGroup.BytesRemaining != 0UL)
                {
                    Console.WriteLine($"{"Data remaining",-16}{InteractionHelper.HumanReadableDataString1024(targetGroup.BytesRemaining),-32}");
                }
                if (targetGroup.DataLimitInBytes != 0UL)
                {
                    Console.WriteLine($"{"Data limit",-16}{InteractionHelper.HumanReadableDataString1024(targetGroup.DataLimitInBytes),-32}");
                }
            }

            if (records.All(x => x.bytesRemaining == 0UL)) // Omit data remaining column if no data.
            {
                ConsoleHelper.PrintTableBorder(nameFieldWidth, 11);
                Console.WriteLine($"|{"User".PadRight(nameFieldWidth)}|{"Data Used",11}|");
                ConsoleHelper.PrintTableBorder(nameFieldWidth, 11);

                foreach (var(username, bytesUsed, _) in records)
                {
                    Console.WriteLine($"|{username.PadRight(nameFieldWidth)}|{InteractionHelper.HumanReadableDataString1024(bytesUsed),11}|");
                }

                ConsoleHelper.PrintTableBorder(nameFieldWidth, 11);
            }
            else
            {
                ConsoleHelper.PrintTableBorder(nameFieldWidth, 11, 16);
                Console.WriteLine($"|{"User".PadRight(nameFieldWidth)}|{"Data Used",11}|{"Data Remaining",16}|");
                ConsoleHelper.PrintTableBorder(nameFieldWidth, 11, 16);

                foreach (var(username, bytesUsed, bytesRemaining) in records)
                {
                    Console.Write($"|{username.PadRight(nameFieldWidth)}|{InteractionHelper.HumanReadableDataString1024(bytesUsed),11}|");

                    if (bytesRemaining != 0UL)
                    {
                        Console.WriteLine($"{InteractionHelper.HumanReadableDataString1024(bytesRemaining),16}|");
                    }
                    else
                    {
                        Console.WriteLine($"{string.Empty,16}|");
                    }
                }

                ConsoleHelper.PrintTableBorder(nameFieldWidth, 11, 16);
            }

            return(0);
        }
Exemple #26
0
 private ContactSorter GetSorter(SortBy?sortBy = null)
 {
     return(SortOrderFactory.GetSorter(sortBy ?? SortBy));
 }
Exemple #27
0
 public Task <List <ScoreItem> > GetBestScoresAsync(SortBy?sortBy = null, OrderBy?orderBy = null, int?startingAt = null, int?numberToRetrieve = null, DateTime?startDate = null, DateTime?endDate = null, string platform = null, int difficulty = 0, string usernames = null)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Gets the files for folder.
        /// </summary>
        /// <param name="folderId">The folder id.</param>
        /// <param name="filters">The filters.</param>
        /// <param name="limit">The limit.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="sortBy">The sort by.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public static string GetFilesForFolder(string folderId, List <FolderFilter> filters = null, int?limit = null, int?offset = null, SortBy?sortBy = null, SortOrder?sortOrder = null)
        {
            if (string.IsNullOrEmpty(folderId))
            {
                throw new ArgumentNullException(folderId);
            }

            var query = GetQuery(filters, limit, offset, sortBy, sortOrder);

            return(string.Format("{0}/{1}{2}", folderId, SkyDriveConstants.GetFiles, query));
        }
Exemple #29
0
 public IList <WebTVShowBasic> GetAllTVShowsBasic(int?provider, string genre = null, string actor = null, SortBy?sort = SortBy.Title, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllTVShowsBasic().AsQueryable().CommonFilter(genre, actor).SortMediaItemList(sort, order).Finalize(provider, ProviderType.TVShow));
 }
Exemple #30
0
 public IList <WebTVEpisodeDetailed> GetTVEpisodesDetailedByRange(int?provider, int start, int end, SortBy?sort = SortBy.TVEpisodeNumber, OrderBy?order = OrderBy.Asc)
 {
     return(TVShowLibraries[provider].GetAllEpisodesDetailed().AsQueryable().SortMediaItemList(sort, order, SortBy.TVEpisodeNumber).TakeRange(start, end).Finalize(provider, ProviderType.TVShow));
 }