Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SSIS Card number check

$
0
0

Hi i've come up with the following code for a SSIS script component. My programming is pretty weak so could someone help me and check this for me and let me know if there is a better way of doing it? It basically just looks for a regex in specified columns and nulls them if it finds anything... Thanks! This is to remove any card numbers that get stuck in phone or email columns in a dataflow... I am also getting errors when i try to build it...

Error 1 The type or namespace name 'Wrapper' does not exist in the namespace 'Microsoft.SqlServer.Dts.Pipeline' (are you missing an assembly reference?)

Error 2 The type or namespace name 'Runtime' does not exist in the namespace 'Microsoft.SqlServer.Dts' (are you missing an assembly reference?)

/* Microsoft SQL Server Integration Services Script Component
*  This is CozyRoc Script Component Plus Extended Script
*  Write scripts using Microsoft Visual C# 2008.
*  ScriptMain is the entry point class of the script.*/

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Text.RegularExpressions;

[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{

    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        //Replace each \ with \\ so that C# doesn't treat \ as escape character
        //Pattern: Card matching Switch, Solo, Visa, MasterCard, Discover, American Express
        string sPattern = "^((67\\d{2})|(4\\d{3})|(5[1-5]\\d{2})|(6011))-?\\s?\\d{4}-?\\s?\\d{4}-?\\s?\\d{4}|3[4,7]\\d{13}$";
        string BusinessEmail = Row.BusinessEmail;
        string BusinessPhone = Row.BusinessPhone;
        string HomePhone = Row.HomePhone;
        string MobilePhone = Row.MobilePhone;
        string PersonalEmail = Row.PersonalEmail;
        //Find any matches of the pattern in the string
        Match One = Regex.Match(BusinessEmail, sPattern, RegexOptions.IgnoreCase);
        Match Two = Regex.Match(BusinessPhone, sPattern, RegexOptions.IgnoreCase);
        Match Three = Regex.Match(HomePhone, sPattern, RegexOptions.IgnoreCase);
        Match Four = Regex.Match(MobilePhone, sPattern, RegexOptions.IgnoreCase);
        Match Five = Regex.Match(PersonalEmail, sPattern, RegexOptions.IgnoreCase);

        //If a match is found set field to null
        if (One.Success)
            Row.BusinessEmail = null;
        if (Two.Success)
            Row.BusinessPhone = null;
        if (Three.Success)
            Row.HomePhone = null;
        if (Four.Success)
            Row.MobilePhone = null;
        if (Five.Success)
            Row.PersonalEmail = null;
    }

}



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>