public static WFEvent StartProcInst(string piID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = svc.StartProcInst(piID); return(evt); }
public static WFEvent CreateLinkedWorkItem(string sourceWorkItemID, string workToPerform, string userID, WFTimeDuration duration, string clientData) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); // get existing work item string workItemID = sourceWorkItemID;// for example,"90CF843AC57644058A391FBFA030F607" WFEvent evt = null; try { // Get the source WFManualWorkItem object //WFManualWorkItem sourceWorkItem = svc.GetWorkItem(workItemID); //string workToPerform = sourceWorkItem.Name; //different workToPerform can be used if desired //WFTimeDuration duration = new WFTimeDuration(); //duration.Length = "15"; //for example, 15 days //duration.Unit = WFTimeUnit.DAY; //string user = @"[DOMAIN NAME]\username"; //the participant of the linked work item evt = svc.CreateLinkedWorkItem(workItemID, workToPerform, userID, duration, clientData); } catch (Exception ex) { } return(evt); }
private WFEvent getFullEvent(WFEvent evt) { while (evt.Status == WFEvent.SENT) { System.Threading.Thread.Sleep(500); evt = api.GetEvent(evt.EventID); } return(evt); }
public static WFEvent ReassignWorkItem(string wID, string userID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; try { evt = svc.ReassignWorkItem(wID, userID); } catch (Exception ex) { } return(evt); }
public static WFEvent UndoAssignWorkItem(string wID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string workItemID = wID;// for example, "03ABD59A0EB74D7A8741709478E83877"; WFEvent evt = null; try { evt = svc.UndoAssignWorkItem(workItemID); } catch (Exception ex) { } return(evt); }
public static WFEvent GetEvent(string evtID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string eventID = evtID;// for example, "049C3974240F47D3BA8EB6D4A3CDCD3F"; WFEvent evt = null; try { evt = svc.GetEvent(eventID); } catch (Exception ex) { } return(evt); }
public static WFEvent RollbackActivityInst(string activityInstanceID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; try { evt = svc.RollbackActivityInst(activityInstanceID); } catch (Exception ex) { } return(evt); }
public static WFEvent CompleteWorkItem(string wID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string workItemID = wID;// work item ID WFEvent evt = null; try { evt = svc.CompleteWorkItem(workItemID); } catch (Exception ex) { } return(evt); }
public static WFEvent CreatePseudoWorkItem(string sourceWorkItemID, string workToPerform, string userID, WFTimeDuration duration, string clientData, bool reserved) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; try { evt = svc.CreatePseudoWorkItem(sourceWorkItemID, workToPerform, userID, duration, clientData, false); } catch (Exception ex) { } return(evt); }
public static WFEvent AssignWorkItem(string wID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string WorkItemID = wID; WFEvent evt = null; try { evt = svc.AssignWorkItem(WorkItemID); } catch (Exception ex) { } return(evt); }
public static WFEvent CreateLinkedWorkItemEx(string sourceWorkItemID, string workToPerform, string userID, WFTimeDuration duration, string clientData, bool bDependent) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; try { evt = svc.CreateLinkedWorkItemEx(sourceWorkItemID, workToPerform, userID, duration, null, true); } catch (Exception ex) { } return(evt); }
public static WFEvent ReassignUpdateWorkItem(string workItemID, string originalUserID, string newAssigneeUserID, string clientData) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; try { evt = ReassignUpdateWorkItem(workItemID, originalUserID, newAssigneeUserID, null); } catch (Exception ex) { } return(evt); }
public static WFEvent CompleteWorkItemEx(string wID, string clientData) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string workItemID = wID;// work item ID string clientDataValue = clientData; WFEvent evt = null; try { evt = svc.CompleteWorkItemEx(workItemID, clientData); } catch (Exception ex) { } return(evt); }
public static WFEvent SuspendProcInst(string piID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; try { string processInstanceID = piID;// process instance to be suspended. evt = svc.SuspendProcInst(processInstanceID); } catch (Exception ex) { } return(evt); }
public static WFEvent RollbackProcInst(String AIID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string activityInstanceID = AIID;// target activity instance to roll back WFEvent evt = null; try { evt = svc.RollbackProcInst(activityInstanceID); } catch (Exception ex) { } return(evt); }
public static WFEvent CancelActivityInst(string activityInstanceID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string ActInstanceID = activityInstanceID;// activity instance needs to be canceled. WFEvent evt = null; try { evt = svc.CancelActivityInst(ActInstanceID); } catch (Exception ex) { } return(evt); }
public static WFEvent CancelProcInst(string piID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string processInstanceID = piID;// the ID of the process instance to becanceled. WFEvent evt = null; try { evt = svc.CancelProcInst(processInstanceID); } catch (Exception ex) { } return(evt); }
public static WFEvent AssignWorkItemEx(string WorkItemID, string clientData) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string wID = WorkItemID;// work item ID WFEvent evt = null; string clientDataValue = clientData; try { evt = svc.AssignWorkItemEx(wID, clientDataValue); } catch (Exception ex) { } return(evt); }
public static WFEvent CompleteProcedure(string wID) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; string autoWorkItemID = wID;// try { evt = svc.CompleteProcedure(autoWorkItemID); } catch (Exception ex) { } return(evt); }
public static WFEvent CreateProcInstEx(string PID, string PIID, string PIName, string workObjectID, string superPIID, string customID, NameValue[] attributes, bool startImmediately) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = svc.CreateProcInstEx( PID, PIID, PIName, workObjectID, superPIID, customID, attributes, true); return(evt); }
public string createProcess(string processName, string processTemplateName, Dictionary <string, Object> param) { try { if (String.IsNullOrEmpty(processName)) { throw new Exception("createProcess - processName is empty"); } if (String.IsNullOrEmpty(processTemplateName)) { throw new Exception("createProcess - processTemplateName is empty"); } string processTemplateID = api.GetReleasedPID(processTemplateName); if (processTemplateID == null) { throw new Exception("createProcess - 流程模板" + processTemplateName + "未定义"); } string PiID = Ascentn.Workflow.Base.UUID.GetID(); string Woid = Ascentn.Workflow.Base.UUID.GetID(); WFEvent evt = api.CreateProcInst(processTemplateID, PiID, processName, Woid, null, false); evt = getFullEvent(evt); if (!String.IsNullOrEmpty(evt.Error)) { throw new Exception("createProcess - " + evt.Error); } if (param != null && param.Count > 0) { ArrayList attrList = new ArrayList(); foreach (string key in param.Keys) { attrList.Add(new NameValue(key, param[key])); } NameValue[] attributes = (NameValue[])attrList.ToArray(typeof(NameValue)); api.SetCustomAttrs(Woid, attributes); } return(PiID); } catch (Exception e) { throw new Exception(errorMSGPrefix + e.Message, e); } }
public string startProcess(string processInstanceID, int OrganizationUnitID, ref string email, string UserID, string UserName) { try { if (String.IsNullOrEmpty(processInstanceID)) { throw new Exception("startProcess - processInstanceID is empty"); } WFEvent evt = api.StartProcInst(processInstanceID); evt = getFullEvent(evt); if (!String.IsNullOrEmpty(evt.Error)) { throw new Exception("startProcess - " + evt.Error); } string nextUser = prepareNextNode(processInstanceID, "PROCESS START", OrganizationUnitID, ref email); if (!String.IsNullOrEmpty(nextUser) && nextUser.IndexOf("P" + UserID + "P") > -1) // 如果下一步包有同一个人就自动审批(后面需要在审批历史里加入自动通过的标识) { return(approve(true, "", UserID, UserName, processInstanceID, "", OrganizationUnitID, ref email)); } else { return(nextUser); } //return "111"; } catch (Exception e) { try { api.CancelProcInst(processInstanceID); } catch (Exception ex) { } if (e is ApplicationException) { throw e; } throw new Exception(errorMSGPrefix + e.Message, e); } }
public static WFEvent RollbackActivityInsts(WFPartialRollbackInstruction instruction) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); WFEvent evt = null; //ROLL BACK UNIT WFPartialRollbackInstruction.PartialRollbackUnit unit1 = new WFPartialRollbackInstruction.PartialRollbackUnit(); unit1.DestinationActivityInstanceID = ""; // destination activity instance ID unit1.SourceActivityInstanceIDs = new string[] { "", "", "" }; // array of source activity instance ID WFPartialRollbackInstruction.PartialRollbackUnit unit2 = new WFPartialRollbackInstruction.PartialRollbackUnit(); unit2.DestinationActivityInstanceID = ""; // destination activityinstance ID unit2.SourceActivityInstanceIDs = new string[] { "", "" }; // array of source activity instance ID WFPartialRollbackInstruction instructions = new WFPartialRollbackInstruction(); evt = svc.RollbackActivityInsts(instruction); return(evt); }
public static WFEvent CreateWorkItem(string activityInstanceID, string workToPerform, string userID, WFTimeDuration duration, string clientData) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string ActivityInstanceID = activityInstanceID; // for example, "0172460E0AF943C6A6520044452BCAB3"; string WorkToPerform = workToPerform; // for example, "SubmitRequest"; //different workToPerform can be used if desired WFEvent evt = null; //WFTimeDuration duration = new WFTimeDuration("15", WFTimeUnit.DAY, true );// business time string user = userID; //the participant of the linked work item try { evt = svc.CreateWorkItem(activityInstanceID, workToPerform, user, duration, null); } catch (Exception ex) { } return(evt); }
public static WFEvent CreateProcInst(string PID, string PIID, string PIName, string workObjectID, string superPIID, bool startImmediately) { IWFWorkflowService svc = Common.GetWorkFlowAPI(); string processDefinitionName = "EmployeeOnboardProcess"; // get UUID of released process definition string processDefinitionID = svc.GetReleasedPID(processDefinitionName); // assign UUID of process instance string processInstanceID = UUID.GetID(); // process instance name that has to be unique within process definition ID string processInstanceName = string.Format("{0}-{1}", processDefinitionName, DateTime.Now.Ticks); // work object ID workObjectID = UUID.GetID(); // create process instance WFEvent E = svc.CreateProcInst(PID, PIID, PIName, workObjectID, null, true); return(E); }
public string approve(bool isApproved, string approvalComment, string userID, string userName, string processInstanceID, string proxyUserName, int OrganizationUnitID, ref string email) { try { if (String.IsNullOrEmpty(processInstanceID)) { throw new Exception("approve - processInstanceID is empty"); } if (String.IsNullOrEmpty(userID)) { throw new Exception("approve - userID is empty"); } if (String.IsNullOrEmpty(userName)) { throw new Exception("approve - userName is empty"); } string where = "WF_MANUAL_WORKITEMS.PROC_INST_ID='" + processInstanceID + "' and WF_MANUAL_WORKITEMS.STATUS in ('" + WFManualWorkItem.ASSIGNED + "','" + WFManualWorkItem.OVERDUE + "','" + WFManualWorkItem.REASSIGNED + "','" + WFManualWorkItem.PSEUDO + "') and CHARINDEX('P" + userID + "P',WF_MANUAL_WORKITEMS.USER_ID)>0"; WFManualWorkItem[] wis = api.QueryWorkListEx(where); if (wis.Length > 0) { WFManualWorkItem wi = wis[0]; APWorkFlow.NodeStatusDataTable dt = new APWorkFlow.NodeStatusDataTable(); StringReader sr = new StringReader(wi.ClientData); dt.ReadXml(sr); APWorkFlow.NodeStatusRow dr = dt[0]; if (String.IsNullOrEmpty(proxyUserName)) { dr.APPROVED_BY = userName; } else { dr.APPROVED_BY = proxyUserName + " 代理 " + userName; } if (String.IsNullOrEmpty(approvalComment)) { dr.COMMENTS = ""; } else { dr.COMMENTS = approvalComment; } dr.COMPLETED_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); if (isApproved)//若状态为通过 { // 首先判断是否为尝试修复的 if (dr.STATUS.Equals(FlowNodeStatus.ONERROR)) { // recover this node System.Collections.ArrayList attrList = new System.Collections.ArrayList(); attrList.Add(new NameValue("UserID", wi.OriginalUserID)); NameValue[] attributes = (NameValue[])attrList.ToArray(typeof(NameValue)); api.UpdateWorkItem(wi.WorkItemID, attributes); } else { dr.STATUS = FlowNodeStatus.APPROVED;//通过 //dr.AcceptChanges(); dt.AcceptChanges(); StringWriter sw = new StringWriter(); dt.WriteXml(sw); string clientData = sw.ToString(); //将信息写入XML并保存 WFEvent evt = api.CompleteWorkItemEx(wi.WorkItemID, clientData); //完成当前步骤 evt = getFullEvent(evt); if (!String.IsNullOrEmpty(evt.Error)) { throw new Exception("approve - " + evt.Error); } } } else { //直接取消流程 if (dr.STATUS.Equals(FlowNodeStatus.ONERROR)) { dr.COMMENTS = dr.ERROR_MSG; } dr.STATUS = FlowNodeStatus.CANCELLED; //dr.AcceptChanges(); dt.AcceptChanges(); StringWriter sw = new StringWriter(); dt.WriteXml(sw); string clientData = sw.ToString(); ArrayList attrList = new ArrayList(); attrList.Add(new NameValue("CLIENT_DATA", clientData)); NameValue[] nv = (NameValue[])attrList.ToArray(typeof(NameValue)); api.UpdateWorkItem(wi.WorkItemID, nv); WFEvent evt = api.CancelProcInst(processInstanceID); evt = getFullEvent(evt); if (!String.IsNullOrEmpty(evt.Error)) { throw new Exception("approve - " + evt.Error); } } //prepare next node string nextUser = prepareNextNode(processInstanceID, userID, OrganizationUnitID, ref email); //if (!String.IsNullOrEmpty(nextUser) && nextUser == "P" + userID + "P") // 如果下一步包有且只有同一个人就自动审批(后面需要在审批历史里加入自动通过的标识) // return approve(isApproved, approvalComment, userID, userName, processInstanceID, proxyUserName, OrganizationUnitID, ref email); //else return(nextUser); } else { throw new Exception("approve - 用户不能操作当前流程"); } } catch (Exception e) { if (e is ApplicationException) { throw e; } throw new Exception(errorMSGPrefix + e.Message, e); } }
private WFEvent getFullEvent(WFEvent evt) { while (evt.Status == WFEvent.SENT) { System.Threading.Thread.Sleep(500); evt = api.GetEvent(evt.EventID); } return evt; }