IJobServiceJobQuery Method

Gets the jobs corresponding to query criteria.

Namespace:  Dundas.BI.Scheduling
Assembly:  Dundas.BI.Core (in Dundas.BI.Core.dll) Version: 2.0.0.0 (24.3.0.1000)
Syntax
IList<Job> JobQuery(
	int pageNumber,
	int pageSize,
	IList<Tuple<JobQueryField, SortDirection>>? orderBy,
	ICollection<JobQueryFilterRule>? filter
)

Parameters

pageNumber
Type: SystemInt32
The page number, or 0 to indicate that all pages should be returned.
pageSize
Type: SystemInt32
The number of results in each page (ignored if pageNumber is 0).
orderBy
Type: System.Collections.GenericIListTupleJobQueryField, SortDirection
The sort order of the result, or if the order does not matter.
filter
Type: System.Collections.GenericICollectionJobQueryFilterRule
The filter rules which should be applied to the query, or if no filtering is required.

Return Value

Type: IListJob
The collection of Jobs matching the query criteria which are visible to the caller.
Exceptions
ExceptionCondition
ArgumentOutOfRangeException

pageNumber is less than zero;

-or-

pageSize is less or equal to than zero.

InvalidOperationExceptionfilter contains invalid rule.
InvalidSessionExceptionThe caller context is not associated with a valid session.
Remarks
If the caller is associated with a tenant, jobs associated with other tenants are automatically filtered out.
Examples

This example demonstrates how to wait for a data cube warehouse job to stop running.

C#
using Dundas.BI;
using Dundas.BI.AccountServices;
using Dundas.BI.Entities.DataCubes;
using Dundas.BI.FileSystem;
using Dundas.BI.Services;
using Dundas.BI.Scheduling;

using System.Threading.Tasks;
using System.Collections.ObjectModel;

   ...

/*
// Note:
// This example assumes that the Dundas BI Engine already has started, and the calling user has logged on.*/


// The data cube ID.
Guid dataCubeId = new Guid("be130c8d-88b1-4332-a373-a3a0dd7b0485");

// Get the data cube service.
IDataCubeService dataCubeService = Engine.Current.GetService<IDataCubeService>();
// Get the file system service.
IFileSystemService fileSystemService = Engine.Current.GetService<IFileSystemService>();
// Get the job service.
IJobService jobService = Engine.Current.GetService<IJobService>();

// Check out the data cube.
CheckOutResult checkOutResult = fileSystemService.CheckOut(dataCubeId);

// Get the data cube.
var dataCube = dataCubeService.Get(dataCubeId);
// Change the storage type to data warehouse.
dataCube.Storage = StorageType.DataWarehouse;
// Save the data cube.
dataCubeService.Save(dataCube);

// Check-in the data cube.
fileSystemService.CheckIn(dataCubeId, "My CheckInComment");

// Build the data warehouse for the data cube.
Task dataCubeBuildTask = dataCubeService.BuildDataWarehouseAsync(dataCubeId);

Thread.Sleep(2000);

// Gets the warehouse job based on the data cube id.
Job warehouseJob = 
    jobService.JobQuery(
        0,
        0,  
        new List<Tuple<JobQueryField,SortDirection>>() 
        { 
            new Tuple<JobQueryField,SortDirection>(JobQueryField.ModifiedTime, SortDirection.Descending)
        }, 
        new Collection<JobQueryFilterRule>() 
        { 
            new JobQueryFilterRule(JobQueryField.RelatedItemId, QueryFilterOperator.Equals, dataCubeId) 
        }
    ).First();

// Waits for the job to stop running.
while(warehouseJob.Status == JobStatus.Running)
{
    Thread.Sleep(1000);

  // Re-get the warehouse job.
  warehouseJob = 
      jobService.JobQuery(
          0,
          0,  
          new List<Tuple<JobQueryField,SortDirection>>() 
          { 
              new Tuple<JobQueryField,SortDirection>(JobQueryField.ModifiedTime, SortDirection.Descending)
          }, 
          new Collection<JobQueryFilterRule>() 
          { 
              new JobQueryFilterRule(JobQueryField.RelatedItemId, QueryFilterOperator.Equals, dataCubeId) 
          }
      ).First();
}
See Also