Getting to Audit Data in BlackPearl

  • 30 April 2008
  • 2 replies
  • 2 views

Badge

In 2003, it was recommended we use the FilterService web service to access Audited field data.


How is this done in BlackPearl?


2 replies

Badge +10
you should just be able to get this from building a report in Workspace, or just building any RDL type report.
Badge +9

Randy,


You mentioned the K2 2003 FilterService.  You are correct that this was recommended for retrieving any reporting data in K2 2003.  By retrieving I mean programmatically.  As such if you need to programmatically retrieve this type of data in blackpearl you have a new option: the out of box reporting SmartObjects (which is what the out-of-box reports use).


The most common auditing smartobject is 'Process Data Audit'.  Below is a code sample that shows how you can call this SmartObject with a specific Process Instance ID to get all audited process data fields for a given process instance.


HTH.


    private void GetProcessInstDataAudit(int nProcInstID)
    {
        string _SmartObjectName = "Process_Data_Audit";


        string _serverName = "localhost";
        string _domain = "k2demo";
        string _user = "administrator";
        string _password = "k2pass";


        SourceCode.SmartObjects.Client.SmartObjectClientServer serverName = new SourceCode.SmartObjects.Client.SmartObjectClientServer();


        SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();


        // build a connection string
        connectionString.Authenticate = true;
        connectionString.Host = _serverName;
        connectionString.Integrated = true;
        connectionString.IsPrimaryLogin = true;
        connectionString.Port = 5555;
        connectionString.UserID = _user;
        connectionString.WindowsDomain = _domain;
        connectionString.Password = _password;
        connectionString.SecurityLabelName = "K2"; //the default label


        // open a K2 Server connection
        serverName.CreateConnection();
        serverName.Connection.Open(connectionString.ToString());


        try
        {
            // get a handle to the 'Employee' SmartObject
            SourceCode.SmartObjects.Client.SmartObject smartObject = serverName.GetSmartObject(_SmartObjectName);


            // specify which method will be called
            smartObject.MethodToExecute = "List";


            // specify input parameters for the method
            smartObject.Properties["ProcInstID"].Value = nProcInstID.ToString();


            // call the method
            SourceCode.SmartObjects.Client.SmartObjectList oList = serverName.ExecuteList(smartObject);


            if (oList.SmartObjectsList.Count > 0)
            {
                foreach (SourceCode.SmartObjects.Client.SmartObject oSmO in oList.SmartObjectsList)
                {
                    string strProcName = oSmO.Properties["Process_Name"].Value;
                    string strFieldName = oSmO.Properties["Data_Name"].Value;
                    string strUser = oSmO.Properties["Destination"].Value;
                    string strValue = oSmO.Properties["Current_Value"].Value;
                    string strDateChanged = oSmO.Properties["Date_Changed"].Value;


                    // do something with this data
                }
            }
        }
        catch (Exception ex)
        {
        }


        finally
        {
            // close the connection
            serverName.Connection.Close();
        }
    }

Reply