public void WF_Delay() { //if (!Node.Exists("/Root/System/WorkflowProtoTypes/DelayTest")) //{ // var prototypesFolder = Node.LoadNode("/Root/System/WorkflowProtoTypes"); // if (prototypesFolder == null) // { // prototypesFolder = Content.CreateNew("Folder", Repository.SystemFolder, "WorkflowProtoTypes").ContentHandler; // prototypesFolder.Save(); // } // var wfProto = new DelayTestWorkflow(prototypesFolder); // wfProto.Name = "DelayTest"; // wfProto.Save(); //} DelayTestWorkflow wfContent1, wfContent2; //-- creating workflow state contents wfContent1 = new DelayTestWorkflow(TestRoot); wfContent1.Name = "WF1"; wfContent1.TestInstanceId = "WF1"; wfContent1.Timeout = TimeSpan.Parse("00:00:00:10"); wfContent1.Save(); wfContent1 = Node.Load <DelayTestWorkflow>(wfContent1.Id); wfContent2 = new DelayTestWorkflow(TestRoot); wfContent2.Name = "WF2"; wfContent2.TestInstanceId = "WF2"; wfContent2.Timeout = TimeSpan.Parse("00:00:00:10"); wfContent2.Save(); wfContent2 = Node.Load <DelayTestWorkflow>(wfContent2.Id); //-- starting the workflow InstanceManager.Start(wfContent1); Thread.Sleep(10); InstanceManager.Start(wfContent2); Thread.Sleep(25 * 1000); wfContent1 = Node.Load <DelayTestWorkflow>(wfContent1.Id); Debug.WriteLine("##WF> @@@@ WorkflowStatus: " + wfContent1.WorkflowStatus); wfContent2 = Node.Load <DelayTestWorkflow>(wfContent2.Id); Debug.WriteLine("##WF> @@@@ WorkflowStatus: " + wfContent2.WorkflowStatus); // var result = SenseNet.Search.ContentQuery.Query("WorkflowStarted:yes .AUTOFILTERS:OFF"); //-- checking final status var expectedMessage = "Finished"; string msg; if (!WfWatcher.WaitForFinished(out msg)) { Assert.Inconclusive("Workflow message was not received"); } Assert.IsTrue(msg == expectedMessage, String.Concat("Received message: '", msg, "'. Expected: '", expectedMessage, "'")); }
private void WaitForMultipleTasksTest(int taskCount, bool waitForAll, string expectedMessage, params string[] taskResults) { Content content; var paths = new string[taskCount]; var tasks = new Node[taskCount]; for (int i = 0; i < paths.Length; i++) { var name = Guid.NewGuid().ToString(); paths[i] = RepositoryPath.Combine(TestRoot.Path, name); content = Content.CreateNew("ApprovalWorkflowTask", TestRoot, name); content.Save(); tasks[i] = content.ContentHandler; } var wfContent = new WaitForMultipleTasksWorkflow(TestRoot); wfContent.Tasks = tasks; wfContent.WaitForAll = waitForAll; wfContent.Save(); wfContent = Node.Load <WaitForMultipleTasksWorkflow>(wfContent.Id); InstanceManager.Start(wfContent); for (int i = 0; i < taskResults.Length; i++) { if (taskResults[i] != "no" && taskResults[i] != "yes") { continue; } var task = Node.LoadNode(paths[i]); task["Result"] = taskResults[i]; task.Save(); } string msg; if (!WfWatcher.WaitForFinished(out msg)) { Assert.Inconclusive("Workflow message was not received"); } Assert.IsTrue(msg == expectedMessage, String.Concat("Received message: '", msg, "'. Expected: '", expectedMessage, "'")); }
public void WF_WaitForMultipleContent_All() { Content content; var paths = new string[3]; var nodes = new Node[3]; for (int i = 0; i < paths.Length; i++) { paths[i] = RepositoryPath.Combine(TestRoot.Path, "Car" + i); if (Node.Exists(paths[i])) { Node.ForceDelete(paths[i]); } content = Content.CreateNew("Car", TestRoot, "Car" + i); content.Save(); nodes[i] = content.ContentHandler; } var wfContent = new WaitForMultipleContentWorkflow(TestRoot); wfContent.Triggers = nodes; wfContent.WaitForAll = true; wfContent.Save(); wfContent = Node.Load <WaitForMultipleContentWorkflow>(wfContent.Id); InstanceManager.Start(wfContent); for (int i = 0; i < paths.Length; i++) { var car = Node.LoadNode(paths[i]); car.Index++; car.Save(); } string msg; if (!WfWatcher.WaitForFinished(out msg)) { Assert.Inconclusive("#2"); } Assert.IsTrue(msg == "Finished", String.Concat("Received message: '", msg, "'. Expected: 'Finished'")); }