我在Windows服务中有一个工作流,它是一个定期执行工作的循环.这项工作是在一项TryCatch活动中完成的.该Try属性是一个TransactionScope活动,它包含一些读取和更新数据库的自定义活动.当事务失败时,我会指望任何导致它被捕获的异常TryCatch.但是,我的工作流程中止了.我的工作流程如下:
var wf = new While(true)
{
    Body = new Sequence
    {
        Activities =
        {
            new TryCatch
            {
                Try = new TransactionScope
                {
                    IsolationLevel = IsolationLevel.ReadCommitted,
                    Body = new Sequence
                    {
                        Activities = { ..custom database activities.. }
                    },
                    AbortInstanceOnTransactionFailure = false
                },
                Catches =
                {
                    new Catch<Exception>
                    {
                        Action = new ActivityAction<Exception>
                        {
                            Argument = exception,
                            Handler = ..log error..
                        }
                    }
                }
            },
            new Delay { Duration = new InArgument<TimeSpan>(duration) …c# transactions .net-4.0 workflow-foundation workflow-foundation-4
我有一个明确定义的服务合同,它暴露了一堆方法.我们有一个这个合同的典型服务实现,它与我们的MVC应用程序一起托管在IIS 7中.
该体系结构是典型的分布式应用程序,其接口在基础核心库(可重新分发)中定义,独立服务库中的实现,最后是MVC App暴露实现的终点(在服务图书馆).
现在的情况是,这些现有服务方法之一需要执行一个逻辑过程,该过程最多可能需要10分钟才能执行.在正常情况下,我们会考虑工作流服务,但是所讨论的界面正在使用中,我们有一套单元测试来测试我们的服务等,我们真的无法摆脱我们所拥有的这种实现.
所以我的问题是 -
调用托管环境中托管的工作流服务时,我收到以下错误.
Stored procedure returned unknown execution result Unknown.
Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 
Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at IWorkflow.InvokeWorkflowRequest(String id)
   at WorkflowClient.InvokeWorkflowRequest(String id)
我的配置文件
  <system.serviceModel>
    <services>
      <service name="WorkflowService">
       <endpoint binding="basicHttpBinding" contract="IWorkflow"  />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <sqlWorkflowInstanceStore connectionString="Data Source=.;Initial …我正在尝试使用C#而不是设计器和XAML编写一些活动。VS2010一直存在错误,并且运行缓慢,并且它对编译的支持也很差(变量名称,属性等)。
因此,我试图通过直接从Activity类继承来创建活动,但是遇到了麻烦。
这是我的代码:
public class TestActivity : Activity
{
    public InArgument<string> Username { get; set; }
    public InArgument<string> Password { get; set; }
    public OutArgument<bool> ValidCredential { get; set; }
    public OutArgument<ProvisioningRole> Role { get; set; }
    public OutArgument<Guid> Guid { get; set; }
    protected override Func<Activity> Implementation
    {
        get
        {
            return () =>
                {
                    return new Sequence()
                    {
                        Activities =
                        {
                            new AuthenticateUserActivity()
                            {
                                Username = this.Username,
                                Password = this.Password,
                                Guid = this.Guid,
                                Result = this.ValidCredential
                            },
                            new If() …我想要实现以下目标:
一个简单的用例是:用于审阅文档并批准或拒绝文档的工作流程.将为此创建工作流程,将通知个人,并且只要他们想要,他们就可以通过批准或拒绝审核来提供他们的反馈.
我以Andrew Zhu的代码为例,可以在http://xhinker.com/post/WF4.aspx上找到.
我遇到的问题是:
WaitForRunnableInstance无限期等待,因此我从未收到通知我的工作流程已启动并持久保存到数据库;BlockingBookmarks设置为我的自定义活动的id,ExecutionStatus设置为Idle,IsInitialized设置为1,IsSuspended设置为0,IsCompleted设置为0并IsReadyToRun设置为0.我已经开始讨论微软论坛,可以在http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/6262874d-3493-4be1-bd05-b990307e1875/上看到并得到一些反馈,但有些事情仍然不对.
有什么想法吗?使用自定义活动的长时间运行工作流的任何有用模式?
谢谢!
使用System.Diagnostics进行跟踪.虽然我已经使用过log4net和其他日志记录解决方案,但我只对跟踪工作感兴趣System.Diagnostics.
即使我发出的TraceEvent文件没有在任何地方创建.
我有一个托管一些WF服务的应用程序.其中一个服务是状态机,其初始状态如下所示:

在LogMessage自定义活动也非常直截了当.它接收四个基本参数:

将TraceSource变量定义为:

然后简单地调用TraceEvent:

这种情况的结构TraceSource和TraceListener如下:
  <system.diagnostics>
    <trace autoflush="true"/>
    <sources>
      <source name="log" switchValue="All">
        <listeners>
          <add name="file" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
               BaseFileName="gsf_workflows.txt"
               DiskSpaceExhaustedBehavior="ThrowException"
               Location="Custom"
               CustomLocation="D:\Log"
               MaxFileSize="81920000"
               LogFileCreationSchedule="LogFileCreationScheduleOption.Daily"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
我最近有
现在,当我尝试加入 WF Farm 时,收到 401 错误消息
远程服务器返回错误:(401) 未经授权。此操作需要管理声明...
有趣的是,我可以加入SB农场,但不能加入WF农场。
以下是 WF PowerShell 的输出:
PS C:\Program Files\Workflow Manager\1.0> Add-WFHost -WFFarmDBConnectionStringData 'Source=sqlserver;Initial Catalog=WFManagement;Integrated Security=True;Encryt=False' -RunAsPassword $RunAsPassword -EnableFirewallRules $true -SBClientConfiguration $SBClientConfiguration -CertificateAutoGenerationKey $CertificateAutoGenerationKey -Verbose;
VERBOSE: [04-05-2015 07:05:32]: Validating input and configuration parameters.
VERBOSE: [04-05-2015 07:05:33]: Installing auto-generated certificate.
VERBOSE: [04-05-2015 07:05:36]: Granting 'Log on as Service' privilege to the RunAs account.
VERBOSE: [04-05-2015 07:05:36]: Workflow Manager configuration starting.
VERBOSE: [04-05-2015 07:05:37]: Configuring Workflow Manager runtime settings. …servicebus workflow-foundation workflow-foundation-4 workflow-manager-1.x