Cisco Cisco TelePresence Management Suite (TMS) Version 15 Developer's Guide

Page of 81
Error handling examples
The following code examples demonstrate how to handle errors generated from API calls.
Conference in the past
Running this code will output the message: "You cannot book a conference in the past".
public
 
void
 ErrorHandling_BookInThePast()
 
{
 
    InitBookingService();
 
    
var
 conference = bookingService.GetDefaultConference();
 
    
var
 start = DateTime.Now.AddHours(-10);
 
    
var
 end = start.AddMinutes(10);
 
 
    conference.StartTimeUTC = start.ToString(
"u"
);
 
    conference.EndTimeUTC = end.ToString(
"u"
);
 
 
    
try
 
    {
 
        conference = bookingService.SaveConference(conference);
 
    }
 
    
catch
 (SoapException e)
 
    {
 
        Console.WriteLine(
"Got error with error code {0}, and message {1}, from Booking API"
e.Detail.InnerXml, e.Message);
 
    }
 
    
 
    PrintConferenceInformation(conference);
 
}
System unavailable
Running the code below will output a "system unavailable" message.
public
 
void
 ErrorHandling_SystemNotAvailable()
 
{
 
    InitBookingService();
 
    
var
 conference = bookingService.GetDefaultConference();
 
    
var
 start = DateTime.Now.AddHours(1);
 
    
var
 end = start.AddMinutes(10);
 
 
    conference.StartTimeUTC = start.ToString(
"u"
);
 
    conference.EndTimeUTC = end.ToString(
"u"
);
 
 
    
var
 participant = 
new
 Participant {ParticipantCallType = ParticipantType.TMS, ParticipantId = 4};
 
 
    conference.Participants = 
new
 []
 
        {
 
            participant
 
        };
 
    bookingService.SaveConference(conference);
 
 
    
try
            
 
    {
 
        
// By setting the Id to -1, we try to book a new conference, with the same time and participant
 
        conference.ConferenceId = -1;
 
        conference = bookingService.SaveConference(conference);
Cisco TelePresence Management Suite Extension Booking API Programming Reference Guide (14.6)     
Page 79 of 81
Code examples
Error handling examples