WF4 - 在 asp.net 中显示工作流程图像并突出显示活动

发布于 2024-08-31 23:11:42 字数 454 浏览 12 评论 0原文

我需要在 ASP.NET 网页中显示文档审批工作流任务的当前状态,并突出显示特定活动。

我已经看到了可视化工作流跟踪器示例(在 wf 和 wcf 示例中),但我有两个问题,

  1. 我必须在 asp.net 中而不是在 WPF 应用程序中渲染工作流。

  2. 我不需要显示工作流运行的当前状态,所有需要突出显示的活动都是需要用户输入的活动。例如“等待部门主管批准”等。

如果我可以在通过活动 id 突出显示特定活动“创建书签并等待恢复书签”后将工作流程 XAML 转换为 JPG,那么它就可以完成工作。

检查附件中要在 ASP.NET 页面上呈现的所需工作流图像:

突出显示当前活动的工作流(即正在等待恢复)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

束缚m 2024-09-07 23:11:42

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

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

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

First load the workflow into the designer.

You should already know the 'activity' you want highlighted. There is selection service in the workflow you can use to select the appropriate model items. This example shows single selection, but there is multiple.

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

On the workflow designer there is a button to copy workflow as image or something along those lines. This link will show you how to get the jpg from the WorkflowDesigner.View.
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();
        }

As an added note you should check out Kushals example:
http://blogs.msdn.com/b/kushals/archive/2009/12/22/visualworkflowtracking-aka-workflowsimulator.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文