示例#1
0
        private void LoadWorkflow()
        {
            var dialogs        = new List <Dialog>();
            var serviceMethods = new List <ServiceMethod>();
            var subworkflows   = new List <DataAccess.Domain.Workflow>();

            foreach (WorkflowDialog workflowDialog in Workflow.Dialogs)
            {
                Dialog dialog = MetaManagerServices.GetDialogService().GetDialogWithViewTree(workflowDialog.Dialog.Id);
                dialogs.Add(dialog);
            }

            foreach (WorkflowServiceMethod workflowServiceMethod in Workflow.ServiceMethods)
            {
                ServiceMethod serviceMethod = MetaManagerServices.GetApplicationService().GetServiceMethodMapsById(workflowServiceMethod.ServiceMethod.Id);
                serviceMethods.Add(serviceMethod);
            }

            foreach (WorkflowSubworkflow workflowSubworkflow in Workflow.Subworkflows)
            {
                DataAccess.Domain.Workflow subworkflow = MetaManagerServices.GetDialogService().GetWorkflowById(workflowSubworkflow.SubWorkflow.Id);
                subworkflows.Add(subworkflow);
            }

            IList <Type> activityTypes = new List <Type>();

            activityTypes = WorkflowTypeFactory.CreateActivities(Workflow, this.BackendApplication, dialogs, serviceMethods, subworkflows);

            if ((activityTypes.Count > 0) && (!string.IsNullOrEmpty(Workflow.WorkflowXoml)))
            {
                Workflow.WorkflowXoml = ReplaceAssemblyReferences(Workflow.WorkflowXoml, activityTypes[0].Assembly.GetName().Name);
            }

            workflowControl.LoadWorkflow(Workflow.WorkflowXoml, Workflow.RuleSetXml);
            workflowControl.RootActivity.Description = Workflow.Description;

            TypeProvider typeProvider = workflowControl.GetService(typeof(ITypeProvider)) as TypeProvider;

            if (activityTypes.Count > 0)
            {
                foreach (Type activityType in activityTypes)
                {
                    workflowControl.ToolBox.AddToolBoxItem(new SelfHostToolboxItem(activityType));
                }

                typeProvider.AddAssembly(activityTypes[0].Assembly);
            }

            sessionType = RuleContextFactory.LoadUserSessionType(Workflow.Module.Application);
            typeProvider.AddAssembly(sessionType.Assembly);
            requestType = WorkflowTypeFactory.CreateRequestType(Workflow);
            typeProvider.AddAssembly(requestType.Assembly);

            GenerateMembers();

            tbxName.Text = Workflow.Name;
        }
        private void editRuleBtn_Click(object sender, EventArgs e)
        {
            Module temp = new Module();

            temp.Application = FrontendApplication;
            temp.Name        = "temp";

            UXAction action = uxActionService.GetUXActionByIdWithMap(UXAction.Id);

            Type context = RuleContextFactory.CreateActionContext(action, temp);

            using (RuleSetDialog ruleSetDialog = new RuleSetDialog(context, null, UXAction.RuleSet))
            {
                ruleSetDialog.Text += string.Format(" [{0}]", UXAction.Name);

                if (ruleSetDialog.ShowDialog() == DialogResult.OK)
                {
                    if (this.IsEditable)
                    {
                        if (ruleSetDialog.RuleSet.Rules.Count == 0)
                        {
                            UXAction.RuleSet = null;
                        }
                        else
                        {
                            UXAction.RuleSet = ruleSetDialog.RuleSet;
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Your changes will not be saved since the action is not locked for editing. Check out the action and try again");
                        return;
                    }
                }
            }
        }