protected async Task GenerateLoad(int requests) { var srcNumberOfItems = SourceItems.Count(); List <string> selectedItems; var randomResources = SourceItems.OrderBy(i => Guid.NewGuid()); if (requests <= srcNumberOfItems) { selectedItems = randomResources.Take(requests).ToList(); } else { var tmpList = new List <string>(); do { tmpList.AddRange(randomResources.Take(requests)); requests -= srcNumberOfItems; } while (requests >= 0); selectedItems = tmpList; } _executionsPerSecond = selectedItems.Count; Console.WriteLine(PrintTestProgress()); Interlocked.Add(ref ExpectedExecutionCount, selectedItems.Count()); await Load(selectedItems); }
public TradeViewModel(Trade trade, IEnumerable <EquipmentItem> items, IEnumerable <WalletMoney> moneys, ITradeService tradeService) { ID = trade.ID; MoneyToTrade = moneys.ToList().Select(m => new MoneyTradeViewModel(m)).ToList(); ProductToTrade = items.ToList().Select(i => new ProductTradeViewModel(i)).ToList(); SourceName = trade.Source?.Name; SourceImage = new ImageViewModel(trade.Source?.ImgUrl); SourceID = trade.SourceEntityID; DestinationImage = new ImageViewModel(trade?.Destination?.ImgUrl); DestinationName = trade.Destination?.Name; DestinationID = trade.DestinationEntityID; SourceAccepted = trade.SourceAccepted; DestinationAccepted = trade.DestinationAccepted; TradeStatus = (TradeStatusEnum)trade.TradeStatusID; loadProducts(trade); loadMoney(trade); SourceItems = SourceItems.OrderBy(i => i.DateAdded).ToList(); DestinationItems = DestinationItems.OrderBy(i => i.DateAdded).ToList(); CanCancel = trade.Is(TradeStatusEnum.Ongoing); TradeSide = trade.GetTradeSide(SessionHelper.CurrentEntity); CanAccept = TradeStatus == TradeStatusEnum.Ongoing && ((trade.SourceAccepted == false && TradeSide == TradeSideEnum.Source) || (trade.DestinationAccepted == false && TradeSide == TradeSideEnum.Destination)); FuelCost = TradeSide == TradeSideEnum.Source ? trade.SourceUsedFuelAmount : trade.DestinationUsedFuelAmount; var projectedCost = tradeService.GetNeededFuel(SessionHelper.CurrentEntity, trade); if (projectedCost > 0) { FuelCost = projectedCost; } }