Microsoft TS 70-504CSharp Web Demo
This webdemo is just a demo data, only for reference and learning, there is no other purposes
1. A windows application invokes a workflow that performs complex
calculations. When the calculation is done, the workflow returns the
calculated value to the windows application, which must display the
calculated value in a textbox control, as follows:
public void ShowData(string value)
{
mytextBox.Text = value
}
You need to ensure the workflow updates the value in the textbox control.
What should you do?
A. Have the workflow directly call the ShowData() method.
B. Have the workflow call a method in an interface decorated with an
[ExternalDataExchange()] attribute that invokes the ShowData() method directly
C. Set the workflow to call a method in an interface decorated with an
[ExternalDataEventArg()] attribute that invokes the ShowData() method
directly
D. Set the workflow to call a method in a interface decorated with an
[ExternalDataExchange()] attribute that invokes the ShowData() method
indirectly through a delegate if the this.InvokeRequired condition is
true.
Answer: D
2.You create a Windows Workflow Foundation application by using
Microsoft .NET Framework 3.5. The application contains a state workflow.
You write the following code segment.
WorkflowRuntime runtime = new WorkflowRuntime();
WorkflowInstance instance = runtime.CreateWorkflow(
typeof(DynamicUpdateWorkflow));
instance.Start();
StateMachineWorkflowInstance smwi =
new StateMachineWorkflowInstance(runtime,
instance.InstanceId);
A dependency property named Status is defined in this workflow.
The value of a variable named amount is used to set the state of the workflow.
You need to ensure that the host application changes the state of the workflow on the basis of the value of the amount variable.
What are the two possible code segments that you can use to achieve
this goal? (Each correct answer presents a complete solution. Choose
two.)
A. if (amount >= 1000)
smwi.SetState("HighValueState");
else
smwi.SetState("LowValueState");
B. if (amount >= 1000)
smwi.StateMachineWorkflow.SetValue
(DynamicUpdateWorkflow.StatusProperty,"HighValueState")
else
smwi.StateMachineWorkflow.SetValue
(DynamicUpdateWorkflow.StatusProperty, "LowValueState");
C. if (amount >= 1000)
instance.GetWorkflowDefinition().SetValue
(DynamicUpdateWorkflow.StatusProperty,"HighValueState");
else
instance.GetWorkflowDefinition().SetValue
(DynamicUpdateWorkflow.StatusProperty,"LowValueState");
D. if (amount >= 1000)
{
StateActivity high = (StateActivity)
smwi.StateMachineWorkflow.Activities["HighValueState"];
smwi.SetState(high);
}
else
{
StateActivity low = (StateActivity)
smwi.StateMachineWorkflow.Activities["LowValueState"];
smwi.SetState(low);
}
Answer: AD
3. You create a workflow host application by using Microsoft .NET
Framework 3.5. You use Windows Workflow Foundation to create the
application.
You need to configure the workflow runtime to ensure that all the workflow instances run asynchronously.
Which code segment should you use?
A. WorkflowRuntime runtime = new WorkflowRuntime();
runtime.StartRuntime();
WorkflowInstance instance =
runtime.CreateWorkflow(typeof(CustomerWorkflow));
instance.Start();
B. WorkflowRuntime runtime = new WorkflowRuntime();
runtime.StartRuntime();
ManualWorkflowSchedulerService scheduler =
runtime.GetService<ManualWorkflowSchedulerService>();
WorkflowInstance instance =
runtime.CreateWorkflow(typeof(CustomerWorkflow));
scheduler.RunWorkflow(instance.InstanceId);
C. WorkflowRuntime runtime = new WorkflowRuntime();
ManualWorkflowSchedulerService scheduler =
new ManualWorkflowSchedulerService();
runtime.AddService(scheduler);
runtime.StartRuntime();
WorkflowInstance instance =
runtime.CreateWorkflow(typeof(CustomerWorkflow));
instance.Start();
D. WorkflowRuntime runtime = new WorkflowRuntime();
runtime.StartRuntime();
DefaultWorkflowSchedulerService scheduler =
new DefaultWorkflowSchedulerService();
runtime.AddService(scheduler);
WorkflowInstance instance =
runtime.CreateWorkflow(typeof(CustomerWorkflow));
instance.Start();
Answer: A
4. You are writing a sequential console workflow that consists of a
delay activity and a code activity, as shown in the exhibit. (Click the
Exhibit button for the sequential console workflow image)
In the execution code of the second activity, you try to modify the workflow as follows:
private void codeActivity_ExecuteCode(object sender, EventArgs e)
{
CodeActivity delay = sender as CodeActivity;
Console.WriteLine(delay.Name);
WorkflowChanges workflowChanges = new WorkflowChanges(this);
CodeActivity codeActivity = new CodeActivity();
codeActivity.Name = "codeActivity2";
codeActivity.ExecuteCode += new EventHandler(codeActivity2_ExecuteCode);
workflowChanges.TransientWorkflow.Activities.Add(codeActivity);
this.ApplyWorkflowChanges(workflowChanges);
}
private void codeActivity2_ExecuteCode(object sender, EventArgs e)
{
CodeActivity codeActivity = sender as CodeActivity;
Console.WriteLine(codeActivity.Name);
Console.ReadLine();
}
You also have set the modifiability of the workflow to a code condition that is set to the following function:
private void UpdateCondition(object sender, ConditionalEventArgs e)
{
if (TimeSpan.Compare(this.delayActivity.TimeoutDuration, new TimeSpan(0, 0, 5)) > 0) {
e.Result = false;
}
else {
e.Result = true;
}
}
Which code segment should you use to handle the exception?
A. workflowChanges.TransientWorkflow.Activities.Add(codeActivity);
try {
this.ApplyWorkflowChanges(workflowChanges);
}
catch (ArgumentOutOfRangeException ex) {
Console.WriteLine(ex.GetType().ToString());
Console.ReadLine();
}
B. workflowChanges.TransientWorkflow.Activities.Add(codeActivity);
try {
this.ApplyWorkflowChanges(workflowChanges);
}
catch (InvalidProgramException ex) {
Console.WriteLine(ex.GetType().ToString());
Console.ReadLine();
}
C. workflowChanges.TransientWorkflow.Activities.Add(codeActivity);
try {
this.ApplyWorkflowChanges(workflowChanges);
}
catch (InvalidOperationException ex) {
Console.WriteLine(ex.GetType().ToString());
Console.ReadLine();
}
D. workflowChanges.TransientWorkflow.Activities.Add(codeActivity);
try {
this.ApplyWorkflowChanges(workflowChanges);
}
catch (OverflowException ex) {
Console.WriteLine(ex.GetType().ToString());
Console.ReadLine();
}
Answer: C
5. You use a built-in tracking service to track specific workflow parameters.
You need to check whether the workflow parameters have been stored in the tracking database.
What should you do? (Each correct answer presents part of a solution. Choose two.)
A. Display the contents of the WorkflowInstance table of the tracking database.
B. Include the SqlTrackingQuery class in a code segment to retrieve
tracked workflows and SqlTrackingWorkflowInstance class to inspect them.
C. Use the ActivityTrackingLocation class to determine if the value has been set to a database.
D. Display the contents of the TrackingDataItem table of the tracking database.
Answer: BD
6. You create an application in which users design simple sequential
workflows. The designs are stored as XOML in a SQL database. You need
to start one of these sequential workflows from within your own
workflow.
What should you do?
A. Include a custom activity with a code segment that includes an
invocation to the CreateWorkflow method of the WorkflowRuntime class
and then starts the workflow. The signature of the CreateWorkflow
method invoked uses only the workflowType parameter.
B. Include a custom activity with a code segment that includes an
invocation to the CreateWorkflow method of WorkflowRuntime class and
then starts the workflow. The signature of the CreateWorkflow method
invoked uses only the XmlReader and workflowDefinitionReader parameters.
C. Include a custom activity with a code segment that includes an
invocation to the CreateWorkflow method of the WorkflowRuntime class
and then starts the workflow. The signature of the CreateWorkflow
method invoked uses only the workflowType,
Dictionary<string,Object> namedArgumentValues, and Guid
instanceId parameters.
D. Include and configure an InvokeWorkflow activity
Answer: B
7. You create a Windows Workflow Foundation application by using
Microsoft .NET Framework 3. You use the state machine workflow in the
application.
You plan to implement a mechanism that allows a host application to
query a state machine workflow instance that is currently executing.
You write the following code segment. (Line numbers are included for reference only.)
01 WorkflowRuntime runtime = new WorkflowRuntime();
02 WorkflowInstance instance =
03 runtime.CreateWorkflow(typeof(Workflow1));
04 instance.Start();
05
You need to identify the current state of the workflow.
Which code segment should you insert at line 05?
A. string currentstate = instance.GetWorkflowDefinition().ToString();
B. string currentstate = instance.GetWorkflowDefinition().ExecutionStatus.ToString();
C. StateMachineWorkflowInstance smwi = new StateMachineWorkflowInstance(runtime, instance.InstanceId);
string currentstate = smwi.StateHistory[0];
D. StateMachineWorkflowInstance smwi = new StateMachineWorkflowInstance(runtime, instance.InstanceId);
string currentstate = smwi.CurrentStateName;
Answer: D
8. You create a Windows Workflow Foundation application by using Microsoft .NET Framework 3.5.
The application uses a code-only workflow. You define the workflow logic by programmatically adding activities.
You write the following code segment.
public sealed partial class Workflow1
: SequentialWorkflowActivity {
...
}
You also write the following code segment to add a DelayActivity activity to a workflow.
this.CanModifyActivities = true;
DelayActivity delay = new DelayActivity();
delay.TimeoutDuration = new TimeSpan(0, 0, 5);
this.Activities.Add(delay);
this.CanModifyActivities = false;
You need to insert the DelayActivity activity code segment at the correct location in the workflow.
What should you do?
A. Place the following code segment in the class constructor.
public Workflow1() {
...
}
B. Use the following code segment to override the InitializeProperties method.
protected override void InitializeProperties() {
...
}
C. Use the following code segment to override the Execute method.
protected override ActivityExecutionStatus Execute(
ActivityExecutionContext executionContext) {
...
}
D. Override the Initialize method in the following manner.
protected override void Initialize(
?IServiceProvider provider) {
base.Initialize(activity);
...
}
Answer: A