Example

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

Preconditions

  • Designer data model is created (Microsoft SQL Server database BizDataXDemo).
  • The database in which the data will be stored is prepared and the connection string is known.

Steps

  1. From the Solution Explorer open the Package.xaml file.

  2. Delete the HelloWorldScope step created by default.

  3. 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.

  4. Drag the Masking block activity from the Toolbox into the Customer masking activity.

  5. Drag the Pick HR first name from list masking activity from the Toolbox into the Masking block.

  6. In the Pick HR first name from list masking activity, select FirstName as the "Property" you want to mask.

  7. Start the masking process (Debug -> Start Without Debugging) which will result in changes (due to masking) in the "FirstName" column.

  8. Open the Code.cs file from Solution Explorer.

  9. 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.

  10. Open the Properties of the Pick HR first name from list masking activity by selecting it (Properties will open in a new tab).

  11. In the "Input: Repeating" section, for the "RepeaterId" parameter set value Repeaters.FirstNameRepeater.

  12. 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)
    
  13. Open the App.config file to add the connection string to the repeater database and modify repeater settings.

  14. 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.

  15. 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.

  16. Go back to the Package.xaml file.

  17. 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.

  18. 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.

  19. 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.

  20. In the database, in the "Customer" table, change a few records to have "FirstName" column value as Ana.

  21. Start the masking process.

  22. 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.

  23. 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).

  24. Start the masking process.

  25. 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.

Complete example workflow Figure 1: Complete example workflow