102
Web Application Developer Framework là gì? ArcGIS Web Application Developer Framework (ADF) của Microsoft NET Framework. Cho phép bạn tích hợp GIS data và capabilities vào các ứng dụng Web của bạn. ADF bao gồm Web controls, classes, frameworks và APIs mà bạn sẽ sử dụng để xây dựng các ứng dụng Web của bạn. Để bắt đầu, bạn có thể sử dụng Manager, administrative Web application bao gồm ArcGIS Server và ArcIMS, để từng bước hoàn thiện Web application designer để tạo ra một trang web được thiết kế trước. Ngoài ra, bạn có thể bắt đầu xây dựng ứng dụng Web của bạn trong Visual Studio với Web Mapping Application template, trong đó cung cấp hiển thị bản đồ cơ bản, navigation, và khả năng tương tác. Bạn cũng có thể sử dụng Web controls directly để tạo ra một trang web từ đầu hoặc phát triển ứng dụng chuyên ngành của bạn trong một style phù hợp với trang web hiện có của bạn Web ADF được xây dựng trên Microsoft .NET 2.0 Framework đầu tiên và tận dụng nhiều khả năng được cung cấp với ASP.NET 2.0 như callback framework và embedded resources. Biểu đồ dưới đây nêu bật các thành phần chính và các mối quan hệ cơ bản của trong Web ADF. Có bốn phần riêng biệt để xem xét: Web controls, Task framework, Common Data Source API, và Web ADF graphics và consolidation classes. Tất cả phiên làm việc kết hợp với một phần khác. Lưu ý rằng hầu hết của các thành phần Web ADF chỉ cư trú trên máy chủ Web. Khi chạy một số nội dung hỗ trợ phía máy khách, chẳng hạn như Web ADF JavaScript libraries, sẽ được nạp bởi trình duyệt. Một tập hợp các nguồn dữ liệu hỗ trợ ra khỏi hộp Web ADF được bao gồm để tham chiếu, nhưng không yêu cầu Web ADF để được sử dụng. Tùy thuộc vào các nguồn dữ liệu, Web ADF JavaScript có thể có thể tận dụng lợi thế của browser technologies để tương tác trực tiếp với kết quả data source và nội dung, như truy cập vào một hình ảnh bản đồ có sẵn thông qua public virtual directory.

What is the Web Application Developer

Embed Size (px)

Citation preview

Page 1: What is the Web Application Developer

Web Application Developer Framework là gì?ArcGIS Web Application Developer Framework (ADF) của Microsoft NET Framework. Cho phép bạn tích hợp GIS data và capabilities vào các ứng dụng Web của bạn. ADF bao gồm Web controls, classes, frameworks và APIs mà bạn sẽ sử dụng để xây dựng các ứng dụng Web của bạn. Để bắt đầu, bạn có thể sử dụng Manager, administrative Web application bao gồm ArcGIS Server và ArcIMS, để từng bước hoàn thiện Web application designer để tạo ra một trang web được thiết kế trước. Ngoài ra, bạn có thể bắt đầu xây dựng ứng dụng Web của bạn trong Visual Studio với Web Mapping Application template, trong đó cung cấp hiển thị bản đồ cơ bản, navigation, và khả năng tương tác. Bạn cũng có thể sử dụng Web controls directly để tạo ra một trang web từ đầu hoặc phát triển ứng dụng chuyên ngành của bạn trong một style phù hợp với trang web hiện có của bạnWeb ADF được xây dựng trên Microsoft .NET 2.0 Framework đầu tiên và tận dụng nhiều khả năng được cung cấp với ASP.NET 2.0 như callback framework và embedded resources. Biểu đồ dưới đây nêu bật các thành phần chính và các mối quan hệ cơ bản của trong Web ADF. Có bốn phần riêng biệt để xem xét: Web controls, Task framework, Common Data Source API, và Web ADF graphics và consolidation classes. Tất cả phiên làm việc kết hợp với một phần khác. Lưu ý rằng hầu hết của các thành phần Web ADF chỉ cư trú trên máy chủ Web. Khi chạy một số nội dung hỗ trợ phía máy khách, chẳng hạn như Web ADF JavaScript libraries, sẽ được nạp bởi trình duyệt. Một tập hợp các nguồn dữ liệu hỗ trợ ra khỏi hộp Web ADF  được bao gồm để tham chiếu, nhưng không yêu cầu Web ADF để được sử dụng. Tùy thuộc vào các nguồn dữ liệu, Web ADF JavaScript có thể có thể tận dụng lợi thế của browser technologies để tương tác trực tiếp với kết quả data source và nội dung, như truy cập vào một hình ảnh bản đồ có sẵn thông qua public virtual directory.

Một tập hợp của tổ hợp bao gồm với Web ADF  có chứa các thành phần hữu hình liên quan với mỗi phiên làm việc. Sơ đồ dưới đây nêu bật những tiêu chuẩn cho tổ hợp Web ADF sẽ được thảo luận trong

Page 2: What is the Web Application Developer

help system này.

1. Web ControlsWeb ADF bao gồm một tập hợp AJAX-enabled Web controls nó là phần mở rộng kiến trúc ASP.NET 2.0. Các Web controls sử dụng một tập hợp các thư viện JavaScript để xử lý tương tác không đồng bộ giữa các trình duyệt và các thành phần ứng dụng Web cũng như tài nguyên từ xa. Theo mặc định, Web ADF JavaScript libraries được nhúng vào trong Web ADF control assemblies. Mỗi Web ADF control hỗ trợ AJAX thông qua ASP.NET 2.0 Callback framework. Trạng thái giữa các client trình duyệt và ứng dụng Web trên máy chủ được duy trì bằng cách sử dụng Web ADF CallbackResults. CallbackResults class được thiết kế để lưu trữ các callback string trong một định dạng có thể được xử lý bởi Web ADF Javascript để cập nhật nội dung của trình duyệt tự động.Web ADF controls cũng được thiết kế để hỗ trợ công việc với nhiều nguồn dữ liệu tại cùng một thời điểm trong cùng một ứng dụng Web. Một tập hợp các điều khiển để giới hạn tài nguyên quản lý tương tác giữa các Web controls và data sources thông qua Common Data Source API. Tài nguyên có thể hợp nhất để hiển thị (ví dụ, trong một bản đồ) và sử dụng cho các truy vấn và các hoạt động không gian.          2. Task FrameworkWeb ADF Task Framework là một kiến trúc mở rộng bởi người phát triển có thể tích hợp và triển khai các chức năng tùy chỉnh là "Web tasks" trong phạm vi một ứng dụng Web ADF. Nói chung, một "Web tasks" là một Web control mà gói gọn một tập hợp các hành động liên quan để tạo ra kết quả.

Page 3: What is the Web Application Developer

Đó là một thành phần mô-đun có thể được phân tán và " plugged into " ứng dụng Web ADF thông qua Visual Studio hay ArcGIS Manager application. Task framework cung cấp khả năng tích hợp có hiệu quả Web task tùy chỉnh vào ADF Web và quản lý. Task framework interfaces và classes bao gồm ESRI.ArcGIS.ADF.Web.UI.WebControls.dll assembly. Thực hiện task framework được bao gồm ra khỏi hộp với Web ADF như task controls trong ESRI.ArcGIS.ADF.Tasks.dll và ESRI.ArcGIS.ADF.ArcGISServer.Editor.dll (EditorTask control only).3. Common Data Source API Các phiên bản trước của Web ADF, giới hạn ArcGIS Server ADF, được thiết kế để hỗ trợ một nguồn dữ liệu duy nhất, cụ thể là ArcGIS Server thông qua ArcObjects. Web ADF mới được thiết kế để hỗ trợ dữ liệu từ nhiều nguồn, bao gồm ArcGIS Server và ArcIMS. Và thứ hai, các kiến trúc đa nguồn cho phép bạn tích hợp và tương tác với dữ liệu từ các nguồn khác nhau cùng một lúc, trong cùng một ứng dụng. Để thực hiện điều này, Web ADF cần một framework chung, trong đó nguồn dữ liệu có thể được tích hợp với các thành phần Web ADF. Framework này là Common Data Source API, hoặc trong ngắn hạn, Common API.Common API bao gồm một tập hợp của classes và interfaces trong ESRI.ArcGIS.ADF.Web.DataSources.dll assembly. classes và interfaces làm cho framework chung mà Web ADF controls sử dụng để tương tác với các nguồn dữ liệu khác nhau trong một cách phổ biến (như vậy, " Common API "). Để sử dụng một nguồn dữ liệu như là một nguồn tài nguyên trong Web ADF, nguồn dữ liệu phải cung cấp một thực hiện của Common API generic framework. Các khả năng của nguồn dữ liệu sẽ quyết định chiều sâu thực hiện. Một tập hợp các nguồn dữ liệu được hỗ trợ out-of-the-box (bên trong chiếc hộp) bao gồm ArcGIS Server, ArcIMS, ArcWeb, OGC \ WMS, và tập hợp dữ liệu đồ họa Web ADF. Mỗi Common API thực hiện thường được chứa trong một assembly riêng biệt với Web ADF. Một số nguồn dữ liệu có một API rõ ràng được sử dụng trong Common API implementation. Chúng được gọi là các API nguồn dữ liệu cụ thể. Ví dụ, Common API implementation của ArcGIS Server sử dụng các thành phần trong thư viện ESRI.ArcGIS.ADF.ArcGISServer.dll ArcGIS Server. Thư viện này thúc đẩy Server ArcGIS SOAP API để làm việc với ArcGIS Server services thông qua Local hay Internet connection. Lưu ý, các API nguồn dữ liệu cụ thể có thể được sử dụng riêng của chúng, mà không có Web ADF controls hay Common API implementation.Một tập hợp các thư viện kết nối cũng được bao gồm với ADF Web để hỗ trợ các kết nối địa phương để ArcGIS Server và giao thức TCP hoặc HTTP kết nối phần mềm ArcIMS.4. Web ADF Graphics and Consolidation Classes    Nguồn dữ liệu khác nhau có thể được kết hợp và sử dụng một cách phổ biến (Common API) trong Web ADF. Kết quả là, Web ADF bao gồm một tập hợp các thành phần được thiết kế để hỗ trợ và tăng cường làm việc với nhiều tài nguyên trong Web-tier. Hầu hết các thành phần này đều thuộc vào ESRI.ArcGIS.ADF.Web.dll assembly)Nói chung, Web ADF phải hỗ trợ một số khả năng cơ bản của một nguồn dữ liệu hoặc dịch vụ. Ví dụ, nó duy trì một graphics dataset, trong đó tăng cường ADO.NET Dataset để cung cấp spatial properties. Graphics dataset có thể chứa một tập của Web ADF graphics layers trong đó tăng cường ADO.NET DataTable và mô phỏng feature class properties. Các Web ADF bao gồm một tập geometry types, renderers và symbols để quản lý và hiển thị các yếu tố đồ họa trong Web ADF graphics layers. Từ đó Web ADF graphics tăng cường khả năng để quản lý Web-tier và Common API implementation được cung cấp, chúng có thể được tích hợp và sử dụng như nguồn tài nguyên bản đồ. Web ADF graphics cung cấp một Web ADF dataset type  để quản lý các selected features, dynamic data, và custom feature data sources.Other sections of the Web ADF rely on the Web ADF graphics and consolidation classes to do work and interact with one another.  The Map control needs to maintain a spatial reference

Page 4: What is the Web Application Developer

and define display settings for a map resource to generate a map image.  A task control may use task results to display graphics on a map with Web ADF graphics layers.   A developer may use the generic interfaces of the Common API to execute a query using a spatial filter composed of Web ADF geometry.  In addition, a set of Converter classes are included in the Web ADF to provide convenient methods for converting between client, Web ADF and data source specific data types.   In a true consolidation environment such as the Web ADF, managing the translation of information between application tiers and source types is essential to maximizing usability.         (Phần khác của Web ADF dựa trên Web ADF graphics và các consolidation classes để làm việc và tương tác với nhau. Map control cần phải duy trì một tham chiếu không gian và xác định các thiết lập hiển thị cho một nguồn tài nguyên bản đồ để tạo ra một hình ảnh bản đồ. Một task control có thể sử dụng task results để hiển thị đồ họa trên một bản đồ với Web ADF graphics layers. Một nhà phát triển có thể sử dụng interfaces chung của Common API để thực thi một truy vấn bằng cách sử dụng một bộ lọc không gian bao gồm Web ADF geometry. Ngoài ra, một tập hợp của Converter classes bao gồm trong Web ADF để cung cấp các phương thức tiện lợi cho việc chuyển đổi giữa client, Web ADF và các loại nguồn dữ liệu dữ liệu cụ thể. Trong một môi trường hợp nhất cũng như Web ADF, việc quản lý việc chuyển đổi thông tin giữa các tầng ứng dụng và các source types là điều cần thiết để tối đa hóa khả năng sử dụng.)

I. Web Controls

1. Tổng quan Web Control

Web ADF bao gồm một tập các Web controls để tăng cường khả năng cho Web developer và cung cấp một môi trường phát triển ứng dụng nhanh chóng. Tất cả Web ADF controls được thiết kế để làm việc không đồng bộ trong một ứng dụng web bằng cách sử dụng khả năng AJAX capabilities and the Callback Manager included with ASP.NET 2.0. Web ADF bao gồm một tập hợp các nguồn tài nguyên được nhúng (ví dụ như JavaScript libraries, images, CSS files) để quản lý asynchronous callbacks trong trình duyệt. Tương tự như vậy, các nguồn lực này làm việc với Web ADF controls để thực hiện ASP.NET 2.0 System.Web.UI.ICallbackEventHandler interface để xử lý các out-of-band callbacks và tạo ra các kết quả trên máy chủ. Web ADF JavaScript tài nguyên được thảo luận chi tiết hơn bên dưới.Web ADF controls tận dụng các Common Data Source API để tương tác với nhiều nguồn dữ liệu như là nguồn tài nguyên. Trong hầu hết trường hợp, nguồn tài nguyên được quản lý bởi một bộ "resource manager" controls. Điều khiển khác tiêu thụ các nguồn tài nguyên được quản lý trực tiếp hoặc thông qua một điều khiển. Sơ đồ dưới đây minh họa tính chất quan hệ giữa Web ADF Core và Task framework controls và data sources được hỗ trợ out-of-the-box. Ví dụ, MapTips control sử dụng MapResourceManager để lựa chọn một nguồn tài nguyên và layer nó được dùng để cấu trúc map tips và có thể được kết hợp với Map control để hiển thị map tips. Tương tự như vậy, SearchAttributesTask sử dụng MapResourceManager các để chọn các resources, layers, và fields, trong việc tìm kiếm. Nhiệm vụ có thể được kết hợp với một TaskResults control để hiển thị kết quả dạng bảng và TaskResults control có thể kết hợp với Map control để hiển thị các kết quả đồ họa.

Page 5: What is the Web Application Developer

Các phần sau đây cung cấp một mô tả ngắn gọn của từng Web control với Web ADF.

1.1 MapResourceManagerMapResourceManager control thường là control đầu tiên được thêm vào một ứng dụng Web. Tại thời điểm thiết kế giao diện cho phép bạn thêm, loại bỏ, và thiết lập các thuộc tính cho bất kỳ nguồn tài nguyên cung cấp đầu ra lập bản đồ, ví dụ như một ArcIMS Image Service hay ArcGIS Server map service. Từ đó control được thiết kế để quản lý nhiều tài nguyên cùng một lúc, nó cung cấp các thuộc tính để xác định các nguồn lực tương tác như thế nào, cũng như thứ tự của các layers và độ trong suốt của đầu ra hình ảnh bản đồ. Nhiều controls có thể sử dụng cùng MapResourceManager để truy cập vào cùng một tập hợp các tài nguyên. Kết quả là, những thay đổi đến một tài nguyên bởi một control có thể được phản ánh trong các controls khác có kết hợp với cùng MapResourceManager.1.2. MapMap control được thiết kế để hiển thị dữ liệu địa lý từ một hoặc nhiều nguồn được cung cấp bởi các loại nguồn dữ liệu khác nhau. Nó phải được liên kết với một MapResourceManager để xác định các nguồn tài nguyên được hiển thị trong bản đồ. Nhiều nguồn được hiển thị trong cùng một bản đồ được pha trộn với nhau và kết xuất thành một hình ảnh duy nhất. Từ đó mỗi dịch vụ được xử lý như là một lớp riêng biệt trong bản đồ, bạn có thể sử dụng MapResourceManager để thiết lập mức độ trong suốt cho mỗi tài nguyên. Chức năng nâng cao của map tool cho phép di chuyển liên tục và khả năng phóng to mà không cần tải lại trang web có chứa các bản đồ, và một postback đầy đủ là không cần thiết. Ngoài ra, style

Page 6: What is the Web Application Developer

