コード例 #1
0
        public async Task <Notified> SendAsync(IEnumerable <Gem> gems)
        {
            var result = new Notified();

            try
            {
                if (gems.AnyAndNotNull())
                {
                    foreach (var gem in gems)
                    {
                        Task <SingleServiceResponse <TokenInfo> >     tokenInfoTask = null;
                        Task <SingleServiceResponse <SmartContract> > contractTask  = null;
                        Task <SingleServiceResponse <TopHolderList> > holdersTask   = null;

                        await TaskExt.Sequence(
                            () => { return(tokenInfoTask = _ethPlorerService.FetchTokenInfoAsync(gem.Id)); },
                            () => { return(contractTask = _etherScanService.IsSmartContractVerifiedAsync(gem.Id)); },
                            () => { return(Task.Delay(1000)); },
                            () => { return(holdersTask = _ethPlorerService.FetchTopHoldersAsync(gem.Id, 5)); }
                            );

                        var msgPr = KyberMsg.ForPremiumTelegram(
                            gem,
                            tokenInfoTask.Result,
                            contractTask.Result,
                            holdersTask.Result);

                        var sentPr = await _telegramService.SendPremiumMessageAsync(msgPr.Item2, msgPr.Item1);

                        if (!sentPr.Success)
                        {
                            result.Message += $"Telegram Premium Error: {sentPr.Message}";
                        }
                    }
                }
                else
                {
                    result.Message = "Nothing to send";
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.GetFullMessage();
            }
            return(result);
        }
コード例 #2
0
        public async Task <IStepResult> ResultAsync(Gem gem)
        {
            try
            {
                var topHodlersNumber = 5;

                var holdersTask = await _ethPlorerService.FetchTopHoldersAsync(gem.Id, topHodlersNumber);

                var detailsHolders = SharedMessageContent.TokenHoldersContent(gem.Recently, gem.Id, topHodlersNumber, holdersTask);

                return(new StepResult(StepResultType.Success, detailsHolders));
            }
            catch (Exception ex)
            {
                return(await Task.FromResult(new StepResult(StepResultType.Error, ex.GetFullMessage())));
            }
        }