Apress Introducing dot NET 4 0 with Visual Studio 2010_3
Số trang: 45
Loại file: pdf
Dung lượng: 1.90 MB
Lượt xem: 10
Lượt tải: 0
Xem trước 5 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Quan điểm thiết kế cho các sơ đồ có vẻ hơi khác so với các quy trình công việc tuần tự. Các vòng tròn màu xanh lá cây chỉ ra nơi mà công việc này bắt đầu. Chúng ta cần tạo ra một hoạt động mới để đọc đầu vào từ người sử dụng. Tạo một lớp mới gọi là ReadInput.
Nội dung trích xuất từ tài liệu:
Apress Introducing dot NET 4 0 with Visual Studio 2010_3 CHAPTER 6 WINDOWS WORKFLOW FOUNDATION 4Figure 6-13. New flowchart workflow The design view for flowcharts looks slightly different than sequential workflows. The green 3. circle indicates where the workflow starts. We need to create a new activity to read input from the user. Create a new class called ReadInput. Enter the following using statement: 4. using System.Activities; Now enter the following code: 5. public class ReadInput : CodeActivity { protected override Int32 Execute(CodeActivityContext context) { return Convert.ToInt32(Console.ReadLine()); } } Save the class and compile the application. 6. Open Workflow1.xaml. 7. Drag a WriteLine activity beneath the green circle and change the Display Name to “What is 8. your age?” and set the Text to “What is your age?” 147 CHAPTER 6 WINDOWS WORKFLOW FOUNDATION 4 Drag the new ReadInput activity beneath the “What is your age?” activity and change the 9. display name to “Read input.” 10. Create a new variable called age of type Int32. 11. On the ReadInput activity, set the Result property to age. The next thing to do is determine if the customer is old enough to see the film (which in this case will always have an 18 rating). Flow chart workflows have a new type of activity not found in sequential workflows, called FlowDecision. Drag a FlowDecision activity beneath the read input block and change the condition to Age >= 1. 18. There are obviously two possibilities to this expression: Customer is old enough so they can see the film (FlowDecision condition = true). • Customer is too young, so shouldn’t be seeing any movies (FlowDecision • condition = false). To simulate the customer failing age verification, drag a WriteLine activity to the right of the 2. flow decision and change the display name and text to “Sorry not old enough.” Drag another WriteLine activity beneath the flow decision and change the display name and 3. text to “Age validation successful.” We now need to link up the activities we have just created. Move the mouse over the green 4. circle that indicates the start of the flow chart workflow, and three grey dots will appear around it. Click the one on the bottom of the circle and then drag the mouse down to the ReadInput activity. When you near the WriteLine activity, three grey dots will appear around it. Drag the line to one 5. of these dots and then release the mouse button to link up the start of the workflow with our read line activity. Link up the “What is your age?” and ReadInput activities. 6. We need to join the FlowDecision up to the workflow. FlowDecision activities have two nodes, 7. true or false, that surprisingly indicate the path to take when the condition specified is true or false. Drag the false node to the “Sorry not old enough” WriteLine activity and then drag another line from “Sorry not old enough” back round to the ReadInput activity. Drag the true node on the FlowDecision activity to the “Age validation successful” activity. 8. Finally drag a line between the “What is your age?” and ReadInput activity. Your final work flow 9. should look like Figure 6-14. 10. Open Program.cs and add a Console.ReadKey(); beneath the invoke command so the application doesn’t close immediately. 11. That’s it; your workflow is ready to run. Press F5 to run it. 12. Try entering different ages and note that unless you enter at least 18 the workflow will write “Sorry not old enough.”148 CHAPTER 6 WINDOWS WORKFLOW FOUNDATION 4Figure 6-14. Final age validation work flowWCF/Messaging ImprovementsA number of enhancements have been introduced in WF4 to improve integration with WCF and to easemessaging scenarios.CorrelationCorrelation functionality f ...
Nội dung trích xuất từ tài liệu:
Apress Introducing dot NET 4 0 with Visual Studio 2010_3 CHAPTER 6 WINDOWS WORKFLOW FOUNDATION 4Figure 6-13. New flowchart workflow The design view for flowcharts looks slightly different than sequential workflows. The green 3. circle indicates where the workflow starts. We need to create a new activity to read input from the user. Create a new class called ReadInput. Enter the following using statement: 4. using System.Activities; Now enter the following code: 5. public class ReadInput : CodeActivity { protected override Int32 Execute(CodeActivityContext context) { return Convert.ToInt32(Console.ReadLine()); } } Save the class and compile the application. 6. Open Workflow1.xaml. 7. Drag a WriteLine activity beneath the green circle and change the Display Name to “What is 8. your age?” and set the Text to “What is your age?” 147 CHAPTER 6 WINDOWS WORKFLOW FOUNDATION 4 Drag the new ReadInput activity beneath the “What is your age?” activity and change the 9. display name to “Read input.” 10. Create a new variable called age of type Int32. 11. On the ReadInput activity, set the Result property to age. The next thing to do is determine if the customer is old enough to see the film (which in this case will always have an 18 rating). Flow chart workflows have a new type of activity not found in sequential workflows, called FlowDecision. Drag a FlowDecision activity beneath the read input block and change the condition to Age >= 1. 18. There are obviously two possibilities to this expression: Customer is old enough so they can see the film (FlowDecision condition = true). • Customer is too young, so shouldn’t be seeing any movies (FlowDecision • condition = false). To simulate the customer failing age verification, drag a WriteLine activity to the right of the 2. flow decision and change the display name and text to “Sorry not old enough.” Drag another WriteLine activity beneath the flow decision and change the display name and 3. text to “Age validation successful.” We now need to link up the activities we have just created. Move the mouse over the green 4. circle that indicates the start of the flow chart workflow, and three grey dots will appear around it. Click the one on the bottom of the circle and then drag the mouse down to the ReadInput activity. When you near the WriteLine activity, three grey dots will appear around it. Drag the line to one 5. of these dots and then release the mouse button to link up the start of the workflow with our read line activity. Link up the “What is your age?” and ReadInput activities. 6. We need to join the FlowDecision up to the workflow. FlowDecision activities have two nodes, 7. true or false, that surprisingly indicate the path to take when the condition specified is true or false. Drag the false node to the “Sorry not old enough” WriteLine activity and then drag another line from “Sorry not old enough” back round to the ReadInput activity. Drag the true node on the FlowDecision activity to the “Age validation successful” activity. 8. Finally drag a line between the “What is your age?” and ReadInput activity. Your final work flow 9. should look like Figure 6-14. 10. Open Program.cs and add a Console.ReadKey(); beneath the invoke command so the application doesn’t close immediately. 11. That’s it; your workflow is ready to run. Press F5 to run it. 12. Try entering different ages and note that unless you enter at least 18 the workflow will write “Sorry not old enough.”148 CHAPTER 6 WINDOWS WORKFLOW FOUNDATION 4Figure 6-14. Final age validation work flowWCF/Messaging ImprovementsA number of enhancements have been introduced in WF4 to improve integration with WCF and to easemessaging scenarios.CorrelationCorrelation functionality f ...
Tìm kiếm theo từ khóa liên quan:
thủ thuật máy tính tài liệu công nghệ thông tin lập trình máy tính mẹo máy tính cài đặt máy tínhGợi ý tài liệu liên quan:
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 317 0 0 -
Làm việc với Read Only Domain Controllers
20 trang 305 0 0 -
Thêm chức năng hữu dụng cho menu chuột phải trên Windows
4 trang 289 0 0 -
70 trang 251 1 0
-
Bài giảng Tin học lớp 11 bài 1: Giới thiệu ngôn ngữ lập trình C#
15 trang 238 0 0 -
Tổng hợp lỗi Win 8 và cách sửa
3 trang 233 0 0 -
Sửa lỗi các chức năng quan trọng của Win với ReEnable 2.0 Portable Edition
5 trang 214 0 0 -
Giáo trình Bảo trì hệ thống và cài đặt phần mềm
68 trang 207 0 0 -
Tổng hợp 30 lỗi thương gặp cho những bạn mới sử dụng máy tính
9 trang 204 0 0 -
UltraISO chương trình ghi đĩa, tạo ổ đĩa ảo nhỏ gọn
10 trang 204 0 0