예제 #1
0
        static public string getLayerID(string server, string service, string theme)
        {
            string          axl  = "<ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO fields=\"false\" envelope=\"false\" renderer=\"false\" extensions=\"false\" /></REQUEST></ARCXML>";
            dotNETConnector conn = new dotNETConnector();
            string          resp = conn.SendRequest(axl, server, service);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(resp);
            foreach (XmlNode layer in doc.SelectNodes("//LAYERINFO"))
            {
                if (layer.Attributes["name"] == null || layer.Attributes["id"] == null)
                {
                    continue;
                }
                if (layer.Attributes["id"].Value == theme)
                {
                    return(theme);
                }

                if (layer.Attributes["name"].Value == theme)
                {
                    return(layer.Attributes["id"].Value);
                }
            }

            return("");
        }
예제 #2
0
        protected override string SendRequest(IUserData userData, string axlRequest)
        {
            if (!(_dataset is ArcIMSDataset))
            {
                return("");
            }
            string server  = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "server");
            string service = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "service");
            string user    = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "user");
            string pwd     = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "pwd");
            IServiceRequestContext context = (userData != null) ? userData.GetUserData("IServiceRequestContext") as IServiceRequestContext : null;

            if ((user == "#" || user == "$") &&
                context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null)
            {
                string roles = String.Empty;
                if (user == "#" && context.ServiceRequest.Identity.UserRoles != null)
                {
                    foreach (string role in context.ServiceRequest.Identity.UserRoles)
                    {
                        if (String.IsNullOrEmpty(role))
                        {
                            continue;
                        }
                        roles += "|" + role;
                    }
                }
                user = context.ServiceRequest.Identity.UserName + roles;
                pwd  = context.ServiceRequest.Identity.HashedPassword;
            }

            dotNETConnector connector = new dotNETConnector();

            if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd))
            {
                connector.setAuthentification(user, pwd);
            }

            string resp = String.Empty;

            ArcIMSClass.Log(context, "GetFeature Request", server, service, axlRequest);
            try
            {
                resp = connector.SendRequest(axlRequest, server, service, "Query");
            }
            catch (Exception ex)
            {
                ArcIMSClass.ErrorLog(context, "Query", server, service, ex);
                return(String.Empty);
            }
            ArcIMSClass.Log(context, "GetFeature Response", server, service, resp);

            return(resp);
        }
