The following C# code example searches for the create policy
event. (See Searching for Events.)
/**
* Ensure that you create a .NET project that uses
* MS Visual Studio 2008 and version 3.5 of the .NET
* framework. This is required to invoke a
* LiveCycle service using MTOM.
*
* For information, see "Invoking LiveCycle using MTOM" in Programming with LiveCycle
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.IO;
using SearchEvents.ServiceReference1;
namespace SearchEvents
{
class Program
{
static void Main(string[] args)
{
try
{
//Create a RightsManagementServiceClient object
RightsManagementServiceClient rmClient = new RightsManagementServiceClient();
rmClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/RightsManagementService?blob=mtom");
//Enable BASIC HTTP authentication
BasicHttpBinding b = (BasicHttpBinding)rmClient.Endpoint.Binding;
b.MessageEncoding = WSMessageEncoding.Mtom;
rmClient.ClientCredentials.UserName.UserName = "administrator";
rmClient.ClientCredentials.UserName.Password = "password";
b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
//Create an EventSpec object
EventSpec eventSpec = new EventSpec();
//Specify the POLICY_CREATE_EVENT
eventSpec.eventCode = "3003";
eventSpec.firstTime = new DATE();
eventSpec.firstTime.calendar = new DateTime(2007, 4, 1, 5, 5, 5);
eventSpec.lastTime = new DATE();
eventSpec.lastTime.calendar = new DateTime(2009, 7, 30, 5, 5, 5);
//Search for the POLICY_CREATE_EVENT
MyArrayOf_xsd_anyType result = rmClient.searchForEvents(eventSpec, 100);
if (result != null)
{
//Determine how many elements are in MyArrayOf_xsd_anyType
int index = result.Count;
for (int i = 0; i < index; i++)
{
AuditSpec spec = (AuditSpec)result[i];
Console.WriteLine("Policy Created on " + spec.timestamp.date);
}
}
}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}
}
}
}
|
|
|