This walkthrough explains how to mask a fixed-width file by building a package that loads the given file, performs masking and creates a new, masked fixed-width file.
Table of contents |
---|
Preconditions |
Masking activities that are going to be used |
Steps |
C:\Temp
From Solution Explorer open the Code.cs file.
In Code.cs add namespace Ekobit.BizDataX.DataMasking.Files
and class Customer
with properties equal to rows in the fixed-width file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ekobit.BizDataX.DataMasking.Files;
namespace BizDataXPackage
{
/// <summary>
/// Contains custom code to be used during package execution.
/// </summary>
public static class Code
{
// TODO: Add your code here
}
public class Customer
{
[Fixed(25)]
public String FirstName { get; set; }
[Fixed(25)]
public String LastName { get; set; }
}
}
Save your changes and build the project.
First few rows of the fixed-width file that is going to be masked:
Rhiannon Velazquez
Jasmine Conley
Iliana Patrick
Toni Valencia
Stormy Branch
Naomi Guzman
Jaylen Sampson
Destini Downs
From the Solution Explorer open the Package.xaml file.
Delete the workflow created by default.
Drag the Step activity from the Toolbox into the opened Package.xaml.
Drag the Masking engine from the Toolbox into the Step.
Drag the Masking iterator from the Toolbox into the Masking engine.
In the Select Types pop-up window select Browse for Types...
and find Customer
.
Click OK on both pop-up windows.
Drag the API handler from the Toolbox into the Masking iterator, in the place that says "Drop data handler here".
In the API handler write:
api=>api.Fixed().GetHandler<customer>("C:/Temp/Customers.txt","C:/Temp/Customers_masked.txt")
Drag the Pick US first name from list masking activity from the Toolbox into the Masking iterator, where it says "Drop activities here".
In the Pick US first name from list masking activity, select FirstName
as the "Property".
Do the same for the Pick US last name from list masking activity (select LastName
as "Property").
Save your changes and start package execution (Debug->Start Without Debugging).
Open the C:\Temp
directory to check for changes. A new file named Customers_masked.txt is created and it contains masked data from the original Customers.txt file.
Rita Navarro
Gregory Vaughan
Samuel Charles
Francesco Joyner
Robbie Vaughan
Kyla Lowe
Alice Randall
Kelsey Carter
Figure 1: Fixed-width file masking
Note: API Handler can be configured with additional options (using line breaks, different encodings, etc): Figure 2: API handler options