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:
http://www.k2underground.com/blogs/johnny/archive/2008/04/15/deleting-obsolete-process-instances-from-a-k2-net-2003-or-k2-blackpearl-database.aspx
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,
deleted = workflowServer.DeleteProcessInstances(item.ID,
true
); } }
}
catch (WFManagedClientContractException
ex) {
throw
ex; }
catch (Exception
//...ToDo.
throw new WFEngineException(ErrorCode
.ErrorImportingManagedList, ex); }
finally
// close the connection
CloseMng();
//workflowServer.Connection.Close();
return
deleted;
Regards, Abeer Naffa'
The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
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