Kashif Nizam Qureshi

Adding Resource Calendar Exceptions Programmatically

Leave a comment

ResourceDataSet rds = _resourceClient.ReadResource(new Guid(resGuid));

// be sure that the resource is checked out !

if (rds.CalendarExceptions != null)
{
for (int i = 0; i < rds.CalendarExceptions.Rows.Count; i++)
{
// check row data...

// delete row if necessary
rds.CalendarExceptions.Rows[i].Delete();
break;
}
// don´t use GetChanges() method on the dataset !
_resourceClient.UpdateResources(resourceDataSet, false, false);
}

// Read resource data again
rds = _resourceClient.ReadResource(new Guid(resGuid));

// create new datarow
ResourceDataSet.CalendarExceptionsRow exceptionsRow = rds.CalendarExceptions.NewCalendarExceptionsRow();

// set necessary data for the new exception row here
//exceptionsRow.Start
//exceptionsRow.Finish
//exceptionsRow.Name
//exceptionsRow.RES_UID
//...

// update the resource again
_resourceClient.UpdateResources(resourceDataSet, false, false);

...
// don´t forget to check in the resource

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s