public Task <Deployment> Deploy([FromBody] ProcessDefinitionDeployer deployer)
        {
            IDeploymentBuilder deployment = this.repositoryService.CreateDeployment();

            if (deployer.DisableSchemaValidation)
            {
                deployment.DisableSchemaValidation();
            }

            if (deployer.EnableDuplicateFiltering)
            {
                deployment.EnableDuplicateFiltering();
            }

            string resourceName = deployer.Name.EndsWith("bpmn", StringComparison.OrdinalIgnoreCase) ? deployer.Name : $"{deployer.Name}.bpmn";

            IDeployment dep = deployment.Name(deployer.Name)
                              .Category(deployer.Category)
                              .Key(deployer.Key)
                              .TenantId(deployer.TenantId)
                              .BusinessKey(deployer.BusinessKey)
                              .BusinessPath(deployer.BusinessPath)
                              .StartForm(deployer.StartForm, deployer.BpmnXML)
                              .AddString(resourceName, deployer.BpmnXML)
                              .Deploy();

            return(Task.FromResult(deploymentConverter.From(dep)));
        }
Exemplo n.º 2
0
        public Task <Deployment> Save(ProcessDefinitionDeployer deployer)
        {
            try
            {
                IDeploymentBuilder deployment = this.repositoryService
                                                .CreateDeployment()
                                                .DisableDuplicateStartForm();

                deployment.DisableBpmnValidation();
                deployment.DisableSchemaValidation();
                deployment.EnableDuplicateFiltering();

                string resourceName = deployer.Name.EndsWith("bpmn", StringComparison.OrdinalIgnoreCase) ? deployer.Name : $"{deployer.Name}.bpmn";

                IDeployment dep = deployment.Name(deployer.Name)
                                  .Category(deployer.Category)
                                  .Key(deployer.Key)
                                  .TenantId(deployer.TenantId)
                                  .BusinessKey(deployer.BusinessKey)
                                  .BusinessPath(deployer.BusinessPath)
                                  .StartForm(deployer.StartForm, deployer.BpmnXML)
                                  .AddString(resourceName, deployer.BpmnXML)
                                  .Save();

                return(Task.FromResult <Deployment>(deploymentConverter.From(dep)));
            }
            catch (StartFormUniqueException ex)
            {
                throw new Http400Exception(new Http400
                {
                    Code    = "startFormUniqueException",
                    Message = ex.Message
                }, ex);
            }
        }
        /// <summary>
        /// 部署流程
        /// </summary>
        /// <param name="bpmnFile"></param>
        /// <param name="bpmnName"></param>
        /// <returns></returns>
        public async Task <Deployment> DeployAsync(string bpmnFile, string bpmnName = null)
        {
            IProcessDefinitionDeployerController deployerClient = CreateWorkflowHttpProxy().GetDefinitionDeployerClient();

            string depBpmnName = string.IsNullOrWhiteSpace(bpmnName) ? Path.GetFileNameWithoutExtension(bpmnFile) : bpmnName;

            string xml = string.IsNullOrWhiteSpace(bpmnName) ? ReadBpmn(bpmnFile) :
                         ReadBpmn(bpmnFile, bpmnName);

            ProcessDefinitionDeployer deployer = new ProcessDefinitionDeployer
            {
                Name     = depBpmnName,
                BpmnXML  = xml,
                TenantId = TenantId,
                EnableDuplicateFiltering = false
            };

            Deployment deployment = await deployerClient.Deploy(deployer).ConfigureAwait(false);

            var list = await deployerClient.Latest(new DeploymentQuery
            {
                Ids      = new string[] { deployment.Id },
                TenantId = TenantId
            }).ConfigureAwait(false);

            Assert.NotNull(list);
            Assert.True(list.List.Count() == 1);


            return(deployment);
        }
