我的SSIS包正在为记录失败或记录中有任何错误的记录创建自动电子邮件,它将生成一个包含以下详细信息的电子邮件模板。
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
我不想在邮件中显示总EmpID,例如,如果EmpID是123456789,我只想显示12 ##### 89 我怎么能在vb.net脚本中做到这一点。在上面的代码中
寻求帮助谢谢
答案 0 :(得分:0)
我不确定你的规则究竟是什么,但这可以通过子串完成。
Dim id As String = "123456789"
Dim result As String
result = id.Substring(0, 2).PadRight(id.Length - 2, "#") & id.Substring(id.Length - 2)
如果您想了解如何在代码中使用它的示例。我建议做一个功能。
Function ShowPartialId(ByVal id As String)
Return id.Substring(0, 2).PadRight(id.Length - 2, "#") & id.Substring(id.Length - 2)
End Function
然后你只需要调用函数
sErrorDetail.EmpID = ShowPartialId(node("EmpID").InnerText)