日期:2014-05-17 浏览次数:21079 次
[Serializable]
public class jProcess
{
public string Name { get; set; }
public List<jBaseNode> ProcessNodes { get; set; }
public jProcess()
{
ProcessNodes = new List<jBaseNode>();
}
public string GenerateProgress(string currentTaskName)
{
jTask firstTask = ProcessNodes.Where(p => p is jTask).FirstOrDefault() as jTask;
StringBuilder sb = new StringBuilder ();
sb.Append("<span class='blue'>");
Build(currentTaskName,firstTask,sb);
return sb.ToString().TrimEnd('-','-','>');
}
private void Build(string currentTaskName,jTask task,StringBuilder sb)
{
sb.Append(task.AssigneeName+task.Remark);
if(task.Name==currentTaskName)
{
sb.Append("</span>");
}
sb.Append("-->");
jTask nextTask = task.TransitionList.Where(t=>t.Selected).FirstOrDefault().TargetNode as jTask;
if(nextTask==null)
{
return;
}
else
{
Build(currentTaskName,nextTask,sb);
}
}
}