/// <summary> /// Redirect worklist item to specific user by serial number /// </summary> /// <param name="serialNumber">The worklist item's serial number</param> /// <param name="destination">The destination user</param> public void Redirect(string serialNumber, string destination) { try { using (Connection workflowClient = this.GetWorkflowClient()) { K2.WorklistItem worklistItem = workflowClient.OpenWorklistItem(serialNumber, null, false); if (worklistItem == null) { throw new System.InvalidOperationException(string.Format("Not Found", serialNumber)); } worklistItem.Redirect(destination); } } catch (UnauthorizedAccessException ex) { throw ex; } }
/// <summary> /// 任务移交 /// </summary> /// <param name="sn">任务SN</param> /// <param name="sourceUser">源用户</param> /// <param name="targetUser">目标用户</param> public static void RedirectWorkListItem(string sn, string sourceUser, string targetUser) { using (Connection conn = new Connection()) { try { ConnectionSetup conSetup = GetConnectionSetup(); conn.Open(conSetup); conn.ImpersonateUser(sourceUser); SourceCode.Workflow.Client.WorklistItem listItem = conn.OpenWorklistItem(sn); listItem.Redirect(targetUser); } catch (Exception ex) { // TODO: throw? throw ex; } finally { try { conn.RevertUser(); } catch { throw; } if (conn != null) { conn.Close(); } } } }
public static void Redirect(string sn, string targetUser) { SourceCode.Workflow.Client.Connection con = new Connection(); try { ConnectionSetup conSetup = GetConnectionSetup(); con.Open(conSetup); con.ImpersonateUser(_CurrentUser); SourceCode.Workflow.Client.WorklistItem listItem = con.OpenWorklistItem(sn); listItem.Release(); listItem.Redirect(targetUser); DBManager.AddWorkListLog(_CurrentUser, targetUser, listItem.SerialNumber, listItem.ProcessInstance.ID, listItem.ActivityInstanceDestination.ID, "Redirect", _CurrentUser); } catch (Exception ex) { // TODO: throw? throw ex; } finally { try { con.RevertUser(); } catch { throw; } if (con != null) { con.Close(); } } }