@@ -20,9 +20,9 @@ public ReportService(AmazonCredential amazonCredential) : base(amazonCredential)
20
20
{
21
21
}
22
22
#region GetReport
23
- public List < Report > GetReports ( ParameterReportList parameterReportList ) =>
23
+ public IList < Report > GetReports ( ParameterReportList parameterReportList ) =>
24
24
Task . Run ( ( ) => GetReportsAsync ( parameterReportList ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
25
- public async Task < List < Report > > GetReportsAsync ( ParameterReportList parameterReportList , CancellationToken cancellationToken = default )
25
+ public async Task < IList < Report > > GetReportsAsync ( ParameterReportList parameterReportList , CancellationToken cancellationToken = default )
26
26
{
27
27
if ( parameterReportList . marketplaceIds == null || parameterReportList . marketplaceIds . Count == 0 )
28
28
{
@@ -94,10 +94,10 @@ public GetReportsResponseV00 GetReportsByNextToken(ParameterReportList parameter
94
94
Task . Run ( ( ) => GetReportsByNextTokenAsync ( parameterReportList ) ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
95
95
public async Task < GetReportsResponseV00 > GetReportsByNextTokenAsync ( ParameterReportList parameterReportList , CancellationToken cancellationToken = default )
96
96
{
97
- List < KeyValuePair < string , string > > parameters = null ;
98
- if ( string . IsNullOrEmpty ( parameterReportList . nextToken ) )
97
+ List < KeyValuePair < string , string > > parameters = null ;
98
+ if ( string . IsNullOrEmpty ( parameterReportList . nextToken ) )
99
99
parameters = parameterReportList . getParameters ( ) ;
100
- else
100
+ else
101
101
{
102
102
var parameterReportListNew = new ParameterReportList ( ) ;
103
103
parameterReportListNew . nextToken = parameterReportList . nextToken ;
@@ -215,38 +215,44 @@ private async Task<string> GetFileAsync(ReportDocument reportDocument, Cancellat
215
215
216
216
string tempFilePath = Path . Combine ( Path . GetTempPath ( ) + fileName ) ;
217
217
218
- try {
219
- if ( isEncryptedFile ) {
218
+ try
219
+ {
220
+ if ( isEncryptedFile )
221
+ {
220
222
//Later will check
221
223
byte [ ] rawData = client . DownloadData ( reportDocument . Url ) ;
222
224
byte [ ] key = Convert . FromBase64String ( reportDocument . EncryptionDetails . Key ) ;
223
225
byte [ ] iv = Convert . FromBase64String ( reportDocument . EncryptionDetails . InitializationVector ) ;
224
226
var reportData = FileTransform . DecryptString ( key , iv , rawData ) ;
225
227
File . WriteAllText ( tempFilePath , reportData ) ;
226
228
}
227
- else {
229
+ else
230
+ {
228
231
var stream = await client . OpenReadTaskAsync ( new Uri ( reportDocument . Url ) ) ;
229
- using ( Stream s = File . Create ( tempFilePath ) ) {
232
+ using ( Stream s = File . Create ( tempFilePath ) )
233
+ {
230
234
stream ? . CopyTo ( s ) ;
231
235
}
232
236
}
233
237
234
238
cancellationToken . ThrowIfCancellationRequested ( ) ;
235
239
236
- if ( isCompressionFile ) {
240
+ if ( isCompressionFile )
241
+ {
237
242
var compressionFile = tempFilePath ;
238
243
tempFilePath = FileTransform . Decompress ( tempFilePath ) ;
239
244
File . Delete ( compressionFile ) ;
240
245
}
241
246
242
- cancellationToken . ThrowIfCancellationRequested ( ) ;
247
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
243
248
244
- return tempFilePath ;
249
+ return tempFilePath ;
245
250
}
246
- catch ( OperationCanceledException ) {
247
- File . Delete ( tempFilePath ) ;
251
+ catch ( OperationCanceledException )
252
+ {
253
+ File . Delete ( tempFilePath ) ;
248
254
throw ;
249
- }
255
+ }
250
256
}
251
257
252
258
public async Task SaveStreamToFileAsync ( string fileFullPath , Stream stream , CancellationToken cancellationToken = default )
@@ -309,6 +315,12 @@ public async Task<string> CreateReportAndDownloadFileAsync(ReportTypes reportTyp
309
315
parameters . dataEndTime = dataEndTime ;
310
316
311
317
var reportId = await CreateReportAsync ( parameters , cancellationToken ) ;
318
+ return await GetReportFileByReportIdAsync ( reportId , isRestrictedReport , millisecondsDelay , cancellationToken ) ;
319
+
320
+ }
321
+
322
+ public async Task < string > GetReportFileByReportIdAsync ( string reportId , bool isRestrictedReport , int millisecondsDelay = 500 , CancellationToken cancellationToken = default )
323
+ {
312
324
var filePath = string . Empty ;
313
325
string ReportDocumentId = string . Empty ;
314
326
0 commit comments