private void EnterGuess_Click(object sender, EventArgs e) { if (WorkflowInstanceId == Guid.Empty) { MessageBox.Show("Please select a workflow."); return; } int guess; if (!Int32.TryParse(Guess.Text, out guess)) { MessageBox.Show("Please enter an integer."); Guess.SelectAll(); Guess.Focus(); return; } WorkflowApplicationInstance instance = WorkflowApplication.GetInstance(WorkflowInstanceId, store); // Use the persisted WorkflowIdentity to retrieve the correct workflow // definition from the dictionary. Activity wf = WorkflowVersionMap.GetWorkflowDefinition(instance.DefinitionIdentity); // Associate the WorkflowApplication with the correct definition WorkflowApplication wfApp = new WorkflowApplication(wf, instance.DefinitionIdentity); // Configure the extensions and lifecycle handlers. // Do this before the instance is loaded. Once the instance is // loaded it is too late to add extensions. ConfigureWorkflowApplication(wfApp); // Load the workflow. wfApp.Load(instance); // Resume the workflow. wfApp.ResumeBookmark("EnterGuess", guess); // Clear the Guess textbox. Guess.Clear(); Guess.Focus(); }
private void EnterGuess_Click(object sender, EventArgs e) { if (WorkflowInstanceId == Guid.Empty) { MessageBox.Show("Please select a workflow."); return; } int guess; if (!Int32.TryParse(Guess.Text, out guess)) { MessageBox.Show("Please enter an integer."); Guess.SelectAll(); Guess.Focus(); return; } var instance = _workflowApplication.GetInstance(this.WorkflowInstanceId); // Use the persisted WorkflowIdentity to retrieve the correct workflow // definition from the dictionary. Activity wf = WorkflowVersionMap.GetWorkflowDefinition(instance.DefinitionIdentity); // Associate the WorkflowApplication with the correct definition WorkflowApplication wfApp = new WorkflowApplication(wf, instance.DefinitionIdentity); // Configure the extensions and lifecycle handlers. // Do this before the instance is loaded. Once the instance is // loaded it is too late to add extensions. // Configure the instance store, extensions, and // workflow lifecycle handlers. var events = _workflowApplication.ConfigureWorkflowApplication(wfApp); // Load the workflow. //wfApp.Load(instance); // Create game Id GameId = Guid.NewGuid(); var game = new Game() { Id = GameId, InstanceId = WorkflowInstanceId, Guess = guess, WorkflowType = WorkflowType.SelectedItem.ToString(), MaxNumber = Convert.ToInt32(NumberRange.SelectedItem) }; // Resume the workflow. wfApp.ResumeBookmark("Game", game); // Clear the Guess textbox. Guess.Clear(); Guess.Focus(); Game display = null; while (display == null) { display = RetrieveData(); } UpdateStatus(string.Format("Lets see how well you did: \r\n\r\nGuess = {0}\r\n MaxNumber = {1}\r\nResult = {2}\r\nTurns = {3}\r\nWorkflowType = {4}", display.Guess, display.MaxNumber, display.Result, display.Turns, display.WorkflowType)); }