21

I need to display current status of a document approval workflow task in asp.net web page with a specific activity highlighted.

I have seen the Visual workflow tracker example (in wf & wcf samples) but I have two issues,

  1. I have to render workflow in asp.net not in a WPF app.

  2. I don't need to display current status with workflow running, all activities that need to be highlighted are the ones that require user input. e.g. "waiting for approval from department head" etc.

If I could just convert the workflow XAML to JPG after highlighting a specific activity by activity id "that created a bookmark and waiting for resumption the bookmark" it would do the work.

check the attached file for required workflow image to be rendered on asp.net page:

Workflow with current activity highlighted (that is waiting to be resumed)

4

1 回答 1

1

首先将工作流加载到设计器中。

您应该已经知道要突出显示的“活动”。工作流程中有选择服务,您可以使用它来选择适当的模型项目。此示例显示单个选择,但有多个。

ModelService modelService = wd.Context.Services.GetService<ModelService>();
        IEnumerable<ModelItem> activityCollection = modelService.Find(modelService.Root, typeof(Activity));
        Selection.Select(wd.Context, activityCollection.ElementAt(5));

在工作流设计器上,有一个按钮可以将工作流复制为图像或类似的东西。此链接将向您展示如何从 WorkflowDesigner.View 获取 jpg。 http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/b781c8df-608a-485a-80e3-a795d800f08d

        const double DPI = 96.0;

        Rect size = VisualTreeHelper.GetDescendantBounds(view);
        int imageWidth = (int)size.Width;
        int imageHeight = (int)size.Height;

        RenderTargetBitmap renderBitmap = new RenderTargetBitmap(imageWidth, imageHeight, DPI, DPI, PixelFormats.Pbgra32);
        renderBitmap.Render(view);
        BitmapFrame bf = BitmapFrame.Create(renderBitmap);

        using (FileStream fs = new FileStream(@"c:\test.jpg", FileMode.Create))
        {
            JpegBitmapEncoder encoder = new JpegBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(bf));
            encoder.Save(fs);
            fs.Close();
        }

作为补充说明,您应该查看 Kushals 示例:http: //blogs.msdn.com/b/kushals/archive/2009/12/22/visualworkflowtracking-aka-workflowsimulator.aspx

于 2011-04-04T02:39:07.617 回答