This repository has been archived by the owner on Aug 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Examples
David Price edited this page May 7, 2016
·
13 revisions
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");
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();
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();
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();