簡體   English   中英

使用可視化設計器進行動態更新:將流轉換為代碼是否可能或更好?

[英]Dynamic Update using the visual designer: is it possible, or better to convert flows to code?

與我之前關於使用多個子流和自定義活動更新長時間運行流的問題相關,我正在努力實現一個計划以及在將工作流發布到生產后修改工作流的代碼。

除了在另一個問題中概述的各種問題之外,我正在嘗試調試視覺設計器在准備動態更新之后出現混亂。 在.xaml上運行差異后,似乎是WorkflowViewState混淆的問題。

根據以前的帖子 ,似乎放棄視覺設計師是解決這個問題的一種可靠方法。 但是,我發現代碼似乎幾乎讓我在那里。 以下是我在調用DynamicUpdateServices.PrepareForUpdate方法后將MainProcessFlow.xaml保存回文件的方法:

    private static void SaveBuilderToFile(ActivityBuilder builder, string filePath)
    {
        // Make sure the activity builder has the right information about the c# expressions (even though its visual basic)
        VisualBasic.SetSettings(builder, VisualBasic.GetSettings(builder));

        // Set c# as the language
        System.Activities.Presentation.Expressions.ExpressionActivityEditor.SetExpressionActivityEditor(builder, "C#");

        // This is what I was hoping would correctly set the Viewstate
        WorkflowViewState.SetViewStateManager(
            builder.Implementation, WorkflowViewState.GetViewStateManager(builder.Implementation));

        string fullPath = Path.GetFullPath(filePath);

        using (FileStream file = File.Create(fullPath))
        {
            using (XmlWriter xmlWriter = XmlWriter.Create(file, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }))
            {
                using (XamlWriter xamlWriter = ActivityXamlServices.CreateBuilderWriter( new XamlXmlWriter(xmlWriter, new XamlSchemaContext())))
                {
                    XamlServices.Save(xamlWriter, builder);
                }
            }
        }
    }

在調用此方法並在可視化設計器中打開.xaml之后,活動就會出現故障。 流程仍然是“正確的”,因為箭頭指向正確的方向,但布局是混亂的。 進行更改,創建更新映射並在沒有dynamicupdate信息的情況下保存.xaml后,訂單仍然不正確。 在xaml中設置Viewstate時,沒有太多文檔(我可以找到)。 我錯過了什么嗎?

或者,放棄視覺設計師是一個更好的選擇嗎? 我們有近一年的工作流程,所以這將是一項巨大的任務,但讓DynamicUpdate工作是一個更高的優先級。

我剛剛解決了這個問題,我在DynamicUpdateServices.PrepareForUpdate(builder)之前使用了WorkflowViewState.GetViewStateManager(builder.Implementation) DynamicUpdateServices.PrepareForUpdate(builder) 我不知道是什么問題,但在PrepareForUpdate之后,GetViewStateManager的結果為null。 在完成所有操作后,我將ViewStateManager傳遞給SaveBuilderToFile()並在那里使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM