Domanda

My SSIS package is creating a automated email for records which are failed or having any error in the record, it will generate a email template with following details.

Public Shared Sub AddErrorDetail(ByRef sbErrorLst As List(Of ErrorDetail), ByVal ErrorMsg As String, ByVal ErrorLevel As String, Optional ByVal node As XmlNode = Nothing, Optional ByVal paycheckNode As XmlNode = Nothing, Optional ByVal paycheckDetailNode As XmlNode = Nothing, Optional ByVal ddNode As XmlNode = Nothing)
    Dim sErrorDetail As New ErrorDetail
    sErrorDetail.ErrorMsg = ErrorMsg
    sErrorDetail.ErrorLevel = ErrorLevel
    Try
        If node IsNot Nothing Then
            If node("EmpID") IsNot Nothing Then
                sErrorDetail.EmpID = node("EmpID").InnerText
            End If
        End If

        If Not paycheckNode Is Nothing Then
            If Not paycheckNode("DocumentID") Is Nothing Then
                sErrorDetail.DocumentID = paycheckNode("DocumentID").InnerText
            End If
    sbErrorLst.Add(sErrorDetail)
    Catch ex As Exception
        sErrorDetail.ErrorMsg = ex.Message + " " + ex.StackTrace
        sErrorDetail.ErrorLevel = "High"
        sErrorDetail.FunctionID = "AddErrorDetail"
        sErrorDetail.ErrorNbr = "-102"
        sbErrorLst.Add(sErrorDetail)
    End Try

End Sub

I dont want to display total EmpID in the mail for example if EmpID is 123456789 i just want to show 12#####89 how can i do it in vb.net script. in above code

Looking for help Thanks

È stato utile?

Soluzione

I'm not sure what exactly is your rule but this can be done with substring.

    Dim id As String = "123456789"
    Dim result As String

    result = id.Substring(0, 2).PadRight(id.Length - 2, "#") & id.Substring(id.Length - 2)

If you want an example on how to use it with your code. I would suggest making a function.

Function ShowPartialId(ByVal id As String)
    Return id.Substring(0, 2).PadRight(id.Length - 2, "#") & id.Substring(id.Length - 2)
End Function

And then you just need to call the function

sErrorDetail.EmpID = ShowPartialId(node("EmpID").InnerText)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top