Beispiel #1
0
        public WorkflowDialog SaveOrUpdateMerge(WorkflowDialog workflowDialog)
        {
            object mergedObj = Session.Merge(workflowDialog);

            HibernateTemplate.SaveOrUpdate(mergedObj);
            return((WorkflowDialog)mergedObj);
        }
Beispiel #2
0
        private void addDialogBtn_Click(object sender, EventArgs e)
        {
            SelectDialog form = new SelectDialog();

            form.FrontendApplication = FrontendApplication;
            form.BackendApplication  = BackendApplication;

            if (form.ShowDialog() == DialogResult.OK)
            {
                //if (Workflow.Module.Id != form.SelectedDialog.Module.Id)
                //{
                //        MessageBox.Show("You can only add Dialogs from the same Module as the Workflow.", "MetaManager");
                //        return;
                //}

                foreach (WorkflowDialog wfDialog in Workflow.Dialogs)
                {
                    if (wfDialog.Dialog.Id == form.SelectedDialog.Id)
                    {
                        MessageBox.Show("The selected Dialog is already present in the Workflow.", "MetaManager");
                        return;
                    }
                }

                Cdc.MetaManager.DataAccess.Domain.Dialog dialog = MetaManagerServices.GetDialogService().GetDialogWithViewTree(form.SelectedDialog.Id);

                WorkflowDialog workflowDialog = new WorkflowDialog();
                workflowDialog.Dialog   = dialog;
                workflowDialog.Workflow = Workflow;
                Workflow.Dialogs.Add(workflowDialog);

                Type activityType = WorkflowTypeFactory.CreateActivities(Workflow, this.BackendApplication, new Dialog[] { dialog }, new ServiceMethod[0], new DataAccess.Domain.Workflow[0]).Last();

                TypeProvider typeProvider = workflowControl.GetService(typeof(ITypeProvider)) as TypeProvider;
                typeProvider.AddAssembly(activityType.Assembly);
                workflowControl.ToolBox.AddToolBoxItem(new SelfHostToolboxItem(activityType));
            }
        }
Beispiel #3
0
        public static IList <Type> CreateActivities(Workflow workflow, Application backendApplication, IEnumerable <Dialog> dialogs, IEnumerable <ServiceMethod> serviceMethods, IEnumerable <Workflow> subworkflows)
        {
            IList <string> sources = new List <string>();

            AlarmActivityTemplate alarmTemplate = new AlarmActivityTemplate();

            alarmTemplate.SetProperty("module", workflow.Module);
            alarmTemplate.SetProperty("isDesignTime", true);
            alarmTemplate.SetProperty("backendApplication", backendApplication);
            sources.Add(alarmTemplate.RenderToString());

            DialogActivityTemplate dialogTemplate = new DialogActivityTemplate();

            foreach (Dialog dialog in dialogs)
            {
                WorkflowDialog workflowDialog = new WorkflowDialog();
                workflowDialog.Workflow = workflow;
                workflowDialog.Dialog   = dialog;
                dialogTemplate.SetProperty("workflowDialog", workflowDialog);
                dialogTemplate.SetProperty("isDesignTime", true);
                sources.Add(dialogTemplate.RenderToString());
            }

            ServiceMethodActivityTemplate serviceTemplate = new ServiceMethodActivityTemplate();

            foreach (ServiceMethod serviceMethod in serviceMethods)
            {
                WorkflowServiceMethod workflowServiceMethod = new WorkflowServiceMethod();
                workflowServiceMethod.Workflow      = workflow;
                workflowServiceMethod.ServiceMethod = serviceMethod;
                serviceTemplate.SetProperty("workflowServiceMethod", workflowServiceMethod);
                serviceTemplate.SetProperty("isDesignTime", true);
                sources.Add(serviceTemplate.RenderToString());
            }

            SubworkflowActivityTemplate subworkflowTemplate = new SubworkflowActivityTemplate();

            foreach (Workflow subworkflow in subworkflows)
            {
                WorkflowSubworkflow workflowSubworkflow = new WorkflowSubworkflow();
                workflowSubworkflow.Workflow    = workflow;
                workflowSubworkflow.SubWorkflow = subworkflow;

                subworkflowTemplate.SetProperty("workflowSubworkflow", workflowSubworkflow);
                subworkflowTemplate.SetProperty("isDesignTime", true);
                sources.Add(subworkflowTemplate.RenderToString());
            }

            ActivityThemeTemplate themeTemplate = new ActivityThemeTemplate();

            themeTemplate.SetProperty("workflow", workflow);
            sources.Add(themeTemplate.RenderToString());

            CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary <string, string>()
            {
                { "CompilerVersion", "v3.5" }
            });

            CompilerParameters options = new CompilerParameters();

            //options.TempFiles = new TempFileCollection("c:\\temp\\files\\", true);
            options.OutputAssembly = string.Format("Workflow_{0}.dll", Guid.NewGuid().ToString());
            options.ReferencedAssemblies.Add("System.dll");
            options.ReferencedAssemblies.Add("System.Core.dll");
            options.ReferencedAssemblies.Add("System.Drawing.dll");
            options.ReferencedAssemblies.Add("System.Workflow.ComponentModel.dll");
            options.ReferencedAssemblies.Add("System.Workflow.Activities.dll");

            CompilerResults results = provider.CompileAssemblyFromSource(options, sources.ToArray());

            var activityTypes = new List <Type>();

            foreach (Type type in results.CompiledAssembly.GetTypes())
            {
                if (type.BaseType == typeof(Activity))
                {
                    activityTypes.Add(type);
                }
            }

            return(activityTypes);
        }