@ -1,4 +1,5 @@
using System.Net.Http ;
using System ;
using System.Net.Http ;
using System.Text ;
using System.Text ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using Microsoft.Extensions.Logging ;
using Microsoft.Extensions.Logging ;
@ -32,27 +33,37 @@ namespace Volo.Abp.Cli.ProjectBuilding.Analyticses
public async Task CollectAsync ( CliAnalyticsCollectInputDto input )
public async Task CollectAsync ( CliAnalyticsCollectInputDto input )
{
{
var postData = _jsonSerializer . Serialize ( input ) ;
var postData = _jsonSerializer . Serialize ( input ) ;
using ( var client = new CliHttpClient ( ) )
var url = $"{CliUrls.WwwAbpIo}api/clianalytics/collect" ;
try
{
{
var responseMessage = await client . PostAsync (
using ( var client = new CliHttpClient ( ) )
$"{CliUrls.WwwAbpIo}api/clianalytics/collect" ,
new StringContent ( postData , Encoding . UTF8 , MimeTypes . Application . Json ) ,
_cancellationTokenProvider . Token
) ;
if ( ! responseMessage . IsSuccessStatusCode )
{
{
var exceptionMessage = "Remote server returns '" + ( int ) responseMessage . StatusCode + "-" + responseMessage . ReasonPhrase + "'. " ;
var responseMessage = await client . PostAsync (
var remoteServiceErrorMessage = await _remoteServiceExceptionHandler . GetAbpRemoteServiceErrorAsync ( responseMessage ) ;
url ,
new StringContent ( postData , Encoding . UTF8 , MimeTypes . Application . Json ) ,
_cancellationTokenProvider . Token
) ;
if ( remoteServiceErrorMessage ! = null )
if ( ! responseMessage . IsSuccessStatusCode )
{
{
exceptionMessage + = remoteServiceErrorMessage ;
var exceptionMessage = "Remote server returns '" + ( int ) responseMessage . StatusCode + "-" + responseMessage . ReasonPhrase + "'. " ;
}
var remoteServiceErrorMessage = await _remoteServiceExceptionHandler . GetAbpRemoteServiceErrorAsync ( responseMessage ) ;
if ( remoteServiceErrorMessage ! = null )
{
exceptionMessage + = remoteServiceErrorMessage ;
}
_logger . LogInformation ( exceptionMessage ) ;
_logger . LogInformation ( exceptionMessage ) ;
}
}
}
}
}
catch ( Exception ex )
{
Console . WriteLine ( "Error occured while cli analytics from {0} : {1}" , url , ex . Message ) ;
}
}
}
}
}
}
}