Skip to content
armontoya edited this page Jan 17, 2012 · 1 revision

Currently, there are two main ways to pull down data from the Learning Registry, from the obtain and harvest services. Obtain offers direct access to documents with limited options, while harvest serves documents with additional metadata, and has more options for retrieving data sets. We provide usage examples for both here.

Using Obtain

var client = new LRClient("http://localhost");

// Getting a document directly if you already know the doc_ID
lr_document doc = client.ObtainByDocId("<some existing doc_ID>");

// Using an ObtainResult (a static representation of the JSON response received
// from the server).
var result = client.ObtainByResourceLocator("http://exampleuri.com");

// Get the documents directly
List<lr_document> docs = result.GetDocuments();

// Get the documents via the underlying raw JSON structure
string docId = result.documents[0].doc_ID;
doc = result.documents[0].document;

// Retrieve the next page of documents to be served.
// This is the native paging behavior from the LR.
if(result.HasMoreRecords)
   result = result.GetNextPage() as ObtainResult;

Using Harvest

var client = new LRClient("http://localhost");
Harvester harvester = client.Harvester;

// Get a record directly if the doc_id is already known
HarvestRecord rec = harvester.GetRecordByDocId("<some existing doc_ID>");

// List the doc_IDs from 1-1-2012 onwards
ListIdentifiersHarvestResult idResult = harvester.ListIdentifiersFrom(new DateTime(2012, 1, 1));

// Get the list directly (using underlying public fields from JSON document not recommended)
List<string> ids = idResult.GetList();

// Get a result containing list of records before December 31st, 1999
ListRecordsHarvestResult recResult = harvester.ListRecordsUntil(new DateTime(1999,12,31));

// Get the list of records directly (using underlying public fields again not recommended)
List<HarvestRecord> records = recResult.GetRecords();

// Fetch another page of results
if(recResult.HasMoreRecords)
   recResult = recResult.GetNextPage() as ListRecordsHarvestResult;
Clone this wiki locally