Hi OS_Pizza,
Here is the trimmed TEHandler business rule.
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.IO
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports OneStream.Shared.Common
Imports OneStream.Shared.Wcf
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Database
Imports OneStream.Stage.Engine
Imports OneStream.Stage.Database
Imports OneStream.Finance.Engine
Imports OneStream.Finance.Database
Namespace OneStream.BusinessRule.TransformationEventHandler.TransformationEventHandler
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As TransformationEventHandlerArgs) As Object
Try
Dim returnValue As Object = args.DefaultReturnValue
args.UseReturnValueFromBusinessRule = FALSE
args.Cancel = FALSE
'Evaluate the operation type in order to determine which sub-event is being processed
Select Case args.OperationName
Case Is = BREventOperationType.Transformation.ParseAndTrans.DeleteData
If args.IsBeforeEvent Then
Dim objTrans As Transformer = args.Inputs(0)
Dim errorCodes() As String = { "#VALUE!", "#NUM!","#N/A","#REF!" }
For Each dpValues In objTrans.Parser.DelimitedParsedValues
If errorCodes.Contains(dpValues, StringComparer.CurrentCultureIgnoreCase) Then
BRApi.ErrorLog.LogMessage(si,dpValues)
Throw New XFException(si,Nothing, Nothing, "Invalid Data: Excel file contains " + dpValues + " error in calculated cells")
End If
Next
End If
Case Is = BREventOperationType.Transformation.ParseAndTrans.ProcessTransformationRules
'Some Business logic
Case Is = BREventOperationType.Transformation.ParseAndTrans.StartParseAndTransform
'Do Nothing
Case Is = BREventOperationType.Transformation.ParseAndTrans.InitializeExcelRangeLayout
'Check the before / after flag, we want to handle the AFTER event
If Not args.IsBeforeEvent Then
Dim objRange As StageRangeContent = DirectCast(args.Inputs(1), StageRangeContent)
'Check the transformation rule cache to make sure the mappings are correct.
Dim objParser As Parser = DirectCast(args.Inputs(0), Parser)
Dim var As WorkflowUnitPk = objParser.Transformer.WorkflowUnitPk
Dim wfStatus As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si,var,False)
If wfStatus.Locked Then
Throw New XFException(si,Nothing,Nothing,"Cannot load data, the workflow Is locked.")
Else
If Not objRange Is Nothing Then
'Loop over the tokens and find the index of the time dimension
Dim timeIndex As String = SharedConstants.Unknown.ToString
For Each kvpToken As KeyValuePair(Of Integer, String) In objRange.DimensionTokens
'Parse the excel token
Dim token As StageTokenParts = StageConstants.MasterDimensionTokens.GetTokenParts(kvpToken.Value)
'Evaluate the token in order to see if it is time.
If token.DimensionName.Equals(StageConstants.MasterDimensionNames.Time, StringComparison.InvariantCultureIgnoreCase) Then
'< Perform input time validation >
End If
Next
End If
End If
End If
End Select
' Return returnValue
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace