Programmer's Guide:
Getting Started: Hello, eRoom

The Overview topic discussed the concepts behind the eRoom Server Access API. This topic gets you started writing code.

This section describes how to write a simple Server Access API program that runs on the eRoom server. It opens an existing eRoom and creates a Note Page object called "Hello, eRoom" in the Room. This section introduces some of the basic concepts of SAAPI programming and gives you a feel for what SAAPI programs look like.

You must perform the following steps to write this program:

  • Create an Application object. This is a high-level object used to access the rest of the eRoom objects.

  • Get a Facility object from the Server Manager object. A Facility is a container of, and a center of administration for, a collection of Rooms.

  • Get a Room object from the Facility object.

  • Get the Home Page for the Room from the Room object.

  • Create a new Note Page object as a child of the Home Page.

Note: For simplicity, the following sample does not include error checking and error handling code.

The following code snippet is written in Visual Basic:

Dim App as ERUApplication
Dim Facility as IERUFacility
Dim Room as IERURoom
Dim HomePage as IERUContainer
Dim NewNotePage as IERUItem
Dim uc as ERUUserContext

Set App = CreateObject("eRoom.Application")

Set uc = App.LoginUser("MyLoginName")
Set Facility = App.GetFacilityByName("MyFacility")
Set Room = Facility.GetRoomByName("MyRoom")
Set HomePage = Room.HomePage
Set NewNotePage = HomePage.CreateNotePage("Hello, eRoom", "", erFormatPlainText, erCreateOptNone)

The next code snippet shows how to accomplish this task in C++ (using the ActiveX Template Library for convenience):

if (SUCEEDED(CoInitialize(NULL))
{
CComPtr<IERApplication> pApp;
CComPtr<IERUFacility> pFacility;
CComPtr<IERURoom> pRoom;
CComQIPtr<IERUContainer, &IID_IERUContainer> pHomePage;
CComPtr<IERUItem> pNewNotePage;

CoCreateInstance(CLSID_ERUApplication, NULL, CLSCTX_INPROC_SERVER, IID_IERUApplication, (void**)&pApp);

pApp->GetFacilityByName(
  CComBSTR(L"MyFacility"),
  &pFacility);

pFacility->GetRoomByName("MyRoom", &pRoom);

pRoom->get_HomePage(&pHomePage);

pHomePage->CreateNotePage(
  CComBSTR(L"Hello, eRoom"),
  CComBSTR(L""),
  erFormatPlainText,
  erCreateOptNone,
  &pNewNotePage);
}

CoUninitialize();