Example #1
0
        public override void Refresh()
        {
            base.Refresh();

            try
            {
                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);
                //}

                foreach (ServiceDescription service in ArcServerHelper.MapServerServices(server, ProxySettings.Proxy("http://" + server)))
                {
                    base.AddChildObject(
                        new AGSServiceExplorerObject(this, service.Name, "server=" + server + ";service=" + service.Url));
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;

                lstServices.Items.Clear();
                foreach (ServiceDescription sd in ArcServerHelper.MapServerServices(txtServer.Text, ProxySettings.Proxy("http://" + txtServer.Text)))
                {
                    lstServices.Items.Add(new ServiceDescriptionItem(sd));
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;

                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Example #3
0
        public IFeatureCursor GetFeatures(IQueryFilter filter)
        {
            if (_dataset == null || _dataset._mapServer == null || _dataset._mapDescription == null)
            {
                return(null);
            }

            gView.Interoperability.AGS.Proxy.QueryFilter qFilter = ArcServerHelper.QueryFilter(filter, this);
            try
            {
                QueryResultOptions options = new QueryResultOptions();

                RecordSet rSet = _dataset._mapServer.QueryFeatureData(_dataset._mapDescription.Name, int.Parse(_id), qFilter);
                return(new FeatureCursor(rSet));
            }
            catch (Exception ex)
            {
                //if (ex.Message == "The requested capability is not supported." && filter is ISpatialFilter && String.IsNullOrEmpty(filter.WhereClause))
                //{
                //    try
                //    {
                //        MapServerIdentifyResult[] res =
                //        _dataset._mapServer.Identify(_dataset._mapDescription,
                //            null,
                //            ((gView.Interoperability.AGS.Proxy.SpatialFilter)qFilter).FilterGeometry,
                //            0,
                //            esriIdentifyOption.esriIdentifyAllLayers,
                //            new int[] { int.Parse(_id) });
                //    }
                //    catch (Exception e)
                //    {

                //    }
                //}
                throw new gView.Framework.UI.UIException("Can't query features for '" + this.Name + "'!", ex);
            }
        }
Example #4
0
        public bool MapRequest(gView.Framework.Carto.IDisplay display)
        {
            if (_dataset == null ||
                _dataset._mapServer == null ||
                _dataset._mapDescription == 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

            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
            {
                #region Extent
                _dataset._mapDescription.MapArea.Extent =
                    ArcServerHelper.EnvelopeN(display.Envelope);
                if (display.DisplayTransformation.UseTransformation)
                {
                    _dataset._mapDescription.Rotation = display.DisplayTransformation.DisplayRotation;
                }
                #endregion

                #region Back/Transparent Color
                RgbColor         backColor  = ArcServerHelper.RgbColor(display.BackgroundColor);
                SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
                fillSymbol.Color   = backColor;
                fillSymbol.Outline = null;
                _dataset._mapDescription.BackgroundSymbol = fillSymbol;
                _dataset._mapDescription.TransparentColor = backColor;
                #endregion

                #region Layer Visibility
                LayerDescription[] layerDescriptions = _dataset._mapDescription.LayerDescriptions;
                foreach (LayerDescription layerDescr in layerDescriptions)
                {
                    IWebServiceTheme theme = GetThemeByLayerId(layerDescr.LayerID.ToString());
                    if (theme == null)
                    {
                        continue;
                    }
                    layerDescr.Visible = theme.Visible;
                    if (layerDescr.Visible)
                    {
                        foreach (int parentLayerId in _dataset.ParentLayerIds(layerDescr.LayerID))
                        {
                            LayerDescription parent = _dataset.LayerDescriptionById(parentLayerId);
                            if (parent != null)
                            {
                                parent.Visible = true;
                            }
                        }
                    }
                }
                #endregion

                #region ImageDescription
                ImageType imgType = new ImageType();
                imgType.ImageFormat     = esriImageFormat.esriImagePNG24;
                imgType.ImageReturnType = esriImageReturnType.esriImageReturnURL;

                ImageDisplay imgDisp = new ImageDisplay();
                imgDisp.ImageWidth       = iWidth;
                imgDisp.ImageHeight      = iHeight;
                imgDisp.ImageDPI         = display.dpi;
                imgDisp.TransparentColor = backColor;

                ImageDescription imgDescr = new ImageDescription();
                imgDescr.ImageDisplay = imgDisp;
                imgDescr.ImageType    = imgType;
                #endregion

                MapImage mapImg = _dataset._mapServer.ExportMapImage(_dataset._mapDescription, imgDescr);
                if (mapImg != null && !String.IsNullOrEmpty(mapImg.ImageURL))
                {
                    System.Drawing.Bitmap bm = WebFunctions.DownloadImage(mapImg.ImageURL, _dataset._proxy, System.Net.CredentialCache.DefaultNetworkCredentials);
                    if (bm != null)
                    {
                        _image                  = new GeorefBitmap(bm);
                        _image.Envelope         = new gView.Framework.Geometry.Envelope(new gView.Framework.Geometry.Envelope(display.Envelope));
                        _image.SpatialReference = display.SpatialReference;

                        if (AfterMapRequest != null)
                        {
                            AfterMapRequest(this, display, _image);
                        }
                    }
                }
                else
                {
                    if (_image != null)
                    {
                        _image.Dispose();
                        _image = null;
                    }
                }
                return(_image != null);
            }
            catch (Exception ex)
            {
                //ArcIMSClass.ErrorLog(context, "MapRequest", server, service, ex);
                return(false);
            }
        }