navigation cung cấp scroll-wheel zoom và keyboard navigation options trong thời gian chạy. Một số Web ADF controls khác kết hợp với map control để nâng cao khả năng sử dụng với bản đồ, chẳng hạn như Thanh công cụ, Navigation, MapTips, và ZoomLevel controls.1.3. TocBảng của nội dung, hoặc Toc control, liệt kê các layers trên bản đồ và cho thấy những gì các feature đại diện. Một toc được kết hợp với một a map control. Kết quả là, đánh dấu một layer trong toc control sẽ vẽ nó vào map control. Mỗi nguồn tài nguyên kết hợp với một map control có thể chứa một hoặc nhiều layers, do đó toc control đại diện cho mỗi tài nguyên như grouplayer, bản chất là layer có chứa các layer.1.4. ToolbarThe Toolbar control can be associated with one or more map controls. Toolbars contain functions for working with a map, such as common navigation tools like pan and zoom. Custom tools can be added to the toolbar to enhance the capabilities of a Web application. (Toolbar control có thể kết hợp với một hoặc nhiều map controls. Thanh công cụ chứa các chức năng để làm việc với một bản đồ, chẳng hạn như các navigation tools phổ biến giống như pan và zoom. Các Custom tools có thể được thêm vào thanh công cụ để nâng cao khả năng sử dụng của một ứng dụng Web.1.5. NavigationNavigation control được kết hợp với map control duy nhất. Nó cung cấp map navigation functions phổ biến (pan và zoom) trong một control duy nhất. Control cũng có thể được di chuyển tự động trên trang Web trong thời gian chạy, do vậy người sử dụng ứng dụng có thể chọn vị trí của control.1.6. ZoomLevelZoomLevel control cung cấp một tập hợp của các mức độ, hoặc quy mô bản đồ, đại diện cho liên kết mở rộng tĩnh khác nhau để map control có thể phóng to. Map control phải tham chiếu một nguồn tài nguyên có chứa ít nhất một static layer, ví dụ, một ArcGIS Server MapServer với một lớp dữ liệu lưu trữ. Khi tạo ra các lớp dữ liệu lưu trữ định nghĩa một tập hợp của các cấp, hoặc quy mô, mà tại đó dữ liệu lưu trữ được tạo ra. ZoomLevel controlsử dụng các cấp độ để xác định số lượng của các phân đoạn được hiển thị bởi control.1.7 MapTipsMapTips control cung cấp các khả năng, trong thời gian chạy, di chuyển chuột qua một point feature trong bản đồ và ngay lập tức hiển thị thông tin thuộc tính về các feature cụ thể. Control sử dụng client-side logic trong trình duyệt để hiển thị các feature trên đầu trang của map control. MapTips control sử dụng thông tin thuộc tính trong point feature layer, được truy cập thông qua một nguồn tài nguyên trong MapResourceManager. MapTips có thể lấy thông tin từ một tài nguyên trong một MapResourceManager và hiển thị nó trong một map control khác không liên quan.1.8 OverviewMapOverviewMap control là tương tự như Map control trong đó nó hiển thị geographic data. Tuy nhiên, mục đích của nó là hiển thị tổng quan bản đồ để cung cấp một điểm tham chiếu cho khu vực hiển thị trên Map control liên quan của nó. OverviewMap control luôn luôn hiển thị mức độ lớn hơn so với map control. Một khu vực cần quan tâm trên bản đồ tổng quan đại diện khu vực hiện đang hiển thị trên Map control. Lưu ý rằng OverviewMap và Map control có thể sử dụng hai MapResourceManagers nguồn khác nhau, do đó khác nhau nguồn của dữ liệu.1.9 FloatingPanelFloatingPanel control cung cấp một cửa sổ nổi trong phạm vị một trang web có thể chứa các controls khác. Bạn có thể kéo-và-thả, thay đổi kích thước, và giảm thiểu các cửa sổ trong trình duyệt. Thường

Page 7: What is the Web Application Developer

FloatingPanels được sử dụng để nâng cao khả năng sử dụng và sự xuất hiện của một trang Web. Khi bạn thêm một OverviewMap Thanh công cụ đến floating panel, nó có thể được giảm thiểu khi không sử dụng hoặc được kéo đến một vị trí mới trên màn hình.

1.10 ScaleBarScaleBar control cung cấp một scalebar đơn giản cho bản đồ. Nó sử dụng ArcGIS Server hay ArcIMS resources trong Map control để tính toán quy mô tương đối và cấu trúc control.1.11 MagnifierMagnifier control là mở rộng FloatingPanel control để cung cấp một cửa sổ nổi, trong đó có chứa bản đồ của một nguồn tài nguyên trong việc trong việc liên kết Map control . Bản đồ trong Magnifier control phóng to trên Map control để hiển thị chi tiết hơn mà không thay đổi mức độ của bản đồ trong Map control. Một Hình chữ thập ở trung tâm của Magnifier control cho phép người sử dụng xác định vị trí kiểm soát trên Bản đồ để lựa chọn một khu vực để xem. Một danh sách thả xuống (từ 2x đến 10x Map extent hiện tại) cho phép người dùng lựa chọn như thế nào mà họ muốn để phóng to trên bản đồ.1.12 GeocodeResourceManagerGeocodeResourceManager control cho phép một nhà phát triển thêm, loại bỏ, và thiết lập các thuộc tính cho bất kỳ nguồn tài nguyên mà cung cấp các dịch vụ mã hoá địa lý. ArcGIS Server, ArcIMS và ArcWeb data sources có thể được sử dụng. FindAddressTask control được thiết kế để sử dụng các nguồn lực được cung cấp bởi GeocodeResourceManager làm đầu vào địa chỉ mã hoá địa lý.1.13 GeoprocessingResourceManagerGeoprocessingResourceManager control cho phép một nhà phát triển thêm, loại bỏ và thiết lập các thuộc tính cho bất kỳ nguồn tài nguyên cung cấp các geoprocessing services. Chỉ ArcGIS Server geoprocessing services được hỗ trợ tại thời điểm này. GeoprocessingTask control được thiết kế để sử dụng các nguồn lực được cung cấp bởi GeoprocessingResourceManager để làm việc với geoprocessing tasks trên máy chủ. 1.14 TaskManagerTaskManager control được thiết kế để tổ chức các nhiệm vụ trong một ứng dụng Web. TaskManager control tạo ra các dữ liệu phân cấp XML có thể được sử dụng bởi một ASP.NET navigation control cũng như Menu hay TreeView. Khi chạy, các nút trong ASP.NET Menu hoặc TreeView có thể được sử dụng để hiển thị floating panel cho một công việc. Nó chỉ hiển thị tại thời điểm thiết kế.1.15 TaskResultsTaskResults control được thiết kế để lưu trữ các kết quả của nhiệm vụ sản xuất đầu ra ADO.NET DataSet. Các kết quả được trình bày như là các nút trong TreeView. TaskResults control cũng cho phép khả năng để zoom hay pan một tính năng, làm nổi bật một tính năng trong một tập hợp kết quả, lại chạy một tác vụ, hoặc loại bỏ kết quả nhiệm vụ.

1.16 SearchAttributesTaskSearchAttributesTask control cho phép một nhà phát triển để chọn một tập hợp các field, được cung cấp bởi các nguồn lực, trong đó để tìm kiếm cho sự xuất hiện của một giá trị người sử dụng cung cấp. Khi chạy, từng field được truy vấn cho sự xuất hiện của một giá trị người sử dụng cung cấp. Một phần giá trị được cho phép. Chỉ có feature layers trong các nguồn lực được cung cấp bởi MapResourceManager có thể được sử dụng. Các kết quả được cung cấp tại ADO.NET DataSet được hiển thị trong một TaskResults control.1.17 QueryAttributesTask

Page 8: What is the Web Application Developer

QueryAttributesTask control cho phép một nhà phát triển xác định một cách rõ ràng các thông số được sử dụng để truy vấn các giá trị trong một field. Control này giúp tăng cường khả năng truy vấn cơ bản của SearchAttributesTask. Khi chạy, các truy vấn QueryAttributesTask có thể cung cấp một thả xuống danh sách các lựa chọn cài sẵn hoặc textbox để nhập dữ liệu nói chung. Mỗi truy vấn cũng có thể sử dụng một tính hợp lệ để hạn chế giá trị nhập vào. Ngoài ra, nhiều truy vấn có thể được nhóm lại với nhau để xuất ra một kết quả duy nhất. Chỉ có feature layers trong các nguồn lực được cung cấp bởi MapResourceManager có thể được sử dụng. Các kết quả được cung cấp như một ADO.NET DataSet được hiển thị trong một TaskResults control.

FindPlaceTaskFindPlaceTask control được thiết kế để sử dụng ArcWeb services nó cung cấp nơi tìm kiếm name layers. Control interface bao gồm một textbox đơn giản để nhập vào một địa danh. Các kết quả được cung cấp như một ADO.NET DataSet được hiển thị trong một TaskResults control.

FindAddressTask

FindAddressTask control sử dụng tài nguyên trong GeocodeResourceManager để thực hiện các hoạt động mã hoá địa lý. Control interface được tạo ra tự động tại thời gian chạy dựa trên các yếu tố đầu vào được yêu cầu bởi tài nguyên mã hoá địa lý sẽ sử dụng. Các kết quả được cung cấp như một ADO.NET DataSet được hiển thị trong một TaskResults control.

GeoprocessingTask

GeoprocessingTask control sử dụng tài nguyên trong GeoprocessingResourceManager để thực hiện các geoprocessing tasks. Control interface được tạo ra tự động tại thời gian chạy dựa trên các yếu tố đầu vào yêu cầu của nguồn tài nguyên xử lý dữ liệu và công việc sẽ sử dụng. Kết quả, trong đó bao gồm các thông số đầu vào và đầu ra cũng như tiến bộ thông điệp, được cung cấp như một ADO.NET DataSet được hiển thị trong một TaskResults control.

EditorTaskEditorTask control cung cấp một bộ công cụ cho Web-based chỉnh sửa các tính năng trong cả 2 versioned và non-versioned enterprise geodatabases. Nếu cấu hình, phiên bản cụ thể có thể được lựa chọn để chỉnh sửa. Tại thời điểm chay Hộp thoại cung cấp công cụ để sửa đổi, bổ sung, và loại bỏ feature geometry và attributes.

PageLayout

PageLayout control hiển thị layout của bản đồ và tương tự layout view trong ArcMap. Nó hiển thị tất cả các yếu tố bản đồ, bao gồm cả khung dữ liệu và bất kỳ mọi thứ bao quanh bản đồ, chẳng hạn như mũi tên về phía bắc và scale bars. PageLayout control chỉ được hỗ trợ để sử dụng với ArcGIS Server Local data sources.

Page 9: What is the Web Application Developer

2. Web ADF JavaScript Libraries

Theo mặc định, Web ADF JavaScript libraries được nhúng trong các Web ADF controls và theo luồng thông qua ASP.NET HTTP Handler WebResource.axd để client browser xử lý khi cần thiết. ASP.NET 2.0 cung cấp khả năng để nhúng tài nguyên với Web controls để dễ dàng đóng gói và phân tán server và các thành phần client trong cùng assembly.

Web ADF sử dụng nguồn tài nguyên nhúng để hỗ trợ client-side tương tác với các server-side controls. Đáng chú ý nhất, Web ADF JavaScript files được nhúng và theo luồng đến client browser trong thời gian chạy để hỗ trợ client tương tác với server control. Bảng dưới đây liệt kê các tập tin JavaScript với Web ADF. Trang thảo luận cho mỗi Web ADF control bao gồm một danh sách các thư viện JavaScript cần thiết trên client để sử dụng control.

JavaScript File Description

display_common.jsRequired for all Web ADF controls. Contains standard JavaScript functions for CSS layer display, element positioning, conversion and debugging.

display_contextmenu.jsRequired for Web ADF controls that use the ContextMenu control. Supports the display and selection of items within a context menu.

display_dotnetadf.jsRequired for all Web ADF controls. Manages initial postback or callback requests and responses.

display_editorSnapTip.jsManages snapping interaction and display properties for the EditorTask control.

display_editortask.jsManages client functions to edit spatial and attribute data with the EditorTask control.

display_floatingpanel.jsRequired for all Web ADF controls that use the FloatingPanel control. Supports the display, movement and content of a floating panel.

display_magnify.js Manages the display and navigation of the Magnifier control.

display_map.jsManages the display of Map control contents (resources) and map actions.

display_maptips.js Contains functions to generate interactive map tips in a browser.

display_navigation.jsManages the display and user interaction with the Navigation control.

display_overview.js Manages map content and area of interest details for an

Page 10: What is the Web Application Developer

OverviewMap control.

display_pagelayout.jsManages the display of PageLayout control contents (resources) and page layout actions.

display_task.js Required to support task execution and activity indicators.

display_taskresults.js Manages the display and interaction with the TaskResults control.

display_toolbar.jsManages tool, command and drop down interaction in a Toolbar control.

display_treeviewplus.jsRequired for all Web ADF controls that use the TreeViewPlus control, such as the Toc and TaskResults controls. Manages node order and interaction.

display_vector.jsManages vector based drawing tools and interaction with Map and PageLayout controls. Utilizes VML and CSS.

Modifying Web ADF JavaScript files không được hỗ trợ rõ ràng từ tất cả các điều khiển Web ADF phụ thuộc vào nội dung hoạt động như mong đợi. Tuy nhiên, bạn có tùy chọn để cấu hình Web ADF controls tại thời gian thiết kế để sử dụng JavaScript files trên đĩa thay vì nguồn tài nguyên nhúng. Hai tính chất này được sử dụng để cấu hình khả năng này cho tất cả các Web ADF controls: UseDefaultWebResources và WebResourceLocation.UseDefaultWebResources xác định liệu một điều khiển sẽ yêu cầu nhúng vào JavaScript hay không. True (nhúng) là mặc định. Nếu sai, WebResourceLocation property sẽ được sử dụng để xác định vị trí các JavaScript files trên đĩa.

WebResourceLocation phải được thiết lập để một vị trí hợp lệ từ góc nhìn của ứng dụng Web. Giá trị mặc định là "/ aspnet_client / ESRI / WebADF / các" tài liệu tham khảo các tập tin JavaScript trong thư mục <IISROOT> (ví dụ, c: \ Inetpub \ wwwroot \ aspnet_client \ ESRI \ WebADF \ JavaScript). Nếu WebResourceLocation có sản phẩm nào, giá trị mặc định sẽ được sử dụng. Trong mọi trường hợp, các văn bản "JavaScript /" sẽ luôn luôn được nối thêm vào giá trị tài sản. Ví dụ, nếu bạn sao chép một tập hợp các tập tin của Web ADF JavaScript để một thư mục "kịch bản / JavaScript" dưới thư mục gốc ứng dụng web, WebResourceLocation giá trị tài sản sẽ là "kịch bản /".

Lưu ý rằng mỗi Web ADF control duy trì các cá tập thuộc tính của riêng nó, do đó, nó có thể là một trang web duy nhất có chứa một số Web ADF controls mà sử dụng nguồn tài nguyên nhúng và một số thì không. Với điều này trong, Web ADF controls có thể bỏ qua các thiết lập tài nguyên nếu các nguồn tài nguyên mà họ cần là đã có sẵn trong trình duyệt. Ví dụ, tại thời gian chạy một Web ADF control được tải trong một trang web và yêu cầu một JavaScript file được nhúng theo luống đến client browser. Web ADF control khác, được thiết lập để không sử dụng các nguồn lực nhúng, nạp vào trang và cần JavaScript file mà chỉ vào luống cho client. Control này sẽ sử dụng JavaScript đã có sẵn thay vì yêu cầu các tập tin không nhúng trên đĩa. Điều này có nghĩa rằng ngay cả khi bạn thiết lập UseDefaultWebResources là

Page 11: What is the Web Application Developer

false, control có thể sử dụng các nguồn tài nguyên nhúng lấy ra bởi control khác. Tại thời điểm này, những thuộc tính này phải được thiết lập riêng cho mỗi control - chúng có thể được thiết lập một lần cho toàn bộ một trang hay ứng dụng.

3. Using Web ADF Controls in Custom User Controls or Composite Controls

Web ADF controls hỗ trợ cho việc sử dụng trong phạm vi custom Composite và Web User controls. Composite controls được tạo ra và quản lý trong một class library project riêng biệt. Web User controls là các item được quản lý trong Web project. Composite controls cung cấp những ưu điểm sau trên Web User controls:1. Tích hợp tốt với VS2005. Class library projects này chứa Composite controls được tự động tham chiếu và thêm vào VS2005 toolbox. 2. Hỗ trợ phong phú hơn thời điểm thiết kế. Control developers có thể tạo ra wizards và property editors cho end developers để sử dụng khi thiết lập Composite control. 3. Nguồn tài nguyên nhúng trong tổ hợp. Nguồn lực (images, JavaScript files, ...) có thể được nhúng trong tổ hợp Composite control, do đó nó dễ dàng để phân phối.Điều đáng tiết Composite controls không có graphic designer cho control developers để trực quan tạo ra control, như Web User controls, nhưng sự cân bằng rõ ràng. Nói chung, sử dụng Composite controls nếu bạn muốn phân tán custom Web control nó chứa các web control, sử dụng Web User controls cho một ứng dụng custom Web control cụ thể có chứa các Web controls.

II. Working with the Task Framework

Tasks được định nghĩa là một tập hợp các hành động liên quan để cung cấp kết quả chung. Khái niệm về task được trình bày tại một số các cấp trong phạm vi ESRI products. ArcGIS Server Geoprocessing services cung cấp server tasks để thực hiện công việc trong GIS Server. ArcExplorer tasks được thiết kế để củng cố hành động có liên quan trong một ứng dụng desktop client cũng như được phân phối thành phần phân biệt. Web ADF cũng cung cấp task framework để tạo ra, tích hợp, và phân phối các thành phần, hoặc " Web tasks ". Về bản chất, Web tasks là một trang ASP.NET Web control sử dụng và mở rộng Web ADF task framework để đóng gói các chức năng tùy chỉnh trong một thành phần phân phối. Framework bao gồm một tập hợp các interfaces và abstract classes để tạo ra các custom tasks, một bộ controls để hỗ trợ quản lý công việc và kết quả, và kiến trúc cắm vào để tích hợp một công việc tùy chỉnh trong Visual Studio hoặc ArcGIS quản lý. Ngoài ra, một tập hợp các out-of-the-box task controls bao gồm với Web ADF để hỗ trợ một số common GIS functionality yêu cầu trong một ứng dụng Web. Mỗi chủ đề sẽ được thảo luận dưới đây:

Task support controls

Sử dụng controls sau đây là tùy chọn. Chúng được thiết kế để nâng cao khả năng thời gian chạy Web task.

TaskManager

TaskResults

Page 12: What is the Web Application Developer

Out-of-the-box task controls

Tất cả các task controls thực hiện và mở rộng task framework được tích hợp đầy đủ với ứng dụng Web ADF tạo ra khả năng và môi trường phát triển.SearchAttributesTask

QueryAttributesTask

FindPlaceTask

FindAddressTask

GeoprocessingTask

EditorTask

Task framework

Sơ đồ dưới đây minh họa các classes và interfaces trong task framework. Các item màu đỏ là phần của Web ADF task framework. Các item màu xanh lá cây minh họa một nhà phát triển có thể chọn để tùy chỉnh task framework và làm thế nào nó có liên quan đến các framework components hiện tại. Nhìn chung, Task và FloatingPanelTask abstract classes thực hiện giao diện ITask interface. Tất cả có thể được sử dụng để tạo ra một custom task tùy thuộc vào khả năng theo yêu cầu của task. Điều này là tất cả những gì là cần thiết để tạo ra một custom task. Tuy nhiên, để tích hợp với các thành phần Web ADF khác, bạn có tùy chọn tùy biến các thành phần công việc khác. TaskDesigner cho phép các nhà phát triển để tùy chỉnh trong Visual Studio design-time những verbs có sẵn trên custom task control. IWebConfigurator interface định nghĩa như thế nào để tích hợp các custom task vào Manager application. Điều này sẽ cho phép bạn chọn các custom task từ một danh sách khi tạo ra một ứng dụng web mới bằng cách sử dụng Manager. ITaskResultsContainer interface cho phép một nhà phát triển để xác định một custom container\control để hiển thị task results.

Page 13: What is the Web Application Developer

Core task interface là ITask trong ESRI.ArcGIS.ADF.Web.UI.WebControls namespace. Ở mức cơ bản nhất, một task phải thực hiện ITask interface. Interface định nghĩa được cung cấp dưới đây:

namespace ESRI.ArcGIS.ADF.Web.UI.WebControls{ public interface ITask { string ShowUrl { get;} string Title { get; set;} string ToolTip { get;set;} string NavigationPath { get; set;} BuddyControlCollection TaskResultsContainers { get;} object Results { get;set;} void ExecuteTask(); string TaskActivityIndicatorText { get;} bool GroupResultsByTable { get;set;} bool ShowFieldAttributes { get;set;} bool ShowLegend { get; set;}

object Input { get; set;} void Refresh(); void Show(); CallbackResultCollection CallbackResults { get;}

string UniqueID { get;}

List<GISResourceItemDependency> GetGISResourceItemDependencies(); }}

Hai abstract classes đã được cung cấp cho bạn để xử lý hầu hết của tầng trên kết hợp với ITask implementation. Task và FloatingPanelTask abstract classes được thiết kế để mở rộng. Sử dụng các lớp

này được bắt đầu. Sự khác biệt chính giữa hai: custom task đó là extends Task không được chứa trong

FloatingPanel, custom task đó là mở rộng FloatingPanelTask được chứa trong một FloatingPanel tại thời

Page 14: What is the Web Application Developer

gian chạy.Tasks chủ yếu là ASP.NET composite controls. Kết quả là, cả hai Tasks và FloatingPanelTask mở rộng

System.Web.UI.WebControls.CompositeControl. CompositeControl thực thi ICallbackEventHandler interface, cho phép control làm việc với AJAX functionality trong ASP.NET Web application. IBuddyControlSupport interface định nghĩa một phương thức trả về các kiểu của Control the custom task có thể buddy with. Các Task và FloatingPanelTask classes xác định những control của kiểu ITaskResultsContainer, như TaskResults control, có thể buddied with chúng.

Walkthrough: Creating a custom task

Dựa trên thông tin thảo luận, đến nay, cho phép tạo ra một task đơn giản mà có lợi thế của việc thực hiện các lớp cung cấp cho framework. Hướng dẫn theo sau sẽ cung cấp một cách đơn giản để tạo ra custom task. Khi chạy, task sẽ có một nút và hộp văn bản trong floating panel. Nhập văn bản trong hộp văn bản và nhấn vào nút nội dung hộp văn bản sẽ được thêm vào một TaskResults control cùng với thời gian hiện tại trên Web server. Tại thời gian thiết kế, custom task  sẽ cho phép khả năng để chỉnh sửa các thuộc tính trưng ra thông qua một động từ tùy chỉnh trên control  trong Web page design view. Custom task  cũng có thể được sử dụng và cấu hình từ trong phạm vi quản lý. Code ví dụ cho custom task nằm ở đây: Common_SimpleTask.Sử dụng các nhiệm vụ tùy chỉnh trong Visual Studio thiết kế thời gian, sẽ tìm một cái gì đó như:

Page 15: What is the Web Application Developer

Khi chạy, cùng một trang web được đưa ra như sau. Ảnh chụp màn hình này giả định rằng một số chuổi ("Hello World", "Hello Redlands", "Hello California") đã được nhập vào hộp văn bản và Thực hiện click.

         

Thêm tham chiếu System.Web.dll, System.Drawing.dll và ESRI.ArcGIS.ADF.Web.UI.WebControls.dll. Thêm bằng cách sử dụng những câu lệnh được định nghĩa trong ví dụ dưới đây.

Bắt đầu với FloatingPanelTask abstract class . Lớp này sẽ cung cấp một floating panel container trong thời gian chạy, trong đó bạn có thể thêm các task controls của bạn và client-side logic. Tất cả các out-of-the-box controls được mở rộng từ FloatingPanelTask. Trong ví dụ dưới đây, namespace SimpleTask_CSharp chứa một lớp SimpleTask_CSharp nó được mở rộng từ FloatingTaskPanel.

Page 16: What is the Web Application Developer

Từ đó chúng ta đang xây dựng một Web control, cung cấp một số thông tin về control này sẽ xuất hiện trong một trang Web tại thời điểm thiết kế như thế nào. Sử dụng các thuộc tính ToolboxData để xác định nội dung bằng văn bản cho trang web khi control được kéo lên trên nó. Trong ví dụ dưới đây, "{0}" chỉ ra một cách tự động định nghĩa control tag prefix khi thêm vào một trang Web. Các thuộc tính khác định nghĩa control này sẽ chạy trên máy chủ và các thuộc tính khác hiển thị tại thời điểm thiết kế (chiều rộng là 100 pixels, biên giới chiều rộng là 1 pixel).

using System;using System.Collections.Generic;using System.Text;using System.Web.UI;using System.Drawing;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using System.Collections.Specialized;using ESRI.ArcGIS.ADF.Web.UI.WebControls;using System.ComponentModel;

namespace SimpleTask_CSharp{ [ToolboxData("<{0}:SimpleTask_CSharp runat=\"server\" Width=\"100px\" BorderWidth=\"1px\"> </{0}:SimpleTask_CSharp>")] public class SimpleTask_CSharp: FloatingPanelTask {

o Thêm một số biến thành viên để tham chiếu các controls được kết xuất trong thời gian chạy.

private TextBox textBox = null; private TextBox phantomTextBox = null; private HtmlInputButton button = null;

o Override CreateChildControls () method.Phương thức constructs này là visual interface của task trong thời gian chạy, như là một kết quả, đầu ra phải làm việc trong browser client (ví dụ như chứa HTML, JavaScript, ...). Quá trình này phải được thực hiện theo chương trình, vì vậy bạn có thể sử dụng các .NET HTML control classes hoặc làm cho nội dung của một ASP.NET control để tạo ra interface. Trong ví dụ dưới đây, task dialog sẽ chứa một HTML table với hai cells. Một cells chứa textbox, có chứa button. Controls property thừa kế từ System.Web.UI.WebControls.CompositeControl class được sử dụng để thêm nội dung vào task dialog.

protected override void CreateChildControls() { Controls.Clear(); base.CreateChildControls();

textBox = new TextBox(); textBox.ID = "textBox";

Page 17: What is the Web Application Developer

// The phantom text box is an invisible text box that causes the browser to // not do a postback when the enter button is hit. phantomTextBox = new TextBox(); phantomTextBox.ID = "phantomTextBox"; phantomTextBox.Style[HtmlTextWriterStyle.Display] = "none";

button = new HtmlInputButton(); button.ID = "button"; button.Value = ButtonText;

Controls.Add(textBox); Controls.Add(phantomTextBox); Controls.Add(button);

string getArgumentJS = string.Format("'textBoxValue=' + document.getElementById('{0}').value", textBox.ClientID); string onClick = string.Format("executeTask({0},\"{1}\");", getArgumentJS, CallbackFunctionString); string onKeyDown = string.Format("if(event.keyCode==13){{{0}return false;}}", onClick); button.Attributes.Add("onclick", onClick); textBox.Attributes.Add("onkeydown", onKeyDown); }

o Override GetCallbackResult () method (từ FloatingPanelTask) thiết lập giá trị Input property được đệ trình bởi task tại thời điểm chạy. Input property được thực hiện trong phạm vi FloatingPanelTask. Nó là kiểu đối tượng, nhưng thường là chỉ đơn thuần là một chuỗi. Nó thay đổi " input" các biến thành viên được sử dụng trong ExecuteTask ()method để xử lý dữ liệu được cung cấp khi người dùng tương tác với control trong thời gian chạy.

public override string GetCallbackResult() { NameValueCollection keyValColl = CallbackUtility.ParseStringIntoNameValueCollection(_callbackArg); Input = keyValColl["textBoxValue"]; return base.GetCallbackResult(); }

o Thêm execution logic cho custom task. Lấy giá trị đầu vào được cung cấp bởi người sử dụng (nếu có) thông qua Input property hay "input" member variable. Nơi đó Results property với một vài thứ để hiển thị trong TaskResults control. DisplayResult ()method trong TaskResults là chịu trách nhiệm xử lý Results object. Các kiểu sẽ là ESRI.ArcGIS.ADF.Web.UI.WebControls.TaskResultNode, ESRI.ArcGIS.ADF.Web.UI.WebControls.SimpleResultTask, hoặc System.Data.DataSet. TaskResults control sẽ đưa ra nội dung trên TreeView structure. Trong ví dụ này, một SimpleTaskResult tùy chỉnh đang được sử dụng để trả về giá trị đầu vào và thời gian trên máy chủ Web. Heading property là nút cha; chi tiết property được định nghĩa tại nút con nội dung.

public override void ExecuteTask()

Page 18: What is the Web Application Developer

{ Results = null; if (Input == null) return;

string textBoxValue = input as string;

string heading = string.Format("The time on the server is {0}", DateTime.Now.ToShortTimeString()); string detail = string.Format("The value in the text box is: {0}", textBoxValue); SimpleTaskResult str = new SimpleTaskResult(heading, detail); Results = str; }

o Override Refresh ()method để quản lý khả năng để chạy lại task và làm mới các task trong TaskResult control tại thời gian chạy. Cả hai tùy chọn có sẵn như là một context menu off task result nodes.

public override void Refresh() { string tmp = Input as string; if (!string.IsNullOrEmpty(tmp)) textBox.Text = tmp; base.Refresh(); }

o Để hoàn thành custom task, bao gồm một override có tính bắt buộc để duy trì một danh sách các item tài nguyên phụ thuộc, nếu sự phụ thuộc tồn tại. Trong ví dụ này, không phụ thuộc được xác định.

public override List<GISResourceItemDependency> GetGISResourceItemDependencies() { List<GISResourceItemDependency> list = new List<GISResourceItemDependency>(); return list; } }

}

o Để chuẩn bị cho việc triển khai, thêm một custom tag prefix để nhận dạng duy nhất task này từ Web controls, tasks,... khác, trong trang Web. Theo quy ước, thông tin này được lưu trữ trong một file riêng biệt được biên dịch với control. File được đặt tên là AssemblyInfo <language> (ví dụ, các AssemblyInfo.cs cho C# class library projects). TagPrefix attribute kết hợp với Web control namespace\assembly với một tiền tố tag được đề nghị. Nếu Web control không được đăng ký tag prefix trong Web.config file hoặc thông qua Register directive, tagprefix được đề nghị sẽ được sử dụng để đăng ký assembly trong trang. Đối với ví dụ này, sử dụng định nghĩa sau đây:

[assembly: TagPrefix("SimpleTask_CSharp", "simpleTaskCS")]

Tại điểm này, custom task có thể sử dụng trong phạm vi Visual Studio. Xây dựng custom task class library và thêm vào assembly đến Visual Studio toolbar. Dưới đây là các bước để làm điều này:

Page 19: What is the Web Application Developer

Trong Web project, với một trang Web hoạt động, phải bấm trên thanh công cụ và chọn Add Tab. Nhập tên cho tab mới, ví dụ " Custom Task Controls ".

Nhấp chuột phải vào tab mới và chọn " Choose Items...". Trên Choose Items dialog, nhấp vào nút Browse và điều hướng đến vị trí của

SimpleTask_CSharp.dll và nhấp vào nút Open. Controlmới sẽ được thêm vào và lựa chọn trong Choose Items dialog. Chọn và đánh dấu vào ô bên cạnh mục "SimpleTask_CSharp". Click vào OK để thoát khỏi hộp thoại.

Tab mới sẽ chứa custom task control. Kéo task control và Web ADF TaskResults control vào trong Web page. Sử dụng verbs off custom task control, buddy TaskResults control đến custom task.

custom task cũng sẽ hoạt động với một điều khiển ASP.NET navigation control như out-of-the-box tasks.

Task Runtime Workflow Khi chạy, hầu hết các tasks sẽ theo một bộ tiêu chuẩn của các bước để xử lý dữ liệu người dùng và tạo ra và hiển thị những kết quả. Web ADF JavaScript, , Web ADF control classes, và Task framework interfaces và implementations tất cả công việc công tác cùng nhau để hỗ trợ một nhiệm vụ. Sơ đồ dưới đây và tiến trình công việc sẽ thông qua nhiệm vụ thực hiện trong thời gian chạy bằng cách sử dụng thông qua ví dụ (bao gồm ở trên), nơi áp dụng. Các vòng tròn màu xanh lá cây chỉ ra chuỗi các sự kiện callback khởi đầu nhiệm vụ:

Task Execution Steps1. Một hành động của người dùng trong trình duyệt gọi executeTask function trong Web ADF JavaScript file display_task.js. Theo mặc định, display_task.js được nhúng để sử dụng bởi task controls nó là mở rộng FloatingPanelTask. Các hành động của người dùng được xác định bởi task control, thường một hành động trên một controls hay elements tạo nên task user interface. Hai đối số quan trọng cho các chức năng executeTask để làm việc, callback arguments và callback function string. Các callback arguments cung cấp thông tin về những gì người dùng muốn công việc đó làm. Ví dụ, cung cấp một chuỗi văn bản để tìm kiếm một cơ sở dữ liệu. Callback function

Page 20: What is the Web Application Developer

string định nghĩa nội dung của ASP.NET Callback Manager function, WebForm_DoCallback. Để biết thêm thông tin, xem các cuộc thảo luận chung của AJAX và ASP.NET 2.0. Trong ví dụ dưới đây, sự kiện onclick của một phần tử (ví dụ như HTML button) gây nên các cuộc gọi đến executeTask JavaScript function.

onclick="executeTask('textBoxValue=The Payload', "WebForm_DoCallback('TaskManager1$SimpleTask_CSharp1',argument,processCallbackResult,context,postBackError,true)");"

ExecuteTask function sẽ làm hai việc trước khi thực hiện nhiệm vụ: 1) chỉ định một id công việc để theo dõi các yêu cầu không đồng bộ, và 2) khởi tạo một callback để bắt đầu việc theo dõi tình trạng trong

