CustomAttributeValue Class

The value of a custom attribute.
Inheritance Hierarchy
SystemObject
  Dundas.BI.AccountServicesCustomAttributeValue

Namespace:  Dundas.BI.AccountServices
Assembly:  Dundas.BI.Core (in Dundas.BI.Core.dll) Version: 2.0.0.0 (24.1.0.1001)
Syntax
public class CustomAttributeValue

The CustomAttributeValue type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAttributeId
Gets the ID of the CustomAttributeInfo which this value is referenced to.
Public propertyIsInheritanceConflict
Gets a value indicating whether this custom attribute value inherits conflicting values from two or more groups or Windows Group accounts.
Public propertyIsInherited
Gets a value indicating whether the custom attribute value is inherited from others.
Public propertySingleValue
Gets or sets the single value of the attribute.
Public propertyValues
Gets the value of a custom attribute.
Top
Methods
  NameDescription
Public methodGetAttributeInfo
Gets a CustomAttributeInfo object representing the definition of the custom attribute to which this value corresponds.
Top
Examples

This example demonstrates how to create the Dundas BI engine, start the Dundas BI engine, log on, create a custom attribute called Daves, assign that custom attribute to the Dave accounts, and then shutdown the Dundas BI engine.

C#
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.
        Engine.Current.GetService<ICallerContextService>().CurrentContext.SetCurrentSessionId(
            logOnResult.Session.Id
        );


        // Get the custom attribute service.
        ICustomAttributeService customAttributeService =
            Engine.Current.GetService<ICustomAttributeService>();

        // Save the new custom attribute.
        customAttributeService.SaveCustomAttribute(
                new CustomAttributeInfo()
                {
                    Description = "These are the Daves I know",
                    Name = "Daves",
                    InheritanceBehavior = CustomAttributeInheritanceBehavior.Override,
                    IsMultiValue = false
                }
            );

        // Now get the custom attribute.  It's ID will be needed.
        var davesCustomAttribute = customAttributeService.GetCustomAttribute("Daves");

        // Get the account service.
        IAccountService accountService =
            Engine.Current.GetService<IAccountService>();    

        // Create a filter rule to get all the users that have a 
        // display name that starts with <c>dav</c>.
        AccountQueryFilterRule accountQueryFilterRule = 
            new AccountQueryFilterRule(
                AccountQueryField.DisplayName, 
                Dundas.BI.QueryFilterOperator.StartsWith, 
                "dav"
                );

        // Get all the dave accounts
        IList<Account> daveAccounts =
            accountService.AccountQuery(
            0,
            0, 
            null, 
            new List<AccountQueryFilterRule>() { 
                accountQueryFilterRule
                }
            );

        // Loop through the dave accounts.
        foreach(Account daveAccount in daveAccounts)
        {
            // Add the custom attribute to the Dave Account.
            daveAccount.CustomAttributes.Add(
                davesCustomAttribute.Id, new CustomAttributeValue(davesCustomAttribute.Id) { SingleValue = "Is a Dave I know" }
            );

            // Save the account with the custom attribute.
            accountService.SaveAccount(daveAccount);
        }
    }
}
finally
{
    EngineManager.ShutdownEngine();
}
See Also