This is an example of the "FirstName" column masking where repeaters are loaded before masking and saved as "RepeaterKey" and "RepeatingValue" in the defined database after the package execution (masking).
Every time this masking is executed, the value in the "FirstName" column of the target database will be replaced with the corresponding value from the "RepeatingValue" column, if the value from "FirstName" column matches the value in "RepeaterKey" column.
Table of contents |
---|
Preconditions |
Steps |
From the Solution Explorer open the Package.xaml file.
Delete the HelloWorldScope step created by default.
Drag the Customer_Activity from the Toolbox into the Sequence activity. A Masking engine with a Customer iterator, Customer handler and Customer adapter is created inside the Sequence.
Drag the Masking block activity from the Toolbox into the Customer masking activity.
Drag the Pick HR first name from list masking activity from the Toolbox into the Masking block.
In the Pick HR first name from list masking activity, select FirstName
as the "Property" you want to mask.
Start the masking process (Debug -> Start Without Debugging) which will result in changes (due to masking) in the "FirstName" column.
Open the Code.cs file from Solution Explorer.
In Code.cs create a new class Repeaters
with a constant named FirstNameRepeater
public static class Repeaters
{
public const string FirstNameRepeater = "FirstNameRepeater";
}
Repeater names can be passed directly as strings, but it is recommended to store them in a constant so their usage is consistent and more easily understandable throughout the package.
Open the Properties of the Pick HR first name from list masking activity by selecting it (Properties will open in a new tab).
In the "Input: Repeating" section, for the "RepeaterId" parameter set value Repeaters.FirstNameRepeater
.
To change the "RepeatingKey" parameter, click the ... button at the end of the input field to open the Property Selector window. For the "Property 1" parameter select FirstName
and click OK. A value for the "RepeatingKey" parameter has been automatically created.
item => CompositeKey.Create(item.FirstName)
Open the App.config file to add the connection string to the repeater database and modify repeater settings.
Add a connection string to the repeater database and other repeater settings (Persistence Configuration). The section below can vary depending on which database is used. The type of the database being masked and the type of the database in which the repeating values are going to be saved do not have to be the same.
Add the following to the <connectionstrings>
node:
<add name="RepeaterPersistenceSQL" connectionstring="Data Source=Server_Name;Initial Catalog=Repeaters;Integrated Security=True;"></add>
Instead of Server_Name
, write the name of the server that will contain the repeaters database. Instead of Repeaters
, write the name of the database you want your repeaters to be saved to. It is recommended to have a separate database for repeaters.
When you installed the Microsoft SQL Server NuGet package, the ekobit.bizdatax.database.mssql
section has been added to the App.config. This section contains commented sections that are used to define repeating persistence. Uncomment the tag named repeatingPersistence and change the value so they match the following:
<repeatingpersistence persistenceonthefly="false" connectionstringname="RepeaterPersistenceSQL" schemaname="dbo" tableprefix="Rep_"></repeatingpersistence>
As the connectionStringName, put the name of the connection string to the repeater database defined in the previous step. Put the name of the schema you want to save the repeater values to as the schemaName. Lastly, you can write a tablePrefix that will be added to the beggining of the name of every repeater table. If you want to use repeater persistence on the fly, change the persistenceOnTheFly to true
.
Go back to the Package.xaml file.
Drag the Load repeaters activity from the Toolbox into the Sequence activity above the Masking engine. If you are using repeater persistence on the fly, you can skip this step.
Drag the Save repeaters activity from the Toolbox into the Sequence activity below the Masking engine. If you are using repeater persistence on the fly, you can skip this step.
In the Properties of both the Load repeaters and Save repeaters activities, set the "RepeaterIds" parameter as new string[] {Repeaters.FirstNameRepeater}
. If you are using repeater persistence on the fly, you can skip this step.
In the database, in the "Customer" table, change a few records to have "FirstName" column value as Ana
.
Start the masking process.
Check the previously changed records. Values in the "First name" column have changed. Everywhere where the "FirstName" column had the value Ana
there is another (masked) name, but always the same value.
Change a few previously changed records to have the "FirstName" column value as Ana
to check whether these values will change the same way they had in the previous masking (i.e. whether repeaters were saved).
Start the masking process.
Check the previously changed records. Values in column First name
have changed. Every row that had the "FirstName" column value as Ana
now has the same value as after the previous masking.
Figure 1: Complete example workflow