IJobServiceJobQuery Method |
Namespace: Dundas.BI.Scheduling
IList<Job> JobQuery( int pageNumber, int pageSize, IList<Tuple<JobQueryField, SortDirection>>? orderBy, ICollection<JobQueryFilterRule>? filter )
Exception | Condition |
---|---|
ArgumentOutOfRangeException | pageNumber is less than zero; -or- pageSize is less or equal to than zero. |
InvalidOperationException | filter contains invalid rule. |
InvalidSessionException | The caller context is not associated with a valid session. |
This example demonstrates how to wait for a data cube warehouse job to stop running.
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(); }