mashuai684
路人甲
路人甲
  • 注册日期2009-02-17
  • 发帖数4
  • QQ
  • 铜币120枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:941回复:0

求助高手! 类 结构或接口成员中声明的无效!急急!

楼主#
更多 发布于:2010-05-16 17:16
<P>using System;<BR>using System.Data;<BR>using System.Configuration;<BR>using System.Collections;<BR>using System.Web;<BR>using System.Web.Security;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.WebControls.WebParts;<BR>using System.Web.UI.HtmlControls;<BR>using ESRI.ArcGIS.ADF.Web.UI.WebControls;<BR>using System.Collections.Specialized;<BR>using ESRI.ArcGIS.ADF.Web.DataSources;<BR>using System.Collections.Generic;<BR>using ESRI.ArcGIS.ADF.Web;<BR>using ESRI.ArcGIS.ADF.Web.Display.Graphics;</P>
<P>namespace MappingApp<BR>{<BR>    public class MapIdentify<BR>    {<BR>        private Page m_page;<BR>        private Map m_map;<BR>        private string m_callbackInvocation="";<BR>        private string m_filePath="";<BR>        private int m_numberDecimals=3;<BR>        private IdentifyOption m_idOption = IdentifyOption.VisibleLayers;<BR>        public int m_IdentifyTolerance = 5;<BR>        private TaskResults m_resultsDisplay = null;<BR>        private DataSet m_dataset;<BR>        public MapIdentify()<BR>        { <BR>        }<BR>        public MapIdentify(Map map)<BR>        {<BR>            if (map != null)<BR>            {<BR>                m_map = map;<BR>                SetupIdentify(); <BR>            }<BR>        }<BR>        public MapIdentify(Map map, string filePath)<BR>        {<BR>            m_map = map;<BR>            m_filePath = filePath;<BR>            SetupIdentify();<BR>        }<BR>        public void SetupIdentify()<BR>        {<BR>            m_page = m_page.Page;<BR>            System.Text.StringBuilder sb = new System.Text.StringBuilder();<BR>            m_callbackInvocation = m_page.ClientScript.GetCallbackEventReference(m_page, "message", "processCallbackResult", "context", true);<BR>           sb.Append("\n<script language=\"javascript\" type=\"text/javascript\" src=\"" + m_filePath + "JavaScript/display_mapidentify.js\" ></script>\n");<BR>           sb.Append("<script language=\"javascript\" type=\"text/javascript\">var identifyCallbackFunctionString = \"" + m_callbackInvocation + "\";</script>\n");<BR>           if (!m_page.ClientScript.IsClientScriptBlockRegistered("IdentifyScript"))<BR>           {<BR>               m_page.ClientScript.RegisterClientScriptBlock(m_page.GetType(), "IdentifyScript", sb.ToString());</P>
<P>           }<BR>        }<BR>        public string Identify(NameValueCollection queryString)<BR>        {<BR>            string xString = queryString["minx"];<BR>            string yString = queryString["miny"];<BR>            string locXString = "";<BR>            string locYString = "";<BR>            int x = Convert.ToInt32(xString);<BR>            int y = Convert.ToInt32(yString);<BR>            IGISDataSource resource;<BR>            IQueryFunctionality query;<BR>            ESRI.ArcGIS.ADF.Web.Geometry.Point mapPoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(x, y, m_map.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));<BR>            List<DataSet> gdslist = new List<DataSet>();<BR>            foreach (ImapFunctionality mapFunc in m_map.GetFunctionalities())<BR>            {<BR>                if (mapFunc is ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)<BR>                {<BR>                    continue;<BR>                }<BR>                resource = mapFunc.Resource;<BR>                query = resource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), "identify_") as IQueryFunctionality;<BR>                string[] layerIds;<BR>                string[] layerNames;<BR>                query.GetQueryableLayers(null, out layerIds, out layerNames);<BR>                string resourceType = resource.DataSource.GetType().Tostring();<BR>                double roundFactor = Math.Pow(10, m_numberDecimals);<BR>                string pointXString = Convert.ToString(Math.Round(mapPoint.X * roundFactor) / roundFactor);<BR>                string pointYString = Convert.ToString(Math.Round(mapPoint.Y * roundFactor) / roundFactor);<BR>                locXString = pointXString;<BR>                locYString = pointYString;<BR>                DataTable[] ds = null;<BR>                try<BR>                {<BR>                    ds = query.Identify(mapFunc.Name, mapPoint, m_IdentifyTolerance, m_idOption, null);<BR>                }<BR>                catch(Exception e)<BR>                {<BR>                    DataTable table = new DataTable();<BR>                    table.TableName = "Identify  Error:" + e.Message;<BR>                    ds = new DataTable[] { table };</P>
<P>                }<BR>                if (ds != null ;; ds.Length > 0)<BR>                {<BR>                    DataSet gds = new DataSet();<BR>                    DataTable table;<BR>                    for (int j = ds.Length - 1; j >= 0; j--)<BR>                    {<BR>                        table = ds[j];<BR>                        if (table.Rows.Count == 0 ;; table.TableName.IndexOf("Error") < 0)<BR>                        {<BR>                            continue;<BR>                        }<BR>                        GraphicsLayer layer = ESRI.ArcGIS.ADF.Web.Converter.ToGraphicsLayer(table, System.Drawing.Color.Empty, System.Drawing.Color.Aqua);<BR>                        if (layer != null)<BR>                        {<BR>                            gds.Tables.Add(layer);<BR>                        }<BR>                        else<BR>                        {<BR>                            gds.Tables.Add(table);<BR>                        }<BR>                    }<BR>                    if (gds.Tables.Count == 0)<BR>                    {<BR>                        continue;<BR>                    }<BR>                    gds.DataSetName = resource.Name + "(" + pointXString + "," + pointYString + ")";<BR>                    gdslist.Add(gds);<BR>                }<BR>            }<BR>            for (int i = gdslist.Count - 1; i >= 0; i--)<BR>            {<BR>                m_resultsDisplay.DisplayResults(null, null, null, gdslist);<BR>            }<BR>            if (gdslist.Count == 0)<BR>            {<BR>                string heading = "Location(" + locXString + "," + locYString + ")No results found";<BR>                string detail = "No results found";<BR>                SimpleTaskResult str = new SimpleTaskResult(heading, detail);<BR>                m_resultsDisplay.DisplayResults(null, null, null, str);<BR>            }<BR>            return m_resultsDisplay.CallbackResults.ToString();<BR>           }<BR>        public Map Map<BR>        {<BR>            get { return m_map; }<BR>            set { m_map = value; }</P>
<P>        }<BR>        public Page Page<BR>        {<BR>            get { return m_page; }<BR>            set { m_page = value; }</P>
<P>        }<BR>        public DataSet DataSet<BR>        {<BR>            get { return m_dataset; }<BR>            set { m_dataset = value; }<BR>        }<BR>        public string ClientCallbackInvocation<BR>        {<BR>            get { return m_callbackInvocation; }<BR>            set { m_callbackInvocation = value; }<BR>        }<BR>        public string FilePath<BR>        {<BR>            get { return m_filePath; }<BR>            set { m_filePath = value; }<BR>        }<BR>        public TaskResults ResultsDisplay<BR>        {<BR>            get { return m_resultsDisplay; }<BR>            set { m_resultsDisplay = value; }<BR>        }<BR>        public int NumberDecimals<BR>        {<BR>            get { return m_numberDecimals; }<BR>            set { m_numberDecimals = value; }<BR>        }<BR>    }<BR>}</P>
<P>public partial class _Default : System.Web.UI.Page<BR>{<BR>    protected void Page_Load(object sender, EventArgs e)<BR>    {<BR>        MapIdentify identify = new MapIdentify(Map1);<BR>        identify.ResultsDisplay = TaskResults;<BR>        identify.NumberDecimals = 4;<BR>    }<BR>    public virtual string RaiseCallbackEvent(string responseString)<BR>    {<BR>        Array keyValuePairs = responseString.Split(";".ToCharArray());<BR>        NameValueCollection m_queryString = new NameValueCollection();<BR>        string[] keyvalue;<BR>        string response = "";<BR>        if (keyValuePairs.Length > 0)<BR>        {<BR>            for (int i = 0; i < keyValuePairs.Length; i++)<BR>            {<BR>                keyvalue = keyValuePairs.GetValue(i).ToString().Split("=".ToCharArray());<BR>                m_queryString.Add(key[0], keyvalue[1]);<BR>            }<BR>        }<BR>        else<BR>        {<BR>            keyvalue = responseString.Split("=".ToCharArray());<BR>            if (keyvalue.Length > 0)<BR>            {<BR>                m_queryString.Add(keyvalue[0], keyvalue[1]);<BR>            }<BR>        }<BR>        string controlType = m_queryString("ControlType");<BR>        string eventArg = m_queryString("EventArg");<BR>        if (controlType == null)<BR>        {<BR>            controlType = "Map";<BR>        }<BR>        swith(controlType)<BR>        {<BR>            case "Map":<BR>            if(eventArg=="CloseOutApplication")<BR>            {<BR>            IServerConText context;<BR>                for(int i=0;i<Session.Count;i++)<BR>                {<BR>                context=Session as IServerContext;<BR>                }<BR>                if(context!=null)<BR>                {<BR>                context.RemoveAll();<BR>                    context.ReleaseContext();<BR>                }<BR>            }<BR>            Session.RemoveAll();<BR>            response=ConfigurationManager.AppSettings["CloseOutUrl"];<BR>            if(response==null||response.Length==0)<BR>            {<BR>            response="ApplicationClosed.aspx";<BR>            }<BR>        }<BR>        else if (eventArg=="GetCopyrightText")<BR>        {<BR>        System.Text.StringBuilder sb=new System.Text.StringBuilder();<BR>            sb.AppendFormat("///:::{0}:::innercontent:::", "CopyrightTextContents");<BR>            int sbLength=sb.Length;<BR>            sb.Append(GetCopyrightText());<BR>            if(sb.Length==sbLength)<BR>            {<BR>            sb.Append("no copyright information available.");<BR>            }<BR>            response=sb.ToString();</P>
<P>        }<BR>        else if (eventArg=="MapIdentify")<BR>        {<BR>        if(Identify!=null)<BR>        {<BR>        Identify.Map=Map1;<BR>            response=Identify.Identify(m_queryString);</P>
<P>        }<BR>        }<BR>        break;<BR>        default:<BR>        break;</P>
<P><BR>    }<BR>    <FONT color=#dd2222>return response;</FONT></P>
<P>}</P>
<P>这是照着网上的ArcGIS server自带例子做的,一样的代码,目的是实现MapIdentify功能,自定义Tool以及TaskResults应用,可是运行时提示最后一行出现类、结构或接口成员声明中的“return”无效以及同样的“;”无效,这是为什么呢?本人刚入手做,希望有做过类似例子的高手指点一下吧!谢谢啦</P>
喜欢0 评分0
游客

返回顶部