예제 #1
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.Running = true;
            bool ActivityStarted = false;

            if (this.Condition.Evaluate(this, executionContext))
            {
                for (int i = 0; i < this.Activities.Count; i++)
                {
                    if ((string)this.Activities[i].UserData["logger"] == "logger")
                    {
                        LogToHistoryListActivity logger = (LogToHistoryListActivity)this.Activities[i];
                        logger.HistoryDescription = string.Format(@"Begin 
                            Activity Execution:{0} with {1} enabled Children",
                                                                  this.QualifiedName,
                                                                  this.EnabledActivities.Count.ToString());
                        break;
                    }
                }
            }

            for (int childNum = 0; childNum < this.EnabledActivities.Count;
                 childNum++)
            {
                Activity child = this.EnabledActivities[childNum] as Activity;
                if (null != child)
                {
                    child.RegisterForStatusChange(Activity.ClosedEvent, this);
                    executionContext.ExecuteActivity(child);
                    ActivityStarted = true;
                }
            }
            return(ActivityStarted ? ActivityExecutionStatus.Executing : ActivityExecutionStatus.Closed);
        }
        protected override IComponent[] CreateComponentsCore(IDesignerHost host)
        {
            System.Workflow.ComponentModel.CompositeActivity activity = new LoggerActivity();

            LogToHistoryListActivity logger = new LogToHistoryListActivity();

            logger.Name = "logger";
            logger.UserData["logger"] = "logger";
            activity.Activities.Add(logger);

            return(new IComponent[] { activity });
        }