• WF4.0 Beta1 自定义跟踪


    WF4.0 Beta1 自定义跟踪

    public class myTracking : TrackingParticipant

    {

    public override void Track(TrackingRecord record, TimeSpan timeout)

    {

    Console.WriteLine("*");

    Console.WriteLine("RecordNumber:[{2}], Track:[{0}],Level:[{1}]", record.GetType().FullName, record.Level, record.RecordNumber);

    Console.WriteLine("------------------------ content ----------------------------");

    //-------------------WorkflowInstanceRecord---------------------------

    WorkflowInstanceRecord workflowInstanceRecord = record as WorkflowInstanceRecord;

    if (workflowInstanceRecord != null)

    {

    Console.WriteLine("[workflowInstanceRecord]");

    Console.WriteLine("InstanceID: {0} , instance state: {1}", record.InstanceId, workflowInstanceRecord.State);

    }

    //-------------ActivityTrackingRecord-----------------------

    ActivityTrackingRecord activityTrackingRecord = record as ActivityTrackingRecord;

    if (activityTrackingRecord != null)

    {

    Console.WriteLine("[ActivityTrackingRecord]");

    Console.WriteLine("ActivityDisplayName: {0} :ActivityInstanceState: {1} ", activityTrackingRecord.Name, activityTrackingRecord.State);

    IDictionary<String, object> variables = activityTrackingRecord.Variables;

    if (variables.Count > 0)

    {

    Console.WriteLine("Variables:");

    foreach (KeyValuePair<string, object> variable in variables)

    {

    Console.WriteLine("key: {0} , Value: {1}", variable.Key, variable.Value);

    }

    }

    }

    //----------------UserTrackingRecord----------------------

    UserTrackingRecord userTrackingRecord = record as UserTrackingRecord;

    if ((userTrackingRecord != null) && (userTrackingRecord.Data.Count > 0))

    {

    Console.WriteLine("[UserTrackingRecord]");

    foreach (string data in userTrackingRecord.Data.Keys)

    {

    Console.WriteLine( "{0} : {1}", data, userTrackingRecord.Data[data]);

    }

    }

    //---------------End----------------------

    Console.WriteLine("======================== end ===============================");

    Console.WriteLine("");

    }

    }

    一个具备UserTrackingRecord的Activity

    public class myActivity : CodeActivity

    {

    protected override void Execute(CodeActivityContext context)

    {

    Console.WriteLine("myActivity Execute");

    UserTrackingRecord userRecord = new UserTrackingRecord("myUserTrackingRecord");

    userRecord.Data.Add("wxd", 12345);

    userRecord.Data.Add("wxwinter", "lzm");

    context.Track(userRecord);

    }

    }

    一个用于测试的流程

    使用

    class Program

    {

    static void Main(string[] args)

    {

    System.Console.WindowWidth = 120;

    myTracking tracking = new myTracking();

    tracking.TrackingProfile = getTrackingProfile();

    WorkflowInstance myInstance = new WorkflowInstance(new myTestWorkflow());

    myInstance.Extensions.Add(tracking);

    myInstance.Run();

    System.Console.Read();

    }

    static TrackingProfile getTrackingProfile()

    {

    TrackingProfile myTrackingProfile = new TrackingProfile();

    myTrackingProfile.Name = "wxwinterTrackingProfile";

    //

    UserTrackingQuery myUserTrackingQuery = new UserTrackingQuery();

    myUserTrackingQuery.Name = "*";

    myUserTrackingQuery.ActivityName = "*";

    //

    WorkflowInstanceQuery myWorkflowInstanceQuery = new WorkflowInstanceQuery();

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.AbortedEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.CompletedEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.DeletedEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.IdleEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.PersistedEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.ResumedEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.StartedEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.UnhandledExceptionEvent);

    myWorkflowInstanceQuery.States.Add(WorkflowInstanceRecord.UnloadedEvent);

    //

    ActivityQuery myActivityQuery = new ActivityQuery();

    myActivityQuery.ActivityName = "*";

    myActivityQuery.States.Add("*");

    myActivityQuery.EnvironmentQueries.Add("*");

    myActivityQuery.VariableQueries.Add(new VariableQuery{VariableName ="*"});

    //

    myTrackingProfile.Queries.Add(myActivityQuery);

    myTrackingProfile.Queries.Add(myUserTrackingQuery);

    myTrackingProfile.Queries.Add(myWorkflowInstanceQuery);

    //

    return myTrackingProfile;

    }

    }

  • 相关阅读:
    3.6 符号表的应用
    将博客搬至CSDN
    webpack打包vue项目IE报错,“对象不支持“use”属性或方法”
    移动端解决input被输入法挡住的问题
    javascript中对象的深复制的几种方法
    如何随机洗牌一个数组
    setInterval中this指向的问题
    css中的各种常见布局写法
    vue设置全局变量或函数
    【nodejs爬虫】使用async控制并发写一个小说爬虫
  • 原文地址:https://www.cnblogs.com/foundation/p/1536337.html
Copyright © 2020-2023  润新知