Quick Start (Base64): Locking a resource using the web service API

The following C# code example locks /Applications/FormsApplication/1.0/FormsFolder/Loan.xdp. (See Locking Resources.)

/* 
    * Ensure that you create a .NET client assembly that uses  
    * base64 encoding. This is required to populate a BLOB  
    * object with data or retrieve data from a BLOB object. 
    *  
    * For information, see "Invoking LiveCycle using Base64 Encoding"  
    * in Programming with LiveCycle 
    */ 
using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Data; 
using System.IO; 
 
namespace RepositoryWebService 
{ 
       class LockFile 
       { 
           [STAThread] 
           static void Main(string[] args) 
           { 
               // This example will lock and unlock a resource to the LiveCycle repository. 
               try 
               { 
                   //Create a RepositoryServiceService object 
                   RepositoryServiceService repositoryClient = new RepositoryServiceService(); 
                   repositoryClient.Credentials = new System.Net.NetworkCredential("administrator", "password"); 
 
                   // Specify the URI of the resource to lock 
                   String resourceUri = "/Applications/FormsApplication/1.0/FormsFolder/Loan.xdp"; 
 
                   // Lock the resource 
                   repositoryClient.lockResource( 
                       resourceUri, 
                       11, 
                       2, 
                       1000, 
                       null); 
 
                   // Retrieve the locks on the resource 
                   object[] locks = repositoryClient.getLocks(resourceUri, null); 
 
                   // Print out the locks for the resource 
                   Console.WriteLine("The following locks now exist for the resource:"); 
                   for (int i = 0; i < locks.Length; i++) 
                   { 
                       Lock l = (Lock)(locks[i]); 
                       Console.WriteLine( 
                           "Lock owner: " + 
                           l.ownerUserId + 
                           "  Lock depth: " + 
                           l.depth + 
                           " Lock scope: " + 
                           l.type 
                       ); 
                   } 
 
                   // Unlock the resource 
                   repositoryClient.unlockResource(resourceUri, null); 
 
               } 
               catch (Exception e) 
               { 
                   Console.WriteLine( 
                       "Exception thrown while trying to lock the resource" + 
                       e.Message 
                   ); 
               } 
 
           } 
       } 
} 
 

// Ethnio survey code removed