cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Axeda Code Snippet: Getting Audit Records

No ratings

The following code snippet will retrieve a months worth of data from the system and return it as a CSV document suitable for import into your spreadsheet or reporting tool of choice.

import static com.axeda.sdk.v2.dsl.Bridges.*

import com.axeda.drm.sdk.Context

import com.axeda.common.sdk.id.Identifier

import com.axeda.services.v2.*

import com.axeda.sdk.v2.exception.*

def ac = new AuditCriteria()

ac.fromDate = Date.parse('yyyy-MM-dd', '2017-03-01')

ac.toDate   = Date.parse('yyyy-MM-dd', '2017-03-31')

def retString = ''

tcount = 0

while ( (results = auditBridge.find(ac)) != null  && tcount < results .totalCount) {

  results.audits.each { res ->

    retString += "${res?.user?.id},${res?.asset?.serialNumber},${res?.category},${res.message},${res.date}\n"

    tcount++

  }

  ac.pageNumber = ac.pageNumber + 1

}

return retString

Comments

I would suggest to move tcount++ to the first statement in audits each loop.

This would help when we define a logic to build retString as shown below.

results.audits.each { res ->

  tcount++

  // you can skip some records

  if(!satisfyingMyCondition)

    return

  retString += "${res?.user?.id},${res?.asset?.serialNumber},${res?.category},${res.message},${res.date}\n"

}

Regards

Arunkumar D

http://www.arundhaj.com/

How do I specify categories in AuditCriteria? I want to only query FILE_UPLOAD and SYSTEM_CONFIGURATION e.g.

def ac = new AuditCriteria()

ac.fromDate = Date.parse('yyyy-MM-dd', '2018-07-01')
ac.toDate = Date.parse('yyyy-MM-dd', '2018-07-05')
ac.categories = AuditCategory.SYSTEM_CONFIGURATION - ??

The following I would expect to work:

ac.categories = [  AuditCategory.FILE_UPLOAD, AuditCategory.SYSTEM_CONFIGURATION ]

Version history
Last update:
‎Mar 22, 2017 03:34 PM
Updated by:
Labels (2)