Forum Discussion

aorange's avatar
aorange
New Contributor III
12 days ago

Calculation Definitions Filter -Data Quality Event Handler

Hello,  I setup a filter on a workflow profile calculation to run a data management job as long as the no calculate is the selected option.  We have a Data Quality Event Handler Business rule to ...
  • Big_Rick_CPM's avatar
    Big_Rick_CPM
    11 days ago

    I would just check the WF start time and just run it for that year only. But there could be other ways to do this depending on your setup.

    Imports System
    Imports System.Data
    Imports System.Data.Common
    Imports System.IO
    Imports System.Collections.Generic
    Imports System.Globalization
    Imports System.Net.Mail
    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.DataQualityEventHandler.DataQualityEventHandler
    	Public Class MainClass
    		'------------------------------------------------------------------------------------------------------------
    		'Reference Code: 	DataQualityEventHandler 
    		'
    		'Description:		Event handler method that provides an opertunity to supplement a normal data quality
    		'					action with your own custom functionality. 
    		'					(Example: email after ProcessCube or publish report to sharepoint after failed Confirmation).
    		'
    		'Usage:				Executes when a Data Quality action is run and fires this business rule.  If you have written
    		'					code in that handles the specified event operation the code will be executed.
    		'				
    		'Created By:		Tom Shea
    		'Date Created:		1-30-2013
    		'------------------------------------------------------------------------------------------------------------		
    		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DataQualityEventHandlerArgs) As Object
    			Try
    				'Define a switch to control event processing, since many of these are reference examples we do not want them to run all the time
    				Dim processEvents As Boolean = False
    
    				'Set the default return values
    				Dim returnValue As Object = args.DefaultReturnValue
    				args.UseReturnValueFromBusinessRule = False
    				args.Cancel = False
    
    				'Evaluate the operation type in order to determine which subroutine to process
    				Select Case args.OperationName
    					Case Is = BREventOperationType.DataQuality.ProcessCube.NoCalculate
    						'Execute a Data Management job after process cube runs
    						Me.XFR_HandleProcessCubeNoCalculate(si, globals, api, args)
    						
    					'Case Is = BREventOperationType.DataQuality.Certify.FinalizeSetCertifyState
    						'Send an email after a workflow profile executes its certification
    						'Me.XFR_HandleFinalizeSetCertifyState(si, globals, api, args)						
    						
    				End Select
    				
    				Return returnValue
    				
    			Catch ex As Exception
    				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    			End Try
    		End Function
    		
    #Region "ProcessCube.NoCalculate Helpers"
    		
    		Private Sub XFR_HandleProcessCubeNoCalculate(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DataQualityEventHandlerArgs)
    			'------------------------------------------------------------------------------------------------------------
    			'Reference Code: 	XFR_HandleProcessCubeNoCalculate 
    			'
    			'Description:		Run a DataMgmt Sequence after the workflow process cube task is run.
    			'					Note: the DataMgmt sequence name is assigned to a Workflow Profile CalcDef filter field
    			'					so this event does not have to be modified, the user can simply edit the CalcDef grid
    			'					for a workflow profile and this business rule will execucte the specified sequence.
    			'
    			'Usage:				Used to supplement the standard "ProcessCube" functionality associated with a 
    			'					workflow profile by allowing a DataManagement sequence to be executed for the workflow profile
    			'					as well.
    			'
    			'Created By:		Tom Shea
    			'Date Created:		1-30-2013
    			'------------------------------------------------------------------------------------------------------------
    			Try
    				'Get the DataUnitInfo from the Event arguaments so that we can get the name of the DataManagement sequence to process.
    				Dim calcInfo As DataUnitInfo = DirectCast(args.Inputs(2), DataUnitInfo)
    				If Not calcInfo Is Nothing Then					
    					'Make sure that a Sequence name as assigned to the filter value of the Calc Definition of the executing Workflow Profile 
    					If calcInfo.FilterValue <> String.Empty Then
    '**************************************************************
    ' NEW CHECK TO ONLY RUN ON THE START YEAR OF WF RANGE TIME
    						If timedimhelper.GetYearFromId(calcInfo.DataUnitIds.TimeId).Equals(timedimhelper.GetYearFromId(brapi.Finance.Scenario.GetWorkflowStartTime(si,calcInfo.DataUnitIds.ScenarioId)))
    '**************************************************************
    						'	Now, execute the DataMgmt Sequence that was specified in the FilterValue (In a background thread)
    							Dim params As New Dictionary(Of String, String)
    							BRApi.Utilities.StartDataMgmtSequence(si, calcInfo.FilterValue, params)		
    						End If
    					End If
    				End If
    
    			Catch ex As Exception
    				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    			End Try
    		End Sub
    
    #End Region
    
    
    	End Class
    End Namespace