private static async Task TerminateWatcherAsync(DurableOrchestrationClient starter, string[] args, string fromPhone)
        {
            var result = await table.ExecuteAsync(TableOperation.Retrieve <Alias>(fromPhone, args[1]));

            if (result.Result != null)
            {
                await starter.TerminateAsync(((Alias)result.Result).Id, "User requested terminate");

                await TwilioSender.SendMessageAsync(fromPhone, $"Terminated instance {args[1]}");
            }
            else
            {
                await TwilioSender.SendMessageAsync(fromPhone, $"No instance exists with id: {args[1]}");
            }
        }
        private static async Task StartWatcher(DurableOrchestrationClient starter, string[] args, string fromPhone)
        {
            string market = await Bittrex.GetMarketName(args[1]);

            string instanceId = await starter.StartNewAsync("watcher", new WatcherRequest
            {
                market      = market,
                threshold   = double.Parse(args[2]),
                maxDuration = TimeSpan.FromMinutes(double.Parse(Constants.MaxDuration)),
                args        = args,
                phone       = fromPhone
            });

            Alias alias = new Alias
            {
                PartitionKey = fromPhone,
                RowKey       = rnd1.Next(1000).ToString(),
                Id           = instanceId
            };
            await table.ExecuteAsync(TableOperation.Insert(alias));

            await TwilioSender.SendMessageAsync(fromPhone, $"Now watching {market} to pass {args[2]}. To cancel, text STOP {alias.RowKey}");
        }
Beispiel #3
0
 public static async Task SendMessage([ActivityTrigger] Message message, TraceWriter log)
 {
     await TwilioSender.SendMessageAsync(message.phone, message.text);
 }