I'd like to write a SQL script that cleans up all of our data and then any related K2 process instances. Up until know, I've been running the SQL script to clear our data, then going to the workspace to delete process instances (this is for cleaning up development, nothing production-quality). I'd like to make this a one step process by doing the process instance deletes in SQL - is there a stored proc somewhere in the K2 server to do delete by process instance Id? Even if it is not recommended to use the stored proc, I don't mind as it is only for development.
The following might help:
Hi, i hope below function would help you, since cleaning process instance is available via APIs why you need stored proc.
-------------------------------------------------------------------------------------------------------------------------------------------
public bool
ClearProcessesInstances()
{
bool deleted = false
;
try
{
ConnectMng();
SourceCode.Workflow.Management.
ProcessInstances items = workflowServer.GetProcessInstancesAll("", "", ""
);
// ManagedWorkListItem managedItem = null;
foreach (SourceCode.Workflow.Management.ProcessInstance item in
items)
{
deleted = workflowServer.DeleteProcessInstances(item.ID,
true
);
}
}
catch (WFManagedClientContractException
ex)
{
throw
ex;
}
catch (Exception
ex)
{
//...ToDo.
throw new WFEngineException(ErrorCode
.ErrorImportingManagedList, ex);
}
finally
{
// close the connection
CloseMng();
//workflowServer.Connection.Close();
}
return
deleted;
}
Close, though these queries specifically exclude 'Active' process instances. Just need to figure out how to clear them even if they are active (simply removing the where status <> '3' doesn't do the trick). Thanks for pointing me in a direction
Sadly, I'd really like to do it in a SQL script so I can clear all of our data and K2 data in one step.
Thanks for the help, everyone! I posted my ultimate solution in my blog: http://blogs.claritycon.com/blogs/tim_byrne/archive/2010/01/27/stumbling-through-clearing-test-k2-data.aspx
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.