Esempio n. 1
0
 public override void Bind(IEditorService service)
 {
     _service = service;
     _service.RegisterCustomNotifier(this);
     _fs = (IFeatureSource)_service.GetEditedResource();
     InitDefaults();
 }
        /// <summary>
        /// Binds the specified service.
        /// </summary>
        /// <param name="service">The service.</param>
        public override void Bind(IEditorService service)
        {
            _fs = service.GetEditedResource() as IFeatureSource;
            service.RegisterCustomNotifier(this);
            Debug.Assert(_fs != null);

            CollapsiblePanel panel = FsEditorMap.GetPanel(_fs.Provider);
            var b = panel as IEditorBindable;

            if (b != null)
            {
                b.Bind(service);
            }

            panel.Dock = DockStyle.Top;

            var ov = new CoordSysOverrideCtrl();

            ov.Bind(service);

            ov.Dock = DockStyle.Top;

            var ext = new ExtensionsCtrl();

            ext.Bind(service);

            ext.Dock = DockStyle.Top;

            this.Controls.Add(ext);
            this.Controls.Add(ov);
            this.Controls.Add(panel);
        }
        public WmsAdvancedConfigurationDialog(IEditorService service)
        {
            InitializeComponent();
            grdSpatialContexts.AutoGenerateColumns = false;
            _service = service;
            _fs      = (IFeatureSource)_service.GetEditedResource();
            txtFeatureServer.Text = _fs.GetConnectionProperty("FeatureServer"); //NOXLATE
            string xml = _fs.GetConfigurationContent(service.CurrentConnection);

            if (!string.IsNullOrEmpty(xml))
            {
                try
                {
                    _config = (WmsConfigurationDocument)ConfigurationDocument.LoadXml(xml);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format(Strings.ErrorLoadingWmsConfig, ex.Message), Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MakeDefaultDocument();
                }
            }
            else
            {
                MakeDefaultDocument();
            }

            lstFeatureClasses.DataSource  = _config.RasterOverrides;
            grdSpatialContexts.DataSource = _config.SpatialContexts;
        }
        /// <summary>
        /// Sets the configuration document content
        /// </summary>
        /// <param name="fs"></param>
        /// <param name="xmlContent"></param>
        public static void SetConfigurationContent(this IFeatureSource fs, string xmlContent)
        {
            Check.NotNull(fs, "fs"); //NOXLATE
            if (string.IsNullOrEmpty(fs.ConfigurationDocument))
            {
                fs.ConfigurationDocument = "config.xml"; //NOXLATE
            }
            if (string.IsNullOrEmpty(xmlContent))
            {
                bool hasResourceData = false;
                var  resDataList     = fs.EnumerateResourceData();
                foreach (var resData in resDataList)
                {
                    if (resData.Name == fs.ConfigurationDocument)
                    {
                        hasResourceData = true;
                        break;
                    }
                }

                if (hasResourceData)
                {
                    fs.DeleteResourceData(fs.ConfigurationDocument);
                }
            }
            else
            {
                using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xmlContent)))
                {
                    fs.SetResourceData(fs.ConfigurationDocument, ResourceDataType.Stream, ms);
                }
            }
        }
        /// <summary>
        /// Gets the names of all the feature classes in the specified schema of this feature source
        /// </summary>
        /// <param name="fs"></param>
        /// <param name="schemaName"></param>
        /// <returns></returns>
        public static string[] GetClassNames(this IFeatureSource fs, string schemaName)
        {
            Check.NotNull(fs, "fs");                  //NOXLATE
            Check.NotEmpty(schemaName, "schemaName"); //NOXLATE

            return(fs.CurrentConnection.FeatureService.GetClassNames(fs.ResourceID, schemaName));
        }
        public WmsAdvancedConfigurationDialog(IEditorService service)
        {
            InitializeComponent();
            grdSpatialContexts.AutoGenerateColumns = false;
            _service = service;
            _fs = (IFeatureSource)_service.GetEditedResource();
            txtFeatureServer.Text = _fs.GetConnectionProperty("FeatureServer"); //NOXLATE
            string xml = _fs.GetConfigurationContent();
            if (!string.IsNullOrEmpty(xml))
            {
                try
                {
                    _config = (WmsConfigurationDocument)ConfigurationDocument.LoadXml(xml);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format(Strings.ErrorLoadingWmsConfig, ex.Message), Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MakeDefaultDocument();
                }
            }
            else
            {
                MakeDefaultDocument();
            }

            lstFeatureClasses.DataSource = _config.RasterOverrides;
            grdSpatialContexts.DataSource = _config.SpatialContexts;
        }
Esempio n. 7
0
            /// <summary>
            /// Sets the configuration document content
            /// </summary>
            /// <param name="fs">The feature source</param>
            /// <param name="conn">The server connection</param>
            /// <param name="xmlContent">The confiugration document XML content</param>
            public static void SetConfigurationContent(this IFeatureSource fs, IServerConnection conn, string xmlContent)
            {
                Check.ArgumentNotNull(fs, nameof(fs));
                Check.ArgumentNotNull(conn, nameof(conn));
                if (string.IsNullOrEmpty(fs.ConfigurationDocument))
                {
                    fs.ConfigurationDocument = "config.xml"; //NOXLATE
                }
                if (string.IsNullOrEmpty(xmlContent))
                {
                    bool hasResourceData = false;
                    var  resDataList     = conn.ResourceService.EnumerateResourceData(fs.ResourceID).ResourceData;
                    foreach (var resData in resDataList)
                    {
                        if (resData.Name == fs.ConfigurationDocument)
                        {
                            hasResourceData = true;
                            break;
                        }
                    }

                    if (hasResourceData)
                    {
                        conn.ResourceService.DeleteResourceData(fs.ResourceID, fs.ConfigurationDocument);
                    }
                }
                else
                {
                    using (var ms = MemoryStreamPool.GetStream("SetConfigurationContent", Encoding.UTF8.GetBytes(xmlContent))) //NOXLATE
                    {
                        conn.ResourceService.SetResourceData(fs.ResourceID, fs.ConfigurationDocument, ResourceDataType.Stream, ms);
                    }
                }
            }
