예제 #1
0
        public override void PerformReflection(ReflectionContext context)
        {
            Type[] workflowTypes = context.WorkflowAssembly.GetWorkflowTypes();

            if (workflowTypes == null)
            {
                return;
            }

            foreach (Type workflowType in workflowTypes)
            {
                WorkflowNode workflowNode = new WorkflowNode();
                workflowNode.Name               = workflowType.Name;
                workflowNode.Text               = workflowType.FullName;
                workflowNode.WorkflowType       = workflowType;
                workflowNode.SelectedImageIndex = workflowNode.ImageIndex = context.GetImageIndex(typeof(WorkflowComponent), WorkflowNodeImageName);

                context.CurrentTreeNode.Nodes.Add(workflowNode);
                ReflectChildComponents(context.CreateClone(workflowNode));
            }

            if (context.WorkflowAssembly.GetWorkflowTypes().Length == 0)
            {
                TreeNode node = new TreeNode();
                node.Text = "<No Workflows Found>";

                context.CurrentTreeNode.Nodes.Add(node);
            }
        }
예제 #2
0
        private void OpenXamlInNotepad(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            WorkflowNode      node = (WorkflowNode)item.Tag;

            object workflowInstance = null;

            try
            {
                workflowInstance = node.WorkflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                MessageBox.Show("The workflow type could not be created: " + exc.ToString());
                return;
            }

            WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();

            string tempFileName = Path.GetTempFileName();


            using (XmlWriter xmlWriter = XmlWriter.Create(tempFileName))
            {
                serializer.Serialize(xmlWriter, workflowInstance);
            }

            ProcessStartInfo psi = new ProcessStartInfo();

            psi.Arguments = tempFileName;
            psi.FileName  = Path.Combine(Environment.GetEnvironmentVariable("windir"), "notepad.exe");

            Process.Start(psi);
        }
예제 #3
0
        private void OnItemClick(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;

            RuleNode node = (RuleNode)item.Tag;
            RuleExpressionCondition expressionCondition = (RuleExpressionCondition)node.Rule;

            WorkflowNode workflowNode = (WorkflowNode)node.Parent;

            EvaluateRuleDialog dialog = new EvaluateRuleDialog(expressionCondition.Expression, workflowNode.WorkflowType);

            dialog.ShowDialog();
        }
예제 #4
0
        public override void PerformReflection(ReflectionContext context)
        {
            WorkflowNode workflowNode = context.CurrentTreeNode as WorkflowNode;

            if (workflowNode == null)
            {
                throw new ApplicationException("Expected the parent node to be a workflow node.");
            }

            object workflowInstance = null;

            try
            {
                workflowInstance = workflowNode.WorkflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Could not create workflow type: " + exc.ToString());
                return;
            }

            TreeNode activitiesNode = new TreeNode();

            activitiesNode.Text       = "Activities";
            activitiesNode.ImageIndex = activitiesNode.SelectedImageIndex = context.GetImageIndex(typeof(WorkflowActivitiesComponent), ActivitiesNodeImageName);

            workflowNode.Nodes.Add(activitiesNode);

            if (!(workflowInstance is CompositeActivity))
            {
                TreeNode none = new TreeNode();
                none.Text = "<Workflow is not a CompositeActivity>";
                activitiesNode.Nodes.Add(none);
            }
            else
            {
                Queue <KeyValuePair <CompositeActivity, TreeNode> > toProcess = new Queue <KeyValuePair <CompositeActivity, TreeNode> >();
                toProcess.Enqueue(new KeyValuePair <CompositeActivity, TreeNode>((CompositeActivity)workflowInstance, activitiesNode));

                while (toProcess.Count > 0)
                {
                    KeyValuePair <CompositeActivity, TreeNode> pair = toProcess.Dequeue();
                    CompositeActivity compositeActivity             = pair.Key;
                    TreeNode          parent = pair.Value;

                    foreach (Activity activity in compositeActivity.Activities)
                    {
                        ActivityNode activityNode = new ActivityNode();
                        activityNode.Activity   = activity;
                        activityNode.ImageIndex = activityNode.SelectedImageIndex = context.GetImageIndex(typeof(WorkflowActivitiesComponent), ActivityNodeImageName);
                        parent.Nodes.Add(activityNode);

                        ReflectChildComponents(context.CreateClone(activityNode));

                        if (activity is CompositeActivity)
                        {
                            toProcess.Enqueue(new KeyValuePair <CompositeActivity, TreeNode>((CompositeActivity)activity, activityNode));
                        }
                    }
                }
            }
        }
예제 #5
0
        public override void PerformReflection(ReflectionContext context)
        {
            Type[] workflowTypes = context.WorkflowAssembly.GetWorkflowTypes();
            
            if (workflowTypes == null)
                return;

            foreach (Type workflowType in workflowTypes)
            {
                WorkflowNode workflowNode = new WorkflowNode();
                workflowNode.Name = workflowType.Name;
                workflowNode.Text = workflowType.FullName;
                workflowNode.WorkflowType = workflowType;
                workflowNode.SelectedImageIndex = workflowNode.ImageIndex = context.GetImageIndex(typeof(WorkflowComponent), WorkflowNodeImageName);

                context.CurrentTreeNode.Nodes.Add(workflowNode);
                ReflectChildComponents(context.CreateClone(workflowNode));
            }

            if (context.WorkflowAssembly.GetWorkflowTypes().Length == 0)
            {
                TreeNode node = new TreeNode();
                node.Text = "<No Workflows Found>";

                context.CurrentTreeNode.Nodes.Add(node);
            }
        }