SharePoint 2010 获取工作流最新的实例

  public SPWorkflow GetTheLatestWorkflowInstance(SPListItem myitem)
        {
            SPWorkflowCollection ss = myitem.Workflows;
            SPWorkflow[] sort = new SPWorkflow[ss.Count];
            int k = 0;
            foreach (SPWorkflow ghy in ss)
            {
                sort[k] = ghy;
                k++;
            }
            SPWorkflow temp = null;
            int i, j;
            for (i = 0; i < sort.Length; i++)
            {
                for (j = i + 1; j < sort.Length; j++)
                {
                    if (sort[i].Created < sort[j].Created)
                    {
                        temp = sort[i];
                        sort[i] = sort[j];
                        sort[j] = temp;
                    }
                }
            }
            return sort[0];
        }

 

posted @ 2013-04-11 09:59  山之子  阅读(235)  评论(0编辑  收藏  举报