public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
{
// The following line is used only once to get the event receiver debugging URL.
// string debugEndpoint = System.ServiceModel.OperationContext.Current.Channel.LocalAddress.Uri.ToString();
SPRemoteEventResult result = new SPRemoteEventResult();
string tenantName = properties.AppEventProperties.HostWebFullUrl.ToString();
if (!tenantName.EndsWith("/"))
{
tenantName += "/";
}
switch (properties.EventType)
{
case SPRemoteEventType.AppInstalled:
try
{
CreateTenant(tenantName);
}
catch (Exception e)
{
// Tell SharePoint to cancel and roll back the event.
result.ErrorMessage = e.Message;
result.Status = SPRemoteEventServiceStatus.CancelWithError;
}
break;
case SPRemoteEventType.AppUpgraded:
// This sample does not implement an add-in upgrade handler.
break;
case SPRemoteEventType.AppUninstalling:
try
{
DeleteTenant(tenantName);
}
catch (Exception e)
{
// Tell SharePoint to cancel and roll back the event.
result.ErrorMessage = e.Message;
result.Status = SPRemoteEventServiceStatus.CancelWithError;
}
break;
}
return result;
}