-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from TunNetCom/ProfileUser
add project producer consumer
- Loading branch information
Showing
55 changed files
with
429 additions
and
303 deletions.
There are no files selected for viewing
8 changes: 1 addition & 7 deletions
8
src/AzureDevopsService/AzureDevopsService.API/AzureDevopsEndpoints.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 24 additions & 26 deletions
50
...plication/AzureDevopsExternalResourceService/OrganizationProjectService/ProjectService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
namespace AzureDevopsService.Application.AzureDevopsExternalResourceService.OrganizationProjectService | ||
namespace AzureDevopsService.Application.AzureDevopsExternalResourceService.OrganizationProjectService; | ||
|
||
public class ProjectService(HttpClient httpClient, ILogger<ProjectService> logger) : IProjectService | ||
{ | ||
public class ProjectService(HttpClient httpClient, ILogger<ProjectService> logger) : IProjectService | ||
{ | ||
private readonly HttpClient _httpClient = httpClient; | ||
private readonly ILogger<ProjectService> _logger = logger; | ||
private readonly HttpClient _httpClient = httpClient; | ||
private readonly ILogger<ProjectService> _logger = logger; | ||
|
||
public async Task<OneOf<AllProjectResponce?, CustomProblemDetailsResponce?>> AllProjectUnderOrganization(AllProjectUnderOrganizationRequest request) | ||
{ | ||
HttpClientHelper.SetAuthHeader(_httpClient, request.Path); | ||
public async Task<OneOf<AllProjectResponce, CustomProblemDetailsResponce>> AllProjectUnderOrganization(AllProjectUnderOrganizationRequest request) | ||
{ | ||
HttpClientHelper.SetAuthHeader(_httpClient, request.Path); | ||
|
||
HttpResponseMessage projectsResult = await _httpClient.GetAsync("_apis/profile/profiles/me?api-version=7.0"); | ||
HttpResponseMessage projectsResult = await _httpClient.GetAsync("_apis/profile/profiles/me?api-version=7.0"); | ||
|
||
if (projectsResult.StatusCode == HttpStatusCode.OK) | ||
{ | ||
AllProjectResponce? projects = await projectsResult.Content.ReadFromJsonAsync<AllProjectResponce>(); | ||
#pragma warning disable CS8602 // Dereference of a possibly null reference. | ||
projects.Path = request.Path; | ||
#pragma warning restore CS8602 // Dereference of a possibly null reference. | ||
projects.Email = request.Email; | ||
return projects; | ||
} | ||
if (projectsResult.StatusCode == HttpStatusCode.OK) | ||
{ | ||
AllProjectResponce projects = await projectsResult.Content.ReadFromJsonAsync<AllProjectResponce>(); | ||
projects.Path = request.Path; | ||
projects.Email = request.Email; | ||
|
||
_logger.LogError(await projectsResult.Content.ReadAsStringAsync()); | ||
return new CustomProblemDetailsResponce() | ||
{ | ||
Path = request.Path, | ||
Email = request.Email, | ||
Status = (int)projectsResult.StatusCode, | ||
Detail = AzureResponseMessage.VerifyAzureDevOpsKeyOrOrgName, | ||
}; | ||
return projects; | ||
} | ||
|
||
_logger.LogError(await projectsResult.Content.ReadAsStringAsync()); | ||
return new CustomProblemDetailsResponce() | ||
{ | ||
Path = request.Path, | ||
Email = request.Email, | ||
Status = (int)projectsResult.StatusCode, | ||
Detail = AzureResponseMessage.VerifyAzureDevOpsKeyOrOrgName, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...vice/AzureDevopsService.Application/Featurs/MessageBroker/Consumer/AzureDevopsConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace AzureDevopsService.Application.Featurs.MessageBroker.Consumer; | ||
|
||
public class AzureDevopsConsumer(IMediator mediator) : IConsumer<BaseRequest>, IConsumer<AllProjectUnderOrganizationRequest>, IConsumer<WorkItemRequest> | ||
{ | ||
private readonly IMediator _mediator = mediator; | ||
|
||
public async Task Consume(ConsumeContext<BaseRequest> context) | ||
{ | ||
await _mediator.Send(new ProfileUserCommand(context.Message)); | ||
} | ||
|
||
public async Task Consume(ConsumeContext<AllProjectUnderOrganizationRequest> context) | ||
{ | ||
await _mediator.Send(new ProjectCommand(context.Message)); | ||
} | ||
|
||
public async Task Consume(ConsumeContext<WorkItemRequest> context) | ||
{ | ||
await _mediator.Send(new WorkItemCommand(context.Message)); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
...vice/AzureDevopsService.Application/Featurs/MessageBroker/Consumer/ProfileUserConsumer.cs
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...evopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace AzureDevopsService.Application.Featurs.MessageBroker.Producer.ProfileUser; | ||
|
||
public record class ProfileUserCommand(BaseRequest BaseRequest) : IRequest; |
41 changes: 41 additions & 0 deletions
41
...rvice.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace AzureDevopsService.Application.Featurs.MessageBroker.Producer.ProfileUser; | ||
|
||
public class ProfileUserCommandHandler(IUserProfileApiClient userProfileApiClient, ISendEndpointProvider sendEndpointProvider) : | ||
IRequestHandler<ProfileUserCommand> | ||
{ | ||
private readonly IUserProfileApiClient _userProfileApiClient = userProfileApiClient; | ||
|
||
private readonly ISendEndpointProvider _sendEndpointProvider = sendEndpointProvider; | ||
|
||
public async Task Handle(ProfileUserCommand request, CancellationToken cancellationToken) | ||
{ | ||
ISendEndpoint endpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri("rabbitmq://rabbitmq/ProfileUserResponce")); | ||
|
||
OneOf<UserProfile, CustomProblemDetailsResponce> adminInfoResponse = await _userProfileApiClient.GetAdminInfo(request.BaseRequest); | ||
if (adminInfoResponse.IsT0) | ||
{ | ||
|
||
OneOf<UserAccount, CustomProblemDetailsResponce> organizationResponce = await _userProfileApiClient.GeUserOrganizations( | ||
new GetUserOrganizationRequest | ||
{ | ||
Email = adminInfoResponse!.AsT0!.Email, | ||
MemberId = adminInfoResponse!.AsT0!.Id, | ||
Path = adminInfoResponse!.AsT0!.Path, | ||
}); | ||
|
||
await endpoint.Send(organizationResponce.AsT0, cancellationToken); | ||
} | ||
else | ||
{ | ||
await endpoint.Send( | ||
new CustomProblemDetailsResponce | ||
{ | ||
Detail = adminInfoResponse!.AsT1!.Detail, | ||
Email = adminInfoResponse!.AsT1!.Email, | ||
Path = adminInfoResponse!.AsT1!.Path, | ||
Status = adminInfoResponse!.AsT1!.Status, | ||
}, | ||
cancellationToken); | ||
} | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
...evopsService.Application/Featurs/MessageBroker/Producer/ProfileUser/ProfileUserCommend.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.