微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ArcGIS API For Silverlight QueryTask 跨图层查询,并监控查询的完成!

(ArcGIS API For Silverlight )QueryTask 跨图层查询,并监控查询的完成!

    直接上源码:
    定义全局变量
   int  index=0;
/// <summary>
        /// QueryTask查询多个图层,并绑定数据
        /// </summary>
        /// <param name="listUrl">图层Url集合</param>
        /// <param name="strsql">图层查询sql</param>
        private void QueryByMultiUrl(List<string> listUrl,string strsql)
        {
            if (strsql=="")
            {
                MessageBox.Show("请输入筛选条件!");
                return;
            }
            loadingMask.LoadMask();
            intUrlCount = listUrl.Count;
            if (intUrlCount != 0)
            {
                    string url = listUrl[index];
                    QueryTask queryTask = new QueryTask(url);
                    queryTask.Failed += QueryTask_AllFailed;
                    Query query = new Query();
                    query.ReturnGeometry = true;
                    query.Where = strsql;
                    query.OutFields.Add("*");
                    queryTask.ExecuteAsync(query);
                    queryTask.ExecuteCompleted += (sender2,args2) =>
                        {
                            QueryTask objQueryTask = sender2 as QueryTask;
                            FeatureSet pFeatureSet = objQueryTask.LastResult;
                            foreach (Graphic item in pFeatureSet)
                            {
                                xmfwxGraphicList.Add(item);
                            }
                            index++;
                            queryFun(listUrl,strsql);
                        };
            }
        }
</pre>  </div><h2><strong> queryFun()函数:</strong></h2><div><strong></strong><pre name="code" class="csharp"> private void queryFun(List<string> listUrl,string strsql)
        {
            if (index == intUrlCount)
            {
                index = 0;

                System.Windows.Data.PagedCollectionView pageView = new System.Windows.Data.PagedCollectionView(xmfwxGraphicList);
                resultGrid.ItemsSource = pageView;
                this._GrdWorkBox_Pager.source = pageView; 
                this.CtrlSearchBox.Binding(resultGrid);
                this.CtrlSearchBox.BingindTextBoxNotify(this.TxtTip,pageView);
                TextBlockExtension.SetRedText(TxtTip,xmfwxGraphicList.Count.ToString());
                TxtTip.Text = xmfwxGraphicList.Count.ToString();
                loadingMask.UnLoadMask();
                if (xmfwxGraphicList.Count <= 0)
                {
                    MessageBox.Show("没查到相关数据!");
                }
                return;
            }
            QueryByMultiUrl(listUrl,strsql);
        }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