public async Task Execute()
        {
            await _logger.WriteInfoAsync("PoolRenewJob", "Execute", "", "PoolRenewJob has been started ", DateTime.UtcNow);

            await _coinRepository.ProcessAllAsync(async (coins) =>
            {
                foreach (var coin in coins)
                {
                    try
                    {
                        string coinPoolQueueName = QueueHelper.GenerateQueueNameForContractPool(coin.AdapterAddress);
                        ITransferContractQueueService transferContractQueueService =
                            _transferContractQueueServiceFactory.Get(coinPoolQueueName);
                        var count = await transferContractQueueService.Count();

                        for (int i = 0; i < count; i++)
                        {
                            var contract = await transferContractQueueService.GetContract();
                            if (contract == null)
                            {
                                return;
                            }
                            await transferContractQueueService.PushContract(contract);
                        }

                        await _logger.WriteInfoAsync("PoolRenewJob", "Execute", "", $"PoolRenewJob has been finished for {count} contracts in {coinPoolQueueName} ", DateTime.UtcNow);
                    }
                    catch (Exception e)
                    {
                        await _logger.WriteErrorAsync("PoolRenewJob", "Execute", "", e);
                    }
                }
            });
        }
 public async Task Execute()
 {
     await _coinRepository.ProcessAllAsync(async (items) =>
     {
         foreach (var item in items)
         {
             try
             {
                 await _transferContractPoolService.Execute(item);
             }
             catch (Exception e)
             {
                 await _logger.WriteErrorAsync("TransferContractPoolJob", "Execute", "", e, DateTime.UtcNow);
             }
         }
     });
 }
Exemple #3
0
        public async Task ExecuteForAdapters()
        {
            try
            {
                await _coinRepository.ProcessAllAsync(async (adapters) =>
                {
                    foreach (var adapter in adapters)
                    {
                        await _log.WriteInfoAsync("CashinIndexingJob", "Execute",
                                                  $"Coin adapter address{adapter.AdapterAddress}",
                                                  "Cashin Indexing has been started", DateTime.UtcNow);

                        await _transactionEventsService.IndexCashinEventsForAdapter(adapter.AdapterAddress, adapter.DeployedTransactionHash);
                    }
                });
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(CashinIndexingJob), nameof(ExecuteForAdapters), "", ex);
            }
        }