TaskResults control, nếu là một trong những kết hợp thực hiện. nhiệm vụ. Việc theo dõi tình trạng callback bỏ qua các bước 5 và 6 khi đầu vào người sử dụng không được xử lý. Sau khi gọi lại để bắt đầu hoạt động chỉ rỏ, startJob function được gọi là xử lý đầu vào người sử dụng cho nhiệm vụ này. 2. Cấu trúc startJob function là một danh sách các cặp giá trị đối số để cung cấp các nhiệm vụ với các thông tin cần thiết để xử lý yêu cầu người sử dụng. Các EventArg argument được sử dụng bởi task control để xác định nếu nó phải thực hiện và cung cấp kết quả. Custom arguments cung cấp các giá trị đầu vào cho công việc cần xử lý callback request. Tất cả được đóng gói như là "argument" parameter của WebForm_DoCallback function call. Một ví dụ có thể bao gồm những điều sau đây mà "textBoxValue" là một custom argument:

"EventArg=executeTask&taskJobID=2&textBoxValue=The Payload"

Tham số đầu tiên trong WebForm_DoCallback function cho biết tên của control này sẽ xử lý callback request. Trong trường hợp này, tên phải phù hợp với tên tại thời điểm chạy của task control. XMLHttpRequest object khởi tạo callback cho máy chủ và các ứng dụng Web để truyền nội dung callback đến task control. Từ đó task control mở rộng của FloatingPanelTask, đó là một điều khiển tổng hợp, RaiseCallbackEvent method trong CompositeControl class bắt được và lưu trữ argument content trong một biến thành viên mang tên "_callbackArg", mà sẽ được sử dụng trong quá trình thực hiện nhiệm vụ.

3. Trong vòng đời callback (thảo luận trong chủ đề và gọi lại các khung ASP.NET 2.0 AJAX) GetCallbackResult method được gọi là sau khi RaiseCallbackEvent. GetCallbackResult method trong task control class được sử dụng để lấy các giá trị cho custom argument values được sử dụng bởi task. Các giá trị được lưu trữ trong thuộc tính có tên là "Input" nó được định nghĩa ITask interface, thực thi tại và kế thừa từ FloatingPanelTask class . Ví dụ code dưới đây là một điển hình cho phương pháp GetCallbackResult trong custom task. Biến thành viên _callbackArg được phân tách bằng cách sử dụng Web ADF CallbackUtility class để trả về một tập hợp các cẵp name\value (argument\value). Trong trường hợp này, chỉ có một custom argument (tên "textBoxValue") là quan tâm đến custom task, do đó, nó được gán cho Input property. Cuộc gọi sau cùng đến lớp cơ sở (FloatingPanelTask) GetCallbackResult method tiếp tục xử lý task tiêu chuẩn.

NameValueCollection keyValColl = CallbackUtility.ParseStringIntoNameValueCollection(_callbackArg);

Input = keyValColl["textBoxValue"];

Page 21: What is the Web Application Developer

return base.GetCallbackResult();

4. GetCallbackResult method trong FloatingPanelTask chịu trách nhiệm để gọi các methods để thực hiện các task và khởi tạo callback response string để hiển thị kết quả trong trình duyệt. Đầu tiên biến _callbackArg được phân tích cú pháp để xác định các đối số sự kiện chính "EventArg". FloatingPanelTask tìm hai giá trị cụ thể, "startTaskActivityIndicator" và "executeTask". Nếu "startTaskActivityIndicator" thì callback response sẽ hiển thị việc theo dõi tình trạng trong TaskResults control, nếu có. Nếu "executeTask", ExecuteTask method trong custom task class sẽ được gọi, tiếp theo là một cuộc gọi đến DisplayResults method trong FloatingPanelTask class để tạo ra callback string.

public override string GetCallbackResult()

{

NameValueCollection keyValColl = CallbackUtility.ParseStringIntoNameValueCollection(_callbackArg);

string eventArg = keyValColl["EventArg"];

string taskJobID = keyValColl["taskJobID"];

if (eventArg == "startTaskActivityIndicator")

{

StartTaskActivityIndicator(taskJobID);

}

else if (eventArg == "executeTask")

{

ExecuteTask();

DisplayResults(taskJobID, Input, Results);

}

else

{

return base.GetCallbackResult();

}

return CallbackResults.ToString();

}

Page 22: What is the Web Application Developer

5. ExecuteTask method trong custom task class là nơi mà phần lớn các diễn ra việc xử lý task. Web ADF controls, resources, functionalities, và data source specific APIs có thể được sử dụng ở đây để xử lý các giá trị đầu vào (được lưu trữ trong Input property). Kết quả thực hiện task có thể được lưu trữ trong một thuộc tính có tên là " Results” sẽ được hiển thị trong TaskResults control. Results property được định nghĩa trong ITask interface, thực hiện và kế thừa từ FloatingPanelTask class. Nó có thể là một trong ba loại khác nhau: SimpleTaskResult, DataSet, và TaskResultNode. Tất cả đều được thảo luận trong các cuộc thảo luận nội dung tuỳ chỉnh của kiểm soát TaskResults.

6. DisplayResults method trong FloatingPanelTask được gọi và cung cấp Results từ thực hiện task. DisplayResults bổ sung thêm Results object đến TaskResults control buddied cho custom task, nếu có sẵn. TaskResults control chính nó có một DisplayResults method được thiết kế để làm việc với các loại được xác định trước (xem bước trước) và đưa ra nội dung HTML cho sự điều khiển trong trình duyệt. Web ADF controls sử dụng CallbackResult objects để cập nhật trình duyệt của control (Control Callbacks cuộc thảo luận chi tiết hơn). Khi TaskResults control thay đổi trên máy chủ, nó sẽ tạo ra một bộ CallbackResults từ việc xử lý bởi client (browser). CallbackResults property của custom task control, được thừa kế từ CompositeControl class, sẽ được sử dụng để tạo ra callback response đến trình duyệt. Kết quả là, các CallbackResults từ TaskResults control cần được bổ sung vào custom task control's CallbackResults property. DisplayResults method trong FloatingPanelTask control được cung cấp dưới đây:

protected virtual void DisplayResults(string jobID, object taskInput, object taskResults)

{

ITaskResultsContainer resultsContainer = null;

for (int i = 0; i < TaskResultsContainers.Count; i++)

{

resultsContainer = Utility.FindControl(TaskResultsContainers[i].Name, Page) as ITaskResultsContainer;

if (resultsContainer != null)

{

resultsContainer.DisplayResults(this, jobID, taskInput, taskResults);

CallbackResults.CopyFrom(resultsContainer.CallbackResults);

}

}

}

Page 23: What is the Web Application Developer

7. Gọi lại bước 4 dùng GetCallbackResult method của custom task control phải gửi callback response đến client browser (phương thức trả về một chuỗi). custom task control sử dụng CallbackResults property để lưu trữ các chuỗi nội dung cần được trả lại cho trình duyệt. Cụ thể hơn, chuỗi nội dung sẽ được xử lý bởi Web ADF JavaScript để cập nhật Web ADF control trong trình duyệt. CallbackResults property lưu trữ một tập của các CallbackResult objects. Mỗi đối tượng được kết hợp với một Web ADF định nghĩa chuỗi để được xử lý bởi Web ADF JavaScript. Phương thức ToString () được gọi trên CallbackResults property để tạo ra callback string. Từ đó callback results cho một TaskResults control bao gồm nội dung HTML và JavaScript sẽ tự động thêm vào các trang trong trình duyệt, hoàn thành callback string có thể khá lớn. Phần đầu của ví dụ callback string được cung cấp dưới đây:

"TaskResults:::TaskResults1:::content:::<div id=\"TaskResults1\" title=\"Right-click for context. . ."

8. ASP.NET 2.0 WebResource cho callbacks trực tiếp callback response string được đăng ký vào callback response function, trong trường hợp này, Web ADF định nghĩa processCallbackResult function. Chức năng này được thiết kế để phân tích callback response cho Web ADF controls trên máy khách và kích hoạt các hành động tiếp theo để cập nhật màn hình hiển thị phía máy khách.9. Các thành phần trong client browser được cập nhật để phản ánh các nội dung mới từ các callback response. Trong ví dụ này, callback response cập nhật nội dung của TaskResults control với kết quả của một task thực thi trên máy chủ.

Enhance Visual Studio Integration Để tăng cường cấu hình tại thời điểm thiết kế Visual Studio của custom task, là mở rộng ESRI.ArcGIS.ADF.Web.UI.WebControls.Design.Designers.TaskDesigner class với Web ADF. Lớp này cung cấp framework cho việc phơi bày custom verbs off một task control khi thiết lập các thuộc tính của điều khiển trong design-view. Quá trình này bao gồm ba bước: 1) trình bày các thuộc tính trong custom task để thay đổi thông qua custom verb2) tạo ra một Windows form cho Visual Studio developer để thiết lập thuộc tính và3) mở rộng TaskDesigner và kết hợo nó với custom task. Phần này được xây dựng dựa trên tiêu chuẩn thực hành NET để tăng cường custom Web controls trong Visual Studio IDE.

Trong custom task class (SimpleTask_CSharp.cs), thêm một public property để sửa đổi các văn bản trên button. Các thuộc tính trước property sẽ xác định TaskDesigner sẽ làm việc với tính năng và property mặc định thế nào.

[Browsable(true)]

[Category("Appearance")]

[DefaultValue("Execute")]

[PersistenceMode(PersistenceMode.Attribute)]

public string ButtonText

{

Page 24: What is the Web Application Developer

get

{

object o = StateManager.GetProperty("buttonText");

return (o == null) ? "Execute" : o as string;

}

set

{

StateManager.SetProperty("buttonText", value);

} }

Tạo một Windows form mới trong cùng custom task library project. Tên của custom form class là ButtonTextEditorForm. Nó nên được bao gồm trong dự án để khi bạn phân phối custom task assembly, Visual Studio developer sẽ có thể sử dụng form  để thiết lập các thuộc tính vào nhiệm vụ, trong thời gian thiết kế. Các hình thức sẽ có sự xuất hiện sau đây:

Đây là mã nguồn cho form (ButtonTextEditorForm.cs). Một lưu ý quan trọng, form có chứa một TextBox tên là txtButtonText:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;

namespace SimpleTask_CSharp{ public partial class ButtonTextEditorForm : Form {

Page 25: What is the Web Application Developer

public ButtonTextEditorForm(string value) { InitializeComponent(); Value = value; }

public string Value { get { return txtButtonText.Text; } set { if (value != null) txtButtonText.Text = value; } }

private void cmdOK_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; Hide(); }

private void cmdCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Hide(); } }}

Form sẽ được khởi tạo bởi custom class nó mở rộng từ System.Drawing.Design.UITypeEditor class. Lớp này cung cấp một lớp cơ sở để thực hiện một custom type editor  cho một Web control trong IDE Visual Studio tại thời điểm thiết kế. custom class, được đặt tên là ButtonTextEditor, sẽ khởi tạo các Windows form để nhập một giá trị - trong trường hợp này, giá trị của văn bảnvào button trong custom task. Giá trị trả lại sẽ được thực hiện custom task.    

using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Diagnostics;using System.Drawing;using System.Drawing.Drawing2D;using System.Drawing.Design;using System.Windows.Forms;using System.Windows.Forms.ComponentModel;using System.Windows.Forms.Design;using System.Collections;

namespace SimpleTask_CSharp{

public class ButtonTextEditor : UITypeEditor

Page 26: What is the Web Application Developer

{

public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context != null) && (provider != null)) { System.Web.UI.Control ctrl = context.Instance as System.Web.UI.Control;

if (ctrl == null) return value;

ButtonTextEditorForm form = new ButtonTextEditorForm(value as string); if (form.ShowDialog() == DialogResult.OK) value = form.Value; } return value; }

public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { if (context != null) { return UITypeEditorEditStyle.Modal; } return base.GetEditStyle(context); } }}

Tạo các lớp links input trong các Windows form cho custom task trong Visual Studio tại thời điểm thiết kế. Tạo một lớp, được đặt tên là SimpleTaskDesigner_CSharp, nó là mở rộng Web ADF TaskDesigner class. Trong khởi tạo, thêm một DesignerVerb mới để custom task control khởi động ButtonTextEditorForm Windows form. Khi khởi động , có mô tả ButtonText property trong custom task, tạo ra một ButtonTextEditor instance bằng cách mở ra Windows form, nắm bắt giá trị đầu vào và cập nhật ButtonText property.

using System;using System.Collections.Generic;using System.Text;using System.Drawing.Design;using System.ComponentModel;using System.ComponentModel.Design;using ESRI.ArcGIS.ADF.Web.UI.WebControls.Design.Designers;

namespace SimpleTask_CSharp{ public class SimpleTaskDesigner_CSharp : TaskDesigner { public SimpleTaskDesigner_CSharp() : base()

Page 27: What is the Web Application Developer

{ verbs.Add(new DesignerVerb("Edit the button text", new EventHandler(OnEditButtonText))); }

protected void OnEditButtonText(object sender, EventArgs args) { SimpleTask_CSharp task = this.Component as SimpleTask_CSharp; PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(task)["ButtonText"]; UITypeEditor editor = new ButtonTextEditor(); object newValue = editor.EditValue(new TaskControlDesignerTypeDescriptorContext(this, propertyDescriptor), (IServiceProvider)this, propertyDescriptor.GetValue(task)); propertyDescriptor.SetValue(task, newValue); } }}

