Ejemplo n.º 1
0
        private VisualTrackingParticipant generateTracker()
        {
            const String all = "*";

            VisualTrackingParticipant simTracker = new VisualTrackingParticipant(this)
            {
                TrackingProfile = new TrackingProfile()
                {
                    Name    = "CustomTrackingProfile",
                    Queries =
                    {
                        new CustomTrackingQuery()
                        {
                            Name         = all,
                            ActivityName = all
                        },
                        new WorkflowInstanceQuery()
                        {
                            // Limit workflow instance tracking records for started and completed workflow states
                            States ={ WorkflowInstanceStates.Started,              WorkflowInstanceStates.Completed },
                        },

                        new ActivityStateQuery()
                        {
                            // Subscribe for track records from all activities for all states
                            ActivityName = all,
                            States       = { all },

                            // Extract workflow variables and arguments as a part of the activity tracking record
                            // VariableName = "*" allows for extraction of all variables in the scope
                            // of the activity
                            Variables =
                            {
                                all
                            },

                            Arguments =
                            {
                                all
                            },
                        },

                        new ActivityScheduledQuery()
                        {
                            ActivityName      = all,
                            ChildActivityName = all
                        },
                    }
                }
            };

            trackerVarsAdd(simTracker);

            simTracker.m_activityIdToWorkflowElementMap = m_activityIdToWfElementMap;

            return(simTracker);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 开始执行调试流程
        /// </summary>
        public void Debug()
        {
            //授权检测
            ViewModelLocator.Instance.SplashScreen.DoAuthorizationCheck();

            Activity workflow = ActivityXamlServices.Load(m_xamlPath);

            var result = ActivityValidationServices.Validate(workflow);

            if (result.Errors.Count == 0)
            {
                Messenger.Default.Send(this, "BeginRun");

                m_wfElementToSourceLocationMap = UpdateSourceLocationMappingInDebuggerService();
                m_activityIdToWfElementMap     = BuildActivityIdToWfElementMap(m_wfElementToSourceLocationMap);

                if (m_app != null)
                {
                    m_app.Terminate("");
                }

                m_app = new WorkflowApplication(workflow);
                m_app.OnUnhandledException = WorkflowApplicationOnUnhandledException;
                m_app.Completed            = WorkflowApplicationExecutionCompleted;

                m_simTracker = generateTracker();
                m_app.Extensions.Add(m_simTracker);
                m_app.Extensions.Add(new LogToOutputWindowTextWriter());

                if (workflow is DynamicActivity)
                {
                    var wr = new WorkflowRuntime();
                    wr.RootActivity = workflow;
                    m_app.Extensions.Add(wr);
                }

                m_app.Run();
            }
            else
            {
                // 工作流校验错误,请检查参数配置
                MessageBox.Show(App.Current.MainWindow, ResxIF.GetString("WorkflowCheckError"), ResxIF.GetString("ErrorText"), MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///提前填充工作流用到的变量,以便在全局作用域里监视
        /// </summary>
        /// <param name="simTracker"></param>
        private void trackerVarsAdd(VisualTrackingParticipant simTracker)
        {
            List <string> varNameLsit = new List <string>();

            ModelService modelService = m_workflowDesigner.Context.Services.GetService <ModelService>();

            IEnumerable <ModelItem> flowcharts = modelService.Find(modelService.Root, typeof(Flowchart));
            IEnumerable <ModelItem> sequences  = modelService.Find(modelService.Root, typeof(Sequence));

            foreach (var modelItem in flowcharts)
            {
                foreach (var varItem in modelItem.Properties["Variables"].Collection)
                {
                    var varName = varItem.Properties["Name"].ComputedValue as string;
                    varNameLsit.Add(varName);
                }
            }

            foreach (var modelItem in sequences)
            {
                foreach (var varItem in modelItem.Properties["Variables"].Collection)
                {
                    var varName = varItem.Properties["Name"].ComputedValue as string;
                    varNameLsit.Add(varName);
                }
            }

            if (varNameLsit.Count > 0)
            {
                foreach (var item in simTracker.TrackingProfile.Queries)
                {
                    if (item is ActivityStateQuery)
                    {
                        var query = item as ActivityStateQuery;

                        foreach (var name in varNameLsit)
                        {
                            query.Variables.Add(name);
                        }
                        break;
                    }
                }
            }
        }