private WFAutomaticWorkItem[] GetAutomaticWorkItems(WorkflowService api, string aiID) { // manual work items WFAny any = new WFAny(); any.Type = WFTypeCode._STRING; any.Value = aiID; WFQueryExpr expr = new WFQueryExpr(); expr.ColumnName = "ACTIVITY_INST_ID"; expr.Operator = SQLExpr.EQ; expr.Any = any; expr.IsValue = true; WFAutomaticWorkItem[] wks = api.QueryProcedureList(expr); if (wks == null || wks.Length == 0) { return(null); } SortedList sl = new SortedList(); string procedure = null; string prefix = WFConstants.BUILT_IN_PROCEDURE; foreach (WFAutomaticWorkItem wk in wks) { procedure = wk.ProcedureInfo; if (!procedure.StartsWith(prefix)) { continue; } procedure = procedure.Remove(0, prefix.Length + 1); if (!procedure.StartsWith("SubProcess")) { continue; } sl.Add((int.MaxValue - wk.Session) + UUID.GetID(), wk); } wks = new WFAutomaticWorkItem[sl.Count]; if (sl.Count > 0) { sl.Values.CopyTo(wks, 0); } return(wks); }
private WFManualWorkItem[] GetManualWorkItems(WorkflowService api, string aiID) { // manual work items WFAny any = WFAny.Create(aiID); WFQueryExpr expr = new WFQueryExpr("ACTIVITY_INST_ID", SQLExpr.EQ, any, true); WFManualWorkItem[] wks = api.QueryWorkList(expr); if (wks == null || wks.Length == 0) { return(null); } SortedList sl = new SortedList(); foreach (WFManualWorkItem wk in wks) { string key = (DateTime.MaxValue - wk.AssignedDate).ToString(); sl.Add(key + UUID.GetID(), wk); } sl.Values.CopyTo(wks, 0); return(wks); }
private Hashtable GetSubProcInstName(WorkflowService api, WFAutomaticWorkItem[] wks) { Hashtable h = new Hashtable(); if (wks == null || wks.Length == 0) { return(h); } Hashtable hPIIDs = new Hashtable(); // ensure unique String piIDs = ""; foreach (WFAutomaticWorkItem w in wks) { if (hPIIDs[w.WorkItemID] == null) { if (piIDs.Length > 0) { piIDs += ","; } piIDs += String.Format("'{0}'", w.WorkItemID); hPIIDs[w.WorkItemID] = w.WorkItemID; } } WFQueryExpr expr = new WFQueryExpr("PROC_INST_ID", SQLExpr.IN, WFAny.Create(piIDs), true); WFBaseProcessInstance[] pis = api.QueryProcInsts(expr); if (pis == null) { return(h); } foreach (WFBaseProcessInstance pi in pis) { h[pi.ProcInstID] = pi.ProcInstName; } return(h); }
private int CountParticipantOnActivity(IWFWorkflowService api, string piID, WFBaseActivityInstance ai) { ArrayList participantList = new ArrayList(); //Retreive Activity definition to know the type of activity WFBaseProcessInstance pi = api.GetProcInst(piID); string xmlString = api.GetProcDefXml(pi.DefID); WFProcessDefinition processDef = new WFProcessDefinition(); ProcDefXmlParser xmlParser = new ProcDefXmlParser(processDef); xmlParser.Parse(xmlString); IWFActivityDefinition ad = processDef.FindActivityByName(ai.Name); WFManualActivityDefinition activityDef = null; //Get the type of activity if (ad != null && ad.GetType() == typeof(WFManualActivityDefinition)) { activityDef = (WFManualActivityDefinition)ad; } // Get manual work items for the given Activity WFAny any = WFAny.Create(ai.ID); WFQueryExpr expr = new WFQueryExpr("ACTIVITY_INST_ID", SQLExpr.EQ, any, true); WFManualWorkItem[] wks = api.QueryWorkList(expr); if (wks != null) { foreach (WFManualWorkItem wk in wks) { if (wk.Status == WFManualWorkItem.ASSIGNED || wk.Status == WFManualWorkItem.OVERDUE || wk.Status == WFManualWorkItem.COMPLETED) { if (!String.IsNullOrEmpty(wk.UserID) && !participantList.Contains(wk.UserID.ToLower())) { participantList.Add(wk.UserID.ToLower()); } } } } // if activity is Agilework of type ProcessAdaptation if (activityDef != null && activityDef.CustomProperties.Contains("Ascentn.AgileWork.Premier.ProcessAdaptation")) { //Get type of the AgileWork string activityType = api.GetCustomAttr(pi.WorkObjectID, ai.ID + "_ApprovalType") as string; //Count number of participant in case of sequential type if (activityType == "Sequential") { string activityProperties = api.GetCustomAttr(pi.WorkObjectID, ai.ID + "_ActivityProperties") as string; if (!String.IsNullOrEmpty(activityProperties)) { string[] approverInfoList = activityProperties.Split(';'); foreach (string approverInfo in approverInfoList) { string[] userInfoList = approverInfo.Split('|'); string user = userInfoList[0]; if (!String.IsNullOrEmpty(user) && !participantList.Contains(user.ToLower())) { participantList.Add(user.ToLower()); } } } } } return(participantList.Count); }
private WFAutomaticWorkItem[] GetAutomaticWorkItems(WorkflowService api, string aiID) { // manual work items WFAny any = new WFAny(); any.Type = WFTypeCode._STRING; any.Value = aiID; WFQueryExpr expr = new WFQueryExpr(); expr.ColumnName = "ACTIVITY_INST_ID"; expr.Operator = SQLExpr.EQ; expr.Any = any; expr.IsValue = true; WFAutomaticWorkItem[] wks = api.QueryProcedureList(expr); if (wks == null || wks.Length == 0) return null; SortedList sl = new SortedList(); string procedure = null; string prefix = WFConstants.BUILT_IN_PROCEDURE; foreach (WFAutomaticWorkItem wk in wks) { procedure = wk.ProcedureInfo; if (!procedure.StartsWith(prefix)) continue; procedure = procedure.Remove(0, prefix.Length + 1); if (!procedure.StartsWith("SubProcess")) continue; sl.Add((int.MaxValue - wk.Session) + UUID.GetID(), wk); } wks = new WFAutomaticWorkItem[sl.Count]; if (sl.Count > 0) sl.Values.CopyTo(wks, 0); return wks; }