Bây giờ, kết hợp chức năng này với custom task. Ở phía trên của custom task class, thêm "Designer" attribute để xác định rằng custom TaskDesigner sẽ được kết hợp với nhiệm vụ. Các thuộc tính sẽ kết hợp với các custom task với một TaskDesigner mới (tên lớp được đặt là SimpleTaskDesigner_CSharp) tạo ra trước đó. Trong đoạn mã ví dụ dưới đây, chỉ có một dòng tham khảo Designer attribute đã được thêm vào nội dung hiện có. 

namespace SimpleTask_CSharp{ [ToolboxData("<{0}:SimpleTask_CSharp runat=\"server\" Width=\"100px\" BorderWidth=\"1px\"> </{0}:SimpleTask_CSharp>")] [Designer(typeof(SimpleTaskDesigner_CSharp))] public class SimpleTask_CSharp: FloatingPanelTask {

Khi custom task control được thêm vào một trang Web, một verb mới bây giờ đã có để thay đổi văn bản của các button trên task. Nhấp vào " Edit the button text " verb và the ButtonTextEditorForm sẽ hiển thị. Ảnh chụp màn hình dưới đây minh họa việc bổ sung mới.

Page 28: What is the Web Application Developer

Manager Integration

Web ADF task framework cũng cho phép một custom task được tích hợp vào Manager Web application building framework. Manager cung cấp một Tasks panel liệt kê danh sách tasks có sẵn, trong khi thiết kế một Web application mới. Trong khi out-of-the-box tasks đã bao hàm bởi sư mặc định, bạn có thể mở rộng danh sách này bằng cách bổ sung thêm custom task của bạn. Manager duy trì một danh sách các tasks được cấu hình trong Tasks.xml file nằm trong thư mục App_Data cho Manager Web application (e.g. C:\Inetpub\wwwroot\ArcGIS\Manager\Applications\App_Data). Một custom task sẽ cần phải thêm một item vào danh sách này để sẵn có trong Manager. Điều quan trọng cần lưu ý khi gỡ bỏ cài đặt hoặc cài đặt lại Web ADF , các tập tinTasks.xml sẽ được ghi đè. Kết quả là, bạn sẽ cần phải thêm các custom task item. Một số tùy chọn được cung cấp trong các cuộc thảo luận dưới đây. ESRI.ArcGIS.ADF.Web.UI.WebControls.IWebConfigurator interface cung cấp framework cơ bản để thực hiện nhiệm vụ sử dụng, xuất hiện và tích hợp trong Manager. Sau khi hoàn tất, Tasks panel trong Manager sẽ cung cấp tùy chọn để thêm và cấu hình custom task. Nếu một Web configurator có sẵn, nó có thể được sử dụng để thiết lập các thuộc tính của task trong phạm vi Manager. Một ảnh chụp màn hình của custom task tích hợp với Manager được cung cấp dưới đây:

Page 29: What is the Web Application Developer

Tạo một custom class mà có thể mở rộng CompositeControl và thực hiện IWebConfigurator và IBuddyControlSupport. Manager là một ứng dụng Web. Vì chúng ta cần phải tạo ra một lớp mà sẽ sử dụng để cấu hình trực quan custom task trong Manager tại thời gian chạy, nó cũng phải là một composite Web control. Để tích hợp với Task configuration framework trong Manager, IWebConfigurator và IBuddyControlSupport interfaces được thực hiện. Tạo một lớp mới tên là SimpleTaskWebConfigurator_CSharp và thêm một tham chiếu đếnSystem.Web.dll, System.Drawing.dll vàESRI.ArcGIS.ADF.Web.UI.WebControls.dll. Giữ namespace tương tự như các lớp trước đây (SimpleTask_CSharp).

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI;

using System.Collections.Specialized;

using System.Web.UI.WebControls;

using System.Drawing.Design;

using System.ComponentModel;

Page 30: What is the Web Application Developer

using System.Collections;

using System.Web.UI.HtmlControls;

using ESRI.ArcGIS.ADF.Web.UI.WebControls;

namespace SimpleTask_CSharp

{

public class SimpleTaskWebConfigurator_CSharp : ESRI.ArcGIS.ADF.Web.UI.WebControls.CompositeControl, IWebConfigurator, IBuddyControlSupport

{

Thêm một số biến thành viên lưu trữ tài tham chiếu cho các điều khiểntrong Web configurator interface.

private Button okButton = null; private Button cancelButton = null; private TextBox buttonText = null; private TextBox title = null; private ColorPicker colorPicker = null;

Override the CreateChildControls() method để tạo ra runtime interface của Web configurator control. Quá trình này tương tự như việc tạo ra các interface cho custom task. Một cách đáng tiết là không có thiết kế trực quan cho quá trình này tại thời điểm này, vì thế chỉ định dạng bằng tay control programmatically được yêu cầu. Web configurator sẽ có hai textboxes để thay đổi tiêu đề của custom task floating panel và button text, hai button để có thể chấp nhận hoặc hủy bỏ những thay đổi và ColorPicker tương tác chọn màu nền của control trong Web application at runtime.

protected override void CreateChildControls() { Controls.Clear();

title = new TextBox(); title.ID = "title";

buttonText = new TextBox(); buttonText.Text = "Find"; buttonText.ID = "buttonText";

colorPicker = new ColorPicker(); colorPicker.ID = "colorPicker"; colorPicker.Font.Name = "Verdana"; colorPicker.Font.Size = new FontUnit(new Unit(8, UnitType.Point)); colorPicker.BackColor = System.Drawing.Color.White;

Page 31: What is the Web Application Developer

colorPicker.DropDownBorderColor = System.Drawing.Color.Silver; colorPicker.DropDownBorderStyle = BorderStyle.Solid; colorPicker.DropDownBorderWidth = new Unit(1, UnitType.Pixel); colorPicker.ChosenColor = System.Drawing.Color.White; colorPicker.ShowColorNames = false; colorPicker.DisplayText = "Background color of the task";

okButton = new Button(); okButton.ID = "okButton"; okButton.Text = "OK"; okButton.Width = new Unit(75, UnitType.Pixel); okButton.Click += new EventHandler(okButton_Click);

cancelButton = new Button(); cancelButton.ID = "cancelButton"; cancelButton.Text = "Cancel"; cancelButton.Width = new Unit(75, UnitType.Pixel); cancelButton.Click += new EventHandler(cancelButton_Click);

Controls.Add(title); Controls.Add(buttonText); Controls.Add(colorPicker); Controls.Add(okButton); Controls.Add(cancelButton); }

Các phương thức sau đây được thiết kế để cho phép Web configurator làm việc trong các sự kiện trong Manager Web application. Các nút OK và Cancel trong Web configurator control sẽ gọi sự kiện mà móc vào phương thức thực hiện cho IWebConfigurator interface, tên cụ thể là "OnWebConfiguration *" xử lý sự kiện.Từ đó control được hoạt động với Web application, nó có thể ghi đè lêncác sự kiện để khởi tạo và cập nhật Web configurator properties.  

void cancelButton_Click(object sender, EventArgs e) { OnWebConfigurationCancel(new EventArgs()); }

private void okButton_Click(object sender, EventArgs e) { if (TaskInstance == null) return; TaskInstance.Title = title.Text; TaskInstance.ButtonText = buttonText.Text; TaskInstance.BackColor = colorPicker.ChosenColor;

OnWebConfigurationComplete(new WebConfigurationCompleteEventArgs(TaskInstance, getDesignTimeTag())); }

protected override HtmlTextWriterTag TagKey { get {

Page 32: What is the Web Application Developer

return HtmlTextWriterTag.Div; } }

protected override void OnLoad(EventArgs e) { base.OnLoad(e); }

protected override void OnPreRender(EventArgs e) { base.OnPreRender(e);

if (!Page.IsCallback) { // load current properties of control to edit loadProperties(); } }

If the custom task has already been configured, for example you attempt to edit an existing Web application that contains the custom task, we need to reload the current control settings. Both loadProperties and Refresh will enable the retrieval of existing custom task control properties. 

private void loadProperties(){if (TaskInstance == null) return;

title.Text = TaskInstance.Title;buttonText.Text = TaskInstance.ButtonText;colorPicker.ChosenColor = TaskInstance.BackColor;}

public override void Refresh(){loadProperties();base.Refresh();}

Một tập IWebConfiguratior properties và methods cần được thực hiện. Trong ví dụ này, thực hiện cơ bản của việc xử lý sự kiện được cung cấp. ControlToConfigure property được thiết kế để trả về một tham chiếu đến một thể hiện custom task, tạo ra khi custom task đã được bổ sung vào Current Tasks panel trong Manager.

private ControlCollection controls = null; private SimpleTask_CSharp TaskInstance = null;

public ControlCollection AdditionalControls { get { return controls; } set { controls = value; } }

public Control ControlToConfigure

Page 33: What is the Web Application Developer

{ get { return TaskInstance; } set { if (!(value is SimpleTask_CSharp)) { throw new ArgumentException(); } TaskInstance = value as SimpleTask_CSharp; } }

public bool ValidateResources(out string message) { message = null; return true; }

private WebConfigurationCompleteEventHandler onWebConfigurationComplete;

public event WebConfigurationCompleteEventHandler WebConfigurationCompleted { add { onWebConfigurationComplete += value; } remove { onWebConfigurationComplete -= value; } }

protected virtual void OnWebConfigurationComplete(WebConfigurationCompleteEventArgs args) { if (onWebConfigurationComplete != null) onWebConfigurationComplete(this, args); }

private WebConfigurationCanceledEventHandler onWebConfigurationCancel;

public event WebConfigurationCanceledEventHandler WebConfigurationCanceled { add { onWebConfigurationCancel += value; } remove { onWebConfigurationCancel -= value; } }

protected virtual void OnWebConfigurationCancel(EventArgs args) { if (onWebConfigurationCancel != null) onWebConfigurationCancel(this, args); }

Abstract class CompositeControl, mà từ đó Web configurator class của chúng xuất phát, thực hiện ICallbackEventHandler interface. Interface này cho phép một control làm việc với callbacks. Chúng cần phải ghi đè lên phương thức này để cập nhật các chuỗi _callbackArg với nội dung mà liên quanđến Web configurator của chúng (ví dụ như thay đổi ColorPicker).

Page 34: What is the Web Application Developer

public override string GetCallbackResult() { NameValueCollection keyValColl = CallbackUtility.ParseStringIntoNameValueCollection(_callbackArg); return CallbackResults.ToString(); }

Thực hiện IBuddyControlSupport interface liên quan đến việc thực hiện GetSupportedBuddyControlTypes() method. Phương thức này trả về các kiểu điều khiển mà một điều khiển khác có thể kết hợp. Trong trường hợp này, Web configurator control có thể kết hợp với custom task control. Điều này cho phép Web configurator có được một tham chiếu đến custom task instance.

public Type[] GetSupportedBuddyControlTypes() { Type[] types = new Type[1]; types[0] = typeof(SimpleTask_CSharp); return types; }

Khi custom task được viết ra để Web application tạo ra bởi quản lý, custom tags nó được thêm để trang phải được xác định. getDesignTimeTag() method xác định nội dung của đầu ra. Về bản chất,đầu ra là một tập các chuỗi để khai báo việc xác định custom task control.

private string getDesignTimeTag() { string openTag = string.Format("<simpleTaskCS:SimpleTask_CSharp ID=\"{0}\" runat=\"server\" Style=\"z-index: 10000; left: 100px; position: absolute; top: 100px\" Width=\"200px\" Visible=\"False\" ButtonText=\"{1}\" Title=\"{2}\" ToolTip=\"{3}\" NavigationPath=\"{4}\" BackColor=\"{5}\">", TaskInstance.ID, TaskInstance.ButtonText, TaskInstance.Title, TaskInstance.ToolTip, TaskInstance.NavigationPath, System.Drawing.ColorTranslator.ToHtml(TaskInstance.BackColor)); StringBuilder trcTag = new StringBuilder(); trcTag.Append("<TaskResultsContainers>"); trcTag.Append("<esri:BuddyControl Name=\"TaskResults1\" />"); trcTag.Append("</TaskResultsContainers>");

string endTag = "</simpleTaskCS:SimpleTask_CSharp>";

StringBuilder tag = new StringBuilder(); tag.Append(openTag); tag.Append(trcTag.ToString()); tag.Append(endTag);

return tag.ToString(); }

Page 35: What is the Web Application Developer

Custom Web configurator hoàn tất. Để kết hợp Web configurator với task class, sử dụng WebConfigurator attribute và chỉ định tên của Web configurator class (SimpleTaskWebConfigurator_CSharp). Trong đoạn mã ví dụ dưới đây,chỉ có một dòng mới tham chiếu thuộc tính WebConfigurator đã được thêm vào nội dung hiện có.

namespace SimpleTask_CSharp{ [ToolboxData("<{0}:SimpleTask_CSharp runat=\"server\" Width=\"100px\" BorderWidth=\"1px\"> </{0}:SimpleTask_CSharp>")] [WebConfigurator(typeof(SimpleTaskWebConfigurator_CSharp))] [Designer(typeof(SimpleTaskDesigner_CSharp))] public class SimpleTask_CSharp: FloatingPanelTask {

Bây giờ custom task assembly cần phải được đánh dấu vì chúng có thể thêm nó vào GAC. Ký hiệu assembly sẽ làm cho nó dễ dàng hơn để phân phối vàđăng ký với Manager. Để đánh dấu assembly, bạn có thể cần phải tạo ra một khóa ký hiệu. Sử dụng sn.exe utility với .NET SDK. Open a Visual Studio 2005 Command Prompt và nhập:

sn -k MyKeyPair.snk 

Trong Visual Studio, kích chuột phải vào custom task class library project trong Solution Explorer window và chọn Properties in the context menu. Nhấp vào Signing tab và check "Sign the assembly" check box. Nhập đường dẫn chính xác để tạo khoá.Biên dịch lại custom task assemblyDeploying the custom task for Manager

Các bước sau đây có thể được sử dụng để triển khai một custom task để sử dụng trong Manager. Các bước là như nhau bất kể cho dù bạn tạo custom task và có mã nguồn hoặc được cung cấp custom task assembly từ một bên khác.383. Thêm custom task assembly đến GAC. Thông qua đến vị trí của SimpleTask_CSharp.dll. Sử dụng tiện ích gacutil.exe bao gồm với .NET SDK. Open a Visual Studio 2005 Command Prompt và nhập:

gacutil -i SimpleTask_CSharp.dll 

Nếu bạn thay đổi custom task, bạn sẽ cần phải cập nhật GAC bằngcách sử dụng- tùy chọn với gacutil.exe. Một lựa chọn khác là tự động cài đặt lại custom task assembly để GAC sửa đổi các sự kiện trước và sau khi xây dựng sự hiện trong Visual Studio. Sử dụng các bước sau đây để cấu hình tùy chọn này:1) Trong Visual Studio, mở trang thuộc tính cho custom task project.2)Thêm tiếp theo vào pre-build event command line textbox. Dòng đầu tiên khởi tạo command line environment for the .NET Framework tools. Dòng thứ haitháo gỡ bỏ các custom task assembly tồn tại từ các GAC:

call "%VS80COMNTOOLS%vsvars32.bat"gacutil -u $(TargetName)

3) Thêm theo sau vào post-build event command line textbox. Một lần nữa,dòng đầu tiên khởi tạo command line environment for the .NET Framework tools.Dòng thứ hai cài custom task assembly tồn tại vào GAC. Dòng cuối cùng khởi động lại IIS và là tùy chọn. Nó giả định rằng task development và thời gian chạy thử nghiệm xảy ra trên cùng một máy. IIS phải được khởi động lại bởi vì ASP.NET Web applications có thể làm việc với một bản sao lưu trong bộ nhớ cache

Page 36: What is the Web Application Developer

của assembly trong GAC (ví dụ như custom task control), nếu không sửa đổi nhiệm vụ gần đây nhất có thể không truy cập trong thời gian chạy thử nghiệm:

call "%VS80COMNTOOLS%vsvars32.bat"

gacutil -i $(TargetPath)iisreset

Thêm thông custom task để các Tasks.xml được sử dụng bởi Manager. Một loạt các Task elements, một yếu tố cho từng task control có sẵn trong Manager, được liệt kê. Task attributes có các định nghĩa sau đây:

Task Attribute Description

Name Task class name.

DisplayName The name of the custom task displayed in the Manager dialog to add and configure a task.

Type

Contains five comma-delimited parameters. Listed in order they are:1) Fully qualified task class name2) Name of the assembly that contains the task classes and resources3) Version number of the assembly4) Culture of the assembly5) PublicKeyToken of the assembly. Defined by the key used to sign the assembly

TagPrefix The tag prefix name assigned to the task control. Defined by the TagPrefix attribute of the assembly.

Trong các thư mục App_Data cho Manager Web application (ví dụ như C: \Inetpub \ wwwroot \ ArcGIS \ quản lý \ Applications \ App_Data) mở các tập tinTasks.xml trong một trình soạn thảo văn bản. Thêm dòng sau trong thẻ <Tasks>:

<Task Name="SimpleTask_CSharp" DisplayName="Simple Task CSharp" Type="SimpleTask_CSharp.SimpleTask_CSharp, SimpleTask_CSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=a284737434b9d17c" TagPrefix="simpleTaskCS" /> Để xác nhận rằng Version, Culture, và PublicKeyToken attributes là chính xác, mở Visual Studio 2005 lệnh Prompt và nhập:

gacutil -l SimpleTask_CSharp

Sau khi gỡ bỏ cài đặt hoặc cài đặt lại của Web ADF, các mục tùy chỉnh trong tập tin Tasks.xml sẽ được ghi đè. Kết quả là, bạn có trách nhiệm giữ lại hay lại thêm mục. Một số tùy chọn có sẵn bao gồm:

1) Nhập lại bằng tay Nhập lại bằng tay các custom task items sẽ làm việc, có thể tùy chọn dễ gây lỗi. Đây có lẽ là chỉ có một lựa chọn cho custom task developers. 2) Giữ lại Tasks.xml với custom task entriesLưu trữ các Tasks.xml tùy chỉnh trong một vị trí khác, cài đặt lại, và sao chép nó vào vị trí quản lý thích hợp. Một lần nữa, tùy chọn này là dễ bị lỗi vì nó dựa trên tự sao chép một tập tin từ một địa điểm khác. Ngoài ra, nó sẽ chỉ làm việc nếu phiên bản Web ADF vẫn giữ nguyên. Một lần nữa, đây chỉ

Page 37: What is the Web Application Developer

là một lựa chọn đáng tin cậy cho các nhà phát triển công việc tùy chỉnh. 3) Tạo ra custom task deployment setup Tạo setup application để cấu hình custom task của bạn. Đây có lẽ là lựa chọn tốt nhất để phân phối kể từ khi một người dùng cuối sẽ chỉ cần chạy một chương trình nhiệm vụ thiết lập tùy chỉnh với các nhiệm vụ tùy chỉnh. Việc cài đặt và thiếtlập các nhiệm vụ tùy chỉnh sẽ quản lý việc bổ sung các mục tùy chỉnh nhiệm vụtrong Tasks.xml. Tùy chọn này sẽ yêu cầu một số công việc bổ sung cho nhà phát triển công việc tùy chỉnh (ví dụ như tạo ra một ứng dụng cài đặt), nhưng sẽ cung cấp một kinh nghiệm người sử dụng quen thuộc hơn.394. Khởi động lại IIS Manager để nhận ra những thay đổi. Mở Command Prompt Visual Studio 2005 và nhập:

iisreset

Quản lý sẽ cung cấp cho bạn khả năng cấu hình custom task trong khi thiết kế một ứng dụng web mới. Trong bảng điều khiển Nhiệm vụ, chọn "Taskđơn giản csharp làm việc" và thêm nó vào danh sách hiện tại của nhiệm vụ được bao gồm trong các ứng dụng Web.1. Đánh dấu những nhiệm vụ tuỳ chỉnh trong cửa sổ Nhiệm vụ hiện tại và nhấp vào nút "Configure". Đặt tên của cửa sổ tác vụ tùy chỉnh, văn bản nút, và màu nềncủa điều khiển.2. Sau khi hoàn thành, khởi tạo các nhiệm vụ tùy chỉnh trong ứng dụng Webbằng cách mở rộng bảng Nhiệm vụ và cách nhấp vào các nhiệm vụ tùy chỉnh trongtrình đơn. Dưới đây là một ảnh chụp màn hình để minh họa những gì bạn có thể thấy:)

III. Web ADF Common Data Source API

Previous versions of the Web ADF (pre-9.2), termed the ArcGIS Server ADF, were designed to support a single data source, namely ArcGIS Server via ArcObjects. The new Web ADF extends and enhances data source support in two ways. One, it is designed to support data from multiple sources, including ArcGIS

Page 38: What is the Web Application Developer

Server and ArcIMS. And two, the multi-source architecture allows you to integrate and interact with data from different sources at the same time, in the same application.

(Các phiên bản trước của Web ADF (pre-9.2), gọi là ArcGIS Server ADF, được thiết kế để hỗ trợ một nguồn dữ liệu duy nhất, cụ thể là ArcGIS Server thông qua ArcObjects. Web ADF mới mở rộng và tăng cường hỗ trợ nguồn dữ liệu theo hai cách. Một, nó được thiết kế để hỗ trợ dữ liệu từ nhiều nguồn, bao gồm ArcGIS Server và ArcIMS. Và thứ hai, các kiến trúc đa nguồn cho phép bạn tích hợp và tương tác với dữ liệu từ các nguồn khác nhau cùng một lúc, trong cùng một ứng dụng.)

How does the Web ADF support working with multiple data sources?

