-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend attachment deletion job to cover TRN request tasks
- Loading branch information
Showing
6 changed files
with
59 additions
and
9 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
5 changes: 5 additions & 0 deletions
5
...gRecordSystem/src/TeachingRecordSystem.Core/Dqt/Queries/GetNonOpenTaskAnnotationsQuery.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,5 @@ | ||
using Microsoft.Xrm.Sdk.Query; | ||
|
||
namespace TeachingRecordSystem.Core.Dqt.Queries; | ||
|
||
public record GetNonOpenTaskAnnotationsQuery(string[] Subjects, DateTime ModifiedBefore, ColumnSet ColumnSet) : ICrmQuery<Annotation[]>; |
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
38 changes: 38 additions & 0 deletions
38
...ystem/src/TeachingRecordSystem.Core/Dqt/QueryHandlers/GetNonOpenTaskAnnotationsHandler.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,38 @@ | ||
using Microsoft.PowerPlatform.Dataverse.Client; | ||
using Microsoft.Xrm.Sdk.Messages; | ||
using Microsoft.Xrm.Sdk.Query; | ||
using TeachingRecordSystem.Core.Dqt.Queries; | ||
|
||
namespace TeachingRecordSystem.Core.Dqt.QueryHandlers; | ||
|
||
public class GetNonOpenTaskAnnotationsHandler : ICrmQueryHandler<GetNonOpenTaskAnnotationsQuery, Annotation[]> | ||
{ | ||
public async Task<Annotation[]> Execute(GetNonOpenTaskAnnotationsQuery query, IOrganizationServiceAsync organizationService) | ||
{ | ||
var queryExpression = new QueryExpression() | ||
{ | ||
EntityName = Annotation.EntityLogicalName, | ||
ColumnSet = query.ColumnSet | ||
}; | ||
|
||
var taskLink = new LinkEntity( | ||
Annotation.EntityLogicalName, | ||
CrmTask.EntityLogicalName, | ||
Annotation.Fields.ObjectId, | ||
CrmTask.PrimaryIdAttribute, | ||
JoinOperator.Inner); | ||
taskLink.LinkCriteria.AddCondition(CrmTask.Fields.StateCode, ConditionOperator.NotEqual, (int)TaskState.Open); | ||
taskLink.LinkCriteria.AddCondition(CrmTask.Fields.ModifiedOn, ConditionOperator.LessThan, query.ModifiedBefore); | ||
taskLink.LinkCriteria.AddCondition(CrmTask.Fields.Subject, ConditionOperator.In, query.Subjects.Cast<object>().ToArray()); | ||
queryExpression.LinkEntities.Add(taskLink); | ||
|
||
var request = new RetrieveMultipleRequest() | ||
{ | ||
Query = queryExpression | ||
}; | ||
|
||
var response = await organizationService.RetrieveMultipleAsync(queryExpression); | ||
|
||
return response.Entities.Select(e => e.ToEntity<Annotation>()).ToArray(); | ||
} | ||
} |
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