/// <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);
        }
Пример #2
0
        public async Task Start_完成用户注册路径_女(string bpmnFile)
        {
            var ex = await Record.ExceptionAsync(async() =>
            {
                IProcessDefinitionDeployerController pdc = ctx.CreateWorkflowHttpProxy().GetDefinitionDeployerClient();

                string formKey = Guid.NewGuid().ToString();

                string xml    = IntegrationTestContext.ReadBpmn(bpmnFile);
                XDocument doc = XDocument.Load(new MemoryStream(Encoding.UTF8.GetBytes(xml)), LoadOptions.PreserveWhitespace);
                var elem      = doc.Descendants(XName.Get("startEvent", BpmnXMLConstants.BPMN2_NAMESPACE)).First();
                elem.Attribute(XName.Get("formKey", BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE)).Value = formKey;

                Deployment deployment = await pdc.Deploy(new ProcessDefinitionDeployer
                {
                    BpmnXML  = doc.ToString(),
                    Name     = Path.GetFileNameWithoutExtension(bpmnFile),
                    TenantId = ctx.TenantId
                }).ConfigureAwait(false);

                string uid = Guid.NewGuid().ToString();
                StartProcessInstanceCmd cmd = new StartProcessInstanceCmd()
                {
                    StartForm = formKey,
                    Variables = new Dictionary <string, object>
                    {
                        { "User", new string[] { uid } }
                    },
                    TenantId = ctx.TenantId
                };

                ProcessInstance[] instances = AsyncHelper.RunSync <ProcessInstance[]>(() => client.Start(new StartProcessInstanceCmd[] { cmd }));

                Assert.NotNull(instances);
                Assert.True(instances.Count() > 0);

                ITaskController tc = ctx.CreateWorkflowHttpProxy().GetTaskClient();

                Resources <TaskModel> myTasks = null;

                while (true)
                {
                    myTasks = await Complete(tc, uid, new Dictionary <string, object>
                    {
                        { "gender", 2 }
                    }).ConfigureAwait(false);

                    if (myTasks == null || myTasks.TotalCount <= 0)
                    {
                        break;
                    }
                }
            }).ConfigureAwait(false);

            Assert.Null(ex);
        }
Пример #3
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);
        }
Пример #4
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);
        }