The Web ADF uses the Common Data Source API (or Common API) to work with multiple data sources. The Common API is an integral part of the Web ADF because it provides a generic framework by which a data source can be consolidated and utilized within the Web ADF. Different data sources can "plug-in" to the Web ADF by implementing classes and interfaces of the generic framework defined via a set of interfaces and classes in the ESRI.ArcGIS.ADF.Web.DataSources assembly\namespace. Three interfaces provide the implementation foundation of the Common API:

• IGISDataSource• IGISResource• IGISFunctionality

In general, data sources are exposed as resources and functionalities for use in the Web ADF. A data source can have one or more resources and a resource can have one or more functionalities.

(Làm thế nào để Web ADF hỗ trợ làm việc với nhiều nguồn dữ liệu?

Web ADF sử dụng Common Data Source API (hay Common API) để làm việc với nhiều nguồn dữ liệu. Các Common API là một phần không thể thiếu của Web ADF bởi vì nó cung cấp một framework chung bởi một nguồn dữ liệu có thể được củng cố và sử dụng trong Web ADF. Các nguồn dữ liệu khác nhau có thể "plug-in" đến Web ADF bằng cách thực hiện các classes và interfaces của các framework chung được xác định thông qua một tập interfaces và classes trong ESRI.ArcGIS.ADF.Web.DataSources assembly\namespace. Ba interfaces cung cấp nền tảng thực hiện của Common API:

• IGISDataSource• IGISResource• IGISFunctionality

Nói chung, các nguồn dữ liệu được đưa ra như tài nguyên và chức năng để sử dụng trong Web ADF. Một nguồn dữ liệu có thể có một hoặc nhiều tài nguyên và một tài nguyên có thể có một hoặc nhiều chức năng.)

Page 39: What is the Web Application Developer

Data source type determines the type of resources available. Data source capabililities determine the type of functionalities available via a resource. The Common API supports a set of standard resource and functionality types for use within the Web ADF by providing a set of interfaces to be implemented by a data source. The resource interfaces (all implement IGISResource) are listed in the table below: (Data source type xác định các loại tài nguyên có sẵn. Nguồn dữ liệu có khả năng xác định các loại chức năng có sẵn thông qua một tài nguyên. Common API hỗ trợ một tập các loại tài nguyên và loại chức năng chuẩn cho việc sử dụng trong Web ADF bằng cách cung cấp một tập các interfaces được thực hiện bởi một nguồn dữ liệu. interfaces tài nguyên (tất cả các IGISResource dụng cụ) được liệt kê trong bảng dưới đây:)

Resource Description

IMapResourceImplemented for data sources that support generating map data as features or a map image.

IGeocodeResourceImplemented for data sources that support address matching and geolocation.

IGeoprocessingResource Implemented for data sources that support geoprocessing.

A functionality can only be associated with one resource type. Functionality interfaces (all implement IGISFunctionality) supported for each resource type are listed below:

(Chức năng chỉ có thể được kết hợp với một loại tài nguyên. interfaces chức năng (tất cả implement IGISFunctionality) được hỗ trợ đối với từng loại tài nguyên được liệt kê dưới đây:)

Map Resource Functionalities

Description

IMapFunctionality Implemented for data sources that support generating a map.

IQueryFunctionalityImplemented for data sources that support spatial and attribute queries.

Page 40: What is the Web Application Developer

IMapTocFunctionalityImplemented for data sources that support generating information for a table of contents.

ITileFunctionalityImplemented for data sources that support providing map data via pregenerated map image tiles.

IScalebarFunctionalityImplemented for data sources that support providing map scale information.

Geocode Resource Functionalities

Description

IGeocodeFunctionality Implemented for data sources that support address matching.

Geoprocessing Resource Functionalities

Description

IGeoprocessingFunctionalityImplemented for data sources that support geoprocessing operations.

To integrate a data source for use within the Web ADF, the Common API generic framework of interfaces for data sources, resources and functionalities must be implemented. Data source capabilities dictate what can be implemented. The Web ADF provides Common API implementation libraries for a set of data sources supported out-of-the-box. These include ArcGIS Server, ArcIMS, ArcWeb, OGC\WMS, and Web ADF Graphics. The diagram below graphically illustrates the Common API generic architecture, a set of implementations for ArcGIS Server and ArcGIS, and how Web ADF controls and resource managers access data sources via the Common API (discussed later).

(Để tích hợp một nguồn dữ liệu để sử dụng trong Web ADF, Common API generic framework của các interfaces cho nguồn dữ liệu, các tài nguyên và chức năng phải được thực hiện. nguồn dữ liệu có khả năng ra lệnh những gì có thể được thực hiện. Web ADF cung cấp Common API implementation libraries cho một tập hợp các nguồn dữ liệu hỗ trợ out-of-the-box. Chúng bao gồm ArcGIS Server, ArcIMS, ArcWeb, OGC \ WMS, và Web ADF Graphics. Sơ đồ dưới đây minh họa đồ họa Common API generic architecture, một tập của triển khai thực hiện cho ArcGIS Server và ArcGIS, và làm thế nào Web ADF controls và resource managers truy cập nguồn dữ liệu thông qua Common API (thảo luận sau).)

Page 41: What is the Web Application Developer

Some data sources, like ArcGIS Server and ArcIMS, have distinct "data source specific APIs" that are used during the implementation process. These data source specific APIs can be used on their own, separate from the Common API and include fine-grained access to data source capabilities. Common API implementations wrap data source capabilities exposed by a data source specific API to integrate it into the Web ADF. The following table lists the data source type, Common API implementation library, and data source specific API library (if available).

(Một số nguồn dữ liệu, như ArcGIS Server, ArcIMS, có khác biệt " data source specific APIs" nó được sử dụng trong quá trình thực hiện. Data source specific APIs này có thể được sử dụng trên chính chúng, tách biệt từ các Common API và bao gồm hạt mịn truy cập đến data source capabilities. Common API triển khai thực hiện gói data source capabilities tiếp xúc với data source specific API để tích hợp nó vào Web ADF. Bảng sau đây liệt kê các loại nguồn dữ liệu, thực hiện Common API implementation library, và data source specific API library (nếu có).)

Data Source

Common API Implementation Library Data Source Specific Library

ArcGIS Server

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.dll

ESRI.ArcGIS.ADF.ArcGISServer.dll

ArcIMS ESRI.ArcGIS.ADF.Web.DataSources.IMS.dll ESRI.ArcGIS.ADF.IMS.dll

ArcWebESRI.ArcGIS.ADF.Web.DataSources.ArcWebService.dll

ESRI.ArcGIS.ADF.ArcWebService.dll

Page 42: What is the Web Application Developer

OGC\WMS

ESRI.ArcGIS.ADF.Web.DataSources.OGCWMSService.dll

Not available - Common API implementation library contains all necessary logic

Web ADF Graphics

ESRI.ArcGIS.ADF.Web.DataSources.Graphics.dll ESRI.ArcGIS.ADF.Web.dll

While the Web ADF provides the Common API framework to expose generic GIS functionality, some data sources provide custom functionality only accessible via a data source specific API. For example, fine-grained ArcObjects can be accessed via an ArcGIS Server map server object to edit a layer within a personal geodatabase. Likewise, an ArcIMS image service can expose the ability to extract data layers into a zip archive. For more information on how to access a data source specific API from the Common API implementation classes, see the section titled Accessing a data source specific API.

One of the major benefits of the Common API is the ability to work with many data source in the same (generic) way. While data source specific APIs provide the foundation for implementation of common capabilities, interfaces in the Common API enable you to work with implementations regardless of the data source type. One illustration of this capability is that properties and methods on a resource or functionality interface use or return Web ADF (in ESRI.ArcGIS.ADF.Web.dll ) or .NET data types, regardless of whether the underlying data source is an ArcIMS, ArcGIS Server, or ArcWeb service. In essence, this means you don't necessarily have to know which data source you're working with, only its capabilities. (Trong khi Web ADF cung cấp Common API framework để trình bày các chức năng GIS chung chung, một số data sources cung cấp chức năng tùy chỉnh chỉ có thể truy cập thông qua data source specific API. Ví dụ, fine-grained ArcObjects có thể được truy cập thông qua ArcGIS Server map server object để chỉnh sửa layer trong personal geodatabase. Tương tự như vậy, ArcIMS image service có thể trình bày khả năng để giải nén data layers vào một kho lưu trữ zip. Để biết thêm thông tin về việc làm thế nào để truy cập vào data source specific API từ Common API implementation classes, xem phần có tiêu đề Accessing a data source specific API.

Một trong những lợi ích lớn của Common API là khả năng để làm việc với nhiều nguồn dữ liệu trong cùng (generic) một cách. Trong khi data source specific APIs cung cấp nền tảng cho việc thực hiện các common capabilities, interfaces trong Common API cho phép bạn làm việc với việc thực hiện không phân biệt data source type. Một minh họa cho khả năng này là properties và methods trong sử dụng resource hay functionality interface hoặc trả lại Web ADF (in ESRI.ArcGIS.ADF.Web.dll ) hay .NET data types, bất kể có các nguồn dữ liệu cơ bản là ArcIMS, ArcGIS Server, hay ArcWeb service. Về bản chất, điều này có nghĩa là bạn không nhất thiết phải biết nguồn dữ liệu mà bạn đang làm việc, chỉ vào khả năng của mình.)

How does a data source implement the Common API?

In general, you start with the API used to interact with a data source. For example, ArcGIS Server offers

Page 43: What is the Web Application Developer

both Local and Internet connections to services that may utilize the ArcObjects or SOAP API. Then you start implementing the basic Common API interfaces to expose data source capabilities. The following discussion will walkthrough the implemenation of an ArcGIS Server data source via a Local connection.

(Nói chung, bạn bắt đầu với các API được sử dụng để tương tác với data source. Ví dụ, ArcGIS Server cung cấp cả hai kết nối Local và Internet để phục vụ nó có thể sử dụng các ArcObjects hoặc SOAP API. Sau đó, bạn bắt đầu thực hiện Common API interfaces cơ bản để triển khai data source capabilities. Các cuộc thảo luận sau đây sẽ thông qua sự thực hiện của ArcGIS Server data source qua Local connection.)

The IGISDataSource interface defines the connection to a specific data source, as well as the identity used to connect and state of the connection. Data source implementations of IGISDataSource provide access to data source specific connection objects and parameters. In the diagram below, business objects in the ArcGIS Server APIs implement the IGISDataSource interface in the Common API. While both implementations maintain common properties, such as Identity and State, they define different connection properties, depending on the data source type. An ArcGIS Server Local connection requires the use of connection libraries (ESRI.ArcGIS.ADF.dll and ESRI.ArcGIS.ADF.Connection.dll). ArcGIS Server Internet data sources only require a url (Web service endpoint) so connection libraries are not required. As a result, a specific IGISDataSource implementation for ArcGIS Server data sources that use Local connections has been created (GISDataSourceLocal).

(IGISDataSource interface định nghĩa kết nối đến data source cụ thể, cũng như nhận dạng kết nối và trạng thái kết nối được sử dụng. Data source implementations của IGISDataSource cung cấp quyền truy cập vào những đối tương và các thông số kết nối data source cụ thể. Trong sơ đồ dưới đây, business objects trong ArcGIS Server APIs thực hiện IGISDataSource interface trong Common API. Trong khi cả hai thực hiện việc duy common properties, chẳng hạn như Identity và State, chúng định nghĩa các thuộc tính kết nối khác nhau, tùy thuộc vào loại data source. ArcGIS Server Local connection yêu cầu sử dụng libraries (ESRI.ArcGIS.ADF.dll và ESRI.ArcGIS.ADF.Connection.dll). ArcGIS Server Internet data sources chỉ cần một url (thiết bị đầu cuối Web service) vì thế các thư viện kết nối là không cần thiết. Kết quả là, chỉ rỏ IGISDataSource implementation cho ArcGIS Server data sources này sử dụng Local connections đã được tạo ra (GISDataSourceLocal).)

Each GISDataSource can have a collection of resources. In general, a data source defines the type of resource that can be created. The IGISResource interface defines a generic framework for resources and is implemented by a number of more specific sub interfaces. Two common resource interfaces are IMapResource and IGeocodeResource. IMapResource defines the framework for a data source that provides information associated with spatial data in a map, such as the ability to generate a map image, or query layers within a map. IGeocodeResource defines the framework for a data source that

Page 44: What is the Web Application Developer

provides the ability to perform address matching. In the diagram below, the ArcGIS Server implementation of both interfaces creates a MapResource and GeocodeResource class, respectively. Since it is an ArcGIS Server Local data source, the MapResource also provides access to the map server object and server context. Likewise, the GeocodeResource provides access to the geocode server object and server context.

(Mỗi GISDataSource có thể có một tập của các tài nguyên. Nói chung, một data source định nghĩa kiểu của tài nguyên nó có thể được tạo ra. IGISResource interface định nghĩa framework chung cho các resources và được thực hiện bởi một số sub interfaces cụ thể hơn. Hai common resource interfaces là IMapResource và IGeocodeResource. IMapResource xác định framework cho data source nó cung cấp thông tin liên kết với spatial data trong map, chẳng hạn như khả năng để tạo ra map image, hoặc các truy vấn layers trong bản đồ. IGeocodeResource xác định framework cho data source nó cung cấp khả năng thực thi phù hợp với địa chỉ. Trong sơ đồ dưới đây, ArcGIS Server thực hiện của cả hai interfaces tạo ra a MapResource và GeocodeResource class, tương ứng. Từ đó nó là một ArcGIS Server Local data source, MapResource cũng cung cấp khả năng truy cập đến đối map server object và server context. Tương tự như vậy, GeocodeResource cung cấp khả năng truy cập đến geocode server object và server context.)

Each resource can have a collection of functionalities. In general, a functionality defines the capabilities of a data source as a resource, and how it can be used. If a resource supports a functionality the resource can create a functionality. The functionality can then be used to perform an action or series of actions. In most cases, working with the Common API will involve interacting with functionalities. The IGISFunctionality interface defines a generic framework for functionalities and is implemented by a number of more specific sub interfaces. Two common functionality interfaces are IMapFunctionality and IQueryFunctionality. Both are created by a MapResource. IMapFunctionality enables interaction with the mapping capability of a resource, such as creating a map image, getting\setting the extent, or changing the visible layers. IQueryFunctionality enables interaction with the spatial and attribute query capabilities of a resource, such as using a where clause and/or spatial filter to return feature geometry and attributes. In the diagram below, the ArcGIS Server implementation of both interfaces creates a MapFunctionality and QueryFunctionality class, respectively. While a MapDescription is unique to the

Page 45: What is the Web Application Developer

ArcGIS Server implementation of IMapFunctionality, note that most of the methods and properties of a functionality are available at a generic level on the interface.

(Mỗi tài nguyên có thể có một tập các chức năng. Nhìn chung, chức năng định nghĩa khả năng của một data source cũng như tài nguyên, và nó có thể được sử dụng như thế nào. Nếu một tài nguyên hỗ trợ một chức năng thì tài nguyên có thể tạo ra một chức năng. Chức năng sau đó có thể được sử dụng để thực hiện một hành động hay một loạt các hành động. Trong hầu hết trường hợp, làm việc với các API thông thường sẽ liên quan đến việc tương tác với các chức năng. IGISFunctionality interface định nghĩa một framework chung cho các chức năng và được thực hiện bởi một số specific sub interfaces. Hai interfaces chức năng phổ biến là IMapFunctionality và IQueryFunctionality. Cả hai đều được tạo ra bởi MapResource. IMapFunctionality cho phép tương tác với mapping capability của resource, như tạo ra map image, getting\setting độ lớn, hoặc thay đổi các layers có thể nhìn thấy. IQueryFunctionality cho phép tương tác với các khả năng truy vấn không gian và thuộc tính của một tài nguyên, chẳng hạn như sử dụng where clause and/or spatial filter để trả về feature geometry và attributes. Trong sơ đồ dưới đây, ArcGIS Server implementation của cả hai interfaces tạo ra MapFunctionality và QueryFunctionality class, tương ứng. Trong khi MapDescription là duy nhất để ArcGIS Server implementation của IMapFunctionality, lưu ý rằng hầu hết các methods và properties của các chức năng có sẵn ở một mức độ chung chung trên interface.)

How do you use the Common API?

Once an implementation is provided, the Common API can be used by Web ADF controls or programatically to interact with a data source. Managing interaction with data sources via the Common API is the responsibility of a set of controls termed resource managers. Resource managers manage a set of resource items and dictate which data sources are available as resources, how the resources are prepared for use, and subsequently how the resources interact with one another. A resource item (IGISResourceItem) is a container for the resource and maintains other properties, such as display settings for a map resource item. There is a resource manager control for each resource type. For example, a MapResourceManager controls manages map resources as map resource items. We'll discuss how Web ADF controls work with the Common API below. For more details on

Page 46: What is the Web Application Developer

programatically utilizing the Common API, see the Resources and Functionalities topic. In essence, Web ADF controls depend on resource manager controls to expose resources and provide access to data source capabilities via functionalities.

(Sau khi implementation được cung cấp, các Common API có thể được sử dụng bởi các Web ADF controls hay programatically để tương tác với data source. Managing tương tác với data sources thông qua Common API là trách nhiệm của một tập controls termed resource managers. Resource managers quản lý một tập resource items và đọc data sources có sẵn từ resources, resources được chuẩn bị sẵn sàng cho sử dụng như thế nào, và sau đó làm thế nào các resources tương tác với nhau. Một resource item (IGISResourceItem) là chứa đựng resource và duy trì các properties khác, chẳng hạn như thiết lập hiển thị cho map resource item. Có một resource manager control cho mỗi resource type. Ví dụ, một MapResourceManager controls quản lý map resources do map resource items. Chúng ta sẽ thảo luận về Web ADF controls làm việc như thế nào với Common API dưới đây. Để biết thêm chi tiết về chương trình sử dụng các Common API, xem Resources and Functionalities topic. . Về bản chất, Web ADF controls phụ thuộc vào resource manager controls để tiếp xúc với nguồn lực và cung cấp truy cập đến data source capabilities thông qua functionalities.)

How do the Web ADF controls use the Common API framework to work with data sources?

You can think of the Web ADF controls as the user interface components, and the Common and data source specific API classes as the part that does most of the GIS work. The Web ADF controls are similar to other ASP.NET Server controls - they have properties such as height, width, visibility, or anything that relates to arranging the control on a Web form and controlling its appearance. In addition, the controls generate events based on client interaction which a server-side component can respond to, such as when a control is clicked. For example, in the case of a Map control, the client action might be dragging a box, and the associated server action uses the box to define an extent for the map to zoom to, or selects all features that intersect the box. The action executed on the server is handled by the appropriate functionality. Since each data source, available as a resource within the Web ADF, supports one or more functionalities, the control creates the functionality it needs to do its job. In this example, the Map control's server action uses a box defined by the client to zoom to an extent. The Map control displays map data, thus each resource it accesses must be able to generate a map. If a data source can generate a map and is available via the MapResourceManager as a MapResource, the Map control is able to use its mapping functionality. The Map control will use each MapResource to generate a MapFunctionality, which it will then use to handle all map-based interaction with the data source. In this example, the Map control gets the extent defined by the client action to draw a new map image via the MapFunctionality DrawExtent method. Note, the Map control calls this method for you, you do not need to explicitly call methods on the MapFunctionality for the Map to function. The diagram below illustrates the creation of a MapFunctionality for a MapResource. The DrawExtent method on the MapFunctionality is used by the Map control to work with the data source as a MapResource and generate a map image.

