Generate and convert to number

The Generate and convert to number masking activity allows you to generate a value using an IGenerator implementation and convert it to a number, i.e. an int value, before saving it to the database.

It functions the same as the Generate and convert, if you choose Int32 as the output value.

Table of contents
Usage
Example
Properties

Usage

To use the Generate and convert to number masking activity, it must be placed inside a table masking activity or a similar activity that iterates over data. Once placed, a Select Types window will open where you must choose the TGeneratedValue type, i.e. the type you want to generate. Selecting the Browse for Types... option will open the Browse and Select a .Net Type window where you can search for more types. After clicking OK, you can choose the property you want to mask, and then enter an instance of a generator you want to you to generate new values. You can create a new instance as a part of the masking activity, or you can choose an instance from custom code. Lastly, you have to enter an expression that will convert you generated value to int.

Example

This example will demonstrate the functionality of the Generate and convert to number activity by generating a random date and then assigning a value from the date to an address number in the database. We do this by first placing the Address masking activity into opened Package.xaml, placing the Generate and convert to number masking activity inside it. In the Select Types window we want to choose the DateTime type, but since it isn't one of the common types, we choose Browse for Types... to open the Browse and Select a .Net Type window.

Select Types window Figure 1: Select Types window

In this window we can search for the type we want, in this case we search for the DateTime type. We select it and click OK on both windows.

Selecting DateTime as the generator output Figure 2: Selecting DateTime as the generator output

After selecting the value type, we choose the Number column. As the generator, we create a new instance of the RandomDateTimeGenerator, and set it to generate random dates ranging from the date at the moment the package starts executing, to the maximum date the DateTime type can handle. We then need to create an expression that selects the DayOfYear property of the date and returns it as the result of the activity, effectively converting the value to int.

Generate and convert to number example Figure 3: Generating and converting values to int

Note: Generally, convertors are defined through lambda expressions. To learn more about lambda expressions see lambda expressions.

Properties

Property group Property name Description Example
Input properties DataItemProperty The property to mask. Write x => x.Number or choose property from the dropdown list
Expression Expression used to convert generated values. x => x.DayOfYear
Generator Generator used to generate values. new RandomDateTimeGenerator(DateTime.Now, DateTime.MaxValue)
Input: Filter Filter Expression used for filtering records - only filtered items will be masked. x => x.Number.IsBetween(1, 100)
SkipDefaultValues If true, default values will be omitted in masking (i.e. null values are not masked). true or false
Input: Repeating RepeaterId The ID of the repeater that will be used to detect repeating and save results when masking item key repeats. GenerateAndConvertToNumberRepeater
RepeatingKey Key to use for repeating detection. Write x => CompositeKey.Create(x.Number) or choose properties from the pop-up window
Misc DisplayName Display name of the activity in the workflow. Generate and convert to number
Result Contains the masking definition object. It's a part of the masking infrastructure and should be ignored. -