public StringBuilder Execute(Dictionary<string, StringBuilder> values, IWorkspace theWorkspace)
{
string resourceIdString = null;
StringBuilder tmp;
values.TryGetValue("ResourceID", out tmp);
if (tmp != null)
{
resourceIdString = tmp.ToString();
}
if(resourceIdString == null)
{
throw new InvalidDataContractException("ResourceID is missing");
}
var res = new ExecuteMessage { HasError = false };
Guid resourceId;
var hasResourceId = Guid.TryParse(resourceIdString, out resourceId);
if(!hasResourceId)
{
res.SetMessage(Resources.CompilerError_TerminationFailed);
res.HasError = true;
}
var service = ExecutableServiceRepository.Instance.Get(theWorkspace.ID, resourceId);
if(service == null)
{
res.SetMessage(Resources.CompilerError_TerminationFailed);
res.HasError = true;
}
if(service != null)
{
service.Terminate();
res.SetMessage(Resources.CompilerMessage_TerminationSuccess);
}
Dev2JsonSerializer serializer = new Dev2JsonSerializer();
return serializer.SerializeToBuilder(res);
}