/// <summary> /// Open a worklist item by serial number /// </summary> /// <param name="con">The worklist connection</param> /// <param name="serialNumber">The serial number</param> /// <param name="sharedUser">The shared user</param> /// <param name="managedUser">The manager user</param> /// <returns>The worklist item</returns> public K2.WorklistItem OpenWorklistItem(Connection con, string serialNumber, string sharedUser, string managedUser, bool alloc) { K2.WorklistItem worklistItem = null; if (sharedUser == string.Empty && managedUser == string.Empty) { worklistItem = con.OpenWorklistItem(serialNumber, "ASP", alloc); } if (sharedUser != string.Empty && managedUser == string.Empty) { worklistItem = con.OpenSharedWorklistItem(sharedUser, managedUser, serialNumber, "ASP", alloc); } if (sharedUser == string.Empty && managedUser != string.Empty) { worklistItem = con.OpenManagedWorklistItem(managedUser, serialNumber, "ASP", alloc); } if (sharedUser != string.Empty && managedUser != string.Empty) { worklistItem = con.OpenSharedWorklistItem(sharedUser, managedUser, serialNumber, "ASP", alloc); } if (worklistItem == null) { throw new InvalidOperationException(string.Format("Not Found", serialNumber)); } return(worklistItem); }
/// <summary> /// 审批流程实例 /// </summary> /// <param name="SN">流程编号</param> /// <param name="DicDataFields">流程参数</param> /// <param name="ManagedUser">流程审批者</param> /// <param name="SharedUser">流程共同审批者</param> /// <param name="ActionName">流程动作</param> /// <param name="Platform">流程审批页面平台</param> public static void ApprovalProcessInstance(string SN, Dictionary <string, object> DicDataFields, string ApprovalUserInfoString) { Connection Connection = GetK2Connection();//创建K2 链接 try { ApprovalUserInfo ApprovalUserInfo = ApprovalUserInfoString.ToObject <ApprovalUserInfo>(); ImpersonateUser(Connection, ApprovalUserInfo.ApprovalUserId); //获取流程工作项 SourceCode.Workflow.Client.WorklistItem wit = GetWorkListItemBySN(Connection, SN, ApprovalUserInfo.ManagedUser, ApprovalUserInfo.SharedUser, PLATFORM); BatchSetInstanceDataFields(wit, DicDataFields); //添加审批历史 AddProcessInstanceApprovalHistory(wit, ApprovalUserInfo); //设置审批动作 (节点审批成功(任务自动完成)) string ActionName = string.IsNullOrEmpty(ApprovalUserInfo.ActionName) ? ACTIONNAME : ApprovalUserInfo.ActionName; //执行审批动作 wit.Actions[ActionName].Execute(); } catch (Exception ex) { throw new K2Exception(ex.ToString()); } finally { // 关闭连接 if (Connection != null) { Connection.Close(); } } }
/// <summary> /// Delegate or shared worklist to the specific user /// </summary> /// <param name="serialNumber">The serial number</param> /// <param name="destination">The specific user</param> public void DelegateWorklistItem(string serialNumber, string destination) { try { using (Connection workflowClient = this.GetWorkflowClient()) { K2.WorklistItem worklistItem = workflowClient.OpenWorklistItem(serialNumber, null, false); if (worklistItem == null) { throw new InvalidOperationException(string.Format("Not Found", serialNumber)); } K2.Destination destination2 = new K2.Destination(); foreach (K2.Action action in worklistItem.Actions) { if (action != null) { destination2.AllowedActions.Add(action.Name); } } destination2.Name = destination; destination2.DestinationType = DestinationType.User; worklistItem.Delegate(destination2); } } catch (UnauthorizedAccessException ex) { throw ex; } catch (SmartException ex) { throw ex; } }
/// <summary> /// 获取流程实例审批历史(转JSON) /// </summary> /// <param name="SN"></param> /// <param name="ApprovalUserId"></param> /// <returns></returns> public static string GetProcessInstanceApprovalHistory(string SN, string ApprovalUserId) { Connection connection = GetK2Connection(); try { ImpersonateUser(connection, ApprovalUserId); SourceCode.Workflow.Client.WorklistItem worklistItem = connection.OpenWorklistItem(SN); string ApprovalResultXML = worklistItem.ProcessInstance.XmlFields["ApprovalResult"].Value; if (ApprovalResultXML != null) { XMLApproval xmlApproval = new XMLApproval(); xmlApproval.LoadFromXML(ApprovalResultXML); return(xmlApproval.mobj.ToJson()); } return(""); } catch (Exception ex) { throw new K2Exception(ex.ToString()); } finally { // 关闭连接 if (connection != null) { connection.Close(); } } }
public static void Sleep(string sn, int second) { 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.Sleep(true, second); } catch (Exception ex) { // TODO: throw? throw ex; } finally { try { con.RevertUser(); } catch { throw; } if (con != null) { con.Close(); } } }
/// <summary> /// 添加流程实例审批历史 /// </summary> public static void AddProcessInstanceApprovalHistory(SourceCode.Workflow.Client.WorklistItem worklistItem, ApprovalUserInfo ApprovalUserInfo) { //获取流程审批历史 string ApprovalResultXML = GetInstanceDataFields(worklistItem, "ApprovalResult", true); string LastApprovalResultXML = GetInstanceDataFields(worklistItem, "LastApprovalResult", true); ApprovalResultXML = XMLApproval.ToResultXML(ApprovalResultXML); LastApprovalResultXML = XMLApproval.ToResultXML(LastApprovalResultXML); XMLApproval xmlApproval = new XMLApproval(); //增加一个审批记录 xmlApproval.LoadFromXML(ApprovalResultXML); xmlApproval.AddApproval(ApprovalUserInfo.ApprovalUserName, ApprovalUserInfo.ApprovalUserId, ApprovalUserInfo.ComAuditText, ApprovalUserInfo.ComAuditComment, GetCurrentActivityName(worklistItem)); SetInstanceDataFields(worklistItem, "ApprovalResult", xmlApproval.ToXML(), true); //设置最后审批历史记录 xmlApproval.LoadFromXML(LastApprovalResultXML); xmlApproval.SetLastApproval(ApprovalUserInfo.ApprovalUserName, ApprovalUserInfo.ApprovalUserId, ApprovalUserInfo.ComAuditText, ApprovalUserInfo.ComAuditComment, GetCurrentActivityName(worklistItem)); SetInstanceDataFields(worklistItem, "LastApprovalResult", xmlApproval.ToXML(), true); //设置审批结果 SetInstanceDataFields(worklistItem, "ComAuditComment", ApprovalUserInfo.ComAuditComment, false); SetInstanceDataFields(worklistItem, "ComAuditResult", ApprovalUserInfo.ComAuditResult, false); }
/// <summary> /// 批量修改流程实例数据字段 /// </summary> public static void BatchSetInstanceDataFields(SourceCode.Workflow.Client.WorklistItem worklistItem, Dictionary <string, object> DicDataFields) { foreach (var dic in DicDataFields) { worklistItem.ProcessInstance.DataFields[dic.Key].Value = dic.Value; } }
/// <summary> /// 根据SN 获取流程工作项 /// </summary> /// <param name="Connection">K2 链接</param> /// <param name="sn">SN 流程编号</param> /// <param name="ManagedUser">审批者</param> /// <param name="SharedUser">共同审批者</param> /// <param name="Platform">平台</param> /// <returns></returns> public static SourceCode.Workflow.Client.WorklistItem GetWorkListItemBySN(Connection Connection, string sn, string ManagedUser, string SharedUser, string Platform) { SourceCode.Workflow.Client.WorklistItem worklistItem = null; //正常的 if ((string.IsNullOrEmpty(SharedUser)) && (ManagedUser == string.Empty)) { worklistItem = Connection.OpenWorklistItem(sn, Platform); } if ((!string.IsNullOrEmpty(SharedUser)) && (ManagedUser == string.Empty)) { worklistItem = Connection.OpenSharedWorklistItem(SharedUser, ManagedUser, sn); } if ((string.IsNullOrEmpty(SharedUser)) && (ManagedUser != string.Empty)) { worklistItem = Connection.OpenManagedWorklistItem(ManagedUser, sn); } // 检查是否为委托的 if ((!string.IsNullOrEmpty(SharedUser)) && (ManagedUser != string.Empty)) { worklistItem = Connection.OpenSharedWorklistItem(SharedUser, ManagedUser, sn); } return(worklistItem); }
/// <summary> /// Sleep worklist item by Serial Number /// </summary> /// <param name="serialNumber">The Serial Number of worklist item</param> /// <param name="hours">The durations in Hours</param> public void SleepWorklistItem(string serialNumber, int hours, string sharedUser, string managedUser) { try { using (Connection workflowClient = this.GetWorkflowClient()) { K2.WorklistItem worklistItem = workflowClient.OpenWorklistItem(serialNumber, "ASP", false, false, managedUser, sharedUser); if (worklistItem == null) { throw new InvalidOperationException(string.Format("Not Found", serialNumber)); } var duration = GetCalulateSeconds(hours); if (duration <= 0) { worklistItem.Sleep(false); } else { worklistItem.Sleep(true, duration); } } } catch (SmartException ex) { throw ex; } }
/// <summary> /// Execute a worklist item's action by serial number /// </summary> /// <param name="serial">The serial number</param> /// <param name="actionName">The worklist item's action name</param> /// <param name="commonKey">The Common key data field</param> /// <param name="comment">The worklist item's comment</param> public void ExecuteWorklistItem(string serial, string actionName, IDictionary <string, object> dataFields) { if (dataFields == null) { dataFields = new Dictionary <string, object>(); } using (Connection conn = GetWorkflowClient()) { string sharedUser = GetSharedUsersBySerialNumber(serial); string managedUser = GetFQN(); SourceCode.Workflow.Client.WorklistItem item = conn.OpenWorklistItem(serial, "ASP", false, false, managedUser, sharedUser); if (item == null || item.Actions[actionName] == null) { return; } string commentKey = string.Empty, comment = string.Empty; foreach (string key in _comments) { comment = dataFields.SingleOrDefault(p => p.Key == key).Value?.ToString(); dataFields.Remove(key); if (!string.IsNullOrEmpty(comment)) { break; } } ; if (!string.IsNullOrEmpty(comment)) { foreach (K2.DataField dataField in item.ProcessInstance.DataFields) { commentKey = _comments.SingleOrDefault(p => p == dataField.Name); if (!string.IsNullOrEmpty(commentKey)) { item.ProcessInstance.DataFields[commentKey].Value = comment; break; } } } if (dataFields != null && dataFields.Count > 0) { List <string> keys = dataFields.Keys.ToList(); keys.ForEach((key) => { item.ProcessInstance.DataFields[key].Value = dataFields[key]; }); } item.Actions[actionName].Execute(); } }
/// <summary> /// To execute Worklist Item action by serial number and action name /// </summary> /// <param name="sn">The worklist item serial number</param> /// <param name="actionName">The Action name</param> public void ExecuteWorklistItem(string sn, string actionName, string sharedUser, string managedUser) { using (Connection conn = GetWorkflowClient()) { K2.WorklistItem item = conn.OpenWorklistItem(sn, "ASP", false, false, managedUser, sharedUser); if (item == null || item.Actions[actionName] == null) { return; } item.Actions[actionName].Execute(); } }
//修改流程实例数据字段 public static void SetInstanceDataFields(SourceCode.Workflow.Client.WorklistItem worklistItem, string fieldName, string fieldValue, bool isXMLField) { if (worklistItem != null) { if (isXMLField) { worklistItem.ProcessInstance.XmlFields[fieldName].Value = fieldValue; } else { worklistItem.ProcessInstance.DataFields[fieldName].Value = fieldValue; } } }
public static WorklistItem FromApi(K2API.WorklistItem wli) { return(new WorklistItem { AllocatedUser = wli.AllocatedUser, Data = wli.Data, ID = (long)wli.ID, SerialNumber = wli.SerialNumber, Status = (WorklistStatus)wli.Status, Actions = ActionCollection.FromApi(wli.Actions), ActivityInstanceDestination = ActivityInstanceDestination.FromApi(wli.ActivityInstanceDestination), EventInstance = EventInstance.FromApi(wli.EventInstance), ProcessInstance = ProcessInstance.FromApi(wli.ProcessInstance) }); }
public void ToApi(SourceCode.Workflow.Client.WorklistItem wli) { if (this.ActivityInstanceDestination != null) { this.ActivityInstanceDestination.ToApi(wli.ActivityInstanceDestination); } if (this.EventInstance != null) { this.EventInstance.ToApi(wli.EventInstance); } if (this.ProcessInstance != null) { this.ProcessInstance.ToApi(wli.ProcessInstance); } }
/// <summary> /// Share worlist item to some users by serial number /// </summary> /// <param name="serialNumber">The worklist item's serial number</param> /// <param name="destination">The destination users</param> public void Share(string serialNumber, string destination) { try { using (Connection workflowClient = this.GetWorkflowClient()) { K2.WorklistItem worklistItem = workflowClient.OpenWorklistItem(serialNumber, null, false); if (worklistItem == null) { throw new InvalidOperationException(string.Format("Not Found", serialNumber)); } worklistItem.Delegate(new K2.Destination(destination)); } } catch (UnauthorizedAccessException ex) { throw ex; } }
/// <summary> /// 审批流程 /// </summary> /// <param name="sn">流程SN,必选</param> /// <param name="action">流程操作,为空则默认执行第0个操作</param> /// <param name="folio">流程编码,可选</param> /// <param name="dataFields">流程变量,必选</param> public static void ExecuteProcess(string sn, string action, string folio, string currentUser, CDataFields dataFields) { using (Connection conn = new Connection()) { try { ConnectionSetup conSetup = GetConnectionSetup(); conn.Open(conSetup); conn.RevertUser(); conn.ImpersonateUser(currentUser); SourceCode.Workflow.Client.WorklistItem listItem = conn.OpenWorklistItem(sn); SetDataFields(listItem, dataFields); if (!string.IsNullOrEmpty(folio)) { listItem.ProcessInstance.Folio = folio; } if (!string.IsNullOrEmpty(action)) { listItem.Actions[action].Execute(); } else { listItem.Actions[0].Execute(); } } catch { // TODO: throw? throw; } finally { try { conn.RevertUser(); } catch { } if (conn != null) { conn.Close(); } } } }
private Domain.K2.WorklistItem ConvertTaskObject(K2.WorklistItem wli) { var actions = new List <string>(); for (int i = 0; i < wli.Actions.Count; i++) { actions.Add(wli.Actions[i].Name); } return(new Domain.K2.WorklistItem() { ActInstDestName = wli.ActivityInstanceDestination.Name, Actions = actions, SerialNumber = wli.SerialNumber, AllocatedUser = wli.AllocatedUser }); }
public static void Delegate(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(); Destination dest = new Destination(); dest.DestinationType = DestinationType.User; for (int i = 0; i < listItem.Actions.Count; i++) { dest.AllowedActions.Add(listItem.Actions[i].Name); } dest.Name = targetUser; listItem.Delegate(dest); DBManager.AddWorkListLog(_CurrentUser, targetUser, listItem.SerialNumber, listItem.ProcessInstance.ID, listItem.ActivityInstanceDestination.ID, "Delegate", _CurrentUser); } catch (Exception ex) { // TODO: throw? throw ex; } finally { try { con.RevertUser(); } catch { throw; } if (con != null) { con.Close(); } } }
/// <summary> /// 获取流程实例数据字段 /// </summary> /// <param name="oK2Connection"></param> /// <param name="sn"></param> /// <param name="fieldName"></param> /// <param name="isXMLField"></param> /// <param name="managedUser"></param> /// <param name="sharedUser"></param> /// <returns></returns> public static string GetInstanceDataFields(SourceCode.Workflow.Client.WorklistItem worklistItem, string fieldName, bool isXMLField) { string retValue = ""; if (worklistItem != null) { if (isXMLField) { retValue = worklistItem.ProcessInstance.XmlFields[fieldName].Value.ToString(); } else { retValue = worklistItem.ProcessInstance.DataFields[fieldName].Value.ToString(); } } return(retValue); }
/// <summary> /// Call and execute worklist item's action /// </summary> /// <param name="serialNumber">The worklist item's serial number</param> /// <param name="action">The worklist item's action name</param> /// <param name="synchronous">The execution by synchronus or asynchronous</param> /// <param name="allowNonBatch">The allow non batch</param> /// <param name="item">The worklist item</param> /// <param name="sharedUser">The shared users</param> /// <param name="managedUser">The manager user</param> private void ExecuteAction(string serialNumber, string action, bool synchronous, bool allowNonBatch, Cores.WorklistItem item, string sharedUser, string managedUser) { string text = action.ToUpperInvariant(); if (text.StartsWith("A:") || text.StartsWith("ACTION:")) { action = RemovePrefix(action); } else { if (text.StartsWith("R:") || text.StartsWith("REDIRECT:")) { this.Redirect(serialNumber, RemovePrefix(action)); return; } if (text.StartsWith("D:") || text.StartsWith("DELEGATE:")) { this.DelegateWorklistItem(serialNumber, RemovePrefix(action)); return; } } using (Connection workflowClient = this.GetWorkflowClient()) { K2.WorklistItem worklistItem = this.OpenWorklistItem(workflowClient, serialNumber, sharedUser, managedUser); K2.Action newAction = worklistItem.Actions[action]; if (newAction == null) { throw new InvalidOperationException(string.Format("Not Found", action)); } if (!newAction.Batchable && !allowNonBatch) { throw new InvalidOperationException(string.Format("Not Batchable", action)); } if (item != null) { item.ToApi(worklistItem); } newAction.Execute(synchronous); } }
public static void Approve(string sn, string action, NameValueCollection dataFields) { 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(); if (dataFields != null) { for (int i = 0; i < dataFields.Count; i++) { string key = dataFields.GetKey(i).ToString(); string value = dataFields[key].ToString(); listItem.ProcessInstance.DataFields[key].Value = value; } } listItem.Actions[action].Execute(); } catch (Exception ex) { // TODO: throw? throw ex; } finally { try { con.RevertUser(); } catch { } if (con != null) { con.Close(); } } }
public List <string> GetSharedUsers(string sn) { List <string> destUsers = new List <string>(); K2.WorklistItem wItem = null; try { wItem = _client.GetWorklistItem(sn); if (wItem == null) { throw new System.InvalidOperationException(string.Format("Not Found", sn)); } var delegateUsers = wItem.DelegatedUsers; if (delegateUsers != null && delegateUsers.Count > 0) { foreach (K2.Destination dest in delegateUsers) { if (dest.Name.IsCaseInsensitiveEqual(_userAccount)) { continue; } var criteria = K2Service.Cores.SecurityLabelUtils.GetNameWithoutLabel(dest.Name).ToLower(); destUsers.Add(criteria); } } wItem.Release(); return(destUsers); } catch (Exception) { return(destUsers); } }
/// <summary> /// Delegate or shared worklist to other users /// </summary> /// <param name="serialNumber">The serial number</param> /// <param name="destinations">The other users</param> public void Share(string serialNumber, IList <string> destinations) { try { K2.WorklistItem worklistItem = GetWorklistItem(serialNumber); if (worklistItem == null) { throw new InvalidOperationException(string.Format("Not Found", serialNumber)); } if (destinations == null || destinations.Count == 0) { throw new InvalidOperationException(string.Format("Destination users is null or empty")); } var destinationUsers = new K2.Destinations(); foreach (string dest in destinations) { K2.Destination destination = new K2.Destination(); foreach (K2.Action action in worklistItem.Actions) { if (action != null) { destination.AllowedActions.Add(action.Name); } } destination.Name = dest; destination.DestinationType = DestinationType.User; destinationUsers.Add(destination); } worklistItem.Delegate(destinationUsers); } catch (Exception ex) { } }
/// <summary> /// 挂起 /// </summary> /// <param name="sn"></param> /// <param name="sourceUser"></param> /// <param name="second"></param> public static void SleepWorkListItem(string sn, string sourceUser, int second) { using (Connection conn = new Connection()) { try { ConnectionSetup conSetup = GetConnectionSetup(); conn.Open(conSetup); conn.ImpersonateUser(sourceUser); SourceCode.Workflow.Client.WorklistItem listItem = conn.OpenWorklistItem(sn); listItem.Sleep(true, second); } catch { // TODO: throw? throw; } finally { try { conn.RevertUser(); } catch { throw; } if (conn != null) { conn.Close(); } } } }
/// <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(); } } }
/// <summary> /// 获取当前流程实例节点名称 /// </summary> /// <param name="worklistItem"></param> /// <returns></returns> public static string GetCurrentActivityName(SourceCode.Workflow.Client.WorklistItem worklistItem) { return(worklistItem.ActivityInstanceDestination.Name); }
/// <summary> /// 委托代办 /// </summary> /// <param name="sn"></param> /// <param name="sourceUser"></param> /// <param name="targetUser"></param> public static string DelegateWorkListItem(string sn, string sourceUser, string targetUser) { using (Connection conn = new Connection()) { string result = ""; bool ContainsTargetUser = false; try { string targetUserSL = SecurityLabelName + ":" + targetUser; ConnectionSetup conSetup = GetConnectionSetup(); conn.Open(conSetup); conn.ImpersonateUser(sourceUser); SourceCode.Workflow.Client.WorklistItem listItem = conn.OpenWorklistItem(sn); //重置任务状态为Available,只有Available状态下的任务才有权限代理 listItem.Release(); //判断该任务是否已经代理给targetUser foreach (Destination destuser in listItem.DelegatedUsers) { if (destuser.Name.Equals(targetUserSL, StringComparison.InvariantCultureIgnoreCase)) { ContainsTargetUser = true; result = "任务不能重复代理给[" + targetUser + "]"; break; } } if (!ContainsTargetUser) { //如果该任务是其它人代理给sourceUser的,则sourceUser不能再次代理给targetUser,即禁止传递代理 DataTable DelegationLog = K2DBHelper.GetDelegationsLog(listItem.SerialNumber).Tables[0]; foreach (DataRow dr in DelegationLog.Rows) { if (sourceUser.Equals(dr["ToUser"].ToString(), StringComparison.InvariantCultureIgnoreCase)) { ContainsTargetUser = true; result = "该任务由[" + dr["FromUser"].ToString() + "]代理给[" + sourceUser + "]"; break; } } } if (!ContainsTargetUser) { Destination dest = new Destination(); dest.DestinationType = DestinationType.User; for (int i = 0; i < listItem.Actions.Count; i++) { dest.AllowedActions.Add(listItem.Actions[i].Name); } dest.Name = targetUserSL; //代理任务 listItem.Delegate(dest); //Todo:给代理人邮件 //Todo:添加代理历史记录 int parentProcInstID = K2DBHelper.GetRootParentsID(listItem.ProcessInstance.ID); K2DBHelper.AddDelegationsLog(listItem.ProcessInstance.ID, parentProcInstID, sn, sourceUser, targetUser, sourceUser); result = "任务代理成功"; } return(result); } catch { // TODO: throw? throw; } finally { try { conn.RevertUser(); } catch { throw; } if (conn != null) { conn.Close(); } } } }
/// <summary> /// Open a worklist item by serial number /// </summary> /// <param name="con">The worklist connection</param> /// <param name="serialNumber">The serial number</param> /// <param name="sharedUser">The shared user</param> /// <param name="managedUser">The manager user</param> /// <returns>The worklist item</returns> public K2.WorklistItem OpenWorklistItem(Connection con, string serialNumber, string sharedUser, string managedUser) { K2.WorklistItem worklistItem = OpenWorklistItem(con, serialNumber, sharedUser, managedUser, true); return(worklistItem); }