public void UpdateWorkflow(Workflow workflow)
        {
            MetaManagerServices.GetConfigurationManagementService().CheckOutDomainObject(workflow.Id, typeof(Workflow));

            Workflow readWorkflow = WorkflowDao.FindById(workflow.Id);

            XDocument x = XDocument.Load(XmlReader.Create(new StringReader(readWorkflow.WorkflowXoml)));

            var dialogs = from d in x.Descendants()
                          where d.Attribute("DialogId") != null
                          select d;

            foreach (XElement element in dialogs)
            {
                Dialog d = DialogDao.FindById(new Guid(element.Attribute("DialogId").Value));
                element.Name = XName.Get(WorkflowTypeFactory.GetDialogActivityClassName(d), element.Name.NamespaceName);
            }

            var serviceMethods = from s in x.Descendants()
                                 where s.Attribute("ServiceMethodId") != null
                                 select s;

            foreach (XElement element in serviceMethods)
            {
                ServiceMethod s = ServiceMethodDao.FindById(new Guid(element.Attribute("ServiceMethodId").Value));
                element.Name = XName.Get(WorkflowTypeFactory.GetServiceMethodActivityClassName(s), element.Name.NamespaceName);
            }

            readWorkflow.WorkflowXoml = x.ToString();

            WorkflowDao.SaveOrUpdate(readWorkflow);
        }
        public Workflow GetWorkflowById(Guid workflowId)
        {
            Workflow workflow = WorkflowDao.FindById(workflowId);

            NHibernateUtil.Initialize(workflow.Dialogs);
            NHibernateUtil.Initialize(workflow.ServiceMethods);
            NHibernateUtil.Initialize(workflow.Subworkflows);
            NHibernateUtil.Initialize(workflow.Module);
            NHibernateUtil.Initialize(workflow.Module.Application);

            MetaManagerUtil.InitializePropertyMap(workflow.RequestMap);

            return(workflow);
        }