I'm trying to read some DOM instances based on some conditions but I'm getting an exception.
These are the conditions:
var resourceDomGuids = resourcesData.Keys.ToList();
// Get jobs using nodes that have have certain dim id in the reference
var searchQueryJobs = resourceDomGuids.Select(resourceDomId =>
DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflow.Sections.Nodes.NodeReferenceID)
.Equal(resourceDomId)).ToArray();
var orFilterJobs = new ORFilterElement<DomInstance>(searchQueryJobs);
// Only jobs in the future and within 4 hours
var timeFilterStart = DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflow.Sections.JobInfo.JobStart).GreaterThan(DateTime.UtcNow);
var timeFilterEnd = DomInstanceExposers.FieldValues.DomInstanceField(SlcWorkflow.Sections.JobInfo.JobStart).LessThan(DateTime.UtcNow.AddHours(4));
var andTimeFilter = new ANDFilterElement<DomInstance>(timeFilterStart, timeFilterEnd);
// Only jobs in confirmed or canceled state
var confirmedFilter = DomInstanceExposers.StatusId.Equal(SlcWorkflow.Behaviors.Job_Behavior.Statuses.Confirmed);
var canceledFilter = DomInstanceExposers.StatusId.Equal(SlcWorkflow.Behaviors.Job_Behavior.Statuses.Canceled);
var orFilterState = new ORFilterElement<DomInstance>(confirmedFilter, canceledFilter);
// Definition filter
var definitionFilterJobs = DomInstanceExposers.DomDefinitionId.Equal(SlcWorkflow.Definitions.Jobs.Id);
My goal is that this query works:
// Query
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, andTimeFilter, orFilterState);
var domInstanceJobs = domHelperWorkflow.DomInstances.Read(andFilterJobs);
But i can only make it to work like this:
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs);
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, confirmedFilter);
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, timeFilterStart);
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, confirmedFilter, timeFilterStart);
If I introduce another condition for the state or the time it fails.
var andFilterJobs = new ANDFilterElement<DomInstance>(definitionFilterJobs, orFilterJobs, timeFilterStart, timeFilterEnd);