Imports System.Runtime.InteropServices
Imports System.Text
Imports System.IO
Imports Interop_PipeComplib
Imports Interop_MscsCore
Public Class AICPipeline
Implements IPipelineComponentAdmin
Implements IPipelineComponent
Const E_NOTIMPL = &H80004001
Private Const E_FAIL = &H80004005
Private m_strFileLocation As String
Private m_strLogFileLocation As String
Private Sub IPipelineComponent_EnableDesign(ByVal fEnable As Integer) Implements IPipelineComponent.EnableDesign
'Do Nothing
End Sub 'IPipelineComponent_EnableDesign
Private Function IPipelineComponent_Execute(ByVal dictTransport As Object, _
ByVal pdispContext As Object, _
ByVal lFlags As Integer) As Integer Implements IPipelineComponent.Execute
On Error GoTo ExecuteError
EventLog.WriteEntry("AIC", "Starting AIC Test (BizTalk AIC)", EventLogEntryType.Information)
'Overwrite configuration defaults with any values passed in
IPipelineComponentAdmin_SetConfigData(dictTransport)
If Not pdispContext Is Nothing Then
IPipelineComponentAdmin_SetConfigData(pdispContext)
End If
' Log the string values supplied by the server for all AICs
' Src_ID_Type: The type of identifier used for the source organization.
LogToFile(m_strLogFileLocation, True, dictTransport("Src_ID_Type"))
' Src_ID_Value: The value of the source organization identifier.
LogToFile(m_strLogFileLocation, False, dictTransport("Src_ID_Value"))
' Dest_ID_Type: The type of identifier used for the destination organization.
LogToFile(m_strLogFileLocation, False, dictTransport("Dest_ID_Type"))
' Dest_ID_Value: The value of the destination organization identifier.
LogToFile(m_strLogFileLocation, False, dictTransport("Dest_ID_Value"))
' Document_Name: The name of the inbound document definition.
LogToFile(m_strLogFileLocation, False, dictTransport("Document_Name"))
' Tracking_ID: A key value that is based on the GUID and used for tracking.
LogToFile(m_strLogFileLocation, False, dictTransport("Tracking_ID"))
' Log working_data
LogToFile(m_strFileLocation, True, dictTransport("working_data"))
EventLog.WriteEntry("AIC", "Ending AIC Test (BizTalk AIC)", EventLogEntryType.Information)
'return success
IPipelineComponent_Execute = 0
Exit Function
ExecuteError:
IPipelineComponent_Execute = 2 'Serious Error Occurred
LogFail("The following Error was encountered: " + Err.Description)
End Function 'IPipelineComponent_Execute
Private Function IPipelineComponentAdmin_GetConfigData() As Object Implements IPipelineComponentAdmin.GetConfigData
Dim objectConfig As New CDictionary()
objectConfig.Value("File_Location") = m_strFileLocation
objectConfig.Value("LogFile_Location") = m_strLogFileLocation
IPipelineComponentAdmin_GetConfigData = objectConfig
End Function 'IPipelineComponentAdmin_GetConfigData
Private Sub IPipelineComponentAdmin_SetConfigData(ByVal pDict As Object) Implements IPipelineComponentAdmin.SetConfigData
' set m_strFileLocation
If Not IsDBNull(pDict("File_Location")) Then
m_strFileLocation = CStr(pDict("File_Location"))
End If
If m_strFileLocation = "" Then
m_strFileLocation = Environ$("Temp") + "\BTSSamples_pipe.out"
End If
' set m_strLogFileLocation
If Not IsDBNull(pDict("LogFile_Location")) Then
m_strLogFileLocation = CStr(pDict("LogFile_Location"))
End If
If m_strLogFileLocation = "" Then
m_strLogFileLocation = Environ$("Temp") + "\BTSSamples.log"
End If
End Sub 'IPipelineComponentAdmin_SetConfigData
Private Sub LogFail(ByVal strFail As String)
Dim lFileHandle As Long
'On Error Resume Next
lFileHandle = FreeFile()
If m_strLogFileLocation = "" Then
FileOpen(1, "c:\temp\BTSSamples.LOG", OpenMode.Append, OpenAccess.ReadWrite, OpenShare.Default)
FileClose(1)
Else
FileOpen(1, m_strLogFileLocation, OpenMode.Append, OpenAccess.ReadWrite, OpenShare.Default)
FileClose(1)
End If
Print(1, "[FAIL] " & strFail)
FileClose(1)
End Sub
Private Sub LogSuccess(ByVal strSuccess As String)
Dim lFileHandle As Long
On Error Resume Next
lFileHandle = FreeFile()
If m_strLogFileLocation = "" Then
FileOpen(1, "c:\temp\BTSSamples.LOG", OpenMode.Append, OpenAccess.ReadWrite, OpenShare.Default)
FileClose(1)
Else
FileOpen(1, m_strLogFileLocation, OpenMode.Append, OpenAccess.ReadWrite, OpenShare.Default)
FileClose(1)
End If
Print(1, "[PASS] " & strSuccess)
FileClose(1)
End Sub
Private Sub LogInfo(ByVal strInfo As String)
Dim lFileHandle As Long
On Error Resume Next
lFileHandle = FreeFile()
If m_strLogFileLocation = "" Then
FileOpen(1, "c:\temp\BTSSamples.LOG", OpenMode.Append, OpenAccess.ReadWrite, OpenShare.Default)
FileClose(1)
Else
FileOpen(1, m_strLogFileLocation, OpenMode.Append, OpenAccess.ReadWrite, OpenShare.Default)
FileClose(1)
End If
Print(1, "[INFO] " & strInfo)
FileClose(1)
End Sub
Private Sub LogToFile(ByVal FileLocation As String, ByVal OverwriteFile As Boolean, ByVal DatatoWrite As String)
Dim lFileHandle As Long
lFileHandle = FreeFile()
If OverwriteFile Then
FileOpen(1, FileLocation, OpenMode.Binary)
FilePut(1, DatatoWrite)
FileClose(1)
Else
FileOpen(1, FileLocation, OpenMode.Append, OpenAccess.Default)
Write(1, DatatoWrite)
FileClose(1)
End If
FileClose(1)
End Sub
<ComRegisterFunction()> Public Shared Sub RegisterFunction(ByVal t As Type)
Try
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Implemented Categories\\{5C6C30E7-C66D-40E3-889D-08C5C3099E52}")
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Implemented Categories\\{BD193E1D-D7DC-4B7C-B9D2-92AE0344C836}")
Catch
End Try
End Sub
<ComUnregisterFunction()> Public Shared Sub UnregisterFunction(ByVal t As Type)
Try
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Implemented Categories\\{5C6C30E7-C66D-40E3-889D-08C5C3099E52}")
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Implemented Categories\\{BD193E1D-D7DC-4B7C-B9D2-92AE0344C836}")
Catch
End Try
End Sub
End Class