Streaming transaction - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

The streaming loader is an alternate way of loading information. The streaming loader is designed to use less memory and process information much faster. However, it won't fire any of the events on the interfaces or allow any customization.

How to use the streaming loader

The first argument on the Begin method is True for a memory stream and False for a file stream. The recommendation is to use a memory stream for smaller file because it is faster, but larger transactions should use the file stream.

try

SPFRequestContext.Instance.StreamingTransaction.Begin(False, "VTLComponent")

If SPFRequestContext.Instance.StreamingTransaction.InTransaction Then

SPFRequestContext.Instance.StreamingTransaction.Commit()

End If

Catch ex As Exception

'

' Rollback the transaction on an error

'

If SPFRequestContext.Instance.StreamingTransaction.InTransaction Then

SPFRequestContext.Instance.StreamingTransaction.Rollback()

End Try

To create objects and relationships you have to use a different utility function that does not put the new item into the cache. Then set properties on the new object and call FinishCreate. Finally, add the item into the transaction.

Dim lobjExecutionRecord As IObject = SPF.Server.Utilities.GeneralUtilities.InstantiateObjectNoFootprint (

"VTLDataValidationRuleExecutionRecord", Me.Name & "-" & pobjItem.Name, Me.Description & "-" & pobjItem.Description, "SPFAUTHORING")

lobjExecutionRecord.Interfaces("IDataValidationRuleExecutionRecord").Properties("IsDataValid", True).SetValue("OK")

lobjExecutionRecord.Interfaces("IDataValidationRuleExecutionRecord").Properties("ValidationMessage", True).SetValue(e.ValidationMessage)

'lobjExecutionRecord.GetClassDefinition.FinishCreate(lobjExecutionRecord, True)

SPFRequestContext.Instance.StreamingTransaction.AddItem(lobjExecutionRecord)

'

' Create the relationship to the Rule

'

Dim lobjExecutionRuleRel As IObject = SPF.Server.Utilities.GeneralUtilities.InstantiateRelationNoFootprint( "DataValidatonRuleExecutionRecord", Me, lobjExecutionRecord, False)

' Set the suppress events flag.

'lobjExecutionRuleRel.GetClassDefinition.FinishCreate(lobjExecutionRuleRel)

'lobjExecutionRuleRel.GetClassDefinition.FinishCreate(lobjExecutionRuleRel, True)

SPFRequestContext.Instance.StreamingTransaction.AddItem(lobjExecutionRuleRel)