To demonstrate storing and retrieving documents from content management for .Net we’ll first look at the high level code to actually create and retrieve the file. Then we’ll examine how to make a new class particular to the RIM Training record type. I need to caveat everything first by pointing out that there are some assumption upfront regarding access to CM, the process for determining record attributes, and the use of NU.Configuration for encrypting accounts that will not be covered. See the Setup / Preconditions for more information.
Creating Records Content Management
Using the API the process of creating a record is straight forward and to demonstrate this we’ll use the ‘RIM Training’ record type. First an instance of the RIMTrainingRecord is created and then the custom attributes set. After the record information has been filled out .Create is called. This will return the new unique id of the record (RIMTrainingRecord.Id property). Here is an example.
RIMTrainingRecord target = new RIMTrainingRecord("Create RIMTrainingRecord Test", new File("c:\\temp\\myRecord.doc", null));
target.Keyword = "testing .Net api"; target.NUCompany = "NUSCO";
target.Date = DateTime.Now.ToString("yyyy-mm-dd");
// TODO: Change the app/web config entry to the correct creds
string id = target.Create("TestCM");
Note: A full example can be found in the NU.ContentManagement.RIMTraining.Test project. To verify that the record was created you can check the Test Content manager server*. In the example the new File (path, mimetype) ctor can take the record mime type. If this is left null it will attempt to set the information from the local registry.The record owner / creator (RIMTrainingRecord.Owner property) can be set as well. If left null, it defaults to the authorization of the account running the process. In a desktop application this is desirable. In a web scenario they should be specifically set to e.g. User.Identity.Name.The custom attributes for the RIM Training record as Keyword, NUCompany, and Date we will look at how those are defined later.*Requires Logon
Retrieving a Content Management Record File
To retrieve a content management record you will need the Id property. Existing records are created from one of the static factory methods as Bytes or saved to a file. Simply pass the record Id to the
Creating a Custom Content Management Record Class
Now that you understand how storing and retrieving of records works you’ll need to work with the Records Information Management team to determine the best attributes for your record type. If you’re lucky this will done by the business analystJ. After this has been determined you will use those attributes to create a class specific to your project. To better understand this we’ll look to the RIMTrainingRecord class again. Steps:Inherit from the content Management record class and define the XmlRootAttribute to the document type specified by the RIM Team.
Create a custom property for each attribute and set the XmlAttribute to the exact name defined by the RIM team.