public void Remove_删除部署的流程_如果当前流程已存在实例则抛出异常_否则删除(string bpmnFile) { var ex = Record.Exception(() => { string bpmnName = string.Join("", ctx.Guid2IntString(Guid.NewGuid())); Deployment deployment = AsyncHelper.RunSync <Deployment>(() => ctx.DeployAsync(bpmnFile, bpmnName)); IProcessInstanceController instanceController = ctx.CreateWorkflowHttpProxy().GetProcessInstanceClient(); StartProcessInstanceCmd cmd = new StartProcessInstanceCmd { ProcessName = bpmnName, TenantId = ctx.TenantId, Variables = new Dictionary <string, object> { { "name", new string[] { "用户1" } } }, }; ProcessInstance[] instances = AsyncHelper.RunSync <ProcessInstance[]>(() => instanceController.Start(new StartProcessInstanceCmd[] { cmd })); Assert.True(instances.Length > 0); IProcessDefinitionDeployerController deployerController = ctx.CreateWorkflowHttpProxy().GetDefinitionDeployerClient(); AsyncHelper.RunSync(() => deployerController.Remove(deployment.Id)); }); Assert.NotNull(ex); Assert.IsType <Http400Exception>(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); }
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); }
public WorkflowClientController(WorkflowHttpClientProxyProvider workflowHttpClientProxy, IAccessTokenProvider accessToken, IHttpContextAccessor httpContextAccessor) { httpContext = httpContextAccessor.HttpContext; this.accessToken = accessToken; processInstanceClient = workflowHttpClientProxy.GetProcessInstanceClient(); taskClient = workflowHttpClientProxy.GetTaskClient(); taskAdminClient = workflowHttpClientProxy.GetTaskAdminClient(); deployerClient = workflowHttpClientProxy.GetDefinitionDeployerClient(); processDefinitionClient = workflowHttpClientProxy.GetProcessDefinitionClient(); processInstanceTaskClient = workflowHttpClientProxy.GetProcessInstanceTasksClient(); }
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); }
public ProcessDefinitionDeployerClientTest() { client = ctx.CreateWorkflowHttpProxy().GetDefinitionDeployerClient(); }