Exemplo n.º 4
0
        public Task <Deployment> Deploy([FromBody] ProcessDefinitionDeployer deployer)
        {
            try
            {
                IDeploymentBuilder deployment = this.repositoryService.CreateDeployment();

                if (deployer.DisableSchemaValidation)
                {
                    deployment.DisableSchemaValidation();
                }

                if (deployer.EnableDuplicateFiltering)
                {
                    deployment.EnableDuplicateFiltering();
                }

                string resourceName = deployer.Name.EndsWith("bpmn", StringComparison.OrdinalIgnoreCase) ? deployer.Name : $"{deployer.Name}.bpmn";

                IDeployment dep = deployment.Name(deployer.Name)
                                  .Category(deployer.Category)
                                  .Key(deployer.Key)
                                  .TenantId(deployer.TenantId)
                                  .BusinessKey(deployer.BusinessKey)
                                  .BusinessPath(deployer.BusinessPath)
                                  .StartForm(deployer.StartForm, deployer.BpmnXML)
                                  .AddString(resourceName, deployer.BpmnXML)
                                  .Deploy();

                return(Task.FromResult(deploymentConverter.From(dep)));
            }
            catch (ActivitiValidationException ex)
            {
                var http400 = new Http400()
                {
                    Code    = "activitiValidationException",
                    Message = "流程定义验证失败",
                    Target  = this.GetType().Name,
                };

                http400.Details = new List <HttpException>();
                foreach (var err in ex.ValidationErrors ?? new List <ValidationError>())
                {
                    http400.Details.Add(new Http400
                    {
                        Code        = "activitiValidationException",
                        OriginError = err,
                        Message     = err.ToString()
                    });
                }

                throw new Http400Exception(http400, ex);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 保存为草稿
        /// </summary>
        /// <param name="bpmnFile"></param>
        /// <param name="bpmnName"></param>
        /// <returns></returns>
        private async Task <Deployment> Save(string bpmnFile, string bpmnName)
        {
            string xml = ctx.ReadBpmn(bpmnFile, bpmnName);

            ProcessDefinitionDeployer deployer = new ProcessDefinitionDeployer
            {
                Name     = bpmnName,
                BpmnXML  = xml,
                TenantId = ctx.TenantId
            };

            Deployment deployment = await client.Save(deployer).ConfigureAwait(false);

            return(deployment);
        }
Exemplo n.º 6
0
        public Deployment Deploy(string bpmnFile)
        {
            string xml = IntegrationTestContext.ReadBpmn(bpmnFile);

            ProcessDefinitionDeployer deployer = new ProcessDefinitionDeployer
            {
                Name     = Path.GetFileNameWithoutExtension(bpmnFile),
                BpmnXML  = xml,
                TenantId = ctx.TenantId,
                EnableDuplicateFiltering = false
            };

            Deployment deployment = AsyncHelper.RunSync <Deployment>(() => client.Deploy(deployer));

            return(deployment);
        }
Exemplo n.º 7
0
        public async void 使用表单启动流程(string bpmnFile)
        {
            var ex = await Record.ExceptionAsync(async() =>
            {
                string formKey = Guid.NewGuid().ToString();

                IProcessDefinitionDeployerController deployerClient = ctx.CreateWorkflowHttpProxy().GetDefinitionDeployerClient();

                string depBpmnName = Path.GetFileNameWithoutExtension(bpmnFile);

                string xml = IntegrationTestContext.ReadBpmn(bpmnFile);

                XDocument doc = XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(xml)), LoadOptions.PreserveWhitespace);

                XElement elem = doc.Descendants(XName.Get("startEvent", BpmnXMLConstants.BPMN2_NAMESPACE)).First();

                XAttribute attr = elem.Attribute(XName.Get("formKey", BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE));
                attr.Value      = formKey;
                xml             = doc.ToString();

                ProcessDefinitionDeployer deployer = new ProcessDefinitionDeployer
                {
                    Name     = depBpmnName,
                    BpmnXML  = xml,
                    TenantId = ctx.TenantId,
                    EnableDuplicateFiltering = false
                };

                Deployment deployment = await deployerClient.Deploy(deployer).ConfigureAwait(false);

                ProcessInstance[] insts = await client.Start(new StartProcessInstanceCmd[]
                {
                    new StartProcessInstanceCmd
                    {
                        StartForm = formKey,
                        TenantId  = ctx.TenantId
                    }
                }).ConfigureAwait(false);

                Assert.Single(insts);
            }).ConfigureAwait(false);

            Assert.Null(ex);
        }
        /// <summary>
        /// 部署流程
        /// </summary>
        /// <param name="bpmnFile"></param>
        /// <param name="bpmnName"></param>
        /// <returns></returns>
        public Deployment Deploy(string bpmnFile, string bpmnName = null)
        {
            IProcessDefinitionDeployerController deployerClient = CreateWorkflowHttpProxy().GetDefinitionDeployerClient();

            string depBpmnName = string.IsNullOrWhiteSpace(bpmnName) ? Path.GetFileNameWithoutExtension(bpmnFile) : bpmnName;

            string xml = string.IsNullOrWhiteSpace(bpmnName) ? ReadBpmn(bpmnFile) :
                         ReadBpmn(bpmnFile, bpmnName);

            ProcessDefinitionDeployer deployer = new ProcessDefinitionDeployer
            {
                Name     = depBpmnName,
                BpmnXML  = xml,
                TenantId = TenantId,
                EnableDuplicateFiltering = false
            };

            Deployment deployment = deployerClient.Deploy(deployer).GetAwaiter().GetResult();

            return(deployment);
        }
 /// <inheritdoc />
 public async Task <Deployment> Save(ProcessDefinitionDeployer deployer)
 {
     return(await httpProxy.PostAsync <Deployment>($"{serviceUrl}/save", deployer).ConfigureAwait(false));
 }