public async Task <ServerCommandResult> Execute(RequestCommand cmd, ExpandoObject dataToExec) { var rwi = new ResumeWorkflowInfo { Id = dataToExec.Get <Int64>("Id") }; if (rwi.Id == 0) { throw new RequestModelException("InboxId must be specified"); } rwi.UserId = dataToExec.Get <Int64>("UserId"); rwi.Answer = dataToExec.Get <String>("Answer"); rwi.Comment = dataToExec.Get <String>("Comment"); rwi.Params = dataToExec.Get <ExpandoObject>("Params"); WorkflowResult wr = await _workflowEngine.ResumeWorkflow(rwi); return(new ServerCommandResult(JsonConvert.SerializeObject(wr, JsonHelpers.StandardSerializerSettings))); }
public async Task SimpleRequest() { Int64 modelId = 123; // predefined Int64 userId = 50; // predefined String bookmark = "Bookmark1"; var info = new StartWorkflowInfo() { Source = "file:Workflows/SimpleRequest_v1", UserId = userId, Schema = "a2test", Model = "SimpleModel", ActionBase = "simple/model", ModelId = modelId }; WorkflowResult result = await _workflow.StartWorkflow(info); Assert.AreNotEqual(0, result.ProcessId); var pm = await _dbContext.LoadModelAsync(String.Empty, "a2workflow.[Process.Load]", new { UserId = userId, Id = result.ProcessId } ); var dt = new DataTester(pm, "Process"); dt.AreValueEqual(result.ProcessId, "Id"); dt.AreValueEqual("a2test", "Schema"); dt.AreValueEqual("SimpleModel", "Model"); dt.AreValueEqual(modelId, "ModelId"); dt.AreValueEqual(userId, "Owner"); dt.AreValueEqual("simple/model", "ActionBase"); dt = new DataTester(pm, "Process.Inboxes"); dt.IsArray(1); dt.AreArrayValueEqual(bookmark, 0, "Bookmark"); dt.AreArrayValueEqual("User", 0, "For"); dt.AreArrayValueEqual(userId, 0, "ForId"); dt.AreArrayValueEqual("inbox/action", 0, "Action"); Int64 inboxId = dt.GetArrayValue <Int64>(0, "Id"); Assert.AreEqual(inboxId, result.InboxIds[0]); dt = new DataTester(pm, "Process.Workflow"); dt.AreValueEqual("Idle", "ExecutionStatus"); var rInfo = new ResumeWorkflowInfo() { Id = inboxId, Answer = "OK", UserId = userId }; var resumeResult = await _workflow.ResumeWorkflow(rInfo); Assert.AreEqual(resumeResult.ProcessId, result.ProcessId); Assert.AreEqual(resumeResult.InboxIds.Count, 0); pm = await _dbContext.LoadModelAsync(String.Empty, "a2workflow.[Process.Load]", new { UserId = userId, Id = result.ProcessId } ); dt = new DataTester(pm, "Process.Workflow"); dt.AreValueEqual("Closed", "ExecutionStatus"); pm = await _dbContext.LoadModelAsync(String.Empty, "a2workflow.[Inbox.Debug.Load]", new { UserId = userId, Id = inboxId } ); dt = new DataTester(pm, "Inbox"); dt.AreValueEqual(inboxId, "Id"); dt.AreValueEqual(bookmark, "Bookmark"); dt.AreValueEqual(userId, "UserRemoved"); dt.AreValueEqual("OK", "Answer"); dt.AreValueEqual(true, "Void"); }