@@ -400,22 +400,6 @@ public NodeId CreateNode(
400400 instance . Create ( contextToUse , null , browseName , null , true ) ;
401401 AddPredefinedNode ( contextToUse , instance ) ;
402402
403- // report audit event
404- if ( Server ? . EventManager ? . ServerAuditing == true )
405- {
406- // current server supports auditing, prepare the added nodes info
407- AddNodesItem [ ] addNodesItems = GetFlattenedNodeTree ( context , instance ) . Select ( n => new AddNodesItem ( ) {
408- BrowseName = n . BrowseName ,
409- NodeClass = n . NodeClass ,
410- RequestedNewNodeId = n . NodeId ,
411- TypeDefinition = n . TypeDefinitionId ,
412- ReferenceTypeId = n . ReferenceTypeId ,
413- ParentNodeId = n . Parent ? . NodeId
414- } ) . ToArray ( ) ;
415-
416- ReportAuditAddNodesEvent ( context , addNodesItems , "CreateNode" , StatusCodes . Good ) ;
417- }
418-
419403 return instance . NodeId ;
420404 }
421405 }
@@ -443,18 +427,6 @@ public bool DeleteNode(
443427
444428 if ( PredefinedNodes . TryGetValue ( nodeId , out node ) )
445429 {
446- // report audit event
447- if ( Server ? . EventManager ? . ServerAuditing == true )
448- {
449- // current server supports auditing, prepare the deleted nodes info
450- DeleteNodesItem [ ] nodesToDelete = GetFlattenedNodeTree ( context , node as BaseInstanceState ) . Select ( n => new DeleteNodesItem ( ) {
451- NodeId = n . NodeId ,
452- DeleteTargetReferences = true
453- } ) . ToArray ( ) ;
454-
455- ReportAuditDeleteNodesEvent ( context , nodesToDelete , "DeleteNode" , StatusCodes . Good ) ;
456- }
457-
458430 RemovePredefinedNode ( contextToUse , node , referencesToRemove ) ;
459431 found = true ;
460432 }
@@ -740,36 +712,6 @@ protected virtual void RemovePredefinedNode(
740712 }
741713 }
742714
743-
744- /// <summary>
745- /// Get the flattened tree of nodes starting from the specified node
746- /// </summary>
747- /// <param name="context">Current server context.</param>
748- /// <param name="rootNode">The root node from where the search begins.</param>
749- /// <returns></returns>
750- protected IList < BaseInstanceState > GetFlattenedNodeTree ( ISystemContext context , BaseInstanceState rootNode )
751- {
752- if ( rootNode == null ) return new List < BaseInstanceState > ( ) ;
753-
754- List < BaseInstanceState > nodes = new List < BaseInstanceState > ( ) { rootNode } ;
755- List < BaseInstanceState > results = new List < BaseInstanceState > { rootNode } ;
756- while ( nodes . Count > 0 )
757- {
758- List < BaseInstanceState > childNodes = new List < BaseInstanceState > ( ) ;
759- foreach ( BaseInstanceState node in nodes )
760- {
761- IList < BaseInstanceState > children = new List < BaseInstanceState > ( ) ;
762- node . GetChildren ( context , children ) ;
763-
764- childNodes . AddRange ( children ) ;
765- results . AddRange ( children ) ;
766- }
767- nodes = childNodes ;
768- }
769-
770- return results ;
771- }
772-
773715 /// <summary>
774716 /// Called after a node has been deleted.
775717 /// </summary>
@@ -5104,6 +5046,62 @@ protected void ReportAuditDeleteNodesEvent(ISystemContext systemContext, DeleteN
51045046 Utils . LogError ( ex , "Error while reporting AuditDeleteNodesEvent event." ) ;
51055047 }
51065048 }
5049+
5050+ /// <summary>
5051+ /// Reports the AuditUpdateMethodEventType
5052+ /// </summary>
5053+ /// <param name="systemContext">Server information.</param>
5054+ /// <param name="objectId">The id of the object where the method is executed.</param>
5055+ /// <param name="methodId">The NodeId of the object that the method resides in.</param>
5056+ /// <param name="inputArgs">The InputArguments of the method </param>
5057+ /// <param name="customMessage">Custom message for delete nodes.</param>
5058+ /// <param name="statusCode">The resulting status code.</param>
5059+ protected void ReportAuditUpdateMethodEvent ( ISystemContext systemContext ,
5060+ NodeId objectId ,
5061+ NodeId methodId ,
5062+ object [ ] inputArgs ,
5063+ string customMessage ,
5064+ StatusCode statusCode )
5065+ {
5066+ if ( Server ? . EventManager ? . ServerAuditing != true )
5067+ {
5068+ // current server does not support auditing
5069+ return ;
5070+ }
5071+ try
5072+ {
5073+ AuditUpdateMethodEventState e = new AuditUpdateMethodEventState ( null ) ;
5074+
5075+ TranslationInfo message = new TranslationInfo (
5076+ "AuditUpdateMethodEventState" ,
5077+ "en-US" ,
5078+ $ "'{ customMessage } ' returns StatusCode: { statusCode . ToString ( null , CultureInfo . InvariantCulture ) } .") ;
5079+
5080+ e . Initialize (
5081+ systemContext ,
5082+ null ,
5083+ EventSeverity . Min ,
5084+ new LocalizedText ( message ) ,
5085+ StatusCode . IsGood ( statusCode ) ,
5086+ DateTime . UtcNow ) ; // initializes Status, ActionTimeStamp, ServerId, ClientAuditEntryId, ClientUserId
5087+
5088+ e . SetChildValue ( systemContext , BrowseNames . SourceNode , objectId , false ) ;
5089+ e . SetChildValue ( systemContext , BrowseNames . SourceName , "Attribute/Call" , false ) ;
5090+ e . SetChildValue ( systemContext , BrowseNames . LocalTime , Utils . GetTimeZoneInfo ( ) , false ) ;
5091+
5092+ e . SetChildValue ( systemContext , BrowseNames . ClientUserId , systemContext ? . UserIdentity ? . DisplayName , false ) ;
5093+ e . SetChildValue ( systemContext , BrowseNames . ClientAuditEntryId , systemContext ? . AuditEntryId , false ) ;
5094+
5095+ e . SetChildValue ( systemContext , BrowseNames . MethodId , methodId , false ) ;
5096+ e . SetChildValue ( systemContext , BrowseNames . InputArguments , inputArgs , false ) ;
5097+
5098+ Server . ReportEvent ( systemContext , e ) ;
5099+ }
5100+ catch ( Exception ex )
5101+ {
5102+ Utils . LogError ( ex , "Error while reporting AuditDeleteNodesEvent event." ) ;
5103+ }
5104+ }
51075105 #endregion Report Audit Events
51085106
51095107 #region ComponentCache Functions
0 commit comments