(Bạn có thể nghĩ rằng Web ADF controls như interface components người dùng, và Common và data source specific API classes như là phần mà hầu hết GIS làm việc. Web ADF controls tương tự như ASP.NET Server controls khác - họ có propertiesnhư chiều rộng, chiều cao, khả năng hiển thị, hoặc bất

Page 47: What is the Web Application Developer

cứ điều gì liên quan đến được sắp xếp controls trên Web form và kiểm soát sự xuất hiện của nó. Ngoài ra, controls tạo ra các sự kiện dựa vào client tương tác mà server-side component có thể đáp ứng, chẳng hạn như khi control được click. Ví dụ, trong trường hợp của Map control, hành động của client có thể kéo một box, và các hành động liên quan đến máy chủ sử dụng box để xác định kích thước cho map to zoom to, hay selects all features giao nhau box. Các hành động thực thi trên máy chủ được xử lý bởi các chức năng thích hợp. Kể từ khi mỗi data source, có sẵn như là một nguồn tài nguyên trong Web ADF, hỗ trợ một hoặc nhiều chức năng, control tạo ra các chức năng cần thiết để làm công việc của mình. Trong ví dụ này, hành động Map control's server sử dụng một box được xác định bởi the client to zoom đến một kích thước. Map control hiển thị map data, do đó mỗi tài nguyên nó truy cập có khả năng tạo ra một bản đồ. Nếu data source có thể tạo ra một bản đồ và là sẵn sàng thông qua MapResourceManager như MapResource, Map control có thể sử dụng chức năng lập bản đồ của nó. Map control sẽ sử dụng mỗi MapResource để tạo ra MapFunctionality, mà sau đó sẽ sử dụng để xử lý tất cả map-based để tương tác với data source. Trong ví dụ này, Map control nhận được mở rông được định nghĩa bởi client action để vẽ một map image mới thông qua MapFunctionality DrawExtent method. Lưu ý, Map control gọi phương thức này cho bạn, bạn không cần gọi phương thức trên MapFunctionality cho Map to function. Biểu đồ dưới đây minh họa việc tạo ra các một MapFunctionality cho MapResource. DrawExtent method trên MapFunctionality được sử dụng bởi Map control để làm việc với data source như MapResource và tạo ra map image.)

~

Page 48: What is the Web Application Developer

What happens when there is more than one resource accessed by a control?

Each resource is associated with a set of functionalities. In our previous example, when the extent is set on the Map control, the control in turn sets the extent for each resource via its associated MapFunctionality. Each resource works with the data source to generate its own output, in this case, a map image. The Map control is also responsible for consolidating MapFunctionality output, or map images, within the same display area. This means that each resource is treated as a single layer, termed a "resource layer", within a Web ADF Map control (see the Image Blending discussion in the Map control for more details). Again, resource item display settings (e.g. map image transparency) are used by the MapFunctionality to define a rendering scheme for each "resource layer" (map image) so that the content of each "resource layer" is visible in the Map. The diagram below illustrates the creation of a MapFunctionality for each MapResource consumed by a Map control, and how the Map control works with each MapFunctionality exclusively to generate a map image. (Mỗi tài nguyên được liên kết với một tập các chức năng. Trong ví dụ trước đây của chúng tôi, khi mở rông được thiết lập trên Map control, control lần lượt thiết lập mở rộng cho mỗi tài nguyên thông qua MapFunctionality được kết hợp của nó. Mỗi tài nguyên làm việc với data source để tạo ra đầu ra của riêng của nó, trong trường hợp này, là một map image. Map control cũng là trách nhiệm củng cố đầu ra MapFunctionality, hoặc hình ảnh bản đồ, trong cùng một khu vực hiển thị. Điều này có nghĩa là mỗi tài nguyên được coi là một single layer, gọi là " resource layer ", trong phạm vi Web ADF Map control (Xem Image Blending được thảo luận trong Map control để biết thêm chi tiết). Một lần nữa, resource item hiển thị những thiết lập (ví dụ như map image trong suốt) được sử dụng bởi các MapFunctionality để xác định việc biểu diễn theo lược đồ cho “resource layer" (map image) vì thế nội dung của mỗi "resource layer" có thể nhìn thấy trong bản đồ. Biểu đồ dưới đây minh họa việc tạo ra các một MapFunctionality cho mỗi MapResource được dùng bởi Map control, Map control làm việc với mỗi MapFunctionality độc quyền để tạo ra a map image như thế nào.)

What happens when more than one control uses the same set of resources?

As mentioned before, the Web ADF controls and classes support the use of data from multiple sources in the same application. At the same time, multiple Web controls often work with the same set of data sources. How does the Web ADF manage this relationship? One resource manager can be utilized by

Page 49: What is the Web Application Developer

many controls. The control is responsible for initializing the resource and create the functionality it needs to do work. So if you add two Map controls to a Web application and reference the same MapResourceManager, both controls will use the same set of resources, but access different functionalities. By default, the resource will be shared for all controls that utilized them. The diagram below illustrates how two Map controls work with the same MapResource available via a MapResourceManager. Each Map creates and uses a MapFunctionality to work with a data source via a shared MapResource.

(Như đã đề cập trước đây, Web ADF controls và các lớp học hỗ trợ việc sử dụng dữ liệu từ nhiều nguồn khác nhau trong cùng một ứng dụng. Đồng thời, nhiều Web controls thường xuyên làm việc với cùng một tập data sources. Làm thế nào để Web ADF quản lý mối quan hệ này? Một resource manager có thể được sử dụng bởi nhiều controls. Control chịu trách nhiệm để khởi tạo tài nguyên và tạo ra các chức năng cần thiết để làm việc. Vì vậy, nếu bạn thêm hai Map controls vào một ứng dụng Web và tham chiếu cùng MapResourceManager, cả hai điều khiển sẽ sử dụng cùng một tập resources, nhưng truy cập các chức năng khác nhau. Theo mặc định, resource sẽ được chia sẻ cho tất cả các điều khiển sử dụng chúng. Biểu đồ dưới đây minh họa làm thế nào hai Map controls làm việc cùng với MapResource có sẵn thông qua MapResourceManager. Bản đồ từng tạo ra và sử dụng một MapFunctionality để làm việc với một data source qua một MapResource chia sẻ.)

IV. Working with graphics and consolidation classes

1. Tổng quan

The multi-source nature of the Web ADF means that Web ADF applications may work with one or more different data sources in the same application.  Each data source may operate independently of the Web ADF and maintains it's own unique API.  Since the Web ADF is responsible for consolidating results from one or more data sources in the Web or client-tier, Web ADF itself must maintain some logic to integrate these result in a common environment.   To accomplish this the Web ADF contains a set of classes to support consolidation, such as Web ADF geometry, spatial reference, query and spatial filters.  Most importantly, the Web ADF manages a set of classes to support Web-tier graphics data sets and layers using Web ADF geometry, symbols, and renderers.  Since the Web ADF Common Data Source API provides a generic framework for data sources to be integrated into the Web ADF as resources, the generic framework leverages the consolidation classes to work with any

Page 50: What is the Web Application Developer

implemented data source in a common way.  Most of the Web ADF graphics and consolidation classes are located in the ESRI.ArcGIS.ADF.Web.dll.  This assembly contains a number of namespaces to intuitively categorize its contents.

(Bản chất đa nguồn của Web ADF có nghĩa là Web ADF applications có thể làm việc với một hoặc nhiều nguồn dữ liệu khác nhau trong cùng một ứng dụng. Mỗi nguồn dữ liệu có thể hoạt động độc lập của Web ADF và duy trì API duy nhất của chính. Từ đó Web ADF có trách nhiệm củng cố kết quả từ một hay nhiều nguồn dữ liệu trong trang web hoặc client-tier, chính Web ADF phải duy trì một số logic để tích hợp những kết quả này trong một môi trường chung. Để thực hiện điều này ADF Web có chứa một tập các lớp để hỗ trợ hợp nhất, chẳng hạn như Web ADF geometry, spatial reference, query và spatial filters. Quan trọng nhất, ADF Web quản lý một tập hợp của các lớp để hỗ trợ Web-tier graphics data set và các layer bằng cách sử dụng Web ADF geometry, symbols, và renderers. Từ đó Web ADF Common Data Source API cung cấp một framework chung cho data sources được tích hợp vào Web ADF as resources, framework chung thúc đẩy các lớp hợp nhất để làm việc với bất kỳ data source được thực hiện một cách phổ biến. Hầu hết các Web ADF graphics và các lớp học hợp nhất được đặt trong ESRI.ArcGIS.ADF.Web.dll. Assembly này có chứa một số namespaces trực quan để phân loại các nội dung của nó.)

Namespace in ESRI.ArcGIS.ADF.Web.dll

Content Description

ESRI.ArcGIS.ADF.Web

Map image creation and management in the Web-tier, spatial and query filters, Toc layer contentMap image Tạo ra quản lý trong Web-tier, spatial và query filters, Toc layer content

ESRI.ArcGIS.ADF.Web.Display.GraphicsWeb ADF graphics data sets, layers, and elements

ESRI.ArcGIS.ADF.Web.Display.Renderer

Renderer types for use with Web ADF graphicsRenderer types  để sử dụng với Web ADF graphics

ESRI.ArcGIS.ADF.Web.Display.Swatch

Used to generate swatches in a Toc for Web ADF graphicsSử dụng để tạo ra vùng quan sát trong Toc for Web ADF graphics

ESRI.ArcGIS.ADF.Web.Display.SymbolSymbol types for use with Web ADF graphicsSymbol types để sử dụng Web ADF graphics

ESRI.ArcGIS.ADF.Web.Geocode

Generic types for use with geocode resources and functionalitiesGeneric types để sử dụng với geocode resources và functionalities

ESRI.ArcGIS.ADF.Web.Geometry Web ADF managed geometry types usedfor any geometry managed on the Web-tier.  Often used to define features for Web ADF graphics layer contents, extent for a Map control, the spatial component of a spatial filter, etc.Web ADF managed geometry types được sử dụng cho

Page 51: What is the Web Application Developer

bất kỳ geometry được quản lý trên Web-tier. Thường được sử dụng để xác định các features cho Web ADF graphics layer contents, khoanh vùng cho Map control, các thành phần không gian của spatial filter,...

ESRI.ArcGIS.ADF.Web.SpatialReference

Manages coordinate system details for Web ADF components such as controls (e.g. Map), resources and functionalities.Manages coordinate system chi tiết cho Web ADF components cũng như controls (ví dụ: Map), resources và functionalities.

      This section will discuss the following topics associated with the consolidation capabilities of the Web ADF:

2. Working with graphics

Drawing graphics on a Web ADF map can be accomplished using techniques available in each tier of a Web ADF application: client, Web, and server. Each tier is associated with a different development environment and thus a different means for rendering graphic elements on a map is utilized. Since the Web ADF is designed to consolidate multiple data sources in a single application, it offers a rich Web-tier solution for generating and managing graphic content. However, it is important to understand where graphics in general can be created and how the Web ADF integrates graphics in every tier. The diagram below illustrates where graphics layers can be created in each tier. The Web ADF manages a set of resources of type Web ADF graphics, ArcGIS Server and ArcIMS. The Web ADF graphics resources uses Web ADF capabilities to create graphics layers and generate a map image. Both the ArcGIS Server and ArcIMS resources use their respective service capabilities in the server-tier to create a graphics layer and merge it other map data layers to create a map image. Assuming browser blending is enabled for the Web ADF Map control, each map image will be overlayed in the browser in the order of the Web ADF resources. Additionally, the browser in the client-tier has the ability to utilize browser capabilities to create graphics. The sections below cover different options available in each tier and how they apply to the Web ADF in more detail.

(Drawing graphics trên Web ADF map có thể được thực hiện bằng cách sử dụng kỹ thuật sẵn có trong mỗi tầng của Web ADF application: client, Web, và server. Mỗi tầng được kết hợp với một môi trường phát triển khác nhau và do đó có ý nghĩa khác nhau để vẽ các yếu tố đồ họa trên bản đồ được sử dụng. Kể từ khi Web ADF được thiết kế để hợp nhất nhiều nguồn dữ liệu trong một ứng dụng duy nhất, nó cung cấp một giải pháp Web-tier để tạo ra và quản lý graphic content. Tuy nhiên, điều quan trọng là hiểu ở đó graphics nói chung có thể được tạo ra và làm thế nào Web ADF tích hợp graphics trong mỗi tầng. Biểu đồ dưới đây minh họa ở đó graphics layers có thể được tạo ra trong mỗi tầng. Web ADF quản lý một tập resources của kiểu Web ADF graphics, ArcGIS Server, ArcIMS. Web ADF graphics resources sử dụng Web ADF capabilities để tạo ra graphics layers và sinh ra map image. Cả ArcGIS Server và ArcIMS resources sử dụng chúng tương ứng service capabilities trong server-tier để tạo ra graphics layer và hợp nhất map data layers khác để tạo ra map image. Giả sử browser blending cho phép Web ADF Map

Page 52: What is the Web Application Developer

control, mỗi map image sẽ được phủ trong trình duyệt theo thứ tự Web ADF resources. Ngoài ra, trình duyệt trong client-tier có khả năng tận dụng browser capabilities để tạo ra graphics. Các phần dưới đây bao gồm các tùy chọn có sẵn trong mỗi tầng khác nhau và cách họ áp dụng đối với Web ADF chi tiết hơn.)

Client tier For a Web application, the client is almost always a browser. In general, browsers work with a number of Web standards for display and interaction with a Web page, such as HTML, CSS, JavaScript, etc. The tools available in this development environment are limited by what the browser supports. CSS can be used to place elements, such as images, over other elements on a page. Vector graphic support is variable, but SVG (Scalable Vector Graphics) and VML (Vector Markup Language) can be used to draw vector graphics on or over other elements on a page. (Đối với một ứng dụng Web, client hầu như luôn luôn là một trình duyệt. Nhìn chung, trình duyệt làm việc với một số các Web standards để hiển thị và tương tác với một trang Web, chẳng hạn như HTML, CSS, JavaScript, vv Các công cụ có sẵn trong development environment bị hạn chế bởi trình duyệt hỗ trợ. CSS có thể được sử dụng để định vi các yếu tố, chẳng hạn như hình ảnh, trên các yếu tố khác trên một trang. Vector graphic hỗ trợ có thể thay đổi, nhưng SVG (Scalable Vector Graphics) và VML (Vector Markup Language) có thể được sử dụng để vẽ vector graphics trên hoặc qua các yếu tố khác trên một trang.) A number of controls in the Web ADF work with client tier graphics. The MapTips control utilizes CSS in a browser to place map tip images on top of a map. Tools that draw graphics on a map during interaction (such as ZoomIn) utilize VML in Internet Explorer and CSS in other browsers. All of these browser based technologies can be leveraged by a Web ADF developer. Two issues

Page 53: What is the Web Application Developer

to consider are 1) the browser uses screen units (pixels) instead of map units and 2) the position of the map element on the page for accurate placement of graphics. Often graphic element details in the client tier are populated by Web tier processing.

(Một số các controls trong Web ADF làm việc với client tier graphics. MapTips control sử dụng CSS trong một trình duyệt để đặt map tip images trên đầu của Map. Tools này vẽ graphics trên map trong quá trình tương tác (chẳng hạn như ZoomIn) sử dụng VML trong Internet Explorer và CSS trong các trình duyệt khác. Tất cả các công nghệ này dựa trên trình duyệt có thể được thừa hưởng bởi một nhà phát triển Web ADF. Hai vấn đề cần xem xét là 1) trình duyệt sử dụng màn hình đơn vị (pixel) thay vì các đơn vị bản đồ và 2) vị trí của các yếu tố bản đồ trên trang web để có vị trí chính xác của đồ họa. Thường chi tiết yếu tố đồ họa trong client tier đưa đến bởi Web tier xử lý.)

Web tier

The Web tier can provide a rich, full-featured development environment and access to server-side resources. ASP.NET Web applications leverage the Microsoft .NET Framework and its capabilities. The .NET environment provides a few options for drawing graphics on a map, but the implementation can be quite complex. However, the .NET framework does provide the Web ADF with a set of objects to extend from which the Web ADF exposes a simple API for creating graphics on a map.

The Web ADF provides a Graphics data source unique to the Web ADF. The Graphics data source can be added as a Graphics Layer to a MapResourceManager and displayed in an associated Map control. A Graphics Layer resource is a type of System.Data.DataSet which can hold many DataTables. You can access the Web ADF GraphicsDataSet via the Graphics property on a Graphics Layer resource. (Web tier có thể cung cấp một môi trường phát triển phong phú, đầy đủ tính năng và truy cập vào server-side resources. ASP.NET Web applications tận dụng Microsoft NET Framework và khả năng của chính nó. .NET environment cung cấp một vài lựa chọn để drawing graphics trên bản đồ, nhưng việc thực hiện có thể khá phức tạp. Tuy nhiên, .NET framework cung cấp Web ADF với một tập các đối tượng để mở rộng từ Web ADF đưa ra một API đơn giản cho việc tạo graphics trên map.

Web ADF cung cấp một Graphics data source duy nhất đến Web ADF. Graphics data source có thể được thêm vào như Graphics Layer đến MapResourceManager và hiển thị trong Map control liên quan. Graphics Layer resource là một loại System.Data.DataSet mà có thể tổ chức nhiều DataTables. Bạn có thể truy cập vào Web ADF GraphicsDataSet qua Graphics property trên Graphics Layer resource.) The Web ADF also defines two graphics layer types: ElementGraphicsLayer and FeatureGraphicsLayer. Both are a type of System.Data.DataTable, thus they can be added to the GraphicsDataSet Tables collection. Graphics layer content is stored in-memory by the Web application. As a result, the amount of content in a graphics layer is proportional to the amount of memory required for the Web application. Note that graphics layer types must be created and managed programmatically. (Web ADF cũng định nghĩa hai loại graphics layer: ElementGraphicsLayer và FeatureGraphicsLayer. Cả hai đều là một loại System.Data.DataTable, do đó họ có thể được thêm vào GraphicsDataSet Tables collection.. Graphics layer content được lưu trữ trong bộ nhớ của Web application. Kết quả là, số lượng nội dung trong graphics layer là tỉ lệ thuận với số

Page 54: What is the Web Application Developer

lượng bộ nhớ yêu cầu cho Web application. Lưu ý rằng graphics layer types phải được tạo ra và được quản lý của chương trình.) ElementGraphicsLayers are designed to store basic graphic elements, namely geometry and a symbol. One ElementGraphicsLayer can store different types of geometry. In general, ElementGraphicsLayers are used to display selected features in a map. They are not designed for attribute storage.

FeatureGraphicsLayers are designed to emulate a true feature layer. Each layer only supports one geometry type. Web ADF renderers can be applied to symbolize geometry based on attribute values in the DataTable. FeatureGraphicsLayers also support queries. (ElementGraphicsLayers được thiết kế để lưu trữ các yếu tố đồ họa cơ bản, cụ thể là geometry và symbol. Một ElementGraphicsLayer có thể lưu trữ các loại khác nhau của geometry. Nói chung, ElementGraphicsLayers được sử dụng để hiển thị các selected features trong bản đồ. Chúng không được thiết kế cho việc lưu trữ thuộc tính.

FeatureGraphicsLayers được thiết kế để mô phỏng một feature layer thật sự. Mỗi layer chỉ hỗ trợ một geometry type. Web ADF kết xuất đồ họa có thể được áp dụng đến symbolize geometry dựa trên các giá trị thuộc tính trong DataTable. FeatureGraphicsLayers cũng hỗ trợ truy vấn.)The Web ADF handles drawing each graphics layer type within a Graphics Layer resource. As a result, the Web ADF also provides a set of geometry types, symbols, and renderers that can be used with graphics layer types. Note, Web ADF symbology supports variable transparency (0%-100%). The example below illustrates working with a Graphics Layer resource (gResource), a GraphicsDataSet (gResource.Graphics) and both graphics layer types.

(Web ADF xử lý vẽ cho mỗi graphics layer type trong phạm vi Graphics Layer resource. Kết quả là, Web ADF cũng cung cấp một tập geometry types, symbols, và renderers mà có thể được sử dụng với graphics layer types. Lưu ý, Web ADF symbology hỗ trợ rỏ ràng biến đổi (0% -100%). Ví dụ dưới đây minh họa làm việc với Graphics Layer resource (gResource), một GraphicsDataSet (gResource.Graphics) và cả hai graphics layer types.)

[C#]

IEnumerable gfc = Map1.GetFunctionalities(); ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource gResource = null; foreach (IGISFunctionality gfunc in gfc) { if (gfunc.Resource is

ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource) { gResource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)

gfunc.Resource; break; } } // *** ElementGraphicsLayer Example ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer eglayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();

Page 55: What is the Web Application Developer

ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol sms = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol(); sms.Color = System.Drawing.Color.Black; sms.Width = 40; ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement ge = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(point, sms); eglayer.Add(ge);

gResource.Graphics.Tables.Add(eglayer); // *** FeatureGraphicsLayer Example ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer fglayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer(); ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol fs = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol(); fs.Color = System.Drawing.Color.Red; fs.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Circle; fs.Width = 12; ESRI.ArcGIS.ADF.Web.Display.Renderer.SimpleRenderer sr = new ESRI.ArcGIS.ADF.Web.Display.Renderer.SimpleRenderer(fs); fglayer.Renderer = sr; fglayer.Add(point); gResource.Graphics.Tables.Add(fglayer);

Graphics Layer resources are frequently the first resource in a MapResourceManager and thus can be drawn on top of other resources in the map, which makes them ideal for displaying selected features. Since graphics layer content is created and populated programmatically, they can also be used to display dynamic or event data, such as reading geometry coordinates and attributes from a database or data file. The following code provides an example of creating a Web ADF graphics resource dynamically. If an existing Web ADF graphics resource named "AGResource" is not already available in the MapResourceManager (MapResourceManager1) used by the Map (Map1), a new MapResourceItem is created using a graphics resource definition. When finished the resource item is added to the MapResourceManager and the CreateResource method initializes the new graphics resource. The graphics resource is now ready to use. When finished, depending on the Map blending mode, the Map or the individual resource is refreshed. (Graphics Layer resources thường là tài nguyên đầu tiên trong MapResourceManager và do đó có thể được vẽ trên cùng của các resources khác trong bản đồ, để làm cho chúng hoàn thiện cho việc hiển thị selected features.Từ đó graphics layer content được tạo ra và lưu trú tại chương trình, chúng cũng có thể được sử dụng để hiển thị dữ liệu động hoặc sự kiện, chẳng hạn như đọc các tọa độ hình học và các thuộc tính từ database or data file. Các mã sau đây cung cấp một ví dụ của việc tạo ra một Web ADF graphics resource dynamically. Nếu một Web ADF graphics resource có tên "AGResource" không có sẵn trong MapResourceManager (MapResourceManager1) được sử dụng bởi Map (Map1), một MapResourceItem mới được tạo ra bằng cách sử dụng một graphics resource. Khi hoàn tất resource item được thêm vào MapResourceManager và CreateResource method khởi tạo graphics resource mới. graphics resource đã sẵn sàng để sử dụng. Khi hoàn thành, tùy thuộc vào Map blending mode, bản đồ hoặc các nguồn tài nguyên cá nhân được làm mới lại.)

Page 56: What is the Web Application Developer

