/// <summary> /// If for any reason you have to resume from a previous application state, /// you can use an existing download request identifier and use it /// to download the result file. Use TrackAsync to indicate that the application /// should wait to ensure that the download status is completed. /// </summary> /// <param name="requestId"></param> /// <param name="authorizationData"></param> /// <returns></returns> private async Task DownloadResultsAsync( string requestId, AuthorizationData authorizationData) { // You may optionally cancel the TrackAsync operation after a specified time interval. var tokenSource = new CancellationTokenSource(); tokenSource.CancelAfter(TimeoutInMilliseconds); var bulkDownloadOperation = new BulkDownloadOperation(requestId, authorizationData); // Use TrackAsync to indicate that the application should wait to ensure that // the download status is completed. var bulkOperationStatus = await bulkDownloadOperation.TrackAsync(null, tokenSource.Token); var resultFilePath = await bulkDownloadOperation.DownloadResultFileAsync( FileDirectory, ResultFileName, decompress : true, overwrite : true); // Set this value true if you want to overwrite the same file. OutputStatusMessage(string.Format("Download result file: {0}", resultFilePath)); OutputStatusMessage(string.Format("Status: {0}", bulkOperationStatus.Status)); OutputStatusMessage(string.Format("TrackingId: {0}\n", bulkOperationStatus.TrackingId)); }
/// <summary> /// If for any reason you have to resume from a previous application state, /// you can use an existing download request identifier and use it /// to download the result file. Use TrackAsync to indicate that the application /// should wait to ensure that the download status is completed. /// </summary> /// <param name="requestId"></param> /// <param name="authorizationData"></param> /// <returns></returns> private async Task DownloadResultsAsync( string requestId, AuthorizationData authorizationData, Progress <BulkOperationProgressInfo> progress, CancellationToken cancellationToken) { var bulkDownloadOperation = new BulkDownloadOperation(requestId, authorizationData); // Use TrackAsync to indicate that the application should wait to ensure that // the download status is completed. var bulkOperationStatus = await bulkDownloadOperation.TrackAsync( progress : progress, cancellationToken : cancellationToken); var resultFilePath = await bulkDownloadOperation.DownloadResultFileAsync( localResultDirectoryName : FileDirectory, localResultFileName : ResultFileName, decompress : true, overwrite : true); // Set this value true if you want to overwrite the same file. OutputStatusMessage(string.Format("Download result file: {0}", resultFilePath)); OutputStatusMessage(string.Format("Status: {0}", bulkOperationStatus.Status)); OutputStatusMessage(string.Format("TrackingId: {0}", bulkOperationStatus.TrackingId)); }
/// <summary> /// If for any reason you have to resume from a previous application state, /// you can use an existing download request identifier and use it /// to download the result file. Use TrackAsync to indicate that the application /// should wait to ensure that the download status is completed. /// </summary> /// <param name="requestId"></param> /// <param name="authorizationData"></param> /// <returns></returns> private async Task DownloadResultsAsync( string requestId, AuthorizationData authorizationData) { // You may optionally cancel the TrackAsync operation after a specified time interval. var tokenSource = new CancellationTokenSource(); tokenSource.CancelAfter(TimeoutInMilliseconds); var bulkDownloadOperation = new BulkDownloadOperation(requestId, authorizationData); // Use TrackAsync to indicate that the application should wait to ensure that // the download status is completed. var bulkOperationStatus = await bulkDownloadOperation.TrackAsync(null, tokenSource.Token); var resultFilePath = await bulkDownloadOperation.DownloadResultFileAsync( FileDirectory, ResultFileName, decompress: true, overwrite: true); // Set this value true if you want to overwrite the same file. OutputStatusMessage(String.Format("Download result file: {0}", resultFilePath)); OutputStatusMessage(String.Format("Status: {0}", bulkOperationStatus.Status)); OutputStatusMessage(String.Format("TrackingId: {0}\n", bulkOperationStatus.TrackingId)); }