public void GetAtivities() { WorkFlowContext context = work.GetContext().SetArea("AreaPURCHASEASK") .SetSourceState("ATDRAFT"); IList <Activity> act = work.GetActivities(context); Assert.AreEqual(2, act.Count); }
public void Run(IWorkFlow workFlow) { foreach (var activity in workFlow.GetActivities()) { activity.Execute(); } }
public void ConditionWithDifferentOperatorsWithCustomEvaluator() { IWorkFlow workteste = WorkFlowManager.GetManager(); WorkFlowContext context = workteste.GetContext() .AddEvaluator(new CustomEvaluator()) .SetArea("TESTCONDITIONSICK") .SetSourceState("INITIAL"); context["TESTCONDITIONEQUAL"] = new List <string> { "COLD" }; context["TESTCONDITIONLT"] = new List <string> { "4" }; context["CUSTOM"] = new List <string> { "http://" }; context["TESTCONDITIONIN"] = new List <string> { "5", "8" }; var activities = workteste.GetActivities(context); Assert.AreEqual(2, activities.Count); }
public void Run(IWorkFlow workFlow) { foreach (var activity in workFlow.GetActivities()) { //This method can be inserted in a try-catch block for handling Exceptions. activity.Execute(); } }
public void Run(IWorkFlow workflow) { var i = 1; foreach (var task in workflow.GetActivities()) { Console.WriteLine("Running task {0}", i); task.Execute(); Console.WriteLine("\n"); i++; } }
public void Run(IWorkFlow workFlow) { if (workFlow == null) { throw new ArgumentNullException("Please Provide the WorkFlow"); } foreach (var activity in workFlow.GetActivities()) { activity.Execute(); } }
public void Run(IWorkFlow workflow) { foreach (var activity in workflow.GetActivities()) { try { activity.Execute(); } catch (Exception) { Console.WriteLine("Error: Unable to process activity in workflow."); } } }
public void Run(IWorkFlow workFlow) { foreach (var activity in workFlow.GetActivities()) { try { activity.Execute(); } catch (Exception e) { Console.WriteLine(e); throw; } } }
public void ConditionWithDifferentOperatorsLastParameterFalse() { IWorkFlow workteste = WorkFlowManager.GetManager(); WorkFlowContext context = workteste.GetContext() .SetArea("TESTCONDITIONSICK") .SetSourceState("INITIAL"); context["TESTCONDITIONEQUAL"] = new List <string> { "COLD" }; context["TESTCONDITIONLT"] = new List <string> { "4" }; context["TESTCONDITIONIN"] = new List <string> { "5", "8", "9", "10" }; var activities = workteste.GetActivities(context); Assert.AreEqual(1, activities.Count); }
public void ConditionWithDifferentOperators() { IWorkFlow workteste = WorkFlowManager.GetManager(); WorkFlowContext context = workteste.GetContext() .SetArea("TESTCONDITIONSICK") .SetSourceState("INITIAL"); context["TESTCONDITIONEQUAL"] = new List <string> { "COLD" }; context["TESTCONDITIONLT"] = new List <string> { "4" }; context["TESTCONDITIONIN"] = new List <string> { "5", "8" }; var activities = workteste.GetActivities(context); // must be one because im not passing custom parameter... Assert.AreEqual(1, activities.Count); }
static void Main(string[] args) { //put this line in a global.asax for web WorkFlowConfiguration.Binder.SetRepository(typeof(DAOEmbeddedResource)) .Setup(x => x.TypeName, "WorkFlow.Json.workflow.json , LightWorkFlow"); IWorkFlow work = WorkFlowManager.GetManager();//getting instance of workflow. /* * { * "Id": 36, * "SourceState": "ATDRAFT", * "StateOrder": "Initial", * "Transitions": [{ Operation:"AskAprovePURCHASEASK", Description:"Ask Aproving" , "DestinyState": "WAITINGALLOW"}, * { Operation:"CancelDraft", Description:"Erase Draft" , "DestinyState": "None"}], * * "Area": "AreaPURCHASEASK" * }, */ //1) Getting Initial State string initialstate = work.GetInitialStatus("AreaPURCHASEASK");//ATDRAFT //====================================================================================================== //2) listing operations that can be done from a specific state. WorkFlowContext workoperation = work.GetContext() .SetArea("AreaPURCHASEASK") .SetSourceState("ATDRAFT"); IList <Activity> operations = work.GetActivities(workoperation); //AskAprovePURCHASEASK, CancelDraft string description = work.GetActivityDescription("AskAprovePURCHASEASK"); //Ask Aproving //======================================================================================================= //3) Get Next Status WorkFlowContext workgetnextstatus = work.GetContext() .SetArea("AreaPURCHASEASK") .SetSourceState("ATDRAFT") .SetOperation("AskAprovePURCHASEASK"); string nextstatus = work.GetNextStatus(workgetnextstatus);//WAITINGALLOW //======================================================================================================== //4)Runner - walk throughout workflow in depth and breadth //setting area and initial state from which runner will start to look at. WorkFlowContext workc = work.GetContext() .SetArea("AreaPURCHASEASK") .SetSourceState("ATDRAFT"); var depth = work.Run(workc, SearchMode.Depth);//all transitions printed in a depth search mode. work.GetContext() .SetArea("AreaPURCHASEASK") .SetSourceState("ATDRAFT"); var breadth = (IList <string>)work.Run(workc, SearchMode.Breadth);//all transitions printed in a breadth search mode. //4.1 configuring visitor WorkFlowContext workvisitor = work.GetContext() .SetArea("AreaPURCHASEASK") .SetSourceState("ATDRAFT"); var workvisitordepth = work.Run(workc, SearchMode.Depth, new CustomVisitor());//ok //======================================================================================================== //5) setting conditions /* * { * "Name": "EXTINTION", * "Parameters": [ * { * "Key": "Objective", * "Value": [ * "4", * "3", * "7", * "5", * "9", * "8" * ] * } * ] * }, * { * "Id": 10, * "SourceState": "WAITMOVEMENTDESTINY", * "Transitions": [{ Condition:"!EXTINTION", Operation:"PURCHASEORDER_CONFIRM_ARRIVE_DESTINY", Description:"Confirm chegada" , "DestinyState": "WAITRETURN"}, * { Condition: "EXTINTION", Operation:"PROTOCOLR_REQUIREMENT", Description:"Protocolar Requerimento" , "DestinyState": "PROTOCOLREQUIREMENT"}], * "Area": "AreaPURCHASEORDER" * }, */ WorkFlowContext workoperationcond = work.GetContext() .SetArea("AreaPURCHASEORDER") .SetSourceState("WAITMOVEMENTDESTINY"); workoperationcond["Objective"] = new List <string> { "4" }; IList <Activity> operationsExtintion = work.GetActivities(workoperationcond); //PROTOCOLR_REQUIREMENT,PURCHASEORDER_CANCEL workoperationcond["Objective"] = new List <string> { "1" }; IList <Activity> operationsNoExtintion = work.GetActivities(workoperationcond); //PURCHASEORDER_CONFIRM_ARRIVE_DESTINY,PURCHASEORDER_CANCEL //PURCHASEORDER_CANCEL shows up here because SourceState is configured with "All" in the area "AreaPURCHASEORDER". //if you dont want this operation shows up in a set of states, use "But" inside operation. //6) Setting a new condition match class WorkFlowContext context = new WorkFlowContext { Area = "AreaPURCHASEORDER", Operation = "PURCHASEORDER_CONFIRM_ARRIVE_DESTINY", SourceState = "WAITMOVEMENTDESTINY" }.SetCondition(typeof(NewMatch)); context["Objective"] = new List <string> { "2" }; string state = work.GetNextStatus(context); }