Asked by:
IFilterCollection with multiple conditions per attribute

Question
-
I want to filter on jobs between 8pm and 1am.
I cant seem to add more than one operator per PropId.
[Edit: Even worse ... for the time stuff I can't even seem to get greater than PropId.Job_CreateTime and less than PropId.Job_EndTime to work. ... This I figured out ... I have to convert my DateTime to universal time before doing the comparison.]
So ... we only get one operator per property?
I would have to do a secondary filter later in the code?
// --------------------------------------------------------------- // Create the filters // --------------------------------------------------------------- IFilterCollection jobFilters = null; jobFilters = scheduler.CreateFilterCollection(); jobFilters.Add(FilterOperator.Equal, PropId.Job_Owner, "myID"); jobFilters.Add(FilterOperator.StartWith, PropId.Job_Name, "myProgram "); jobFilters.Add(FilterOperator.GreaterThanOrEqual, PropId.Job_CreateTime, dtStart.ToUniversalTime()); jobFilters.Add(FilterOperator.LessThanOrEqual, PropId.Job_CreateTime, dtEnd.ToUniversalTime());
robert jackson
- Edited by Robert Jackson.The Machine Shop Tuesday, June 6, 2017 5:58 PM
Tuesday, June 6, 2017 5:45 PM
All replies
-
Hi Robert,
This should be supported, could you tell us what errors you got at your side?
Qiufang Shi
Wednesday, June 7, 2017 2:49 PM -
So what I want to do is filter on jobs both in running and queued state so I can cancel them,
How do I do PropId.Job_State = JobState.Running || PropId.Job_State = JobState.Queued
As is it seems to be doing an AND when I want to do an OR
// --------------------------------------------------------------
// Create the filters
// ---------------------------------------------------------------IFilterCollection jobFilters = null;
jobFilters = scheduler.CreateFilterCollection();jobFilters.Add(FilterOperator.Equal, PropId.Job_Owner, sUserName);
jobFilters.Add(FilterOperator.Equal, PropId.Job_State, JobState.Running);
jobFilters.Add(FilterOperator.Equal, PropId.Job_State, JobState.Queued);
robert jackson
Monday, June 26, 2017 5:55 PM -
OK....figured it out when I looked at the actual header file.....all set.
IFilterCollection jobFilters = null;
jobFilters = scheduler.CreateFilterCollection();jobFilters.Add(FilterOperator.Equal, PropId.Job_Owner, sUserName);
jobFilters.Add(FilterOperator.HasBitSet, PropId.Job_State, JobState.Running | JobState.Queued);robert jackson
- Proposed as answer by qiufang shiMicrosoft employee Tuesday, June 27, 2017 1:55 AM
Monday, June 26, 2017 6:03 PM