protected override void DoDefaultAction()
        {
            base.DoDefaultAction();
            WorkflowDesignerLoader service = this.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;

            if ((service != null) && service.InDebugMode)
            {
                throw new InvalidOperationException(Messages.DebugModeEditsDisallowed);
            }
            PolicyActivity activity = (PolicyActivity)base.Activity;

            if (!System.Workflow.Activities.Common.Helpers.IsActivityLocked(activity))
            {
                RuleDefinitions definitions = ConditionHelper.Load_Rules_DT(this, System.Workflow.Activities.Common.Helpers.GetRootActivity(activity));
                if (definitions != null)
                {
                    RuleSetCollection ruleSets         = definitions.RuleSets;
                    RuleSetReference  ruleSetReference = activity.RuleSetReference;
                    RuleSet           ruleSet          = null;
                    string            key = null;
                    if ((ruleSetReference != null) && !string.IsNullOrEmpty(ruleSetReference.RuleSetName))
                    {
                        key = ruleSetReference.RuleSetName;
                        if (ruleSets.Contains(key))
                        {
                            ruleSet = ruleSets[key];
                        }
                    }
                    else
                    {
                        key = ruleSets.GenerateRuleSetName();
                    }
                    using (RuleSetDialog dialog = new RuleSetDialog(activity, ruleSet))
                    {
                        if (DialogResult.OK == dialog.ShowDialog())
                        {
                            if (ruleSet != null)
                            {
                                ruleSets.Remove(key);
                            }
                            else
                            {
                                dialog.RuleSet.Name       = key;
                                activity.RuleSetReference = new RuleSetReference(key);
                            }
                            ruleSets.Add(dialog.RuleSet);
                            ConditionHelper.Flush_Rules_DT(this, System.Workflow.Activities.Common.Helpers.GetRootActivity(activity));
                        }
                    }
                }
                TypeDescriptor.GetProperties(activity)["RuleSetReference"].SetValue(activity, activity.RuleSetReference);
            }
        }
 private void InitializeComponent()
 {
     this.CanModifyActivities = true;
     System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
     System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
     Sage.SalesLogix.Process.Activities.RelativeDateTime relativedatetime1 = new Sage.SalesLogix.Process.Activities.RelativeDateTime();
     System.Workflow.Activities.Rules.RuleSetReference rulesetreference1 = new System.Workflow.Activities.Rules.RuleSetReference();
     this.createToDo1 = new Sage.SalesLogix.Process.Activities.CreateToDo();
     this.codeActivity1 = new System.Workflow.Activities.CodeActivity();
     this.policyActivity1 = new System.Workflow.Activities.PolicyActivity();
     activitybind1.Name = "Workflow2";
     activitybind1.Path = "CurrentEntity.Id";
     activitybind2.Name = "Workflow2";
     activitybind2.Path = "CurrentEntity.ModifyUser";
     //
     // createToDo1
     //
     this.createToDo1.ActivityDescription = "Created from Process";
     this.createToDo1.Description = "Created from Process";
     this.createToDo1.Name = "createToDo1";
     relativedatetime1.BaseDateTime = new System.DateTime(2008, 10, 2, 0, 0, 0, 0);
     relativedatetime1.Offset = System.TimeSpan.Parse("00:00:00");
     relativedatetime1.RelativeTo = Sage.SalesLogix.Process.Activities.RelativeTo.UtcNow;
     this.createToDo1.StartDate = relativedatetime1;
     this.createToDo1.SetBinding(Sage.SalesLogix.Process.Activities.CreateActivityBase.AccountIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
     this.createToDo1.SetBinding(Sage.SalesLogix.Process.Activities.CreateActivityBase.UserIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
     //
     // codeActivity1
     //
     this.codeActivity1.Name = "codeActivity1";
     this.codeActivity1.ExecuteCode += new System.EventHandler(this.codeActivity1_ExecuteCode);
     //
     // policyActivity1
     //
     this.policyActivity1.Name = "policyActivity1";
     rulesetreference1.RuleSetName = "Rule Set1";
     this.policyActivity1.RuleSetReference = rulesetreference1;
     //
     // Workflow2
     //
     this.Activities.Add(this.policyActivity1);
     this.Activities.Add(this.codeActivity1);
     this.Activities.Add(this.createToDo1);
     this.Description = "y 2nd Workflow";
     this.EntityId = null;
     this.EntityType = typeof(Sage.Entity.Interfaces.IAccount);
     this.Name = "Workflow2";
     this.CanModifyActivities = false;
 }
 private void InitializeComponent()
 {
     this.CanModifyActivities = true;
     System.Workflow.Activities.Rules.RuleSetReference rulesetreference1 = new System.Workflow.Activities.Rules.RuleSetReference();
     this.policyActivity1 = new System.Workflow.Activities.PolicyActivity();
     //
     // policyActivity1
     //
     this.policyActivity1.Name = "policyActivity1";
     rulesetreference1.RuleSetName = "ValidateOrders";
     this.policyActivity1.RuleSetReference = rulesetreference1;
     //
     // Workflow
     //
     this.Activities.Add(this.policyActivity1);
     this.Name = "Workflow";
     this.CanModifyActivities = false;
 }
 private void InitializeComponent()
 {
     this.CanModifyActivities = true;
     System.Workflow.Activities.Rules.RuleSetReference rulesetreference1 = new System.Workflow.Activities.Rules.RuleSetReference();
     this.simpleDiscountPolicy = new System.Workflow.Activities.PolicyActivity();
     //
     // simpleDiscountPolicy
     //
     this.simpleDiscountPolicy.Name = "simpleDiscountPolicy";
     rulesetreference1.RuleSetName = "DiscountRuleSet";
     this.simpleDiscountPolicy.RuleSetReference = rulesetreference1;
     //
     // SimplePolicyWorkflow
     //
     this.Activities.Add(this.simpleDiscountPolicy);
     this.Name = "SimplePolicyWorkflow";
     this.Completed += new System.EventHandler(this.WorkflowCompleted);
     this.CanModifyActivities = false;
 }
示例#5
0
        protected override void DoDefaultAction()
        {
            base.DoDefaultAction();

            // Do not allow editing if in debug mode.
            WorkflowDesignerLoader workflowDesignerLoader = this.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;

            if (workflowDesignerLoader != null && workflowDesignerLoader.InDebugMode)
            {
                throw new InvalidOperationException(Messages.DebugModeEditsDisallowed);
            }

            // Do not allow editing if locked
            PolicyActivity activity = (PolicyActivity)this.Activity;

            if (Helpers.IsActivityLocked(activity))
            {
                return;
            }

            RuleDefinitions rules = ConditionHelper.Load_Rules_DT(this, Helpers.GetRootActivity(activity));

            if (rules != null)
            {
                RuleSetCollection ruleSetCollection = rules.RuleSets;
                RuleSetReference  ruleSetReference  = activity.RuleSetReference;
                RuleSet           ruleSet           = null;
                string            ruleSetName       = null;
                if (ruleSetReference != null &&
                    !string.IsNullOrEmpty(ruleSetReference.RuleSetName))
                {
                    ruleSetName = ruleSetReference.RuleSetName;
                    if (ruleSetCollection.Contains(ruleSetName))
                    {
                        ruleSet = ruleSetCollection[ruleSetName];
                    }
                }
                else
                {
                    ruleSetName = ruleSetCollection.GenerateRuleSetName();
                }
                using (RuleSetDialog dlg = new RuleSetDialog(activity, ruleSet))
                {
                    if (DialogResult.OK == dlg.ShowDialog())
                    {
                        if (ruleSet != null) // modifying
                        {
                            ruleSetCollection.Remove(ruleSetName);
                        }
                        else // creating
                        {
                            dlg.RuleSet.Name          = ruleSetName;
                            activity.RuleSetReference = new RuleSetReference(ruleSetName);
                        }
                        ruleSetCollection.Add(dlg.RuleSet);
                        ConditionHelper.Flush_Rules_DT(this, Helpers.GetRootActivity(activity));
                    }
                }
            }

            // force revalidation by setting a property
            TypeDescriptor.GetProperties(activity)["RuleSetReference"].SetValue(activity, activity.RuleSetReference);
        }