예제 #3
0
        async public override Task <bool> Refresh()
        {
            await base.Refresh();

            try
            {
                dotNETConnector connector = new dotNETConnector();

                string server = ConfigTextStream.ExtractValue(_connectionString, "server");
                string usr    = ConfigTextStream.ExtractValue(_connectionString, "user");
                string pwd    = ConfigTextStream.ExtractValue(_connectionString, "pwd");

                if (usr != "" || pwd != "")
                {
                    connector.setAuthentification(usr, pwd);
                }

                string axl = connector.SendRequest("<?xml version=\"1.0\" encoding=\"UTF-8\"?><GETCLIENTSERVICES/>", server, "catalog");
                if (axl == "")
                {
                    return(false);
                }

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(axl);
                foreach (XmlNode mapService in doc.SelectNodes("//SERVICE[@name]"))
                {
                    base.AddChildObject(new ArcIMSServiceExplorerObject(this, mapService.Attributes["name"].Value, _connectionString));
                }
                if (doc.SelectNodes("//SERVICE[@name]").Count == 0)
                {
                    foreach (XmlNode mapService in doc.SelectNodes("//SERVICE[@NAME]"))
                    {
                        base.AddChildObject(new ArcIMSServiceExplorerObject(this, mapService.Attributes["NAME"].Value, _connectionString));
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);

                return(false);
            }
        }
예제 #4
0
        public bool MapRequest(gView.Framework.Carto.IDisplay display)
        {
            if (_dataset == null || Themes == null)
            {
                return(false);
            }

            List <IWebServiceTheme> themes = Themes;

            #region Check for visible Layers
            bool visFound = false;
            foreach (IWebServiceTheme theme in themes)
            {
                if (!theme.Visible)
                {
                    continue;
                }
                if (theme.MinimumScale > 1 && theme.MinimumScale > display.mapScale)
                {
                    continue;
                }
                if (theme.MaximumScale > 1 && theme.MaximumScale < display.mapScale)
                {
                    continue;
                }

                visFound = true;
                break;
            }
            if (!visFound)
            {
                if (_image != null)
                {
                    _image.Dispose();
                    _image = null;
                }
                return(true);
            }
            #endregion

            string server  = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "server");
            string service = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "service");
            string user    = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "user");
            string pwd     = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "pwd");
            IServiceRequestContext context = display.Map as IServiceRequestContext;
            if ((user == "#" || user == "$") &&
                context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null)
            {
                string roles = String.Empty;
                if (user == "#" && context.ServiceRequest.Identity.UserRoles != null)
                {
                    foreach (string role in context.ServiceRequest.Identity.UserRoles)
                    {
                        if (String.IsNullOrEmpty(role))
                        {
                            continue;
                        }
                        roles += "|" + role;
                    }
                }
                user = context.ServiceRequest.Identity.UserName + roles;
                pwd  = context.ServiceRequest.Identity.HashedPassword;
            }

            dotNETConnector connector = new dotNETConnector();
            if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd))
            {
                connector.setAuthentification(user, pwd);
            }

            if (_dataset.State != DatasetState.opened)
            {
                if (!_dataset.Open(context))
                {
                    return(false);
                }
            }

            ISpatialReference sRef = (display.SpatialReference != null) ?
                                     display.SpatialReference.Clone() as ISpatialReference :
                                     null;

            int iWidth  = display.iWidth;
            int iHeight = display.iHeight;

            if (BeforeMapRequest != null)
            {
                BeforeMapRequest(this, display, ref sRef, ref iWidth, ref iHeight);
            }

            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<?xml version='1.0' encoding='utf-8'?>");
                sb.Append("<ARCXML version='1.1'>");
                sb.Append("<REQUEST>");
                sb.Append("<GET_IMAGE>");
                sb.Append("<PROPERTIES>");
                IEnvelope bounds = display.DisplayTransformation.TransformedBounds(display);
                if (display.DisplayTransformation.UseTransformation == true)
                {
                    iWidth  = (int)(bounds.Width * display.dpm / display.mapScale);
                    iHeight = (int)(bounds.Height * display.dpm / display.mapScale);
                }
                sb.Append("<ENVELOPE minx='" + bounds.minx.ToString() + "' miny='" + bounds.miny.ToString() + "' maxx='" + bounds.maxx.ToString() + "' maxy='" + bounds.maxy.ToString() + "' />");
                sb.Append("<IMAGESIZE width='" + iWidth + "' height='" + iHeight + "' />");
                sb.Append("<BACKGROUND color='" + Color2AXL(display.BackgroundColor) + "' transcolor='" + Color2AXL(display.TransparentColor) + "' />");

                string propertyString = _dataset._properties.PropertyString;
                if (propertyString != String.Empty)
                {
                    sb.Append(_dataset._properties.PropertyString);
                }
                else
                {
                    if (sRef != null)
                    {
                        //if (this.SpatialReference != null && !display.SpatialReference.Equals(this.SpatialReference))
                        {
                            string wkt        = gView.Framework.Geometry.SpatialReference.ToESRIWKT(sRef);
                            string geotranwkt = gView.Framework.Geometry.SpatialReference.ToESRIGeotransWKT(sRef);

                            if (wkt != null)
                            {
                                //wkt = "PROJCS[\"MGI_M31\",GEOGCS[\"GCS_MGI\",DATUM[\"D_MGI\",SPHEROID[\"Bessel_1841\",6377397.155,0]],PRIMEM[\"Greenwich\",0.0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",450000],PARAMETER[\"False_Northing\",-5000000],PARAMETER[\"Central_Meridian\",13.3333333333333],PARAMETER[\"Scale_Factor\",1],PARAMETER[\"latitude_of_origin\",0],UNIT[\"Meter\",1]]";
                                //wkt = "PROJCS[\"MGI_M31\",GEOGCS[\"GCS_MGI\",DATUM[\"D_MGI\",SPHEROID[\"Bessel_1841\",6377397.155,299.1528128]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",450000.0],PARAMETER[\"False_Northing\",-5000000.0],PARAMETER[\"Central_Meridian\",13.33333333333333],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]";

                                //geotranwkt = "GEOGTRAN[\"MGISTMK_To_WGS_1984\",GEOGCS[\"MGISTMK\",DATUM[\"Militar_Geographische_Institute_STMK\",SPHEROID[\"Bessel_1841\",6377397.155,299.1528128]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],METHOD[\"Position_Vector\"],PARAMETER[\"X_Axis_Translation\",577.326],PARAMETER[\"Y_Axis_Translation\",90.129],PARAMETER[\"Z_Axis_Translation\",463.919],PARAMETER[\"X_Axis_Rotation\",5.1365988],PARAMETER[\"Y_Axis_Rotation\",1.4742],PARAMETER[\"Z_Axis_Rotation\",5.2970436],PARAMETER[\"Scale_Difference\",2.4232]]";
                                wkt        = wkt.Replace("\"", "&quot;");
                                geotranwkt = geotranwkt.Replace("\"", "&quot;");
                                if (!String.IsNullOrEmpty(geotranwkt))
                                {
                                    sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" datumtransformstring=\"" + geotranwkt + "\" />");
                                    sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" datumtransformstring=\"" + geotranwkt + "\" />");
                                }
                                else
                                {
                                    sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" />");
                                    sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" />");
                                }
                                //sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" datumtransformid=\"8415\" />");
                                //sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" datumtransformid=\"8415\" />");
                            }
                        }
                    }
                }

                sb.Append("<LAYERLIST>");
                foreach (IWebServiceTheme theme in themes)
                {
                    sb.Append("<LAYERDEF id='" + theme.LayerID + "' visible='" + (theme.Visible && !theme.Locked).ToString() + "'");
                    XmlNode xmlnode;
                    if (LayerRenderer.TryGetValue(theme.LayerID, out xmlnode))
                    {
                        sb.Append(">\n" + xmlnode.OuterXml + "\n</LAYERDEF>");
                    }
                    else if (theme.FeatureRenderer != null)
                    {
                        string renderer = ObjectFromAXLFactory.ConvertToAXL(theme.FeatureRenderer);
                        sb.Append(">\n" + renderer + "\n</LAYERDEF>");
                    }
                    else
                    {
                        sb.Append("/>");
                    }
                }
                sb.Append("</LAYERLIST>");
                sb.Append("</PROPERTIES>");
                foreach (XmlNode additional in this.AppendedLayers)
                {
                    if (additional != null)
                    {
                        sb.Append(additional.OuterXml);
                    }
                }
                sb.Append("</GET_IMAGE>");
                sb.Append("</REQUEST>");
                sb.Append("</ARCXML>");

