mirror of https://github.com/abpframework/abp.git
committed by
GitHub
9 changed files with 166 additions and 14 deletions
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.Abp.Cli |
||||
|
{ |
||||
|
public static class CliConsts |
||||
|
{ |
||||
|
public const string Command = "AbpCliCommand"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
using System.Net.Http; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using Volo.Abp.Cli.Http; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Http; |
||||
|
using Volo.Abp.Json; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Analyticses |
||||
|
{ |
||||
|
public class CliAnalyticsCollect : ICliAnalyticsCollect, ITransientDependency |
||||
|
{ |
||||
|
private readonly ICancellationTokenProvider _cancellationTokenProvider; |
||||
|
private readonly IJsonSerializer _jsonSerializer; |
||||
|
private readonly ILogger<CliAnalyticsCollect> _logger; |
||||
|
|
||||
|
public CliAnalyticsCollect(ICancellationTokenProvider cancellationTokenProvider, |
||||
|
IJsonSerializer jsonSerializer) |
||||
|
{ |
||||
|
_cancellationTokenProvider = cancellationTokenProvider; |
||||
|
_jsonSerializer = jsonSerializer; |
||||
|
_logger = NullLogger<CliAnalyticsCollect>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task CollectAsync(CliAnalyticsCollectInputDto input) |
||||
|
{ |
||||
|
var postData = _jsonSerializer.Serialize(input); |
||||
|
using (var client = new CliHttpClient()) |
||||
|
{ |
||||
|
var responseMessage = await client.PostAsync( |
||||
|
$"{CliUrls.WwwAbpIo}api/clianalytics/collect", |
||||
|
new StringContent(postData, Encoding.UTF8, MimeTypes.Application.Json), |
||||
|
_cancellationTokenProvider.Token |
||||
|
); |
||||
|
|
||||
|
if (!responseMessage.IsSuccessStatusCode) |
||||
|
{ |
||||
|
_logger.LogInformation("Remote server returns error! HTTP status code: " + |
||||
|
responseMessage.StatusCode); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Analyticses |
||||
|
{ |
||||
|
public class CliAnalyticsCollectInputDto |
||||
|
{ |
||||
|
public string Tool { get; set; } |
||||
|
|
||||
|
public string TemplateName { get; set; } |
||||
|
|
||||
|
public string TemplateVersion { get; set; } |
||||
|
|
||||
|
public string Command { get; set; } |
||||
|
|
||||
|
public string DatabaseProvider { get; set; } |
||||
|
|
||||
|
public string ProjectName { get; set; } |
||||
|
|
||||
|
public bool? IsTiered { get; set; } |
||||
|
|
||||
|
public string Options { get; set; } |
||||
|
|
||||
|
public string Language { get; set; } |
||||
|
|
||||
|
public string Ip { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Analyticses |
||||
|
{ |
||||
|
public interface ICliAnalyticsCollect |
||||
|
{ |
||||
|
Task CollectAsync(CliAnalyticsCollectInputDto input); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue