public static JsonItem GetTaskStateJsonItem(BPMConnection cn, TaskState state, int taskid) { JsonItem rv = new JsonItem(); rv.Attributes.Add("State", state.ToString().ToLower()); if (state == TaskState.Running) { JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); foreach (BPMProcStep step in steps) { JsonItem item = new JsonItem(); item.Attributes.Add("StepName", step.StepDisplayName); item.Attributes.Add("Share", step.Share); item.Attributes.Add("RecipientAccount", step.RecipientAccount); item.Attributes.Add("RecipientDisplayName", step.RecipientFullName); children.Add(item); } } return(rv); }
public static string GetTaskStateDisplayString(BPMConnection cn, TaskState state, int taskid) { if (state != TaskState.Running) { return(YZStringHelper.GetTaskStateDisplayName(state)); } Dictionary <string, BPMObjectNameCollection> results = new Dictionary <string, BPMObjectNameCollection>(); BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); foreach (BPMProcStep step in steps) { string stepName = step.StepDisplayName; if (step.Share && String.IsNullOrEmpty(step.RecipientAccount)) { stepName = stepName + "(等待获取)"; } BPMObjectNameCollection users = null; if (results.ContainsKey(stepName)) { users = results[stepName]; } else { users = new BPMObjectNameCollection(); results.Add(stepName, users); } string userName = YZStringHelper.GetUserShortName(step.RecipientAccount, step.RecipientFullName); if (!String.IsNullOrEmpty(userName) && !users.Contains(userName)) { users.Add(userName); } } List <string> rvs = new List <string>(); foreach (KeyValuePair <string, BPMObjectNameCollection> kv in results) { string users = String.Join(",", kv.Value.ToArray()); if (String.IsNullOrEmpty(users)) { rvs.Add(kv.Key); } else { rvs.Add(String.Format("{0}:{1}", kv.Key, users)); } } return(String.Join(";", rvs.ToArray())); }
public static string GetTaskStatusHTML(BPMConnection cn, TaskState state, int taskid) { if (state == TaskState.Running) { BPMStepCollection steps = BPMTask.GetInProcessSteps(cn, taskid); StringBuilder sb = new StringBuilder(); foreach (BPMProcStep step in steps) { if (sb.Length != 0) { sb.Append("</br>"); } sb.AppendFormat("{0} [{1}]", step.NodeName, GetUserFriendlyName(step.RecipientAccount, step.RecipientFullName)); } return(sb.ToString()); } else { return(GetTaskStatusHTML(state)); } }