#if (DEBUG)
                gView.Framework.system.Logger.LogDebug("Start ArcXML SendRequest");
#endif
                ArcIMSClass.Log(display as IServiceRequestContext, "GetImage Request", server, service, sb);
                string resp = connector.SendRequest(sb, server, service);
                ArcIMSClass.Log(display as IServiceRequestContext, "GetImage Response", server, service, resp);
#if (DEBUG)
                gView.Framework.system.Logger.LogDebug("ArcXML SendRequest Finished");
#endif

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(resp);

                XmlNode outputNode   = doc.SelectSingleNode("//IMAGE/OUTPUT");
                XmlNode envelopeNode = doc.SelectSingleNode("//IMAGE/ENVELOPE");

                if (ModifyResponseOuput != null)
                {
                    ModifyResponseOuput(this, new ModifyOutputEventArgs(outputNode));
                }

                if (_image != null)
                {
                    _image.Dispose();
                    _image = null;
                }

#if (DEBUG)
                //gView.Framework.system.Logger.LogDebug("Start ArcXML DownloadImage");
#endif
                System.Drawing.Bitmap bm = null;
                if (outputNode != null)
                {
#if (DEBUG)
                    gView.Framework.system.Logger.LogDebug("Start ArcXML DownloadImage");
#endif
                    bm = WebFunctions.DownloadImage(outputNode /*_dataset._connector.Proxy*/);
#if (DEBUG)
                    gView.Framework.system.Logger.LogDebug("ArcXML DownloadImage Finished");
#endif
                }
                else
                {
                    bm = null;
                }
