public static OrchestrationInstance StartOrchestrationInstance(TaskHubClient client, string name, string instanceId, string[] parameters) { OrchestrationInstance instance = null; switch (name) { case "Signup": if (parameters == null || parameters.Length < 2) { throw new ArgumentException("Signup parameters not provided."); } UtilitySignupOrchestrationInput signupInput = new UtilitySignupOrchestrationInput { Name = parameters[0], AccountNumber = parameters[1], NumberOfCreditAgencies = parameters.Length > 2 ? int.Parse(parameters[2]) : 0, Address = new CustomerAddress { Street = "One Microsoft Way", City = "Redmond", State = "WA", Zip = 98052, }, Checks = SignupChecks.All, }; instance = client.CreateOrchestrationInstance(typeof(UtilitySignupOrchestration), instanceId, signupInput); break; default: throw new Exception("Unsupported Orchestration Name: " + name); } return(instance); }
public static void RunSimulation(TaskHubClient client, string[] parameters) { int numberOfInstances = 1; int delayInSeconds = 2; if (parameters != null && parameters.Length == 2) { numberOfInstances = int.Parse(parameters[0]); delayInSeconds = int.Parse(parameters[1]); } Task.Factory.StartNew(async() => { Random random = new Random(); for (int i = 0; i < numberOfInstances; i++) { UtilitySignupOrchestrationInput signupInput = new UtilitySignupOrchestrationInput { Name = "TestName-" + i.ToString(), AccountNumber = "TestAccount-" + i.ToString(), NumberOfCreditAgencies = random.Next(0, 4), Address = new CustomerAddress { Street = "One Microsoft Way", City = "Redmond", State = "WA", Zip = 98052, }, Checks = SignupChecks.All, }; client.CreateOrchestrationInstance(typeof(UtilitySignupOrchestration), "instance-" + i.ToString(), signupInput); await Task.Delay(delayInSeconds * 1000); } }); }