Totally untested. But I think this will do it.
#Region "SetICStatus Helpers"
Private Sub XFR_FinalizeAddICTransactionStatus(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal args As DataQualityEventHandlerArgs)
Try
Dim objICMatchStatusInfo As ICMatchStatusInfo = DirectCast(args.Inputs(0), ICMatchStatusInfo)
If objICMatchStatusInfo.TransactionState = 40 'Finalized
Dim intEntityID As Integer = objICMatchStatusInfo.ICMatchTransaction.EntityId
Dim entMbr As Member =BRApi.Finance.Members.ReadMemberNoCache(si, DimTypeId.Entity, intEntityID)
Dim readWriteGroup As GroupInfo = BRApi.Security.Admin.GetGroupInfoEx(si, entMbr.ReadWriteDataGroupUniqueID).GroupInfo
Dim readWriteGroup2 As GroupInfo = BRApi.Security.Admin.GetGroupInfoEx(si, entMbr.ReadWriteDataGroupUniqueID2).GroupInfo
Dim usrList As New List(Of UserInfo)
Me.GetUsersInGroup(si, readWriteGroup.Group.UniqueID, usrList)
Me.GetUsersInGroup(si, readWriteGroup2.Group.UniqueID, usrList)
For Each userSummary As UserInfo In usrList.Distinct()
'Send the email
Me.CreateMessageAndSendMail(si, objICMatchStatusInfo, userSummary)
Next
End If
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub
Private Sub GetUsersInGroup(ByVal si As SessionInfo, ByVal groupID As Guid, ByRef usrList As list(Of UserInfo))
Try
Using dbFwConn As DbConnInfoFW = BRApi.Database.CreateFrameworkDbConnInfo(si)
Dim sql As New Text.StringBuilder
sql.AppendLine("WITH ChildUser as
(
SELECT ChildKey,ChildIsAUser FROM SecGroupChild
WHERE ChildIsAUser = 0
UNION ALL
SELECT b.ChildKey,b.ChildIsAUser FROM SecGroupChild as b
INNER JOIN ChildUser as a on a.ChildKey= b.GroupKey
)
Select distinct ChildKey from (
SELECT distinct ChildKey FROM ChildUser
where ChildIsAUser <> 0
UNION ALL
SELECT distinct ChildKey FROM SecGroupChild
WHERE ChildIsAUser = 1)p")
Dim userDT As DataTable = BRApi.Database.ExecuteSqlUsingReader(dbFwConn, sql.ToString, True)
If userDT.Rows.Count > 0 Then
For Each userDR As DataRow In userDT.rows
usrList.Add(BRApi.Security.Admin.GetUser(si, DirectCast(userDR("ChildKey"),Guid)))
Next
End If
End Using
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub
Private Sub CreateMessageAndSendMail(ByVal si As SessionInfo, objICMatchStatus As ICMatchStatusInfo, userSummary As UserInfo)
'------------------------------------------------------------------------------------------------------------
'Reference Code: CreateMessageAndSendMail
'
'Description: Create the email message body and execute the "Send Mail" function.
'
'------------------------------------------------------------------------------------------------------------
Try
Using dbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
Dim emailInfo As New Text.StringBuilder
emailInfo.AppendLine("To: " & userSummary.User.Email)
'Create the message title
Dim messageTitle As New Text.StringBuilder
messageTitle.Append("IC Match for [")
messageTitle.Append(objICMatchStatus.ICMatchTransaction.EntityId)
messageTitle.Append(", ")
messageTitle.Append(objICMatchStatus.ICMatchTransaction.PartnerId)
messageTitle.Append("] is ready for you to review.")
messageTitle.AppendLine("")
'Create the message body
Dim messageBody As New Text.StringBuilder
messageBody.AppendLine("IC Match Information:")
messageBody.AppendLine("User Name........... " & objICMatchStatus.UserName)
messageBody.AppendLine("Time Completed...... " & objICMatchStatus.TimeStamp)
messageBody.AppendLine("Comments............ " & objICMatchStatus.Comments)
messageBody.AppendLine("")
'Test the email by writing a log message
ErrorHandler.LogMessage(si, emailInfo.ToString & vbcrlf & messageTitle.ToString & vbcrlf & messageBody.ToString)
'Send an email message
'Me.SendMail(si, userSummary.User.Email, messageTitle.ToString, messageBody.ToString)
End Using
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub
#End Region