Пример #1
0
        public override async Task StartAsync(ManagedTaskProgress progress, CancellationToken cancellationToken = default)
        {
            progress.Report(50, 1, "Preparing files...");

            var downloadStream = await _connectionFlatFile.DownloadFiles(_flatFile, _path, _files, _files.Length > 1, cancellationToken);

            var filename = _files.Length == 1 ? _files[0] : _flatFile.Name + "_files.zip";

            progress.Report(100, 2, "Files ready for download...");

            await _sharedSettings.StartDataStream(_messageId, downloadStream, _downloadUrl, "file", filename, false, cancellationToken);

            var url = $"{_sharedSettings.RemoteSettings.Network.ProxyUrl}/download/{_messageId}";

            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 file download did not completed.  {returnValue.Message}", returnValue.Exception);
            }
        }
Пример #2
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);
            }
        }