IAccountServiceAccountQuery Method |
Namespace: Dundas.BI.AccountServices
IList<Account> AccountQuery( int pageNumber, int pageSize, IList<Tuple<AccountQueryField, SortDirection>>? orderBy, ICollection<AccountQueryFilterRule>? filter )
Exception | Condition |
---|---|
ArgumentOutOfRangeException | pageNumber is less than zero; -or- pageSize is less or equal to than zero. |
InvalidOperationException | filter contains invalid rule. |
NoPrivilegeException | The caller does not have system administration privileges. -or- The caller is associated with a tenant, but does not have administration privileges for that tenant. |
InvalidSessionException | The caller context is not associated with a valid session. |
This example demonstrates how to create the Dundas BI engine, start the Dundas BI engine, log on, queries accounts that start with the letter 'A', and then shutdown the Dundas BI engine.
using Dundas.BI; using Dundas.BI.AccountServices; using Dundas.BI.Services; using System.Collections.ObjectModel; ... // Create the engine. EngineManager.CreateEngine( // Path to the application's data folder. Type: System.String @"C:\Program Files\Dundas Data Visualization Inc\Dundas BI\Instances\Instance1\www\BIWebsite\App_Data" ); try { // Start the Dundas BI Engine. EngineManager.StartEngine(); // Create a caller context not associated with any session. using(Engine.Current.GetService<ICallerContextService>().CreateAndSetCurrentContext(null)) { // LogOn. LogOnResult logOnResult = Engine.Current.GetService<ILogOnService>().LogOn( // The account name. Type: System.String "admin", // The password. Type: System.String "1234", // Delete other sessions for the logon to succeed. Type: System.Boolean true, // Culture to associate with the session, or null. Type: System.Globalization.CultureInfo null ); // Set the current session ID. using(Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId( logOnResult.Session.Id ); // Get the account service. IAccountService accountService = Engine.Current.GetService<IAccountService>(); // Order by name descending. var orderQueryBy = new List<Tuple<AccountQueryField, SortDirection>>() { new Tuple<AccountQueryField, SortDirection>(AccountQueryField.Name, SortDirection.Descending) }; // Get the accounts that start with the letter 'a'. var rules = new List<AccountQueryFilterRule>(); rules.Add( new AccountQueryFilterRule( AccountQueryField.Name, QueryFilterOperator.StartsWith, "a" ) ); // Get the accounts. var accounts = accountService.AccountQuery( // The first page. 1, // Get maximum ten entries during query. 10, // pass the order by. orderQueryBy, // pass the query rules. rules ); // Write the account names to the console. foreach(var account in accounts) { Console.WriteLine(account.Name); } } } finally { EngineManager.ShutdownEngine(); }