示例#1
0
        public void RemoveVariables_启动流程实例_设置变量_移除变量(string bpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string uid             = Guid.NewGuid().ToString();
                ProcessInstance[] inst = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, new string[] { uid }));

                Assert.True(inst.Length > 0);

                IProcessInstanceVariableController varClient = ctx.CreateWorkflowHttpProxy().GetProcessInstanceVariableClient();

                Guid guidValue = Guid.NewGuid();

                AsyncHelper.RunSync(() => varClient.SetVariables(new SetProcessVariablesCmd(inst[0].Id, new Dictionary <string, object>
                {
                    { "guidValue", guidValue }
                })));

                Resources <ProcessInstanceVariable> variables = AsyncHelper.RunSync <Resources <ProcessInstanceVariable> >(() => varClient.GetVariables(inst[0].Id));

                ProcessInstanceVariable varInst = variables.List.FirstOrDefault(x => x.Name == "guidValue");

                Assert.True(guidValue == new Guid(varInst.Value.ToString()));

                AsyncHelper.RunSync(() => varClient.RemoveVariables(new RemoveProcessVariablesCmd(inst[0].Id, new string[] { "guidValue" })));

                variables = AsyncHelper.RunSync <Resources <ProcessInstanceVariable> >(() => varClient.GetVariables(inst[0].Id));

                varInst = variables.List.FirstOrDefault(x => x.Name == "guidValue");

                Assert.Null(varInst);
            });

            Assert.Null(ex);
        }
示例#2
0
        public Task <ProcessInstanceVariable> GetVariable(string processInstanceId, string variableName)
        {
            IVariableInstance variableInstance = runtimeService.GetVariableInstance(processInstanceId, variableName);

            ProcessInstanceVariable variable = new ProcessInstanceVariable(variableInstance.ProcessInstanceId, variableInstance.Name, variableInstance.TypeName, variableInstance.Value, variableInstance.ExecutionId);

            return(Task.FromResult(variable));
        }
示例#3
0
        public void SetVariables_启动流程实例设置实例变量_改变流程变量(string bpmnFile)
        {
            var ex = Record.Exception(() =>
            {
                string uid             = Guid.NewGuid().ToString();
                ProcessInstance[] inst = ctx.StartUseFile(bpmnFile, new string[] { uid }).GetAwaiter().GetResult();

                Assert.True(inst.Length > 0);

                IProcessInstanceVariableController varClient = ctx.CreateWorkflowHttpProxy().GetProcessInstanceVariableClient();

                Guid guidValue = Guid.NewGuid();

                Resources <ProcessInstanceVariable> variables = null;

                varClient.SetVariables(new SetProcessVariablesCmd(inst[0].Id, new Dictionary <string, object>
                {
                    { "guidValue", guidValue }
                })).GetAwaiter().GetResult();

                variables = varClient.GetVariables(inst[0].Id).GetAwaiter().GetResult();

                ProcessInstanceVariable varInst = variables.List.FirstOrDefault(x => x.Name == "guidValue");

                Assert.True(guidValue == new Guid(varInst.Value.ToString()));

                guidValue = Guid.NewGuid();

                varClient.SetVariables(new SetProcessVariablesCmd(inst[0].Id, new Dictionary <string, object>
                {
                    { "guidValue", guidValue }
                })).GetAwaiter().GetResult();

                variables = varClient.GetVariables(inst[0].Id).GetAwaiter().GetResult();

                varInst = variables.List.FirstOrDefault(x => x.Name == "guidValue");

                Assert.True(guidValue == new Guid(varInst.Value.ToString()));
            });

            Assert.Null(ex);
        }