[C#]

ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource gResource = null;foreach (IGISFunctionality gfunc in Map1.GetFunctionalities()){ if (gfunc.Resource.Name == "AGResource") {gResource =

(ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)gfunc.Resource;break;

} else {MapResourceItem mapResourceItem = new MapResourceItem();

GISResourceItemDefinition definition = new GISResourceItemDefinition();

mapResourceItem.Name = "AGResource";definition.ResourceDefinition = "GraphicsResource";definition.DataSourceDefinition = "In Memory";definition.DataSourceType = "GraphicsLayer";

definition.DataSourceShared = true;mapResourceItem.Parent = MapResourceManager1;mapResourceItem.Definition = definition;ESRI.ArcGIS.ADF.Web.DisplaySettings displaysettings = new

ESRI.ArcGIS.ADF.Web.DisplaySettings();displaysettings.Transparency = 0.0F;displaysettings.Visible = true;mapResourceItem.DisplaySettings = displaysettings;

MapResourceManager1.ResourceItems.Insert(0, mapResourceItem);gResource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource) MapResourceManager1.CreateResource(mapResourceItem);break;

} }

// Create a graphics layer, add content, then add it to the graphics resource

if (Map1.ImageBlendingMode == ImageBlendingMode.WebTier){ Map1.Refresh();}else{ Map1.RefreshResource(gResource.Name);}

Server tier

In general, working with graphics in the server-tier means creating graphics in a map image

Page 57: What is the Web Application Developer

generated by a server, which may be subsequently utilized by the Web ADF. The ability to create graphics on the server depends on the capabilities of the service or data source. Both ArcIMS and ArcGIS Server are capable of creating custom graphics in map images they generate. However, since each provides a different interface to create graphics, different APIs must also be used. Also, graphics added at the server tier will be part of the map image returned to the client. You should consider the order of resources in a map to determine if the graphics will be visible, since another resource may cover the server generated graphics.

(Nói chung, làm việc với đồ họa trong server-tier có nghĩa tạo ra graphics trong map image được sinh ra bởi một máy chủ, có thể sau đó được sử dụng bởi ADF Web. Khả năng để tạo ra graphics trên máy chủ phụ thuộc vào khả năng của service hay data source. Cả hai ArcIMS và ArcGIS Server có khả năng tạo ra custom graphics trong map images mà chúng sinh ra. Tuy nhiên, mỗi khi cung cấp một interface khác nhau để tạo ra graphics, các API khác nhau cũng phải được sử dụng. Ngoài ra, graphics được thêm tại server tier sẽ là một phần của map image được trả lại cho client. Bạn nên xem xét thứ tự của resources trong map để xác định xem graphics sẽ được nhìn thấy, từ một resource khác có thể bao hàm server sinh ra graphics.)(Stateful ngược lại với stateless, stateful tức là trong quá trình xử lý của server, có xét đến các trạng thái của request trước đó)The Web ADF is a shallowly stateful application in that it works with data sources in a stateless manner and manages state in the Web-tier. Since both ArcIMS and ArcGIS Server data sources support server-tier graphics, the MapFunctionality for each data source also provides a mechanism to access the data source specific API and add server-side graphics. The server graphics are stored in session state by the Web ADF and reapplied for each map image generated. (Web ADF là một shallowly stateful application tróng đó nó làm việc với data sources trong stateless manner và manages state trên Web-tier. Kể cả hai ArcIMS và ArcGIS Server data sources hỗ trợ server-tier graphics, các MapFunctionality cho mỗi data source cũng cung cấp một cơ chế để truy cập vào nguồn dữ liệu data source specific API và thêm vào server-side graphics. server graphics được lưu trữ trong session state bởi Web ADF và sử dụng lại cho mỗi map image được sinh ra.)Two tutorials presented in this help system introduce developing with ArcGIS Server and ArcIMS in the Web ADF. In both tutorials, graphics are created and rendered on the server using the data source specific API.

(Hai hướng dẫn được trình bày trong hệ thống trợ giúp này giới thiệu phát triển với ArcGIS Server, ArcIMS trong ADF Web. Trong cả hai hướng dẫn, đồ họa được tạo ra và trả lại trên máy chủ bằng cách sử dụng API nguồn dữ liệu cụ thể.)

3. Converting between data types

The multi-source nature of the Web ADF means that Web ADF applications may work with one or more different data sources in the same application.  Each data source may operate independently of the Web ADF and maintains its own unique API.  Since the Web ADF integrates and consolidates client-tier interaction with a Web-tier application that works with data sources that are often in the server-tier, converting between data types is often the responsiblity of the Web ADF developer.   This topic covers a number of conversion tasks and capabilities of the Web ADF.  The general topics are geometry, ArcGIS Server COM and Value objects, and datasets. 

Page 58: What is the Web Application Developer

(Bản chất đa nguồn của Web ADF có nghĩa rằng Web ADF applications có thể làm việc với một hoặc nhiều data sources khác nhau trong cùng một ứng dụng.Mỗi data sources có thể hoạt động độc lập bởi Web ADF và duy trì API duy nhất của chính nó. Từ đó Web ADF tích hợp và hợp nhất client-tier tương tác với Web-tier application khi làm việc với data sources một cách thường xuyên trong server-tier, chuyển đổi giữa data types thường là bổn phận của Web ADF developer. Chủ đề này bao gồm conversion tasks và capabilities của Web ADF. Các chủ đề chung là geometry, ArcGIS Server COM and Value objects, và datasets.)

The Web ADF maintains multiple Converter classes, each in a different namespace, all with static methods.  The namespace provides an indication of which APIs the Converter class will work with.  These classes are designed to make the conversion process easier and are by no means comprehensive.  (ADF Web duy trì nhiều Converter classes, trong namespace khác nhau, với tất cả các phương pháp tĩnh. Namespace cung cấp một dấu hiệu của APIs the Converter class  sẽ làm việc. Các lớp này được thiết kế để làm cho quá trình chuyển đổi dễ dàng hơn và không có nghĩa là toàn diện.

Dưới đây là bản tóm tắt ngắn gọn về khả năng của từng Converter class:)http://www.scribd.com/Alberta%20Geological%20Survey/d/29101948-Implementation-of-a-Web-GIS-Application-for-the-Turtle-Mountain-Monitoring-Project-in-ArcGIS-Server-9-2-OFR-2009-05

Namespace Description

ESRI.ArcGIS.ADF.ArcGISServer.Converter

Work with ArcGIS Server Web service and Dcom proxy classes and the Value objects shared by both.  Convert from Value object to COM object and vise versa.  Serialize and deserialize Value objects.

ESRI.ArcGIS.ADF.Converter

Work with Web ADF types.  Encrypt Identity and manage image bitmap creation.

ESRI.ArcGIS.ADF.Web.Converter

Work with Web ADF types.  Convert a .NET DataSet to a Web ADF graphics data set.  Convert a .NET DataTable to a Web ADF graphics layer type.

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter

Work with the ArcGIS Server COM and Value object types. Convert to/from Web ADF geometry types, graphics layers, and .NET

Page 59: What is the Web Application Developer

DataTables.

ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter

Work with ArcIMS types.  Convert to/from Web ADF geometry types and units.

ESRI.ArcGIS.ADF.Web.UI.WebControls.Converter

Used internally for Web ADF controls.  Same capabilities as ESRI.ArcGIS.ADF.Web.Converter and ESRI.ArcGIS.ADF.Converter classes.

Note that some data source APIs maintain their own converter classes.  The ArcWeb Service conversion samples in the geometry section below will provide an example.(Lưu ý rằng data source APIs duy trì converter classes của mình. ArcWeb Service chuyển đổi mẫu trong geometry section dưới đây sẽ cung cấp một ví dụ.) GeometryA core task of a GIS application or service is to work with spatial data - such as retrieving the location of user interaction in a client or defining a spatial filter to select a subset of feature data.  In each tier and for each data source, spatial information must be managed.  As a result, each tier and data source also provides a means for storing and working with geometry.   The following scenario simulates a process in which multiple geometry types must be utilized.  The goal of this scenario is to buffer a point from a user click on a map in a browser, display the buffer in the map, and use it to display a subset of features in a feature layer.  The process is divided into four steps, each is discussed below:(Một core task của một ứng dụng GIS, service  là để làm việc với spatial data, chẳng hạn như lấy các vị trí người dùng tương tác trong một client hoặc định nghĩa một spatial filter để chọn một tập con của feature data. Trong mỗi tầng và cho mỗi data source, spatial information phải được quản lý. Kết quả là, mỗi tầng và data source cũng cung cấp một phương tiện để lưu trữ và làm việc với geometry.Các kịch bản sau đây mô phỏng một quá trình mà trong đó nhiều geometry types phải được sử dụng. Mục tiêu của kịch bản này là để buffer a point từ một nhấp chuột của người dùng trên bản đồ trong trình duyệt, hiển thị buffer trong bản đồ, và sử dụng nó để hiển thị một tập con của features trong feature layer. Quá trình này được chia thành bốn bước, từng được thảo luận dưới đây:)1) Get the location of a user click on the map in a browser |The user entered point in the browser is provided to the Web ADF application in screen units (browser display).  The native .NET drawing library (System.Drawing) is used to store the screen geometry.  The Web ADF converts the geometry from screen units to map units.  The Web ADF maintains its own geometry library to both work with Web ADF specific capabilities (such as GraphicsElementLayer or SpatialFilter) and act as an intermediate type for geometry defined in the client and server tiers.  In this case, the Web ADF geometry is a link between screen geometry and ArcGIS Server geometry. (Lấy vị trí của một người sử dụng nhấp chuột vào bản đồ trong trình duyệt Người dùng nhập vào điểm trong trình duyệt được cung cấp bởi Web ADF application trong các đơn vị màn hình (browser display).  The native .NET drawing library (System.Drawing) được sử dụng để lưu trữ screen geometry. Web ADF chuyển đổi geometry từ c screen units thành map units. Web ADF duy trì geometry library của chính nó để cả hai làm việc với Web ADF specific capabilities

Page 60: What is the Web Application Developer

(như GraphicsElementLayer hoặc SpatialFilter) và hành động như intermediate type  cho geometry quy định trong client và server tiers. Trong trường hợp này, Web ADF geometry là một liên kết giữa screen geometry và ArcGIS Server geometry.)

2) Use ArcGIS Server local service to buffer the point

The Web ADF cannot buffer a point.  ArcGIS Server local data source can buffer geometry and return the buffer polygon geometry.   In order to work with buffer capabilities in ArcGIS Server local services, we need to convert the Web ADF point to an ArcObjects COM object type point.     (Sử dụng ArcGIS Server local service để buffer the pointWeb ADF không thể buffer a point. ArcGIS Server local data source có thể buffer geometry và trả về buffer polygon geometry. Để làm việc với buffer capabilities trong ArcGIS Server local services, chúng ta cần phải chuyển đổi Web ADF point thành ArcObjects COM object type point.) 3) Display the buffer in a Web ADF graphics layer on the map

The ArcGIS Server local service returns an ArcObjects COM polygon type.  To render this in a Web ADF graphics layer, it needs to be converted to Web ADF polygon.  (3) Hiển thị các bộ đệm trong Web ADF graphics layer trên bản đồArcGIS Server local service trả về một ArcObjects COM polygon type. Để làm điều này trong Web ADF graphics layer, nó cần phải được chuyển đổi sang Web ADF polygon.)4) Use the buffer to select features in an ArcIMS serviceTo use the Web ADF buffer polygon to display a subset of features in a layer in an ArcIMS service, it needs to be converted to an ArcIMS polygon type.  If we merely needed to query a layer and return a set of features, we can use the Web ADF buffer polygon with IQueryFunctionality.  Since we are attempting to apply a definition to a layer, we must work with the ArcIMS API.    

(Sử dụng bộ đệm để chọn features trong ArcIMS serviceĐể sử dụng Web ADF buffer polygon hiển thị một tập con các features trong một layer trong ArcIMS service, nó cần phải được chuyển đổi sang ArcIMS polygon type. Nếu chúng chỉ đơn thuần là cần để truy vấn một layer và trả về một tập features, chúng có thể sử dụng Web ADF buffer polygon với IQueryFunctionality. Từ đó chúng ta cố gắng áp dụng một định nghĩa layer, chúng ta phải làm việc với ArcIMS API.)

Page 61: What is the Web Application Developer

In this scenario, we traversed three tiers and four different APIs to work with geometry: .NET Framework, Web ADF, ArcGIS Server - ArcObjects COM, and ArcIMS.   All API's were required based on the requirements of the scenario and capabilities of each API.   The Web ADF provides the focal point for API interaction, thus it must provide the means to integrate types from multiple source in a single application.  

The following code snippets provide examples of converting geometry types between different APIs.   They are organized by geometry type: point, polyline, polygon.  Each type includes conversion examples from screen (.NET Framework) to Web ADF and Web ADF to data source API, and data source API to Web ADF.   Converting between ArcGIS Server ArcObjects-COM and SOAP-Value object types is covered in the next section.  For the sample code snippets below, two variables are assumed to be available:

(Trong kịch bản này, chúng ta đi qua ba tầng và bốn API khác nhau để làm việc với geometry: NET Framework, Web ADF, ArcGIS Server - COM ArcObjects, và ArcIMS. Tất cả các API đã được yêu cầu dựa trên các yêu cầu của kịch bản và khả năng của mỗi API. Web ADF cung cấp đầu mối cho API tương tác, do đó nó phải cung cấp phương tiện để tích hợp các types từ nhiều nguồn trong một ứng dụng duy nhất. Các đoạn mã sau đây cung cấp các ví dụ về chuyển đổi geometry types giữa các API khác nhau. Chúng được tổ chức theo geometry type: point, polyline, polygon. Mỗi loại bao gồm các ví dụ chuyển đổi từ màn hình (.NET Framework) thành Web ADF và Web ADF thành data source API, và data source API thành Web ADF. Chuyển đổi giữa ArcGIS Server ArcObjects-COM và SOAP-Value object types  được đề cập trong phần tiếp theo.Đối với các đoạn mã mẫu dưới đây, hai biến được giả định là có sẵn:)

Variable Description

tooleventargsWeb ADF ToolEventArgs argument for a custom tool

adf_map Web ADF Map control

Notes:

ArcGIS Server curve-based geometry types are not supported in the Web ADF geometry model.  To prepare ArcGIS Server curve types, you can use the ArcObjects API to densify or generalize the curve and generate geometry defined by a point collection.  To do this, use the Densify() or Generalize() method on the ArcObjects curve. 

(•ArcGIS Server curve-based geometry types không được hỗ trợ trong Web ADF geometry model. Để chuẩn bị ArcGIS Server curve types, bạn có thể sử dụng ArcObjects API để thêm độ dày hoặc phổ biến những đường cong và tạo ra các hình học được định nghĩa bởi một tập điểm. Để làm điều này, sử dụng các phương thức Densify () hoặc Generalize() trên ArcObjects curve.)

A set of static methods on the Web ADF Geometry, Point and Envelope classes (in ESRI.ArcGIS.ADF.Web.Geometry) used to convert to and from screen and map units have been overloaded to support map rotation.  Some methods of the same name but a different signature have been marked obsolete because they do not support rotated maps. Obsolete methods will still work with unrotated map content.  The overloads provide a more efficient pattern for transforming Web ADF geometry via the TransformationParams class.

Page 62: What is the Web Application Developer

(Một tập hợp các phương pháp tĩnh trên Web ADF Geometry, Point và Envelope classes (trong ESRI.ArcGIS.ADF.Web.Geometry) được sử dụng để chuyển đổi và từ screen và map units có thể làm quá tải để hỗ trợ map rotation. Một số phương thức cùng tên nhưng ký hiệu khác nhau đã được đánh dấu lỗi thời bởi vì họ không hỗ trợ việc xoay bản đồ. Phương thức lỗi thời vẫn sẽ làm việc với nội dung bản đồ không được xoay. Việc quá tải cung cấp một mô hình hiệu quả hơn để chuyển đổi Web ADF geometry  thông qua TransformationParams class.)TransformationParams stores parameters needed to convert coordinates between screen and map units. The Map control has a GetTransformationParams() method to return a TransformationParams instance set up using Map properties. The TransformationDirection enumeration allows you to select which direction the tranform will take place: either screen to map units (ToMap) or map to screen units (ToScreen). The RotationParams class stores parameters associated with a rotated map extent. The TransformationParams class uses the RotatedParams class to account for rotation when converting coordinates between screen and map units.  (TransformationParams cửa hàng các thông số cần thiết để chuyển đổi screen và map units. Map control có GetTransformationParams() method để trả lại một TransformationParams instance thiết lập bằng cách sử dụng Map properties. Việc liệt kê TransformationDirection cho phép bạn chọn hướng thay đổi sẽ diễn ra: hoặc screen thành map units (ToMap) hoặc map thành screen units (ToScreen). RotationParams class chứa các thông số liên quan với rotated map extent. TransformationParams class sử dụng RotatedParams class vào tài khoản cho phép quay khi chuyển đổi tọa độ giữa screen và map units.)A single TransformationParams instance can be created from scratch or retrieved from a Map control and used in multiple geometry conversion calls. TransformationDirection.ToMap should be used for ToMap_ methods while TransformationDirection.ToScreen should be used with ToScreen_ methods.

(Một ví dụ TransformationParams duy nhất có thể được tạo ra từ đầu hoặc lấy từ một Map control và được sử dụng trong nhiều geometry chuyển đổi được gọi. TransformationDirection.ToMap được sử dụng cho ToMap_ methods trong khi TransformationDirection.ToScreen được sử dụng với ToScreen_ methods.)

 Point

Screen to Web ADF   [C#]PointEventArgs pointargs = (PointEventArgs)tooleventargs;System.Drawing.Point screen_point = pointargs.ScreenPoint;

ESRI.ArcGIS.ADF.Web.Geometry.Point adf_point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point.X, screen_point.Y, adf_map.GetTransformationParams(TransformationDirection.ToMap));

Screen to ArcGIS Server SOAP   [C#]ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay imgDisp = new ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay();imgDisp.ImageHeight = (int)adf_map.Height.Value;imgDisp.ImageWidth = (int)adf_map.Width.Value;

Page 63: What is the Web Application Developer

int[] xvalues = new int[1];xvalues[0] = screen_point.X;

int[] yvalues = new int[1];yvalues[0] = screen_point.Y;

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)adf_map.GetFunctionality(0);

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase ags_mapresource = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase)ags_mapfunctionality.Resource;

ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy ags_mapserverproxy = ags_mapresource.MapServerProxy;

ESRI.ArcGIS.ADF.ArcGISServer.MultipointN value_multipoint = (ESRI.ArcGIS.ADF.ArcGISServer.MultipointN) ags_mapserverproxy.ToMapPoints(ags_mapfunctionality.MapDescription,imgDisp, xvalues, yvalues);

ESRI.ArcGIS.ADF.ArcGISServer.PointN value_point = (ESRI.ArcGIS.ADF.ArcGISServer.PointN)value_multipoint.PointArray[0];

