示例#1
0
        public async Task DownloadTransactions()
        {
            if (HasMissingSecretKeys)
            {
                var missingIds = MissingSecretKeys.Keys.ToArray();
                foreach (var missingId in missingIds)
                {
                    if (ServiceNode.GetSecretKeys(Index, missingId).Count > 0)
                    {
                        MissingSecretKeys.Remove(missingId);
                    }
                }
            }

            await UIApp.PubSub.PublishAsync(new QueryTodoListEvent(QueryTodoResult.DownloadingData, this));

            var lastId = Math.Max(LastProcessedTransactionId, Operation.FirstTransactionId);

            var download = new GroupTransactionDownload(ListId, ServiceNode.GetTransactionDownloadManager(TodoServiceInfo.TodoDataChainIndex))
            {
                MinimalTransactionId = lastId,
                DownloadAttachements = false
            };

            LastDownloadResult = await download.DownloadTransactions();

            if (LastDownloadResult.Ok)
            {
                LastDownloadResult.Transactions.Sort((a, b) => a.TransactionId.CompareTo(b.TransactionId));
                foreach (var transaction in LastDownloadResult.Transactions)
                {
                    transaction.Tag = ServiceNode;
                    await ProcessTransaction(transaction);
                }
                await Todo.SaveAsync();

                await UIApp.PubSub.PublishAsync(new QueryTodoListEvent(QueryTodoResult.LiveData, this));
            }
            else
            {
                await UIApp.PubSub.PublishAsync(new QueryTodoListEvent(QueryTodoResult.DownloadError, this));
            }
        }