Esempio n. 8
0
        /// <summary>
        /// Binds the specified service.
        /// </summary>
        /// <param name="service">The service.</param>
        public override void Bind(IEditorService service)
        {
            _fs = service.GetEditedResource() as IFeatureSource;
            service.RegisterCustomNotifier(this);
            Debug.Assert(_fs != null);

            CollapsiblePanel panel = FsEditorMap.GetPanel(_fs.Provider);
            var b = panel as IEditorBindable;
            if (b != null)
                b.Bind(service);

            panel.Dock = DockStyle.Top;

            var ov = new CoordSysOverrideCtrl();
            ov.Bind(service);

            ov.Dock = DockStyle.Top;

            var ext = new ExtensionsCtrl();
            ext.Bind(service);

            ext.Dock = DockStyle.Top;

            this.Controls.Add(ext);
            this.Controls.Add(ov);
            this.Controls.Add(panel);
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpatialContextsDialog"/> class.
 /// </summary>
 /// <param name="fs">The fs.</param>
 public SpatialContextsDialog(IFeatureSource fs)
     : this()
 {
     lblFeatureSource.Text = fs.ResourceID;
     grdSpatialContexts.DataSource = fs.GetSpatialInfo(false).SpatialContext;
     lblCount.Text = string.Format(Strings.SpatialContextsFound, grdSpatialContexts.Rows.Count);
 }
Esempio n. 10
0
        private IEnumerable <ValidationIssue> ValidateOdbcDoc(IFeatureSource fs, OdbcConfigurationDocument odbcDoc)
        {
            foreach (var schema in odbcDoc.Schemas)
            {
                var featureClasses = schema
                                     .Classes
                                     .Where(c => !string.IsNullOrEmpty(c.DefaultGeometryPropertyName) && c.Properties.Any(p => p.Type == Schema.PropertyDefinitionType.Geometry && p.Name == c.DefaultGeometryPropertyName));

                foreach (var fc in featureClasses)
                {
                    var geomProp = fc.Properties.OfType <GeometricPropertyDefinition>().FirstOrDefault(p => p.Name == fc.DefaultGeometryPropertyName);
                    if (geomProp != null)
                    {
                        //Must be point
                        if (geomProp.GeometricTypes != FeatureGeometricType.Point)
                        {
                            yield return(new ValidationIssue(fs, ValidationStatus.Error, ValidationStatusCode.Error_OdbcConfig_InvalidLogicalGeometryProperty, string.Format(Strings.ODBC_InvalidGeometryProperty, fc.Name, geomProp.Name)));
                        }

                        var ovTable = odbcDoc.GetOverride(schema.Name, fc.Name);
                        if (ovTable == null) //If it has geometry, it must have a table override
                        {
                            yield return(new ValidationIssue(fs, ValidationStatus.Error, ValidationStatusCode.Error_OdbcConfig_NoTableOverrideForFeatureClass, string.Format(Strings.ODBC_NoSuchTableOverrideForFeatureClass, fc.Name)));
                        }
                        else if (geomProp.GeometricTypes == FeatureGeometricType.Point)
                        {
                            if (string.IsNullOrEmpty(ovTable.XColumn) || string.IsNullOrEmpty(ovTable.YColumn))
                            {
                                yield return(new ValidationIssue(fs, ValidationStatus.Error, ValidationStatusCode.Error_OdbcConfig_IncompleteXYZColumnMapping, string.Format(Strings.ODBC_IncompleteXYZColumnMapping, fc.Name)));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        public RasterDefinitionCtrl(WmsConfigurationDocument config, RasterWmsItem item, IEditorService edsvc)
        {
            InitializeComponent();
            cmbBackground.ResetColors();
            _config = config;

            _fs = (IFeatureSource)edsvc.GetEditedResource();
            _item = item;
            _edsvc = edsvc;

            txtImageFormat.Text = item.ImageFormat;
            chkTransparent.Checked = item.IsTransparent;
            cmbBackground.CurrentColor = item.BackgroundColor;
            txtElevation.Text = item.ElevationDimension;
            txtEpsg.Text = item.SpatialContextName;
            txtTime.Text = item.Time;

            txtImageFormat.TextChanged += (s, e) => { item.ImageFormat = txtImageFormat.Text; };
            chkTransparent.CheckedChanged += (s, e) => { item.IsTransparent = chkTransparent.Checked; };
            cmbBackground.SelectedIndexChanged += (s, e) => { item.BackgroundColor = cmbBackground.CurrentColor; };
            txtElevation.TextChanged += (s, e) => { item.ElevationDimension = txtElevation.Text; };
            txtEpsg.TextChanged += (s, e) => { item.SpatialContextName = txtEpsg.Text; };
            txtTime.TextChanged += (s, e) => { item.Time = txtTime.Text; };

            List<string> names = new List<string>();
            foreach (var layer in item.Layers)
            {
                names.Add(layer.Name);
            }
            txtLayers.Lines = names.ToArray();
            lnkUpdate.Enabled = false;
        }
Esempio n. 12
0
        public override void Bind(IEditorService service)
        {
            _init    = true;
            _service = service;
            _fs      = (IFeatureSource)_service.GetEditedResource();

            cmbMethod.DataSource = (OdbcConnectionMethod[])Enum.GetValues(typeof(OdbcConnectionMethod));
            var    values  = _fs.GetConnectionProperties();
            string odbcStr = values["ConnectionString"]; //NOXLATE

            if (!string.IsNullOrEmpty(odbcStr))
            {
                //See if it is file-basd
                if (odbcStr.Contains("Dbq=")) //NOXLATE
                {
                    //Check driver bitness
                    chkUse64Bit.Checked = OdbcDriverNames.Uses64BitDriver(odbcStr);

                    if (odbcStr.Contains("%MG_DATA_FILE_PATH%")) //NOXLATE
                    {
                        cmbMethod.SelectedItem = OdbcConnectionMethod.ManagedFile;
                    }
                    else if (odbcStr.Contains("%MG_DATA_PATH_ALIAS")) //NOXLATE
                    {
                        cmbMethod.SelectedItem = OdbcConnectionMethod.Unmanaged;
                    }
                    else
                    {
                        cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString;
                    }
                }
                else //Non-file connection string. Has to be a known driver
                {
                    cmbMethod.SelectedItem = OdbcConnectionMethod.KnownDriver;
                }
            }
            else if (values["DataSourceName"] != null) //NOXLATE
            {
                cmbMethod.SelectedItem = OdbcConnectionMethod.DSN;
            }
            else
            {
                cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString;
            }

            //Fall back to raw connection string if we still can't figure it out
            if (this.ChildEditor == null)
            {
                cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString;
            }

            System.Diagnostics.Debug.Assert(this.ChildEditor != null);
            if (values.Count > 0)
            {
                this.ChildEditor.ConnectionProperties = values;
            }

            _init = false;
        }
 /// <summary>
 /// Adds a spatial context override
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="name"></param>
 /// <param name="coordSys"></param>
 public static void AddSpatialContextOverride(this IFeatureSource fs, string name, string coordSys)
 {
     Check.NotNull(fs, "fs"); //NOXLATE
     fs.AddSpatialContextOverride(new OSGeo.MapGuide.ObjectModels.FeatureSource.v1_0_0.SpatialContextType()
     {
         Name = name, CoordinateSystem = coordSys
     });
 }
Esempio n. 14
0
 /// <summary>
 /// Adds a spatial context override
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="name"></param>
 /// <param name="coordSys"></param>
 public static void AddSpatialContextOverride(this IFeatureSource fs, string name, string coordSys)
 {
     Check.ArgumentNotNull(fs, nameof(fs));
     fs.AddSpatialContextOverride(new SpatialContextType()
     {
         Name = name, CoordinateSystem = coordSys
     });
 }
Esempio n. 15
0
 public CalculationSettings(IEditorService edSvc, ClassDefinition cls, IFeatureSource parent, ICalculatedProperty calc)
     : this()
 {
     _edSvc = edSvc;
     _cls = cls;
     _parent = parent;
     TextBoxBinder.BindText(txtExpression, calc, "Expression"); //NOXLATE
     TextBoxBinder.BindText(txtName, calc, "Name"); //NOXLATE
 }
        private IFeatureSource GetFeatureSource()
        {
            if (_cachedFs == null)
            {
                _cachedFs = (IFeatureSource)_edsvc.CurrentConnection.ResourceService.GetResource(txtFeatureSource.Text);
            }

            return(_cachedFs);
        }
Esempio n. 17
0
 public CalculationSettings(IEditorService edSvc, ClassDefinition cls, IFeatureSource parent, ICalculatedProperty calc)
     : this()
 {
     _edSvc  = edSvc;
     _cls    = cls;
     _parent = parent;
     TextBoxBinder.BindText(txtExpression, calc, nameof(calc.Expression));
     TextBoxBinder.BindText(txtName, calc, nameof(calc.Name));
 }
        public override void Bind(IEditorService service)
        {
            _ed = service;
            _ed.RegisterCustomNotifier(this);
            _fs = (IFeatureSource)_ed.GetEditedResource();

            grdOverrides.AutoGenerateColumns = false;
            UpdateSpatialContextList();
        }
Esempio n. 19
0
        public override void Bind(IEditorService service)
        {
            _ed = service;
            _ed.RegisterCustomNotifier(this);
            _fs = (IFeatureSource)_ed.GetEditedResource();

            grdOverrides.AutoGenerateColumns = false;
            UpdateSpatialContextList();
        }
        private void AutoGenerateWFSBounds_Click(object sender, EventArgs e)
        {
            try
            {
                m_isUpdating = true;
                System.Globalization.CultureInfo ic = System.Globalization.CultureInfo.InvariantCulture;
                IFeatureSource fs       = (IFeatureSource)m_connection.ResourceService.GetResource(m_resourceId);
                bool           failures = false;

                IEnvelope env  = null;
                var       desc = m_connection.FeatureService.DescribeFeatureSource(fs.ResourceID);
                foreach (ClassDefinition scm in desc.AllClasses)
                {
                    foreach (var col in scm.Properties)
                    {
                        if (col.Type == OSGeo.MapGuide.MaestroAPI.Schema.PropertyDefinitionType.Geometry ||
                            col.Type == OSGeo.MapGuide.MaestroAPI.Schema.PropertyDefinitionType.Raster)
                        {
                            try
                            {
                                IEnvelope re = m_connection.FeatureService.GetSpatialExtent(fs.ResourceID, scm.Name, col.Name, true);
                                if (env == null)
                                {
                                    env = re;
                                }
                                else
                                {
                                    env.ExpandToInclude(re);
                                }
                            }
                            catch
                            {
                                failures = true;
                            }
                        }
                    }
                }

                if (env == null)
                {
                    throw new Exception(failures ? Strings.ResProp_NoSpatialDataWithFailuresError : Strings.ResProp_NoSpatialDataError);
                }

                m_isUpdating   = false;
                WFSBounds.Text = "<Bounds west=\"" + env.MinX.ToString(ic) + "\" east=\"" + env.MaxX.ToString(ic) + "\" south=\"" + env.MinY.ToString(ic) + "\" north=\"" + env.MaxY.ToString(ic) + "\" />"; //NOXLATE
            }
            catch (Exception ex)
            {
                string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                MessageBox.Show(this, string.Format(Strings.ResProp_WFSBoundsReadError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_isUpdating = false;
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Initializes the FDO expression editor
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="cls"></param>
        /// <param name="featureSourceId"></param>
        /// <param name="mode"></param>
        public void Initialize(IServerConnection conn, ClassDefinition cls, string featureSourceId, ExpressionEditorMode mode)
        {
            IFeatureSource           fs   = (IFeatureSource)conn.ResourceService.GetResource(featureSourceId);
            IFdoProviderCapabilities caps = conn.FeatureService.GetProviderCapabilities(fs.Provider);

            //This is normally set by the Editor Service, but we don't have that so do it here
            _featSvc = conn.FeatureService;

            this.Initialize(null, caps, cls, featureSourceId, mode, false);
        }
Esempio n. 22
0
        private void InitPreview()
        {
            var conn = _edSvc.CurrentConnection;

            _fs = (IFeatureSource)conn.ResourceService.GetResource(this.FeatureSourceID);
            var caps = conn.FeatureService.GetProviderCapabilities(_fs.Provider);

            localFsPreviewCtrl.SupportsSQL = caps.Connection.SupportsSQL;
            localFsPreviewCtrl.ReloadTree(this.FeatureSourceID, caps);
        }
Esempio n. 23
0
 private string GetLayerProvider()
 {
     if (_providerName == null)
     {
         IVectorLayerDefinition vl = (IVectorLayerDefinition)_editedLayer.SubLayer;
         IFeatureSource         fs = (IFeatureSource)_edSvc.CurrentConnection.ResourceService.GetResource(vl.ResourceId);
         _providerName = fs.Provider;
     }
     return(_providerName);
 }
        public void FeatureSourceDeserializationWithFullContentModel()
        {
            IResource res = ObjectFactory.DeserializeXml(Utils.ReadAllText($"Resources{System.IO.Path.DirectorySeparatorChar}FeatureSource-1.0.0.txt"));

            Assert.NotNull(res);
            Assert.Equal("FeatureSource", res.ResourceType);
            Assert.Equal(res.ResourceVersion, new Version(1, 0, 0));
            IFeatureSource fs = res as IFeatureSource;

            Assert.NotNull(fs);
        }
Esempio n. 25
0
        public void FeatureSourceDeserializationWithFullContentModel()
        {
            IResource res = ObjectFactory.DeserializeXml(Properties.Resources.FeatureSource_1_0_0);

            Assert.NotNull(res);
            Assert.AreEqual(res.ResourceType, "FeatureSource");
            Assert.AreEqual(res.ResourceVersion, new Version(1, 0, 0));
            IFeatureSource fs = res as IFeatureSource;

            Assert.NotNull(fs);
        }
Esempio n. 26
0
        /// <summary>
        /// Gets a collection of connection properties
        /// </summary>
        /// <param name="fs"></param>
        /// <returns></returns>
        public static NameValueCollection GetConnectionProperties(this IFeatureSource fs)
        {
            Check.ArgumentNotNull(fs, nameof(fs));
            var values = new NameValueCollection();

            foreach (string name in fs.ConnectionPropertyNames)
            {
                values[name] = fs.GetConnectionProperty(name);
            }
            return(values);
        }
        /// <summary>
        /// Gets a collection of connection properties
        /// </summary>
        /// <param name="fs"></param>
        /// <returns></returns>
        public static NameValueCollection GetConnectionProperties(this IFeatureSource fs)
        {
            Check.NotNull(fs, "fs"); //NOXLATE
            var values = new NameValueCollection();

            foreach (string name in fs.ConnectionPropertyNames)
            {
                values[name] = fs.GetConnectionProperty(name);
            }
            return(values);
        }
Esempio n. 28
0
        public override void Bind(IEditorService service)
        {
            try
            {
                _init = true;
                _bSupportsResample = false;
                _service           = service;
                _fs = (IFeatureSource)_service.GetEditedResource();

                var provInfo = _service.CurrentConnection.FeatureService.GetFeatureProvider("OSGeo.Gdal"); //NOXLATE
                foreach (var prop in provInfo.ConnectionProperties)
                {
                    if (prop.Name == "ResamplingMethod") //NOXLATE
                    {
                        chkResamplingMethod.Visible         =
                            cmbResamplingMethod.Visible     =
                                cmbResamplingMethod.Enabled = true;

                        cmbResamplingMethod.DataSource = new List <string>(prop.Value);
                        var method = _fs.GetConnectionProperty("ResamplingMethod"); //NOXLATE
                        if (!string.IsNullOrEmpty(method))
                        {
                            chkResamplingMethod.Checked      = true;
                            cmbResamplingMethod.SelectedItem = method;
                        }
                        else
                        {
                            cmbResamplingMethod.SelectedIndex = 0;
                            chkResamplingMethod.Checked       = false;
                        }
                        _bSupportsResample = true;
                        break;
                    }
                }

                cmbResamplingMethod.Enabled = chkResamplingMethod.Checked;

                _sing.Bind(service);
                _comp.Bind(service);
                if (!string.IsNullOrEmpty(_fs.GetConfigurationContent(service.CurrentConnection)))
                {
                    rdComposite.Checked = true;
                }
                else
                {
                    OnTypeCheckedChanged(null, null); //It is already checked by default
                }
            }
            finally
            {
                _init = false;
            }
        }
Esempio n. 29
0
 /// <summary>
 /// Sets the encrypted credentials for this Feature Source, the credentials are referenced with the %MG_USERNAME%
 /// and %MG_PASSWORD% placeholder tokens in the Feature Source content.
 /// </summary>
 /// <param name="fs"></param>
 /// <param name="conn"></param>
 /// <param name="username"></param>
 /// <param name="password"></param>
 public static void SetEncryptedCredentials(this IFeatureSource fs, IServerConnection conn, string username, string password)
 {
     Check.ArgumentNotNull(fs, nameof(fs));
     if (string.IsNullOrEmpty(fs.ResourceID))
     {
         throw new ArgumentException(Strings.ErrorNoResourceIdAttached);
     }
     using (var stream = CredentialWriter.Write(username, password))
     {
         conn.ResourceService.SetResourceData(fs.ResourceID, StringConstants.MgUserCredentialsResourceData, ObjCommon.ResourceDataType.String, stream);
     }
 }
 public override void Bind(IEditorService service)
 {
     //Only available on MGOS 2.2 and above
     this.LocalPreviewEnabled = service.SiteVersion >= new Version(2, 2);
     _fs    = (IFeatureSource)service.GetEditedResource();
     _fsvc  = service.CurrentConnection.FeatureService;
     _caps  = _fsvc.GetProviderCapabilities(_fs.Provider);
     _rsvc  = service.CurrentConnection.ResourceService;
     _edsvc = service;
     _edsvc.RegisterCustomNotifier(this);
     this.ConfigEnabled = _caps.Connection.SupportsConfiguration;
 }
Esempio n. 31
0
        public override void Bind(IEditorService service)
        {
            _service = service;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            txtProvider.Text = _fs.Provider;

            Debug.Assert(_fs != null);
            resDataCtrl.DataListChanged += (sender, e) => { OnResourceChanged(); };
            resDataCtrl.Init(service);
            InitGrid();
        }
        public override void Bind(IEditorService service)
        {
            _service = service;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            txtProvider.Text = _fs.Provider;

            Debug.Assert(_fs != null);
            resDataCtrl.DataListChanged += (sender, e) => { OnResourceChanged(); };
            resDataCtrl.Init(service);
            InitGrid();
        }
Esempio n. 33
0
 public override void Bind(IEditorService service)
 {
     base.Bind(service);
     _service = service;
     _fs      = service.GetEditedResource() as IFeatureSource;
     Debug.Assert(_fs != null);
     if (_fs.ConnectionPropertyNames.Length == 0)
     {
         _fs.SetConnectionProperty("DefaultFileLocation", StringConstants.MgDataFilePath); //NOXLATE
     }
     MarkSelected();
     resDataCtrl.ResourceDataUploaded += new Maestro.Editors.Common.ResourceDataCtrl.ResourceUploadEventHandler(OnResourceDataUploaded);
 }
Esempio n. 34
0
 public override void Bind(IEditorService service)
 {
     base.Bind(service);
     _service = service;
     _fs = service.GetEditedResource() as IFeatureSource;
     Debug.Assert(_fs != null);
     if (_fs.ConnectionPropertyNames.Length == 0)
     {
         _fs.SetConnectionProperty("DefaultFileLocation", StringConstants.MgDataFilePath); //NOXLATE
     }
     MarkSelected();
     resDataCtrl.ResourceDataUploaded += new Maestro.Editors.Common.ResourceDataCtrl.ResourceUploadEventHandler(OnResourceDataUploaded);
 }
        /// <summary>
        /// Sets the connection properties of the feature source
        /// </summary>
        /// <param name="fs"></param>
        /// <param name="values"></param>
        public static void ApplyConnectionProperties(this IFeatureSource fs, NameValueCollection values)
        {
            Check.NotNull(fs, "fs");         //NOXLATE
            Check.NotNull(values, "values"); //NOXLATE

            fs.ClearConnectionProperties();

            foreach (string name in values.Keys)
            {
                string value = values[name];

                fs.SetConnectionProperty(name, value);
            }
        }
Esempio n. 36
0
        /// <summary>
        /// Sets the connection properties of the feature source
        /// </summary>
        /// <param name="fs"></param>
        /// <param name="values"></param>
        public static void ApplyConnectionProperties(this IFeatureSource fs, NameValueCollection values)
        {
            Check.ArgumentNotNull(fs, nameof(fs));
            Check.ArgumentNotNull(values, nameof(values));

            fs.ClearConnectionProperties();

            foreach (string name in values.Keys)
            {
                string value = values[name];

                fs.SetConnectionProperty(name, value);
            }
        }
Esempio n. 37
0
        /// <summary>
        /// Gets the default spatial context from this configuration document. If none is found, the first spatial
        /// context from the given Feature Source is used
        /// </summary>
        /// <param name="fs"></param>
        /// <param name="conn"></param>
        /// <returns></returns>
        public string GetDefaultSpatialContext(IFeatureSource fs, IServerConnection conn)
        {
            //BOGUS: This was not as sufficient as I originally thought, nevertheless this contains
            //information that would not exist if we constructed the document the old fashioned way.
            string defaultScName = string.Empty;

            if (this.SpatialContexts.Length > 0)
            {
                defaultScName = this.SpatialContexts[0].Name;
            }
            else
            {
                var list = conn.FeatureService.GetSpatialContextInfo(fs.ResourceID, false);
                if (list.SpatialContext.Count > 0)
                {
                    defaultScName = list.SpatialContext[0].Name;
                }
                else //Really? What kind of WMS service are you????
                {
                    var sc = new FdoSpatialContextListSpatialContext()
                    {
                        Name                 = "EPSG:4326",                                                                                                                                //NOXLATE
                        Description          = "Maestro-generated spatial context",                                                                                                        //NOXLATE
                        CoordinateSystemName = "EPSG:4326",                                                                                                                                //NOXLATE
                        CoordinateSystemWkt  = "GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722293]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.01745329251994]]", //NOXLATE
                        Extent               = new FdoSpatialContextListSpatialContextExtent()
                        {
                            LowerLeftCoordinate = new FdoSpatialContextListSpatialContextExtentLowerLeftCoordinate()
                            {
                                X = "-180.0", //NOXLATE
                                Y = "-90.0"   //NOXLATE
                            },
                            UpperRightCoordinate = new FdoSpatialContextListSpatialContextExtentUpperRightCoordinate()
                            {
                                X = "180.0", //NOXLATE
                                Y = "90.0"   //NOXLATE
                            }
                        },
                        ExtentType  = FdoSpatialContextListSpatialContextExtentType.Static,
                        IsActive    = true,
                        XYTolerance = 0.0001,
                        ZTolerance  = 0.0001,
                    };
                    this.AddSpatialContext(sc);
                    defaultScName = sc.Name;
                }
            }
            return(defaultScName);
        }
Esempio n. 38
0
        public override void Bind(IEditorService service)
        {
            try
            {
                _init = true;
                _bSupportsResample = false;
                _service = service;
                _fs = (IFeatureSource)_service.GetEditedResource();

                var provInfo = _service.FeatureService.GetFeatureProvider("OSGeo.Gdal"); //NOXLATE
                foreach (var prop in provInfo.ConnectionProperties)
                {
                    if (prop.Name == "ResamplingMethod") //NOXLATE
                    {
                        chkResamplingMethod.Visible =
                            cmbResamplingMethod.Visible =
                                cmbResamplingMethod.Enabled = true;

                        cmbResamplingMethod.DataSource = new List<string>(prop.Value);
                        var method = _fs.GetConnectionProperty("ResamplingMethod"); //NOXLATE
                        if (!string.IsNullOrEmpty(method))
                        {
                            chkResamplingMethod.Checked = true;
                            cmbResamplingMethod.SelectedItem = method;
                        }
                        else
                        {
                            cmbResamplingMethod.SelectedIndex = 0;
                            chkResamplingMethod.Checked = false;
                        }
                        _bSupportsResample = true;
                        break;
                    }
                }

                cmbResamplingMethod.Enabled = chkResamplingMethod.Checked;

                _sing.Bind(service);
                _comp.Bind(service);
                if (!string.IsNullOrEmpty(_fs.GetConfigurationContent()))
                    rdComposite.Checked = true;
                else
                    OnTypeCheckedChanged(null, null); //It is already checked by default
            }
            finally
            {
                _init = false;
            }
        }
Esempio n. 39
0
        public override void Bind(IEditorService service)
        {
            try
            {
                _init = true;
                service.RegisterCustomNotifier(this);
                _fs = (IFeatureSource)service.GetEditedResource();

                InitDefaults();
            }
            finally
            {
                _init = false;
            }
        }
Esempio n. 40
0
        public ExtendedClassSettings(IFeatureSource fs, IEnumerable<string> qualifiedClassNames, IFeatureSourceExtension ext)
            : this()
        {
            _fs = fs;
            _ext = ext;
            var names = new List<string>(qualifiedClassNames);
            cmbBaseClass.DataSource = names;
            ext.PropertyChanged += (sender, e) => { OnResourceChanged(); };

            //HACK
            if (string.IsNullOrEmpty(_ext.FeatureClass))
                _ext.FeatureClass = names[0];

            ComboBoxBinder.BindSelectedIndexChanged(cmbBaseClass, "SelectedItem", ext, "FeatureClass"); //NOXLATE
        }
Esempio n. 41
0
        public override void Bind(IEditorService service)
        {
            base.Bind(service);
            _service = service;
            _fs = _service.GetEditedResource() as IFeatureSource;
            Debug.Assert(_fs != null);

            MarkSelected();

            //HACK: Set ReadOnly property if not specified otherwise this will be an invalid feature source
            if (string.IsNullOrEmpty(_fs.GetConnectionProperty("ReadOnly"))) //NOXLATE
                _fs.SetConnectionProperty("ReadOnly", "FALSE"); //NOXLATE

            chkReadOnly.Checked = _fs.GetConnectionProperty("ReadOnly").ToUpper().Equals(true.ToString().ToUpper()); //NOXLATE
        }
        public override void Bind(IEditorService service)
        {
            try
            {
                _init = true;
                service.RegisterCustomNotifier(this);
                _fs   = (IFeatureSource)service.GetEditedResource();
                _conn = service.CurrentConnection;

                InitDefaults();
            }
            finally
            {
                _init = false;
            }
        }
Esempio n. 43
0
        public override void Bind(IEditorService service)
        {
            base.Bind(service);
            _service = service;
            _fs      = service.GetEditedResource() as IFeatureSource;
            Debug.Assert(_fs != null);

            MarkSelected();

            //HACK: Set UseFdoMetadata property if not specified otherwise this will be an invalid feature source
            if (string.IsNullOrEmpty(_fs.GetConnectionProperty("UseFdoMetadata")))                                               //NOXLATE
            {
                _fs.SetConnectionProperty("UseFdoMetadata", "FALSE");                                                            //NOXLATE
            }
            chkUseFdoMetadata.Checked = _fs.GetConnectionProperty("UseFdoMetadata").ToUpper().Equals(true.ToString().ToUpper()); //NOXLATE
        }
Esempio n. 44
0
        public override void Bind(IEditorService service)
        {
            _init = true;
            try
            {
                _service = service;
                _service.RegisterCustomNotifier(this);
                _fs = (IFeatureSource)_service.GetEditedResource();

                txtFeatureServer.Text = _fs.GetConnectionProperty("FeatureServer"); //NOXLATE
                txtUsername.Text = _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = _fs.GetConnectionProperty("Password"); //NOXLATE
            }
            finally
            {
                _init = false;
            }
        }
Esempio n. 45
0
        public override void Bind(IEditorService service)
        {
            service.RegisterCustomNotifier(this);
            _edSvc = service;
            _edSvc.Saved += OnResourceSaved;
            _fs = (IFeatureSource)_edSvc.GetEditedResource();

            //Build tree
            if (_fs.Extension != null)
            {
                foreach (var ext in _fs.Extension)
                {
                    TreeNode node = new TreeNode();
                    node.Tag = ext;
                    node.ImageIndex = node.SelectedImageIndex = IDX_EXTENSION;

                    node.Text = ext.Name;
                    node.ToolTipText = string.Format(Strings.ExtendedClassTooltip, ext.FeatureClass);

                    ext.PropertyChanged += (s, evt) =>
                    {
                        if (evt.PropertyName == "Name") //NOXLATE
                        {
                            node.Text = ext.Name;
                        }
                        else if (evt.PropertyName == "FeatureClass") //NOXLATE
                        {
                            node.ToolTipText = string.Format(Strings.ExtendedClassTooltip, ext.FeatureClass);
                        }
                    };

                    trvExtensions.Nodes.Add(node);

                    if (ext.CalculatedProperty != null)
                    {
                        foreach (var calc in ext.CalculatedProperty)
                        {
                            var cNode = new TreeNode();
                            cNode.ImageIndex = cNode.SelectedImageIndex = IDX_CALC;
                            cNode.Tag = calc;

                            cNode.Text = calc.Name;
                            cNode.ToolTipText = calc.Expression;

                            calc.PropertyChanged += (s, evt) =>
                            {
                                if (evt.PropertyName == "Name") //NOXLATE
                                {
                                    cNode.Text = calc.Name;
                                }
                                else if (evt.PropertyName == "Expression") //NOXLATE
                                {
                                    cNode.ToolTipText = calc.Expression;
                                }
                            };

                            node.Nodes.Add(cNode);
                        }
                    }
                    if (ext.AttributeRelate != null)
                    {
                        foreach (var join in ext.AttributeRelate)
                        {
                            var jNode = new TreeNode();
                            jNode.Tag = join;
                            jNode.ImageIndex = jNode.SelectedImageIndex = IDX_JOIN;

                            jNode.Text = join.Name;

                            join.PropertyChanged += (s, evt) =>
                            {
                                if (evt.PropertyName == "Name") //NOXLATE
                                {
                                    jNode.Text = join.Name;
                                }
                            };

                            node.Nodes.Add(jNode);
                        }
                    }
                    node.ExpandAll();
                }
            }
        }
Esempio n. 46
0
 public static void AddConfigSource(IFeatureSource source)
 {
     Instance.AddFeatureSource(source);
 }
Esempio n. 47
0
 public void AddFeatureSource(IFeatureSource source)
 {
     Sources.Add(source);
 }
Esempio n. 48
0
 private void InitPreview()
 {
     _fs = (IFeatureSource)resSvc.GetResource(this.FeatureSourceID);
     var caps = featSvc.GetProviderCapabilities(_fs.Provider);
     localFsPreviewCtrl.SupportsSQL = caps.Connection.SupportsSQL;
     localFsPreviewCtrl.ReloadTree(this.FeatureSourceID, caps);
 }
Esempio n. 49
0
 private static bool TrySetFeature(IFeatureSource source, string featureName, string state, IDictionary<string, string> options)
 {
     try
     {
         return source.SetFeature(featureName, state, options);
     }
     catch (Exception)
     {
         return false;
     }
 }
Esempio n. 50
0
 public override void Bind(IEditorService service)
 {
     service.RegisterCustomNotifier(this);
     _fs = (IFeatureSource)service.GetEditedResource();
     _dsnNames = service.FeatureService.GetConnectionPropertyValues("OSGeo.ODBC", "DataSourceName", string.Empty); //NOXLATE
 }
Esempio n. 51
0
        public override void Bind(IEditorService service)
        {
            _bChangedUsername = false;
            _bChangedPassword = false;
            _service = service;
            _service.BeforeSave += OnBeforeSave;
            _service.BeforePreview += OnBeforePreview;
            _service.RegisterCustomNotifier(this);
            _fs = _service.GetEditedResource() as IFeatureSource;

            //Set the field values
            txtService.Text = _fs.GetConnectionProperty("Service"); //NOXLATE

            //We're gonna follow MG Studio behaviour here which is: Never load the password
            //and auto trigger dirty state.
            if (!_service.IsNew)
            {
                txtUsername.Text = _fs.GetEncryptedUsername() ?? _fs.GetConnectionProperty("Username"); //NOXLATE
                txtPassword.Text = GenerateRandomFakeString();
            }

            //Set initial value of data store if possible
            var dstore = _fs.GetConnectionProperty("DataStore"); //NOXLATE
            txtDataStore.Text = dstore;

            //As our connection properties are not CLR properties,
            //"manually" bind these fields
            txtService.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("Service", txtService.Text); //NOXLATE
            };

            txtUsername.TextChanged += (s, e) =>
            {
                _bChangedUsername = true;
                if (string.IsNullOrEmpty(txtUsername.Text))
                    _fs.SetConnectionProperty("Username", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Username", txtUsername.Text); //NOXLATE
            };

            txtPassword.TextChanged += (s, e) =>
            {
                _bChangedPassword = true;
                if (string.IsNullOrEmpty(txtPassword.Text))
                    _fs.SetConnectionProperty("Password", null); //NOXLATE
                else
                    _fs.SetConnectionProperty("Password", txtPassword.Text); //NOXLATE
            };

            txtDataStore.TextChanged += (s, e) =>
            {
                _fs.SetConnectionProperty("DataStore", txtDataStore.Text); //NOXLATE
            };
        }
        private IFeatureSource GetFeatureSource()
        {
            if (_cachedFs == null)
                _cachedFs = (IFeatureSource)_edsvc.ResourceService.GetResource(txtFeatureSource.Text);

            return _cachedFs;
        }
 private void btnBrowseFeatureSource_Click(object sender, EventArgs e)
 {
     using (var picker = new ResourcePicker(_edsvc.ResourceService, ResourceTypes.FeatureSource, ResourcePickerMode.OpenResource))
     {
         if (picker.ShowDialog() == DialogResult.OK)
         {
             LastSelectedFolder.FolderId = picker.SelectedFolder;
             txtFeatureSource.Text = picker.ResourceID;
             //Invalidate
             _cachedFs = null;
         }
     }
 }
Esempio n. 54
0
        public override void Bind(IEditorService service)
        {
            _init = true;
            _service = service;
            _fs = (IFeatureSource)_service.GetEditedResource();

            cmbMethod.DataSource = (OdbcConnectionMethod[])Enum.GetValues(typeof(OdbcConnectionMethod));
            var values = _fs.GetConnectionProperties();
            string odbcStr = values["ConnectionString"]; //NOXLATE
            if (!string.IsNullOrEmpty(odbcStr))
            {
                //See if it is file-basd
                if (odbcStr.Contains("Dbq=")) //NOXLATE
                {
                    //Check driver bitness
                    chkUse64Bit.Checked = OdbcDriverNames.Uses64BitDriver(odbcStr);

                    if (odbcStr.Contains("%MG_DATA_FILE_PATH%")) //NOXLATE
                    {
                        cmbMethod.SelectedItem = OdbcConnectionMethod.ManagedFile;
                    }
                    else if (odbcStr.Contains("%MG_DATA_PATH_ALIAS")) //NOXLATE
                    {
                        cmbMethod.SelectedItem = OdbcConnectionMethod.Unmanaged;
                    }
                    else
                    {
                        cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString;
                    }
                }
                else //Non-file connection string. Has to be a known driver
                {
                    cmbMethod.SelectedItem = OdbcConnectionMethod.KnownDriver;
                }
            }
            else if (values["DataSourceName"] != null) //NOXLATE
            {
                cmbMethod.SelectedItem = OdbcConnectionMethod.DSN;
            }
            else
            {
                cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString;
            }

            //Fall back to raw connection string if we still can't figure it out
            if (this.ChildEditor == null)
                cmbMethod.SelectedItem = OdbcConnectionMethod.RawConnectionString;

            System.Diagnostics.Debug.Assert(this.ChildEditor != null);
            if (values.Count > 0)
                this.ChildEditor.ConnectionProperties = values;

            _init = false;
        }
Esempio n. 55
0
 public override void Bind(IEditorService service)
 {
     //Only available on MGOS 2.2 and above
     this.LocalPreviewEnabled = service.SiteVersion >= new Version(2, 2);
     _fs = (IFeatureSource)service.GetEditedResource();
     _caps = service.FeatureService.GetProviderCapabilities(_fs.Provider);
     _fsvc = service.FeatureService;
     _rsvc = service.ResourceService;
     _edsvc = service;
     _edsvc.RegisterCustomNotifier(this);
     this.ConfigEnabled = _caps.Connection.SupportsConfiguration;
 }
Esempio n. 56
0
 private void ProfileFeatureSource(IFeatureSource fs)
 {
     //TODO: Determine what profiling benchmarks to use
     string resourceId = fs == m_item ? m_resourceId : fs.ResourceID;
     backgroundWorker.ReportProgress(0, (string.Format(Strings.Prof_LogMessageFeatureSource, resourceId)));
 }