/// <summary> /// 构造函数 /// </summary> /// <param name="processId">实例id</param> /// <param name="variables">变量列表</param> ////[JsonConstructor] public SetProcessVariablesCmd([JsonProperty("ProcessId")] string processId, [JsonProperty("Variables")] WorkflowVariable variables) { this.id = Guid.NewGuid().ToString(); this.processId = processId; this.variables = variables; }
public string TriggerWorkflowAction([FromBody] WorkflowServiceParameter param) { try { logger.InfoFormat("Triggering workflow action: EntityId = {0}, EntityType = {1}, WorkflowInstanceId = {2}, ActionName = {3}, CurrentUserId = {4}, Comment = {5}, WorkflowVersion = {6}, WorkflowDefinitionId = {7}", param.EntityId, param.EntityType, param.WorkflowInstanceId, param.ActionName, param.CurrentUserId, param.Comment, param.WorkflowVersion, param.WorkflowDefinitionId); //new workflow definition from workflow repository var workflowDefinition = GetWorkflowDefinition(param); WorkflowApplication wfApp = null; var variable = new WorkflowVariable { EntityId = param.EntityId, EntityType = param.EntityType, WorkflowDefinitionId = param.WorkflowDefinitionId, CurrentUserId = param.CurrentUserId, CurrentAction = param.ActionName, CurrentComment = param.Comment }; wfApp = CustomWorkflowManager.ResumeWorkflow(workflowDefinition, new Guid(param.WorkflowInstanceId), param.ActionName, variable); logger.InfoFormat("Triggered workflow action: EntityId = {0}, EntityType = {1}, WorkflowInstanceId = {2}, ActionName = {3}, CurrentUserId = {4}, Comment = {5}, WorkflowVersion = {6}, WorkflowDefinitionId = {7}", param.EntityId, param.EntityType, param.WorkflowInstanceId, param.ActionName, param.CurrentUserId, param.Comment, param.WorkflowVersion, param.WorkflowDefinitionId); return(wfApp.Id.ToString()); } catch (Exception ex) { //log exception logger.ErrorFormat("TriggerWorkflowAction: {0}", ex.Message); throw this.ExceptionInternalServerError(ex); } }
public void Workflow_AddExistingVariable_VariableAdded() { // Arrange var correlationId = 100; var type = EntityOnOffWorkflow.TYPE; var state = "Off"; var assignee = "alice"; var workflow = Workflow.Create(correlationId, type, state, assignee); var variable = new LightSwitcherWorkflowVariable(); workflow.AddVariable(variable); var existingVariable = new LightSwitcherWorkflowVariable { CanSwitch = true }; // Act workflow.AddVariable(existingVariable); // Assert Assert.NotNull(workflow); Assert.Single(workflow.WorkflowVariables); var wv = workflow.WorkflowVariables.First(); var v = (LightSwitcherWorkflowVariable)WorkflowVariable.ConvertContent(wv); Assert.True(v.CanSwitch); }
/// <summary> /// 构造函数 /// </summary> /// <param name="taskId">任务id</param> /// <param name="comments">审批意见</param> /// <param name="variables">流程变量</param> //[JsonConstructor] public ApprovaleTaskCmd([JsonProperty("TaskId")] string taskId, [JsonProperty("Comments")] string comments, [JsonProperty("Variables")] WorkflowVariable variables) { this.TaskId = taskId; this.Comments = comments; this.Variables = variables; }
//[JsonConstructor] //public StartProcessInstanceCmd([JsonProperty("ProcessDefinitionKey")]string processDefinitionKey, // [JsonProperty("ProcessDefinitionId")]string processDefinitionId, // [JsonProperty("Variables")]IDictionary<string, object> variables, // [JsonProperty("BusinessKey")]string businessKey) : this() //{ // this.processDefinitionKey = processDefinitionKey; // this.processDefinitionId = processDefinitionId; // this.variables = variables; // this.businessKey = businessKey; //} /// <summary> /// 构造函数 /// </summary> /// <param name="processDefinitionId">流程定义id</param> /// <param name="variables">流程变量</param> //[JsonConstructor] public StartProcessInstanceCmd( [JsonProperty("ProcessDefinitionId")] string processDefinitionId, [JsonProperty("Variables")] WorkflowVariable variables) : this() { this.processDefinitionId = processDefinitionId; this.variables = variables; }
/// <summary> /// 构造函数 /// </summary> /// <param name="taskId">任务id</param> /// <param name="rejectReason">拒绝原因</param> /// <param name="variables">任务附件变量</param> //[JsonConstructor] public RejectTaskCmd([JsonProperty("TaskId")] string taskId, [JsonProperty("ReturnReason")] string rejectReason, [JsonProperty("Variables")] WorkflowVariable variables) { this.TaskId = taskId; this.RejectReason = rejectReason; this.Variables = variables; }
/// <summary> /// 构造函数 /// </summary> /// <param name="taskId">任务id</param> /// <param name="outputVariables">提交的数据</param> /// <param name="runtimeAssignUser">如果下一步需要从当前任务中指定人员处理,则使用这个参数</param> ////[JsonConstructor] public CompleteTaskCmd([JsonProperty("TaskId")] string taskId, [JsonProperty("OutputVariables")] WorkflowVariable outputVariables, [JsonProperty("RuntimeAssignUsers")] RuntimeAssigneeUser runtimeAssignUser) { this.taskId = taskId; this.outputVariables = outputVariables; this.RuntimeAssigneeUser = runtimeAssignUser; }
/// <summary> /// 构造函数 /// </summary> /// <param name="inputVariables">变量</param> /// <param name="name">名称</param> //[JsonConstructor] public SignalCmd( [JsonProperty("Name")] string name, [JsonProperty("TenantId")] string tenantId, [JsonProperty("InputVariables")] WorkflowVariable inputVariables = null) : this() { this.name = name; this.inputVariables = inputVariables; this.TenantId = tenantId; }
protected override void Execute(CodeActivityContext context) { var workflowInput = this.WorkflowInput.Get(context); var workflowVariable = this.WorkflowVariable.Get(context); //in case of start workflow, variable workflowVariable will be null if (workflowVariable == null) { workflowVariable = new WorkflowVariable { CurrentUserId = workflowInput.CreatedUserId, CurrentAction = "", CurrentComment = "", EntityId = workflowInput.EntityId, EntityType = workflowInput.EntityType, WorkflowDefinitionId = workflowInput.WorkflowDefinitionId } } ; //set the currentUser to ThreadStatic to be used later var userRepository = WorkflowServiceEngine.Instance.WorkflowContainerManager.Resolve <IRepository <User> >(); var currentUser = userRepository.GetById(workflowVariable.CurrentUserId); WorkflowContext.CurrentUser = currentUser; //create assignment var expectedDateTime = this.ExpectedStartDateTime.Get(context); var dueDateTime = this.DueDateTime.Get(context); // if Users is a C# method then we handle it here var result = ActivityHelper.GetUsers(Users, workflowInput.EntityId); if (!string.IsNullOrEmpty(result)) { Users = result; } // create assignment var wfService = WorkflowServiceEngine.Instance.WorkflowContainerManager.Resolve <IWorkflowBaseService>(); wfService.CreateApproveAssignment(workflowVariable.EntityId, workflowVariable.EntityType, currentUser, context.WorkflowInstanceId.ToString(), workflowVariable.WorkflowDefinitionId, Name, expectedDateTime, dueDateTime, Users, workflowVariable.CurrentAction, workflowVariable.CurrentComment, this.MessageTemplate ); } }
public void WorkflowVariable_FromObject_测试() { var data = new ObjectData { ReviewDays = 10 }; WorkflowVariable wv = WorkflowVariable.FromObject(data); var obj = ExpressionEvaluator.GetValue(wv, "DateTimeHelper.AddDays(ReviewDays)"); }
/// <summary> /// 构造函数 /// </summary> /// <param name="taskId">任务id</param> /// <param name="rejectReason">拒绝原因</param> /// <param name="variables">任务附件变量</param> //[JsonConstructor] public ReturnToTaskCmd([JsonProperty("TaskId")] string taskId, [JsonProperty("ActivityId")] string activityId, [JsonProperty("ReturnReason")] string returnReason, [JsonProperty("Variables")] WorkflowVariable variables) { this.TaskId = taskId; this.ReturnReason = returnReason; this.ActivityId = activityId; this.Variables = variables; }
/// <summary> /// 构造函数 /// </summary> /// <param name="processInstanceId">流程实例id</param> /// <param name="reason">终止原因</param> //[JsonConstructor] public TerminateProcessInstanceCmd([JsonProperty("ProcessInstanceId")] string processInstanceId, [JsonProperty("BusinessKey")] string businessKey, [JsonProperty("Reason")] string reason, [JsonProperty("OutputVariables")] WorkflowVariable outputVariables) { BusinessKey = businessKey; ProcessInstanceId = processInstanceId; Reason = reason; OutputVariables = outputVariables; }
/// <summary> /// 构造函数 /// </summary> /// <param name="taskId">任务id</param> /// <param name="terminateReason">终止原因</param> //[JsonConstructor] public TerminateTaskCmd([JsonProperty("TaskId")] string taskId, [JsonProperty("Description")] string terminateReason, [JsonProperty("TerminateExecution")] bool terminateExecution, [JsonProperty("OutputVariables")] WorkflowVariable outputVariables) : this() { this.TaskId = taskId; this.TerminateReason = terminateReason; this.TerminateExecution = terminateExecution; this.outputVariables = outputVariables; }
public void 主活动终止事件同时终止子活动(string bpmnFile, string subBpmnFile) { var ex = Record.Exception(() => { string 主任务 = Guid.NewGuid().ToString(); string 一任务 = Guid.NewGuid().ToString(); string[] subUsers = new string[] { Guid.NewGuid().ToString() }; string[] subUsers1 = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; var bizIds = new string[] { Guid.NewGuid().ToString() }; ctx.Deploy(bpmnFile); ctx.Deploy(subBpmnFile); WorkflowVariable vars = new WorkflowVariable(); vars.AddAssignee(nameof(主任务), 主任务) .AddAssignee(nameof(一任务), 一任务) .AddAssignee(nameof(subUsers), subUsers) .AddAssignee(nameof(subUsers1), subUsers1); vars.Add("ids", bizIds); string bizId = Guid.NewGuid().ToString(); ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult(); ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient(); Assert.NotEmpty(taskClient.MyTasks(主任务).GetAwaiter().GetResult().List); Assert.NotEmpty(taskClient.MyTasks(subUsers[0]).GetAwaiter().GetResult().List); ///完成主任务节点的任务 taskClient.CompleteTask(new CompleteTaskCmd { BusinessKey = bizId, Assignee = 主任务 }).GetAwaiter().GetResult(); Assert.Empty(taskClient.MyTasks(subUsers[0]).GetAwaiter().GetResult().List); Assert.Empty(taskClient.MyTasks(一任务).GetAwaiter().GetResult().List); var pi = ctx.CreateWorkflowHttpProxy().GetProcessInstanceClient().GetProcessInstanceById(instances[0].Id).GetAwaiter().GetResult(); }); Assert.NotNull(ex); }
/// <summary> /// 构造函数 /// </summary> /// <param name="processDefinitionId">流程定义id</param> /// <param name="variables">流程变量</param> //[JsonConstructor] public StartProcessInstanceCmd( [JsonProperty("ProcessDefinitionBusinessKey")] string processDefinitionBusinessKey, [JsonProperty("ProcessDefinitionKey")] string processDefinitionKey, [JsonProperty("ProcessDefinitionId")] string processDefinitionId, [JsonProperty("Variables")] WorkflowVariable variables, [JsonProperty("BusinessKey")] string businessKey, [JsonProperty("InitialFlowElementId")] string initialFlowElementId) : this() { this.processDefinitionId = processDefinitionId; this.processDefinitionKey = processDefinitionKey; this.businessKey = businessKey; this.variables = variables; this.initialFlowElementId = initialFlowElementId; }
/// <summary> /// 构造函数 /// </summary> /// <param name="name">任务名称</param> /// <param name="description">任务描述</param> /// <param name="dueDate">过期日期</param> /// <param name="priority">任务优先级</param> /// <param name="assignees">转办人员列表</param> /// <param name="taskId">转办的任务id</param> /// <param name="tenantId">租户id</param> /// <param name="variables">流程变量</param> ////[JsonConstructor] public TransferTaskCmd([JsonProperty("Name")] string name, [JsonProperty("Description")] string description, [JsonProperty("DueDate")] DateTime?dueDate, [JsonProperty("Priority")] int?priority, [JsonProperty("Assignees")] string[] assignees, [JsonProperty("TaskId")] string taskId, [JsonProperty("TenantId")] string tenantId, [JsonProperty("Variables")] WorkflowVariable variables) { this.Name = name; this.Description = description; this.DueDate = dueDate; this.Priority = priority; this.Assignees = assignees; this.TaskId = taskId; this.TenantId = tenantId; this.Variables = variables; }
public async Task <bool> Reject(string id) { //处理业务部分内容 IUserInfo user = await accessToken.FromRequestHeaderAsync(httpContext); WorkflowVariable workflowVariable = new WorkflowVariable(); workflowVariable.Approvaled = false; //提交流程 await taskClient.CompleteTask(new CompleteTaskCmd { BusinessKey = id, Assignee = user.Id, OutputVariables = workflowVariable }); return(true); }
private void EnsureWorkflowVariables(Workflow workflow, TriggerParam param) { if (workflow.WorkflowVariables.Count == 0) { return; } foreach (var workflowVariable in workflow.WorkflowVariables) { var variable = WorkflowVariable.ConvertContent(workflowVariable); if (variable is WorkflowVariableBase) { var key = workflowVariable.Type; if (param.Variables.ContainsKey(key)) { param.Variables[key] = variable as WorkflowVariableBase; } else { param.Variables.Add(key, variable as WorkflowVariableBase); } } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="inputVariables">变量</param> /// <param name="name">名称</param> //[JsonConstructor] public SignalCmd([JsonProperty("Name")] string name, [JsonProperty("InputVariables")] WorkflowVariable inputVariables) : this() { this.name = name; this.inputVariables = inputVariables; }
public void 部分完成并行子活动(string bpmnFile, string subBpmnFile) { var ex = Record.Exception(() => { string teachers = Guid.NewGuid().ToString(); string students = Guid.NewGuid().ToString(); string[] subUsers = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; string[] subUsers1 = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; var bizIds = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; ctx.Deploy(bpmnFile); ctx.Deploy(subBpmnFile); WorkflowVariable vars = new WorkflowVariable(); vars.AddAssignee(nameof(teachers), teachers) .AddAssignee(nameof(students), students) .AddAssignee(nameof(subUsers), subUsers) .AddAssignee(nameof(subUsers1), subUsers1); string bizId = Guid.NewGuid().ToString(); ProcessInstance[] instances = AsyncHelper.RunSync(() => ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId)); ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient(); TaskModel task = AsyncHelper.RunSync(() => taskClient.MyTasks(teachers)).List.FirstOrDefault(); _ = AsyncHelper.RunSync(() => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = task.Id, OutputVariables = WorkflowVariable.FromObject(new { ids = bizIds, 完成 = true }), NotFoundThrowError = true })); ///完成子任务节点1的任务 foreach (var uid in subUsers) { var myTasks = AsyncHelper.RunSync(() => taskClient.MyTasks(uid)).List.ToList(); myTasks.ForEach(tsk => AsyncHelper.RunSync(() => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = tsk.Id }))); } { //任务节点1仅完成子用户1的任务,子活动1应该停在任务节点2 var myTask = AsyncHelper.RunSync(() => taskClient.MyTasks(subUsers1[0])).List.First(); AsyncHelper.RunSync(() => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = myTask.Id })); //完成子活动2的所有任务 var myTasks = AsyncHelper.RunSync(() => taskClient.MyTasks(subUsers1[1])).List.ToList(); myTasks.ForEach(tsk => AsyncHelper.RunSync(() => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = tsk.Id }))); } var sTasks = AsyncHelper.RunSync(() => taskClient.MyTasks(students)).List; Assert.Empty(sTasks); }); Assert.Null(ex); }
/// <summary> /// 构造函数 /// </summary> /// <param name="taskId">任务id</param> /// <param name="variables">变量列表</param> ////[JsonConstructor] public SetTaskVariablesCmd([JsonProperty("TaskId")] string taskId, [JsonProperty("Variables")] WorkflowVariable variables) { this.taskId = taskId; this.variables = variables; }
public void 部分完成并行子活动(string bpmnFile, string subBpmnFile) { var ex = Record.Exception(() => { string teachers = Guid.NewGuid().ToString(); string students = Guid.NewGuid().ToString(); string[] subUsers = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; string[] subUsers1 = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; var bizIds = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; ctx.Deploy(bpmnFile); ctx.Deploy(subBpmnFile); WorkflowVariable vars = new WorkflowVariable(); vars.AddAssignee(nameof(teachers), teachers) .AddAssignee(nameof(students), students) .AddAssignee(nameof(subUsers), subUsers) .AddAssignee(nameof(subUsers1), subUsers1); vars.Add("ids", bizIds); string bizId = Guid.NewGuid().ToString(); ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult(); ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient(); ///完成子任务节点1的任务 foreach (var uid in subUsers) { var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List.ToList(); myTasks.ForEach(tsk => { taskClient.CompleteTask(new CompleteTaskCmd { TaskId = tsk.Id }).GetAwaiter().GetResult(); }); } { //任务节点1仅完成子用户1的任务,子活动1应该停在任务节点2 var myTask = taskClient.MyTasks(subUsers1[0]).GetAwaiter().GetResult().List.First(); _ = taskClient.CompleteTask(new CompleteTaskCmd { TaskId = myTask.Id }).GetAwaiter().GetResult(); //完成子活动2的所有任务 var myTasks = taskClient.MyTasks(subUsers1[1]).GetAwaiter().GetResult().List.ToList(); myTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = tsk.Id }).GetAwaiter().GetResult()); Assert.NotEmpty(taskClient.MyTasks(subUsers1[0]).GetAwaiter().GetResult().List); } var sTasks = taskClient.MyTasks(students).GetAwaiter().GetResult().List; Assert.Empty(sTasks); }); Assert.Null(ex); }
public void 调用子活动(string bpmnFile, string subBpmnFile) { var ex = Record.Exception(() => { string teachers = Guid.NewGuid().ToString(); string students = Guid.NewGuid().ToString(); string[] subUsers = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; string[] subUsers1 = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; var bizIds = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; ctx.Deploy(bpmnFile); ctx.Deploy(subBpmnFile); WorkflowVariable vars = new WorkflowVariable(); vars.AddAssignee(nameof(teachers), teachers) .AddAssignee(nameof(students), students) .AddAssignee(nameof(subUsers), subUsers) .AddAssignee(nameof(subUsers1), subUsers1); string bizId = Guid.NewGuid().ToString(); ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult(); ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient(); TaskModel task = taskClient.MyTasks(teachers).GetAwaiter().GetResult().List.FirstOrDefault(); _ = taskClient.CompleteTask(new CompleteTaskCmd { TaskId = task.Id, OutputVariables = WorkflowVariable.FromObject(new { ids = bizIds, 完成 = true }), NotFoundThrowError = true }).GetAwaiter().GetResult(); Resources <TaskModel> tasks = ctx.CreateWorkflowHttpProxy().GetProcessInstanceTasksClient() .GetTasks(new ProcessInstanceTaskQuery() { IncludeCompleted = false, ProcessInstanceId = instances[0].Id }).GetAwaiter().GetResult(); foreach (var uid in subUsers) { var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List.ToList(); myTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = tsk.Id }).GetAwaiter().GetResult()); } foreach (var uid in subUsers1) { var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List.ToList(); myTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = tsk.Id }).GetAwaiter().GetResult()); } var sTasks = taskClient.MyTasks(students).GetAwaiter().GetResult().List.ToList(); sTasks.ForEach(tsk => taskClient.CompleteTask(new CompleteTaskCmd { TaskId = tsk.Id }).GetAwaiter().GetResult()); ctx.CreateWorkflowHttpProxy().GetProcessInstanceClient().GetProcessInstanceById(instances[0].Id).GetAwaiter().GetResult(); }); Assert.NotNull(ex); }
public void 使用子活动BUSINEEKEY完成并行子活动(string bpmnFile, string subBpmnFile) { var ex = Record.Exception(() => { string teachers = Guid.NewGuid().ToString(); string students = Guid.NewGuid().ToString(); string[] subUsers = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; string[] subUsers1 = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; var bizIds = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; ctx.Deploy(bpmnFile); ctx.Deploy(subBpmnFile); WorkflowVariable vars = new WorkflowVariable(); vars.AddAssignee(nameof(teachers), teachers) .AddAssignee(nameof(students), students) .AddAssignee(nameof(subUsers), subUsers) .AddAssignee(nameof(subUsers1), subUsers1); vars.Add("ids", bizIds); string bizId = Guid.NewGuid().ToString(); ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult(); ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient(); ///完成子任务节点1的任务 foreach (var uid in subUsers) { foreach (var bid in bizIds) { taskClient.CompleteTask(new CompleteTaskCmd { Assignee = uid, BusinessKey = bid }).GetAwaiter().GetResult(); } } //完成子活动1,2的所有任务 foreach (var uid in subUsers1) { foreach (var bid in bizIds) { taskClient.CompleteTask(new CompleteTaskCmd { Assignee = uid, BusinessKey = bid }).GetAwaiter().GetResult(); } } var sTasks = taskClient.MyTasks(students).GetAwaiter().GetResult().List; Assert.NotEmpty(sTasks); }); Assert.Null(ex); }
public void 完成并行子活动(string bpmnFile, string subBpmnFile) { var ex = Record.Exception(() => { string teachers = Guid.NewGuid().ToString(); string students = Guid.NewGuid().ToString(); string[] subUsers = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; string[] subUsers1 = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; var bizIds = new string[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }; ctx.Deploy(bpmnFile); ctx.Deploy(subBpmnFile); WorkflowVariable vars = new WorkflowVariable(); vars.AddAssignee(nameof(teachers), teachers) .AddAssignee(nameof(students), students) .AddAssignee(nameof(subUsers), subUsers) .AddAssignee(nameof(subUsers1), subUsers1); vars.Add("ids", bizIds); string bizId = Guid.NewGuid().ToString(); ProcessInstance[] instances = ctx.StartUseFile(bpmnFile, null, vars, businessKey: bizId).GetAwaiter().GetResult(); ITaskController taskClient = ctx.CreateWorkflowHttpProxy().GetTaskClient(); ///完成子任务节点1的任务 foreach (var uid in subUsers) { var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List; Task.WhenAll(Enumerable.Select(myTasks, (task) => { return(taskClient.CompleteTask(new CompleteTaskCmd { TaskId = task.Id })); })).GetAwaiter().GetResult(); } { //完成子活动1,2的所有任务 foreach (var uid in subUsers1) { var myTasks = taskClient.MyTasks(uid).GetAwaiter().GetResult().List; taskClient.CompleteTask(myTasks.Select(tsk => new CompleteTaskCmd { TaskId = tsk.Id }).ToArray()).GetAwaiter().GetResult(); } } var sTasks = taskClient.MyTasks(students).GetAwaiter().GetResult().List; Assert.NotEmpty(sTasks); }); Assert.Null(ex); }
public static void Example1() { everymessageCredential credential = everymessageCredential.Create("demo", "2sd3ODILm5wXzcWPPKe4CwPK9gDEPk@JsAL7q9!pKANCJWtwN0!skDRta67z@NvY"); WorkflowClient client = WorkflowClient.Create("https://api.everymessage.com/workflow/", credential); // SUBMIT example SubmitRecordsRequest submitRequest = new SubmitRecordsRequest() { InstanceName = "demo_simple_sms", Records = new List <WorkflowRecord>() { new WorkflowRecord() { PrimaryReference = "DEMO001", FirstName = "Mark", PhoneNumber = "07777777777", Variables = new List <WorkflowVariable>() { WorkflowVariable.Create("amount", 311.24M), WorkflowVariable.Create("due", DateTime.Now.ToString("dd MMM yyyy")) } }, new WorkflowRecord() { PrimaryReference = "DEMO002", FirstName = "Hannah", PhoneNumber = "07777777778", Variables = new List <WorkflowVariable>() { WorkflowVariable.Create("amount", 16.07M), WorkflowVariable.Create("due", DateTime.Now.ToString("dd MMM yyyy")) } } } }; var submitResponse = client.SubmitRecords(submitRequest); // QUERY example QueryRecordsRequest queryRequest = new QueryRecordsRequest() { Records = new List <long>() { submitResponse.Body.Records[0].WorkflowRecordId, submitResponse.Body.Records[1].WorkflowRecordId }, IncludeActivities = true, IncludeSmsInformation = true, IncludeEmailInformation = true, IncludeRepositoryData = true }; var queryResponse = client.QueryRecords(queryRequest); // DELETE example DeleteRecordsRequest deleteRequest = new DeleteRecordsRequest() { Records = new List <long>() { submitResponse.Body.Records[0].WorkflowRecordId, submitResponse.Body.Records[1].WorkflowRecordId } }; var deleteResponse = client.DeleteRecords(deleteRequest); Console.Read(); }
private async Task <Resources <TaskModel> > Complete(ITaskController tc, string userId, WorkflowVariable vars) { Resources <TaskModel> tasks = await tc.MyTasks(userId).ConfigureAwait(false); TaskModel task = tasks.List.FirstOrDefault(); await tc.CompleteTask(new CompleteTaskCmd { TaskId = task.Id, OutputVariables = vars }).ConfigureAwait(false); tasks = await tc.MyTasks(userId).ConfigureAwait(false); return(tasks); }
public static WorkflowApplication ResumeWorkflow(System.Activities.Activity workflowDefinition, Guid instanceId, string actionName, WorkflowVariable variable) { // Try to load the workflow and resume the bookmark var ars = new AutoResetEvent(false); WorkflowApplication wfApp = CreateWorkflowApplication(workflowDefinition); InstanceHandle ownerHandle = InitializeInstanceStore(workflowDefinition, wfApp); RegisterWorkflowApplicationEvents(ownerHandle, wfApp, ars); wfApp.Load(instanceId); // Resume the bookmark and Wait for the workflow to complete if (wfApp.ResumeBookmark("ActionExecuted", variable) != BookmarkResumptionResult.Success) { throw new InvalidOperationException("Unable to resume workflow with action name = " + actionName); } ars.WaitOne(); return(wfApp); }