持久化在nativeactivity的execute方法中

发布于 2024-11-15 17:35:00 字数 634 浏览 3 评论 0原文

我需要弄清楚是否有可能,或者是否有更好的解决方案来解决我的问题。下面是我的一个场景。在活动的 Execute 方法内部,我需要能够运行 3 种不同的方法。第一个将呈现 UI(HTML 或 VXML)并等待用户输入。在这个阶段,我预计工作流程会持续下去(如果可能的话)。第二种方法将获取用户输入的数据并对其进行验证。如果输入有效,则将运行下一个方法,该方法将处理数据。如果输入无效,则需要重新呈现 UI。这在执行方法中是可能的吗?或者对于这种情况有更好的解决方案吗?

protected override void Execute(NativeActivityContext context)
    {
        // Present UI and get user's input
        // IRTFunctions.PresentUI(itemRefName);

        // Input validation
        // IRTFunctions.ValidateInput(itemRefName);

        // Additional logic, like setting additional fields
        // IRTFunctions.ProcessAdditionalLogic(itemRefName);
    }

I need to figure out if something is possible or if there is a better solution to my issue. Below is a scenario that I have. Inside of the activity's Execute method, I need to be able to run 3 different methods. The first will present a UI (either HTML or VXML) and wait for user input. At this stage, I'm anticipating having the workflow persist (if possible). The second method will take the data input by user and validate it. If the input is valid, the next method will run, which will process the data. If the input is invalid, the UI will need to be presented again. Is this something that is possible within the execute method or is there a better solution to this scenario?

protected override void Execute(NativeActivityContext context)
    {
        // Present UI and get user's input
        // IRTFunctions.PresentUI(itemRefName);

        // Input validation
        // IRTFunctions.ValidateInput(itemRefName);

        // Additional logic, like setting additional fields
        // IRTFunctions.ProcessAdditionalLogic(itemRefName);
    }

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

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

发布评论

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

评论(1

季末如歌 2024-11-22 17:35:00

您不应该永远不要阻止活动的 Execute() 方法。这样做会严重损害工作流程并阻止其持久化和可能的卸载。

相反,您应该使用 NativeActivityContext 创建书签,并使用书签名称将用户异步重定向到某个 UI 页面。稍后,当用户完成 UI 时,用户恢复书签并传递输入的数据。现在这可能是几天甚至几周后。当书签恢复时,工作流程将重新加载,书签恢复处理程序将被调用,您可以验证输入并决定要做什么。您可以创建多个恢复书签,当您接受输入有效时需要显式关闭这些书签。

You should never block the Execute() method of an activity. Doing so will actively harm the workflow and prevent it from being persisted and possibly unloaded.

Instead you should create a bookmark using the NativeActivityContext and redirect the user to some UI page asynchronously with the bookmark name. Later, when the user has completed the UI, the user resumes the bookmark and passes the data entered. Now this could be days or even weeks later. When a bookmark is resumed the workflow is reloaded and an bookmark resumption handler is invoked and you get to validate the input and decide what to do. You can create multiple resumption bookmarks what you need to explicitly close when you accept the input as valid.

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