Skip to content
This repository has been archived by the owner on Aug 11, 2019. It is now read-only.

Examples

David Price edited this page May 7, 2016 · 13 revisions

Initializing Connection

Creating a new connection to the WebAPI required a number of pieces to configure the initial connection.

  • AuthType - Which form of authentication is being used (ex. Basic, Kerberos)
  • Hostname - Provide the name or IP of the machine that hosts the WebAPI
  • Username - Required for basic authentication
  • Password - Required for basic authentication

WebAPIConnection conn = new WebAPIConnection(AuthType.Basic, "MyHost", "Username", "Password");

Basic Interactions

After creating a connection we will need to find the AFServer that will be used. Each AFServer will have a list of Databases associated with it. We can request the database that we want to work with and begin requesting the AFObjects that we expect to work with.

AFServer server = AFServer.Find(conn, "AFServerName");
AFDatabase AFDB = server.Databases["AFDatabaseName"];
AFElement ele = AFDB.Elements["ElementName"];
AFAttribute attr = ele.Attributes["Name"];
AFValue val = attr.GetValue();

Elements

Create Element

Create Element at AFDatabase level

 AFElement newEle = new AFElement();
 newEle.Name = "My new element";
 newEle.Description = "Creating new element";
 AFDB.Elements.Add(newEle);
 AFDB.CheckIn();

Create element as child of existing element

 AFElement childEle = new AFElement();
 childEle.Name = "Child";
 childEle.Description = "A child element";
 newEle.Elements.Add(childEle);
 newEle.CheckIn();

Change Element

 childEle.Name = "New Element Name";
 childEle.CheckIn();

Delete Element

 childEle.Delete();

EventFrames

Create EventFrame

AFEventFrame frame = new AFEventFrame();
frame.Name = "My EventFrame";
frame.Description = "Example Frame";
frame.StartTime = DateTime.UtcNow; //Times will be handled as UTC to prevent any additional abstraction
AFDB.CreateEventFrame(frame);

Update EventFrame

frame.Name = "Renamed EventFrame";
frame.EndTime = DateTime.UtcNow;
frame.CheckIn();

Delete EventFrame

frame.Delete();
frame.CheckIn();
Clone this wiki locally