コード例 #1
0
    public HomeModule(IMicroBus bus)
    {
        _bus = bus;

        Get("/", async(req, res, routeData) =>
            await _bus.PublishAsync(new TestEventA()));
    }
コード例 #2
0
        public Task Handle(ShipItem command)
        {
            var item = Inventory[command.ProductId];
            int orderQuantity = command.Quantity, shipQuantity;

            do
            {
                if (item.QuantityOnHand <= 0)
                {
                    // restock the item
                    Thread.Sleep(500);
                    item.QuantityOnHand += 12; // cheaper by the dozen :)
                }
                shipQuantity         = Math.Min(orderQuantity, item.QuantityOnHand);
                item.QuantityOnHand -= shipQuantity;
                var shipped = new ItemShipped
                {
                    OrderId   = command.OrderId,
                    ProductId = command.ProductId,
                    Quantity  = shipQuantity
                };
                Bus.PublishAsync(shipped);
            } while (shipQuantity > 0);
            return(Task.CompletedTask);
        }
コード例 #3
0
            public async Task Handle(Command command)
            {
                var @event = new Event();
                await bus.PublishAsync(@event);

                command.Run = @event.Run;
                command.HandlerIds.AddRange(@event.HandlerIds);
            }
コード例 #4
0
 private async Task CheckBalances()
 {
     await _bus.PublishAsync(new BalanceCheckEvent(false));
 }
コード例 #5
0
        private async Task CheckMessage(string message)
        {
            if (message.StartsWith("/acc"))
            {
                _log.LogInformation("Message begins with /acc. Going to split string");
                var splitString = message.Split("_");

                try
                {
                    var accountNumber = splitString[1];
                    var account       = int.Parse(accountNumber);

                    _log.LogInformation($"PnL check for {account}");
                    await _bus.PublishAsync(new BalanceCheckEvent(true, Constants.CoinigyAccountBalance, account));
                }
                catch (Exception)
                {
                    await SendHelpMessage();

                    _log.LogInformation($"Don't know what the user wants to do with the /acc. The message was {message}");
                }
            }
            else if (message.StartsWith(TelegramCommands.CommonPairProfit))
            {
                var splitString = message.Split(" ");
                _log.LogInformation("Profit details requested");

                try
                {
                    var pair = splitString[1];
                    _log.LogInformation($"User wants to check for profit for {pair.ToUpper()}");
                    await _bus.SendAsync(new PairProfitCommand(pair));
                }
                catch (Exception)
                {
                    await SendHelpMessage();

                    _log.LogInformation($"Don't know what the you want to do with the /profit. Format is /profit BTC-ETH for example. The message was {message}");
                }
            }
            else if (message.StartsWith(TelegramCommands.CoinigyAccountList))
            {
                try
                {
                    _log.LogInformation("PnL Account List request");
                    await _bus.SendAsync(new SendCoinigyAccountInfoCommand());
                }
                catch (Exception)
                {
                    await SendHelpMessage();

                    _log.LogInformation($"Don't know what the user wants to do with the /acc. The message was {message}");
                }
            }
            else if (message.StartsWith(TelegramCommands.CommonExcel))
            {
                _log.LogInformation("Excel sheet");
                await _bus.SendAsync(new ExcelExportCommand());
            }
            else if (message.StartsWith(TelegramCommands.CoinigyTotalBalance))
            {
                _log.LogInformation("24 Hour pnl difference for coinigy");
                await _bus.PublishAsync(new BalanceCheckEvent(true, Constants.TotalCoinigyBalance));
            }
            else if (message.StartsWith(TelegramCommands.BittrexBalanceInfo))
            {
                _log.LogInformation("24 Hour pnl difference for bittrex");
                await _bus.PublishAsync(new BalanceCheckEvent(true, Constants.Bittrex));
            }
            else if (message.StartsWith(TelegramCommands.PoloniexBalanceInfo))
            {
                _log.LogInformation("24 Hour pnl difference for poloniex");
                await _bus.PublishAsync(new BalanceCheckEvent(true, Constants.Poloniex));
            }
            else if (message.StartsWith(TelegramCommands.BittrexTradeExportUpload))
            {
                await _bus.SendAsync(new SendMessageCommand("Please upload bittrex trade export"));

                _waitingForFile = true;
            }
            else
            {
                _log.LogInformation($"Don't know what the user wants to do. The message was {message}");
                await SendHelpMessage();
            }
        }
コード例 #6
0
 public async Task BittrexBalance()
 {
     _log.LogInformation("24 Hour pnl difference for bittrex");
     await _bus.PublishAsync(new BalanceCheckEvent(true, Constants.Bittrex));
 }
コード例 #7
0
 public async Task BinanceBalance()
 {
     await _bus.PublishAsync(new BalanceCheckEvent(true, Constants.Binance));
 }