示例#1
0
        public override async Task StartAsync(ManagedTaskProgress progress, CancellationToken cancellationToken = default)
        {
            progress.Report(50, 1, "Running data extract...");
            var downloadStream = await _downloadData.GetStream(cancellationToken);

            var filename = downloadStream.FileName;
            var stream   = downloadStream.Stream;

            progress.Report(100, 2, "Download ready...");

            await _sharedSettings.StartDataStream(_reference, stream, _downloadUrl, "file", filename, false, cancellationToken);

            var url = $"{_downloadUrl.Url}/download/{_reference}";

            var downloadMessage = new DownloadReadyMessage()
            {
                InstanceId    = _sharedSettings.InstanceId,
                SecurityToken = _sharedSettings.SecurityToken,
                ConnectionId  = _connectionId,
                Reference     = _reference,
                HubKey        = _hubKey,
                Url           = url
            };

            var returnValue = await _sharedSettings.PostAsync <DownloadReadyMessage, ReturnValue>("Remote/DownloadReady", downloadMessage, cancellationToken);

            if (!returnValue.Success)
            {
                throw new RemoteOperationException($"The data download did not completed.  {returnValue.Message}", returnValue.Exception);
            }
        }