Hi Rob
Below is my main function:
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Transformer, ByVal args As ConnectorArgs) As Object
Try
Select Case args.ActionType
Case Is = ConnectorActionTypes.GetFieldList
'Return Field Name List if using Field List Method to get field list in GetFieldList
Return Me.GetFieldList(si, globals, api, columnNames)
Case Is = ConnectorActionTypes.GetData
'Get Data.
Return Me.GetData(si, api)
Case Is = ConnectorActionTypes.GetDrillBackTypes
'Return the list of Drill Types (Options) to present to the end user
Return Me.GetDrillBackTypeList(si, globals, api, args)
Case Is = ConnectorActionTypes.GetDrillBack
'Process the specific Drill-Back type
Return Me.GetDrillBack(si, globals, api, args, connectionName, columnNamesDrillBack, accountTypePL, accountTypeBS, accountTypeSignFlip)
End Select
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
And Below is the GetData function:
Private Function GetData(ByVal si As SessionInfo, ByVal api As Transformer) As DataTable
Dim errorlog As String = ""
Try
'Set variables.
Dim wfTime As String = BRApi.Finance.Time.GetNameFromId(si, api.WorkflowUnitPk.TimeKey)
Dim oTime As TimeMemberSubComponents = BRApi.Finance.Time.GetSubComponentsFromName(si, wfTime)
Dim wfMonth As Integer = oTime.Month
Dim wfMonthDesc As String = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}(wfMonth-1)
Dim wfYear As Integer = oTime.year
Dim dt As DataTable = Nothing
'Get assigned entities.
Dim assignedEntitiesWF As List(Of WorkflowProfileEntityInfo) = BRApi.Workflow.Metadata.GetProfileEntities(si, api.WorkflowProfile.ProfileKey)
Dim assignedEntities As String() = assignedEntitiesWF.Where(Function(m) m.EntityName.StartsWith("D_") = False).Select(Function(m) m.EntityName).ToArray()
'Get SQL query.
Dim sSQL As String = Me.GetSQL(si, api, wfYear, wfMonth, wfMonthDesc, assignedEntities, accountTypePL, accountTypeBS, accountTypeSignFlip)
'Get data from source.
Using dbC As DbConnInfo = BRApi.Database.CreateExternalDbConnInfo(si, connectionName)
dt = BRApi.Database.ExecuteSql(dbC, sSQL, True)
End Using
'Execute the data load
api.Parser.ProcessDataTable(si, dt, False, api.ProcessInfo)
Return dt
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function