#if (DEBUG)
                //gView.Framework.system.Logger.LogDebug("ArcXML DownloadImage Finished");
#endif

                if (bm != null)
                {
                    _image = new GeorefBitmap(bm);
                    //_image.MakeTransparent(display.TransparentColor);
                    if (envelopeNode != null &&
                        envelopeNode.Attributes["minx"] != null &&
                        envelopeNode.Attributes["miny"] != null &&
                        envelopeNode.Attributes["maxx"] != null &&
                        envelopeNode.Attributes["maxy"] != null)
                    {
                        _image.Envelope = new Envelope(
                            Convert.ToDouble(envelopeNode.Attributes["minx"].Value.Replace(".", ",")),
                            Convert.ToDouble(envelopeNode.Attributes["miny"].Value.Replace(".", ",")),
                            Convert.ToDouble(envelopeNode.Attributes["maxx"].Value.Replace(".", ",")),
                            Convert.ToDouble(envelopeNode.Attributes["maxy"].Value.Replace(".", ",")));
                    }
                    _image.SpatialReference = display.SpatialReference;

                    if (AfterMapRequest != null)
                    {
                        AfterMapRequest(this, display, _image);
                    }
                }
                return(_image != null);
            }
            catch (Exception ex)
            {
                ArcIMSClass.ErrorLog(context, "MapRequest", server, service, ex);
                return(false);
            }
        }
예제 #5
0
        public bool LegendRequest(gView.Framework.Carto.IDisplay display)
        {
            if (_dataset == null)
            {
                return(false);
            }

            List <IWebServiceTheme> themes = Themes;

            if (themes == null)
            {
                return(false);
            }

            #region Check for visible Layers
            bool visFound = false;
            foreach (IWebServiceTheme theme in themes)
            {
                if (!theme.Visible)
                {
                    continue;
                }
                if (theme.MinimumScale > 1 && theme.MinimumScale > display.mapScale)
                {
                    continue;
                }
                if (theme.MaximumScale > 1 && theme.MaximumScale < display.mapScale)
                {
                    continue;
                }

                visFound = true;
                break;
            }
            if (!visFound)
            {
                if (_legend != null)
                {
                    _legend.Dispose();
                    _legend = null;
                }
                return(true);
            }
            #endregion

            string server  = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "server");
            string service = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "service");
            string user    = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "user");
            string pwd     = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "pwd");
            IServiceRequestContext context = display.Map as IServiceRequestContext;
            if ((user == "#" || user == "$") &&
                context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null)
            {
                string roles = String.Empty;
                if (user == "#" && context.ServiceRequest.Identity.UserRoles != null)
                {
                    foreach (string role in context.ServiceRequest.Identity.UserRoles)
                    {
                        if (String.IsNullOrEmpty(role))
                        {
                            continue;
                        }
                        roles += "|" + role;
                    }
                }
                user = context.ServiceRequest.Identity.UserName + roles;
                pwd  = context.ServiceRequest.Identity.HashedPassword;
            }

            dotNETConnector connector = new dotNETConnector();
            if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd))
            {
                connector.setAuthentification(user, pwd);
            }

            if (_dataset.State != DatasetState.opened)
            {
                if (!_dataset.Open(context))
                {
                    return(false);
                }
            }

            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<?xml version='1.0' encoding='utf-8'?>");
                sb.Append("<ARCXML version='1.1'>");
                sb.Append("<REQUEST>");
                sb.Append("<GET_IMAGE>");
                sb.Append("<PROPERTIES>");
                sb.Append("<ENVELOPE minx='" + display.Envelope.minx.ToString() + "' miny='" + display.Envelope.miny.ToString() + "' maxx='" + display.Envelope.maxx.ToString() + "' maxy='" + display.Envelope.maxy.ToString() + "' />");
                sb.Append("<IMAGESIZE width='" + display.iWidth + "' height='" + display.iHeight + "' />");
                sb.Append("<BACKGROUND color='255,255,255' transcolor='255,255,255' />");

                sb.Append(_dataset._properties.PropertyString);

                sb.Append("<LAYERLIST>");
                foreach (IWebServiceTheme theme in themes)
                {
                    sb.Append("<LAYERDEF id='" + theme.LayerID + "' visible='" + (theme.Visible && !theme.Locked).ToString() + "'");
                    XmlNode xmlnode;
                    if (LayerRenderer.TryGetValue(theme.LayerID, out xmlnode))
                    {
                        sb.Append(">\n" + xmlnode.OuterXml + "\n</LAYERDEF>");
                    }
                    else if (theme.FeatureRenderer != null)
                    {
                        string renderer = ObjectFromAXLFactory.ConvertToAXL(theme.FeatureRenderer);
                        sb.Append(">\n" + renderer + "\n</LAYERDEF>");
                    }
                    else
                    {
                        sb.Append("/>");
                    }
                }
                sb.Append("</LAYERLIST>");
                sb.Append("<DRAW map=\"false\" />");
                sb.Append("<LEGEND font=\"Arial\" autoextend=\"true\" columns=\"1\" width=\"165\" height=\"170\" backgroundcolor=\"255,255,255\" layerfontsize=\"11\" valuefontsize=\"10\">");
                sb.Append("<LAYERS />");
                sb.Append("</LEGEND>");
                sb.Append("</PROPERTIES>");
                foreach (XmlNode additional in this.AppendedLayers)
                {
                    sb.Append(additional.OuterXml);
                }
                sb.Append("</GET_IMAGE>");
                sb.Append("</REQUEST>");
                sb.Append("</ARCXML>");

                ArcIMSClass.Log(display as IServiceRequestContext, "GetLegend Request", server, service, sb);
                string resp = connector.SendRequest(sb, server, service);
                ArcIMSClass.Log(display as IServiceRequestContext, "GetLegend Response", server, service, resp);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(resp);

                XmlNode output = doc.SelectSingleNode("//LEGEND");

                if (ModifyResponseOuput != null)
                {
                    ModifyResponseOuput(this, new ModifyOutputEventArgs(output));
                }

                if (_legend != null)
                {
                    _legend.Dispose();
                }

                _legend = WebFunctions.DownloadImage(output /*_dataset._connector.Proxy*/);
                return(true);
            }
            catch (Exception ex)
            {
                ArcIMSClass.ErrorLog(context, "LegendRequest", server, service, ex);
                return(false);
            }
        }