Screen to ArcIMS   [C#]ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality ims_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)adf_map.GetFunctionality(0);

ESRI.ArcGIS.ADF.IMS.Carto.MapView mapview = ims_mapfunctionality.MapView;

ESRI.ArcGIS.ADF.IMS.Geometry.Envelope ims_extent = mapview.Extent;

ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point = ESRI.ArcGIS.ADF.IMS.Geometry.Point.ToMapPoint(screen_point, ims_extent, mapview.ImageDescriptor.Width, mapview.ImageDescriptor.Height);

Web ADF to ArcGIS Server SOAP  [C#]ESRI.ArcGIS.ADF.ArcGISServer.PointN value_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_point);

Web ADF to ArcGIS Server ArcObjects  [C#]

Page 64: What is the Web Application Developer

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)adf_map.GetFunctionality(ags_local_resource_index); ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mapresourcelocal = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)ags_mapfunctionality.Resource;

ESRI.ArcGIS.Geometry.IPoint com_point = (ESRI.ArcGIS.Geometry.IPoint) ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(adf_point, ags_mapresourcelocal.ServerContextInfo.ServerContext);

Web ADF to ArcIMS  [C#]ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point = (ESRI.ArcGIS.ADF.IMS.Geometry.Point) ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToIMSGeometry(adf_point);

ArcGIS Server SOAP to Web ADF  [C#]ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPoint(value_point);

ArcGIS Server ArcObjects to Web ADF  [C#]ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPoint(com_point);

ArcIMS to Web ADF  [C#]ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point = (ESRI.ArcGIS.ADF.Web.Geometry.Point) ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToADFGeometry(ims_point);

 Polyline

Screen to Web ADF   [C#]VectorEventArgs vectorargs = (VectorEventArgs)tooleventargs;System.Drawing.Point[] screen_points = vectorargs.Vectors;

ESRI.ArcGIS.ADF.Web.Geometry.PointCollection adf_pointcollection = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();

foreach (System.Drawing.Point screen_point in screen_points){

Page 65: What is the Web Application Developer

adf_pointcollection.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint (screen_point, adf_map.Extent, adf_map.GetTransformationParams(TransformationDirection.ToMap));}

ESRI.ArcGIS.ADF.Web.Geometry.Path adf_path = new ESRI.ArcGIS.ADF.Web.Geometry.Path();adf_path.Points = adf_pointcollection;ESRI.ArcGIS.ADF.Web.Geometry.PathCollection adf_paths = new ESRI.ArcGIS.ADF.Web.Geometry.PathCollection();adf_paths.Add(adf_path);ESRI.ArcGIS.ADF.Web.Geometry.Polyline adf_polyline = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline();adf_polyline.Paths = adf_paths;

Screen to ArcGIS Server SOAP   [C#]ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay imgDisp = new ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay();imgDisp.ImageHeight = (int)adf_map.Height.Value;imgDisp.ImageWidth = (int)adf_map.Width.Value;

int[] xvalues = new int[screen_points.Length];int[] yvalues = new int[screen_points.Length];

for (int i = 0; i < screen_points.Length; i++){ xvalues[i] = screen_points[i].X; yvalues[i] = screen_points[i].Y;}

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)adf_map.GetFunctionality(0);

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase ags_mapresource = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase)ags_mapfunctionality.Resource;

ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy ags_mapserverproxy = ags_mapresource.MapServerProxy;

ESRI.ArcGIS.ADF.ArcGISServer.MultipointN value_multipoint = (ESRI.ArcGIS.ADF.ArcGISServer.MultipointN) ags_mapserverproxy.ToMapPoints(ags_mapfunctionality.MapDescription, imgDisp, xvalues, yvalues);

ESRI.ArcGIS.ADF.ArcGISServer.Path value_path = new ESRI.ArcGIS.ADF.ArcGISServer.Path(); value_path.PointArray = value_multipoint.PointArray;

ESRI.ArcGIS.ADF.ArcGISServer.Path[] value_paths = new ESRI.ArcGIS.ADF.ArcGISServer.Path[1];value_paths.SetValue(value_path, 0);

Page 66: What is the Web Application Developer

ESRI.ArcGIS.ADF.ArcGISServer.PolylineN value_polyline = new ESRI.ArcGIS.ADF.ArcGISServer.PolylineN();value_polyline.PathArray = value_paths;

Screen to ArcIMS   [C#]ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality ims_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality) adf_map.GetFunctionality(0);ESRI.ArcGIS.ADF.IMS.Carto.MapView mapview = ims_mapfunctionality.MapView;

ESRI.ArcGIS.ADF.IMS.Geometry.Envelope ims_extent = mapview.Extent;

ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection ims_pointcollection = new ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection();

foreach (System.Drawing.Point screen_point in screen_points){ ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point = ESRI.ArcGIS.ADF.IMS.Geometry.Point.ToMapPoint(screen_point, ims_extent, mapview.ImageDescriptor.Width, mapview.ImageDescriptor.Height); ims_pointcollection.Add(ims_point);}

ESRI.ArcGIS.ADF.IMS.Geometry.Path ims_path = new ESRI.ArcGIS.ADF.IMS.Geometry.Path();ims_path.Points = ims_pointcollection;

ESRI.ArcGIS.ADF.IMS.Geometry.Polyline ims_polyline = new ESRI.ArcGIS.ADF.IMS.Geometry.Polyline();ims_polyline.Paths.Add(ims_path);

Web ADF to ArcGIS Server SOAP  [C#]ESRI.ArcGIS.ADF.ArcGISServer.PolylineN value_polyline = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPolyline(adf_polyline);

Web ADF to ArcGIS Server ArcObjects  [C#]ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality) adf_map.GetFunctionality(0);

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mapresourcelocal = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal) ags_mapfunctionality.Resource;

ESRI.ArcGIS.Geometry.IPointCollection com_polyline_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection)

Page 67: What is the Web Application Developer

ags_mapresourcelocal.ServerContextInfo.ServerContext.CreateObject("esriGeometry.Polyline");

object Missing = Type.Missing;

foreach (ESRI.ArcGIS.ADF.Web.Geometry.Path new_adf_path in adf_polyline.Paths){ ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection) ags_mapresourcelocal.ServerContextInfo.ServerContext.CreateObject("esriGeometry.Path");

foreach (ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point in new_adf_path.Points) { ESRI.ArcGIS.Geometry.IPoint com_point = (ESRI.ArcGIS.Geometry.IPoint) ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(new_adf_point, ags_mapresourcelocal.ServerContextInfo.ServerContext); com_pointcollection.AddPoint(com_point, ref Missing, ref Missing); } com_polyline_pointcollection.AddPointCollection(com_pointcollection); }

ESRI.ArcGIS.Geometry.IPolyline com_polyline = (ESRI.ArcGIS.Geometry.IPolyline)com_polyline_pointcollection;

Web ADF to ArcIMS  [C#]ESRI.ArcGIS.ADF.IMS.Geometry.Polyline ims_polyline = (ESRI.ArcGIS.ADF.IMS.Geometry.Polyline) ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToIMSGeometry(adf_polyline);

ArcGIS Server SOAP to Web ADF  [C#]ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_polyline = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPolyline(value_polyline);

ArcGIS Server ArcObjects to Web ADF  [C#]ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection)com_polyline;

ESRI.ArcGIS.ADF.Web.Geometry.Point[] new_adf_points = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPointCollection(com_pointcollection);

ESRI.ArcGIS.ADF.Web.Geometry.PointCollection new_adf_pointcollection = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();

Page 68: What is the Web Application Developer

for (int i = 0; i < new_adf_points.Length - 1; i++){ new_adf_pointcollection.Add(new_adf_points[i]);}ESRI.ArcGIS.ADF.Web.Geometry.Path new_adf_path = new ESRI.ArcGIS.ADF.Web.Geometry.Path();

new_adf_path.Points = new_adf_pointcollection;

ESRI.ArcGIS.ADF.Web.Geometry.PathCollection new_adf_pathcollection = new ESRI.ArcGIS.ADF.Web.Geometry.PathCollection();adf_pathcollection.Add(new_adf_path);

ESRI.ArcGIS.ADF.Web.Geometry.Polyline new_adf_polyline = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline();new_adf_polyline.Paths = new_adf_pathcollection;

ArcIMS to Web ADF  [C#]ESRI.ArcGIS.ADF.Web.Geometry.Polyline new_adf_polyline = (ESRI.ArcGIS.ADF.Web.Geometry.Polyline) ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToADFGeometry(ims_polyline);

 Polygon

Screen to Web ADF [C#]VectorEventArgs vectorargs = (VectorEventArgs)tooleventargs;System.Drawing.Point[] screen_points = vectorargs.Vectors;

ESRI.ArcGIS.ADF.Web.Geometry.PointCollection adf_pointcollection = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();foreach (System.Drawing.Point screen_point in screen_points){ adf_pointcollection.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point, adf_map.Extent, adf_map.GetTransformationParams(TransformationDirection.ToMap));}

ESRI.ArcGIS.ADF.Web.Geometry.Ring adf_ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();adf_ring.Points = adf_pointcollection;ESRI.ArcGIS.ADF.Web.Geometry.RingCollection adf_rings = new ESRI.ArcGIS.ADF.Web.Geometry.RingCollection();adf_rings.Add(adf_ring);ESRI.ArcGIS.ADF.Web.Geometry.Polygon adf_polygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();adf_polygon.Rings = adf_rings;

Screen to ArcGIS Server SOAP   [C#]ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay imgDisp = new ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay();

Page 69: What is the Web Application Developer

imgDisp.ImageHeight = (int)adf_map.Height.Value;imgDisp.ImageWidth = (int)adf_map.Width.Value;

int[] xvalues = new int[screen_points.Length];int[] yvalues = new int[screen_points.Length];

for (int i = 0; i < screen_points.Length; i++){ xvalues[i] = screen_points[i].X; yvalues[i] = screen_points[i].Y;}

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality) adf_map.GetFunctionality(0);

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase ags_mapresource = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase) ags_mapfunctionality.Resource;

ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy ags_mapserverproxy =ags_mapresource.MapServerProxy;

ESRI.ArcGIS.ADF.ArcGISServer.MultipointN value_multipoint = (ESRI.ArcGIS.ADF.ArcGISServer.MultipointN) ags_mapserverproxy.ToMapPoints(ags_mapfunctionality.MapDescription,imgDisp, xvalues, yvalues);

ESRI.ArcGIS.ADF.ArcGISServer.Ring value_ring = new ESRI.ArcGIS.ADF.ArcGISServer.Ring();value_ring.PointArray = value_multipoint.PointArray;

ESRI.ArcGIS.ADF.ArcGISServer.Ring[] value_rings = new ESRI.ArcGIS.ADF.ArcGISServer.Ring[1];value_rings.SetValue(value_ring, 0);

ESRI.ArcGIS.ADF.ArcGISServer.PolygonN value_polygon = new ESRI.ArcGIS.ADF.ArcGISServer.PolygonN();value_polygon.RingArray = value_rings;

Screen to ArcIMS   [C#]ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality ims_mapfunctionality =(ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality) adf_map.GetFunctionality(0);ESRI.ArcGIS.ADF.IMS.Carto.MapView mapview = ims_mapfunctionality.MapView;

ESRI.ArcGIS.ADF.IMS.Geometry.Envelope ims_extent = mapview.Extent;

ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection ims_pointcollection = new ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection();

foreach (System.Drawing.Point screen_point in screen_points){

Page 70: What is the Web Application Developer

ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point = ESRI.ArcGIS.ADF.IMS.Geometry.Point.ToMapPoint(screen_point, ims_extent, mapview.ImageDescriptor.Width, mapview.ImageDescriptor.Height); ims_pointcollection.Add(ims_point);}

ESRI.ArcGIS.ADF.IMS.Geometry.Ring ims_ring = new ESRI.ArcGIS.ADF.IMS.Geometry.Ring();ims_ring.Points = ims_pointcollection;

ESRI.ArcGIS.ADF.IMS.Geometry.Polygon ims_polygon = new ESRI.ArcGIS.ADF.IMS.Geometry.Polygon();ims_polygon.Rings.Add(ims_ring);

Web ADF to ArcGIS Server SOAP  [C#]ESRI.ArcGIS.ADF.ArcGISServer.PolygonN value_polygon = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPolygon(adf_polygon);

Web ADF to ArcGIS Server ArcObjects[C#]ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality) adf_map.GetFunctionality(0);

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mapresourcelocal = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal) ags_mapfunctionality.Resource;

ESRI.ArcGIS.Geometry.IPolygon com_polygon = (ESRI.ArcGIS.Geometry.IPolygon) ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(adf_polygon, ags_mapresourcelocal.ServerContextInfo.ServerContext);

Web ADF to ArcIMS  [C#]ESRI.ArcGIS.ADF.IMS.Geometry.Polygon ims_polygon = (ESRI.ArcGIS.ADF.IMS.Geometry.Polygon) ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToIMSGeometry(adf_polygon);

ArcGIS Server SOAP to Web ADF  [C#]ESRI.ArcGIS.ADF.Web.Geometry.Polygon new_adf_polygon = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPolygon(value_polygon);

ArcGIS Server ArcObjects to Web ADF

Page 71: What is the Web Application Developer

Note: If the ArcObjects polygon was generated using the ITopologicalOperator.Buffer() method, call IPolygon.Densify() to generate an adequate point collection for the Web ADF polygon.   [C#]// com_polygon.Densify(0,0);

ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection = (ESRI.ArcGIS.Geometry.IPointCollection)com_polygon;

ESRI.ArcGIS.ADF.Web.Geometry.Point[] new_adf_points = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPointCollection(com_pointcollection);

ESRI.ArcGIS.ADF.Web.Geometry.PointCollection new_adf_pointcollection = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();

for (int i = 0; i < new_adf_points.Length - 1; i++){ new_adf_pointcollection.Add(new_adf_points[i]);}ESRI.ArcGIS.ADF.Web.Geometry.Ring new_adf_ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();

new_adf_ring.Points = new_adf_pointcollection;

ESRI.ArcGIS.ADF.Web.Geometry.RingCollection new_adf_ringcollection = new ESRI.ArcGIS.ADF.Web.Geometry.RingCollection();new_adf_ringcollection.Add(new_adf_ring);

ESRI.ArcGIS.ADF.Web.Geometry.Polygon new_adf_polygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();new_adf_polygon.Rings = new_adf_ringcollection;

ArcIMS to Web ADF  [C#]ESRI.ArcGIS.ADF.Web.Geometry.Polygon new_adf_polygon = (ESRI.ArcGIS.ADF.Web.Geometry.Polygon) ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToADFGeometry(ims_polygon);

  ArcGIS Server: COM and Value objectsWhen working with ArcGIS Server, the Web ADF controls and Common API use the inherently stateless ArcGIS Server SOAP API, which includes a set of Value objects and proxies.   An ArcGIS Server Internet data source uses a Web service proxy to serialize Value objects to SOAP and work with an ArcGIS Server Web service endpoint.  An ArcGIS Server local data source uses a DCOM proxy to serialize Value objects to SOAP and work with a server object via the IRequestHandler interface directly.   Whether accessing the SOAP interface of a server object via an Internet or local connection, the the use and limitations of the stateless ArcGIS Server SOAP API are the same.   However, if you are working with an ArcGIS Server local data source, you have access to the server context, and thus the ArcObjects API, via COM on the GIS server.   The ArcGIS Server ArcObjects API has a rich and comprehensive set of the capabilities.  The ArcGIS Server SOAP API only exposes a portion of ArcObjects capability (via a SOAP interface).  To utilize ArcObjects and work with the Web ADF implementation of ArcGIS Server data sources, which uses the SOAP API, a conversion between ArcObjects COM and SOAP

Page 72: What is the Web Application Developer

Value objects must occur.   Two converter methods are available in the ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter class to accomplish this: Converter.COMObjectToValueObject(object, ESRI.ArcGIS.Server.IServerContext, System.Type) returns an ArcGIS Server SOAP API Value object.(Khi làm việc với ArcGIS Server, the Web ADF controls và Common API  sử dụng vốn stateless ArcGIS Server SOAP API, bao gồm một tập Value objects và proxy. ArcGIS Server Internet data source sử dụng Web service proxy để xếp theo thứ tự Value objects đến SOAP và làm việc với ArcGIS Server Web service endpoint. ArcGIS Server local data source sử dụng DCOM proxy  để để xếp theo thứ tự Value objects đến SOAP và làm việc với server object thông qua IRequestHandler interface trực tiếp. Cho dù truy cập vào SOAP interface của server object thông qua Internet hay local connection, sử dụng và hạn chế của stateless ArcGIS Server SOAP API là như nhau. Tuy nhiên, nếu bạn đang làm việc với ArcGIS Server local data source, bạn có thể truy cập đến server context, và do đó các ArcObjects API, thông qua COM trên GIS server. ArcGIS Server ArcObjects API có một tập phong phú và toàn diện các khả năng. ArcGIS Server SOAP API chỉ lộ ra một phần của ArcObjects capability (thông qua SOAP interface). Để sử dụng ArcObjects và làm việc với Web ADF implementation của ArcGIS Server data sources, sử dụng các API SOAP, một chuyển đổi giữa ArcObjects COM và SOAP Value objects phải xảy ra. Hai phương pháp chuyển đổi có sẵn trong lớp ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter để thực hiện điều này:

Converter.COMObjectToValueObject(object, ESRI.ArcGIS.Server.IServerContext, System.Type) trả về ArcGIS Server SOAP API Value object.)

[C#]ESRI.ArcGIS.ADF.ArcGISServer.PolylineN value_polyline = (ESRI.ArcGIS.ADF.ArcGISServer.PolylineN) ESRI.ArcGIS.ADF.ArcGISServer.Converter.ComObjectToValueObject(com_polyline, servercontext, typeof(ESRI.ArcGIS.ADF.ArcGISServer.PolylineN));

Converter.ValueObjectToCOMObject(object, ESRI.ArcGIS.Server.IServerContext) returns an ArcGIS Server ArcObjects API COM object. 

[C#]ESRI.ArcGIS.Geometry.IPolyline com_polyline = (ESRI.ArcGIS.Geometry.IPolyline) ESRI.ArcGIS.ADF.ArcGISServer.Converter.ValueObjectToComObject(value_polyline, servercontext);

Since the SOAP API represents a subset of the ArcObjects API, every Value object has a complimentary COM object. However, not every COM object has a complimentary Value object.  The following table lists some valid conversions between Value object and COM object types.

(Từ đó SOAP API đại diện cho một tập con của ArcObjects API, mỗi Value object có COM object miễn phí. Tuy nhiên, không phải tất cả các COM object có một Value object miễn phí. Bảng dưới đây liệt kê một số chuyển đổi giá trị giữa Value object và COM object types.)

Value object type     ESRI.ArcGIS.ADF.ArcGISServer.* ArcObjects COM object type

 PointN  ESRI.ArcGIS.Geometry.IPoint

Page 73: What is the Web Application Developer

 Line  ESRI.ArcGIS.Geometry.ILine

 PolylineN  ESRI.ArcGIS.Geometry.IPolyline

 PolygonN  ESRI.ArcGIS.Geometry.IPolygon

 MapDescription  ESRI.ArcGIS.Carto.IMapDescription

 GraphicsElement[]  ESRI.ArcGIS.Carto.IGraphicElements

 Field  ESRI.ArcGIS.Geodatabase.IField

 RecordSet  ESRI.ArcGIS.Geodatabase.IRecordSet

Datasets 

Frequently when working with data sources, you need to manage and interact with tabular data.  In most cases, traversing tables of data requires using the data source specific API methods, properties and techniques.  To more effectively handle data source specific datasets and work with a common standardized ADO.NET data structure, the Web ADF provides a set of utility methods.   These methods convert data source specific tabular data to ADO.NET DataTables and Web ADF GraphicsLayers (extends DataTable).

To convert an ArcGIS Server ArcObjects ESRI.ArcGIS.Geodatabase.IRecordSet or ESRI.ArcGIS.ADF.ArcGISServer.RecordSet to an ADO.NET System.Data.DataTable, use the following static method in the ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer namespace.  The ArcObjects type IRecordSet will first need to be converted to a SOAP Value object RecordSet using the ComObjectToValueObject method discussed in the previous section.(Thường gặp khi làm việc với data sources, bạn cần phải quản lý và tương tác với dữ liệu dạng bảng. Trong hầu hết trường hợp, sự tịnh tiến các bảng dữ liệu đòi hỏi phải sử dụng the data source specific API methods, properties và techniques. Để xử lý hiệu quả hơn data source specific datasets và làm việc với một cấu trúc dữ liệu tiêu chuẩn ADO.NET phổ biến, Web ADF cung cấp một tập hợp các phương thức hữu ích. Những phương thức chuyển đổi data source specific  dữ liệu bảng thành ADO.NET DataTables và Web ADF GraphicsLayers (extends DataTable)..

Để chuyển đổi một ArcGIS Server ArcObjects ESRI.ArcGIS.Geodatabase.IRecordSet hoặc ESRI.ArcGIS.ADF.ArcGISServer.RecordSet thành một System.Data.DataTable ADO.NET, sử dụng phương pháp tĩnh sau đây trong ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer namespace. ArcObjects type IRecordSet đầu tiên sẽ cần phải được chuyển đổi sang SOAP Value object RecordSet sử dụng phương pháp ComObjectToValueObject thảo luận trong phần trước.)

ToDataTable(ESRI.ArcGIS.ADF.ArcGISServer.RecordSet)

If the ArcGIS Server RecordSet Value object has a column that contains Geometry Value objects, you can convert the RecordSet to a Web ADF feature graphics layer and display it in a map control.  Use the following static method to return a ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer: (Nếu ArcGIS Server RecordSet Value object có một cột có chứa Geometry Value objects, bạn có thể chuyển đổi các RecordSet thành Web ADF feature graphics layer và hiển thị nó trong một map

Page 74: What is the Web Application Developer

control. Sử dụng static method sau để trả lại ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer:)

ToFeatureGraphicsLayer(ESRI.ArcGIS.ADF.ArcGISServer.RecordSet recordSet)

The Web ADF Common API defines an IQueryFunctionality interface which, if implemented by a data source, provides a number of methods to query data layers exposed by the data source.  The data returned from a query is in the ADO.NET DataTable format.  However, it often contains Web ADF geometry that you would like to display as graphics in a map control.  Instead of creating the Web ADF graphics layer from scratch, the ESRI.ArcGIS.ADF.Web.Converter class contains following static method to create the graphics layer for you: (Web ADF Common API định nghĩa một IQueryFunctionality interface, nếu được thực hiện bởi data source, cung cấp một số methods để các truy vấn dữ liệu layer xuất hiện bởi data source. Các dữ liệu trả về từ một truy vấn là trong ADO.NET DataTable format. Tuy nhiên, nó thường chứa Web ADF geometry mà bạn muốn hiển thị như graphics trong map control. Thay vì tạo ra Web ADF graphics layer từ đầu, ESRI.ArcGIS.ADF.Web.Converter class chứa static method sau để tạo ra các graphics layer cho bạn:)

ToGraphicsLayer(System.Data.DataTable)

If all Web ADF geometry  in the DataTable is the same type, a ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer is returned.  If they are different types, an ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer is returned.  In either case, you can add the graphics layer to a Web ADF Graphics resource, if available.  The following example code illustrates how this may be accomplished:(Nếu tất cả Web ADF geometry trong các DataTable là cùng kiểu, ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer được trả về. Nếu chúng khác kiểu, ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer được trả lại. Trong cả hai trường hợp, bạn có thể thêm graphics layer cho một Web ADF Graphics resource, nếu có. Đoạn mã ví dụ sau đây minh họa điều này có thể được thực hiện) [C#]System.Data.DataTable datatable = queryfunctionality.Query(null, layerids[layer_index], adf_spatialfilter); ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer graphicslayer = Converter.ToGraphicsLayer(datatable, Color.Yellow, Color.Yellow); ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphicsresource = null; foreach (IGISFunctionality gisfunctionality in gisfunctionalitycollection) { if (gisfunctionality.Resource.Name == "Selection") { graphicsresource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)gfunc.Resource; graphicsresource.Graphics.Tables.Clear(); } } graphicsresource.Graphics.Tables.Add(graphicslayer);