-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26da9ed
commit a4b1345
Showing
4 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Apps.Memoq.Contracts; | ||
using Apps.Memoq.Models; | ||
using Apps.Memoq.Models.Files.Requests; | ||
using Blackbird.Applications.Sdk.Common; | ||
using Blackbird.Applications.Sdk.Common.Authentication; | ||
using Blackbird.Applications.Sdk.Common.Dynamic; | ||
using Blackbird.Applications.Sdk.Common.Invocation; | ||
using MQS.ServerProject; | ||
|
||
namespace Apps.Memoq.DataSourceHandlers; | ||
|
||
public class DocumentDataHandler : BaseInvocable, IDataSourceHandler | ||
{ | ||
private IEnumerable<AuthenticationCredentialsProvider> Creds => | ||
InvocationContext.AuthenticationCredentialsProviders; | ||
|
||
private readonly string _projectGuid; | ||
|
||
public DocumentDataHandler(InvocationContext invocationContext, [ActionParameter] GetDocumentRequest request) : | ||
base(invocationContext) | ||
{ | ||
_projectGuid = request.ProjectGuid; | ||
} | ||
|
||
public Dictionary<string, string> GetData(DataSourceContext context) | ||
{ | ||
if (string.IsNullOrEmpty(_projectGuid)) | ||
{ | ||
throw new InvalidOperationException("You should input a project guid first"); | ||
} | ||
|
||
using var projectService = new MemoqServiceFactory<IServerProjectService>( | ||
SoapConstants.ProjectServiceUrl, Creds); | ||
|
||
var response = projectService.Service.ListProjectTranslationDocumentsGroupedBySourceFile( | ||
Guid.Parse(_projectGuid)); | ||
|
||
var files = response | ||
.SelectMany(x => x.Groups) | ||
.SelectMany(x => x.Documents) | ||
.ToList(); | ||
|
||
return files | ||
.Where(x => context.SearchString is null || | ||
x.Name.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase)) | ||
.OrderByDescending(x => x.Name) | ||
.Take(20) | ||
.ToDictionary(x => x.DocumentGuid.ToString(), x => x.Name); | ||
} | ||
} |
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,14 @@ | ||
using Apps.Memoq.DataSourceHandlers; | ||
using Blackbird.Applications.Sdk.Common; | ||
using Blackbird.Applications.Sdk.Common.Dynamic; | ||
|
||
namespace Apps.Memoq.Models.Files.Requests; | ||
|
||
public class GetDocumentRequest | ||
{ | ||
[Display("Project"), DataSource(typeof(ProjectDataHandler))] | ||
public string ProjectGuid { get; set; } | ||
|
||
[Display("Document GUID"), DataSource(typeof(DocumentDataHandler))] | ||
public string DocumentGuid { get; set; } | ||
} |
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