예제 #6
0
        async public Task <bool> Open(IServiceRequestContext context)
        {
            if (_class == null)
            {
                _class = new ArcIMSClass(this);
            }

            string server  = ConfigTextStream.ExtractValue(ConnectionString, "server");
            string service = ConfigTextStream.ExtractValue(ConnectionString, "service");
            string user    = ConfigTextStream.ExtractValue(ConnectionString, "user");
            string pwd     = ConfigTextStream.ExtractValue(ConnectionString, "pwd");

            //if ((user == "#" || user == "$") &&
            //        context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null)
            //{
            //    string roles = String.Empty;
            //    if (user == "#" && context.ServiceRequest.Identity.UserRoles != null)
            //    {
            //        foreach (string role in context.ServiceRequest.Identity.UserRoles)
            //        {
            //            if (String.IsNullOrEmpty(role)) continue;
            //            roles += "|" + role;
            //        }
            //    }
            //    user = context.ServiceRequest.Identity.UserName + roles;
            //    pwd = context.ServiceRequest.Identity.HashedPassword;
            //}

            dotNETConnector connector = new dotNETConnector();

            if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd))
            {
                connector.setAuthentification(user, pwd);
            }

            try
            {
                _themes.Clear();

                string axl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO fields=\"true\" envelope=\"true\" renderer=\"true\" extensions=\"true\" /></REQUEST></ARCXML>";
                //string axl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO dpi=\"96\" toc=\"true\" /></REQUEST></ARCXML>";

                await ArcIMSClass.LogAsync(context, "GetServiceInfo Response", server, service, axl);

                axl = connector.SendRequest(axl, server, service);
                await ArcIMSClass.LogAsync(context, "GetServiceInfo Response", server, service, axl);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(axl);

                double  dpi    = 96.0;
                XmlNode screen = doc.SelectSingleNode("//ENVIRONMENT/SCREEN");
                if (screen != null)
                {
                    if (screen.Attributes["dpi"] != null)
                    {
                        dpi = Convert.ToDouble(screen.Attributes["dpi"].Value.Replace(".", ","));
                    }
                }
                double dpm = (dpi / 0.0254);

                XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS");
                _sRef = ArcXMLGeometry.AXL2SpatialReference(FeatureCoordSysNode);

                foreach (XmlNode envelopeNode in doc.SelectNodes("//ENVELOPE"))
                {
                    if (_envelope == null)
                    {
                        _envelope = new Envelope(envelopeNode);
                    }
                    else
                    {
                        _envelope.Union(new Envelope(envelopeNode));
                    }
                }
                foreach (XmlNode layerNode in doc.SelectNodes("//LAYERINFO[@id]"))
                {
                    bool visible = true;

                    if (layerNode.Attributes["visible"] != null)
                    {
                        bool.TryParse(layerNode.Attributes["visible"].Value, out visible);
                    }

                    XmlNode tocNode = layerNode.SelectSingleNode("TOC");
                    if (tocNode != null)
                    {
                        ReadTocNode(tocNode);
                    }
                    IClass           themeClass = null;
                    IWebServiceTheme theme;
                    if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "featureclass")
                    {
                        themeClass = await ArcIMSThemeFeatureClass.CreateAsync(this, layerNode.Attributes["id"].Value);

                        ((ArcIMSThemeFeatureClass)themeClass).Name             = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value;
                        ((ArcIMSThemeFeatureClass)themeClass).fieldsFromAXL    = layerNode.InnerXml;
                        ((ArcIMSThemeFeatureClass)themeClass).SpatialReference = _sRef;

                        XmlNode FCLASS = layerNode.SelectSingleNode("FCLASS[@type]");
                        if (FCLASS != null)
                        {
                            ((ArcIMSThemeFeatureClass)themeClass).fClassTypeString = FCLASS.Attributes["type"].Value;
                        }
                        foreach (XmlNode child in layerNode.ChildNodes)
                        {
                            switch (child.Name)
                            {
                            case "SIMPLERENDERER":
                            case "SIMPLELABELRENDERER":
                            case "VALUEMAPRENDERER":
                            case "SCALEDEPENDENTRENDERER":
                            case "VALUEMAPLABELRENDERER":
                            case "GROUPRENDERER":
                                ((ArcIMSThemeFeatureClass)themeClass).OriginalRendererNode = child;
                                break;
                            }
                        }
                        theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme;
                        if (theme == null)
                        {
                            continue;
                        }
                        theme.Visible = visible;
                    }
                    else if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "image")
                    {
                        //themeClass = new ArcIMSThemeRasterClass(this,
                        //    layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value);
                        themeClass = new ArcIMSThemeRasterClass(this, layerNode.Attributes["id"].Value);
                        ((ArcIMSThemeRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value;

                        theme = new WebServiceTheme(
                            themeClass,
                            themeClass.Name,
                            layerNode.Attributes["id"].Value,
                            visible,
                            _class as IWebServiceClass);
                    }
                    else
                    {
                        continue;
                    }

                    try
                    {
                        if (layerNode.Attributes["minscale"] != null)
                        {
                            theme.MinimumScale = Convert.ToDouble(layerNode.Attributes["minscale"].Value.Replace(".", ",")) * dpm;
                        }
                        if (layerNode.Attributes["maxscale"] != null)
                        {
                            theme.MaximumScale = Convert.ToDouble(layerNode.Attributes["maxscale"].Value.Replace(".", ",")) * dpm;
                        }
                    }
                    catch { }
                    _themes.Add(theme);
                }
                _state = DatasetState.opened;

                ((ArcIMSClass)_class).SpatialReference = await this.GetSpatialReference();

                return(true);
            }
            catch (Exception ex)
            {
                _state  = DatasetState.unknown;
                _errMsg = ex.Message;
                await ArcIMSClass.ErrorLog(context, "Open Dataset", server, service, ex);

                return(false);
            }
        }