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;
        }
示例#2
0
        public Settings(IDocumentStore documentStore)
        {
            Verify.RequireNotNull(documentStore, "documentStore");
            configurationDocument = new ConfigurationDocument();

            this.documentStore = documentStore;
            Load();
        }
示例#3
0
 public void Load()
 {
     using (var session = documentStore.OpenSessionForDefaultTenant())
     {
         configurationDocument = session.Load <ConfigurationDocument>(1);
         if (configurationDocument == null)
         {
             configurationDocument = new ConfigurationDocument();
             session.Store(configurationDocument);
             session.SaveChanges();
         }
     }
 }
        public ElasticSearchProvider(ConfigurationDocument configurationDocument, string defaultIndex)
        {
            var elasticSearchConfiguration = configurationDocument.GetAs <ConfigurationDocument>("ElasticSearch");
            var connectionString           = elasticSearchConfiguration.GetAs <string>("ConnectionString");
            var username = elasticSearchConfiguration.GetAs <string>("Username");
            var password = elasticSearchConfiguration.GetAs <string>("Password");

            var connectionSettings = new ConnectionSettings(new Uri(connectionString)).DefaultIndex(defaultIndex);

            connectionSettings.BasicAuthentication(username, password);

            this.Client = new ElasticClient(connectionSettings);
            this.Client.ConnectionSettings.DefaultIndices.Add(typeof(string), defaultIndex);
        }
示例#5
0
        private void btnEditSchema_Click(object sender, EventArgs e)
        {
            if (CheckValidConnection())
            {
                if (string.IsNullOrEmpty(_defaultSchemaName))
                {
                    var names = _service.CurrentConnection.FeatureService.GetSchemas(_fs.ResourceID);
                    if (names.Length == 1)
                    {
                        _defaultSchemaName = names[0];
                    }
                    else
                    {
                        MessageBox.Show(Strings.NoSchemasInFeatureSource);
                        return;
                    }
                }

                string xml = _fs.GetConfigurationContent(_service.CurrentConnection);
                if (!string.IsNullOrEmpty(xml))
                {
                    _doc = (OdbcConfigurationDocument)ConfigurationDocument.LoadXml(xml);
                }
                else
                {
                    if (_doc == null)
                    {
                        BuildDefaultDocument();
                    }
                }

                var diag = new TableConfigurationDialog(_service, _doc, _defaultSchemaName);
                if (diag.ShowDialog() == DialogResult.OK)
                {
                    _doc.ClearMappings();
                    foreach (var table in diag.ConfiguredTables)
                    {
                        _doc.AddOverride(table);
                    }
                    foreach (var sc in _doc.SpatialContexts)
                    {
                        sc.CoordinateSystemWkt = diag.CoordinateSystemWkt;
                    }
                    string updatedContent = _doc.ToXml();
                    _fs.SetConfigurationContent(_service.CurrentConnection, updatedContent);
                    OnResourceChanged();
                }
            }
        }
示例#6
0
        public async Task CreateConfigurationAsync(string environment, int divisionId, object configuration, CancellationToken cancellationToken = new CancellationToken())
        {
            var collection = Collection <ConfigurationDocument>(environment);
            var toBeStored = new ConfigurationDocument
            {
                DivisionId    = divisionId,
                Configuration = new ConfigurationSubDocument
                {
                    Value      = BsonDocument.Parse(JsonConvert.SerializeObject(configuration)),
                    LastUpdate = DateTime.Now
                },
                PerApplicationExceptions = new Dictionary <string, ConfigurationSubDocument>()
            };

            await collection.InsertOneAsync(toBeStored, cancellationToken : cancellationToken)
            .ConfigureAwait(false);
        }
示例#7
0
        public static VersioningConfiguration GetDocumentVersioningConfiguration(this DocumentDatabase database, RavenJObject metadata)
        {
            ConfigurationDocument <VersioningConfiguration> config = null;
            var entityName = metadata.Value <string>("Raven-Entity-Name");

            if (entityName != null)
            {
                config = database.ConfigurationRetriever.GetConfigurationDocument <VersioningConfiguration>("Raven/Versioning/" + entityName);
            }

            if (config == null)
            {
                config = database.ConfigurationRetriever.GetConfigurationDocument <VersioningConfiguration>("Raven/Versioning/DefaultConfiguration");
            }

            return(config == null ? null : config.MergedDocument);
        }
示例#8
0
        internal void InitDefaults()
        {
            string xml = _fs.GetConfigurationContent(_service.CurrentConnection);

            if (!string.IsNullOrEmpty(xml))
            {
                try
                {
                    _conf = (GdalConfigurationDocument)ConfigurationDocument.LoadXml(xml);
                }
                catch
                {
                    BuildDefaultDocument();
                }

                lstView.Items.Clear();
                List <string> files = new List <string>();
                foreach (var loc in _conf.RasterLocations)
                {
                    AddRasterItems(loc.Location, loc.Items);
                }
            }
        }
示例#9
0
                                            "<xs:appinfo source=\"http://fdo.osgeo.org/schemas\"><fdo:DefaultDataModel dataModelType=\"Bitonal\" dataType=\"Unknown\" organization=\"Pixel\" bitsPerPixel=\"1\" tileSizeX=\"256\" tileSizeY=\"256\"/></xs:appinfo></xs:annotation></xs:element></xs:sequence></xs:extension></xs:complexContent></xs:complexType></xs:schema><SchemaMapping xmlns=\"http://fdogrfp.osgeo.org/schemas\" provider=\"OSGeo.Gdal.3.2\" name=\"default\"></SchemaMapping></fdo:DataStore>";                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //NOXLATE

        private void BuildDefaultDocument()
        {
            _conf = (GdalConfigurationDocument)ConfigurationDocument.LoadXml(string.Format(TEMPLATE_CFG, -10000000, -10000000, 10000000, 10000000));
        }
示例#10
0
        public void TestWmsLoad3()
        {
            var conf = ConfigurationDocument.LoadXml(Utils.ReadAllText($"UserTestData{System.IO.Path.DirectorySeparatorChar}wms_config_example2.xml")) as WmsConfigurationDocument;

            Assert.NotNull(conf);
        }
示例#11
0
        public void TestOdbcLoad2()
        {
            var conf = ConfigurationDocument.LoadXml(Utils.ReadAllText("UserTestData\\odbc_example_config2.xml")) as OdbcConfigurationDocument;

            Assert.NotNull(conf);
        }
示例#12
0
        public ReplicationTopologyRootNode Discover()
        {
            var nextStart = 0;

            var root = new ReplicationTopologyRootNode(database.ServerUrl, database.TransactionalStorage.Id);

            if (ttl <= 0)
            {
                return(root);
            }

            ConfigurationDocument <ReplicationDocument <ReplicationDestination.ReplicationDestinationWithConfigurationOrigin> > configurationDocument = null;

            try
            {
                configurationDocument = database.ConfigurationRetriever.GetConfigurationDocument <ReplicationDocument <ReplicationDestination.ReplicationDestinationWithConfigurationOrigin> >(Constants.RavenReplicationDestinations);
            }
            catch (Exception)
            {
                root.Errors.Add(string.Format("Could not deserialize '{0}'.", Constants.RavenReplicationDestinations));
            }

            var sources = database.Documents.GetDocumentsWithIdStartingWith(Constants.RavenReplicationSourcesBasePath, null, null, 0, int.MaxValue, database.WorkContext.CancellationToken, ref nextStart);

            if (@from.Contains(database.ServerUrl) == false)
            {
                @from.Add(database.ServerUrl);
            }

            if (configurationDocument != null)
            {
                root.Destinations = HandleDestinations(configurationDocument.MergedDocument);
            }

            root.Sources = HandleSources(sources, root);

            return(root);
        }
示例#13
0
        public void TestAddAndGetPrior()
        {
            DeleteAllDocuments();

            string documentName = "test";
            string instanceKey = null;
            string user = null;

            var oldestKey = new ConfigurationDocumentKey(documentName, new Version(3, 5, 21685, 22177), user, instanceKey);
            var oldest = new ConfigurationDocument
            {
                CreationTime = DateTime.Now,
                DocumentName = oldestKey.DocumentName,
                DocumentVersionString = VersionUtils.ToPaddedVersionString(oldestKey.Version, false, false),
                User = oldestKey.User,
                InstanceKey = oldestKey.InstanceKey,
                DocumentText = "oldest"
            };
            
            var previousKey = new ConfigurationDocumentKey(documentName, new Version(4, 4, 21685, 22177), user, instanceKey);
            var previous = new ConfigurationDocument
            {
                CreationTime = DateTime.Now,
                DocumentName = previousKey.DocumentName,
                DocumentVersionString = VersionUtils.ToPaddedVersionString(previousKey.Version, false, false),
                User = previousKey.User,
                InstanceKey = previousKey.InstanceKey,
                DocumentText = "previous"
            };

            var newestKey = new ConfigurationDocumentKey(documentName, new Version(5, 1, 21685, 22177), user, instanceKey);
            var newest = new ConfigurationDocument
            {
                CreationTime = DateTime.Now,
                DocumentName = newestKey.DocumentName,
                DocumentVersionString = VersionUtils.ToPaddedVersionString(newestKey.Version, false, false),
                User = newestKey.User,
                InstanceKey = newestKey.InstanceKey,
                DocumentText = "newest"
            };

            using (var context = new DataAccessContext())
            {
                var broker = context.GetConfigurationDocumentBroker();
                broker.AddConfigurationDocument(oldest);
                broker.AddConfigurationDocument(previous);
                broker.AddConfigurationDocument(newest);
                context.Commit();
            }

            using (var context = new DataAccessContext())
            {
                var broker = context.GetConfigurationDocumentBroker();
                var oldestRetrieved = broker.GetConfigurationDocument(oldestKey);
                Assert.AreEqual(oldestRetrieved.DocumentName, oldest.DocumentName);
                Assert.AreEqual(oldestRetrieved.DocumentVersionString, oldest.DocumentVersionString);

                var previousRetrieved = broker.GetConfigurationDocument(previousKey);
                Assert.AreEqual(previousRetrieved.DocumentName, previous.DocumentName);
                Assert.AreEqual(previousRetrieved.DocumentVersionString, previous.DocumentVersionString);

                var newestRetrieved = broker.GetConfigurationDocument(newestKey);
                Assert.AreEqual(newestRetrieved.DocumentName, newest.DocumentName);
                Assert.AreEqual(newestRetrieved.DocumentVersionString, newest.DocumentVersionString);

                var previousOfNewest = broker.GetPriorConfigurationDocument(newestKey);
                Assert.AreEqual(previousOfNewest.DocumentName, previous.DocumentName);
                Assert.AreEqual(previousOfNewest.DocumentVersionString, previous.DocumentVersionString);
            }
        }
示例#14
0
        /// <summary>
        /// The initialize configuration.
        /// </summary>
        private void InitializeConfiguration()
        {
            this.configs         = new List <Configuration>();
            this.configDocuments = new List <ConfigurationDocument>();
            var publishTime = DateTime.UtcNow.AddHours(-1);
            var archiveTime = DateTime.UtcNow;

            var target1         = "target 1";
            var mof1            = "Mof Document 1";
            var configDocument1 = new ConfigurationDocument {
                Document = mof1, Id = 1
            };

            this.configDocuments.Add(configDocument1);
            this.TestConfigT1C1 = new Configuration
            {
                ConfigurationDocument   = configDocument1,
                ConfigurationDocumentId = configDocument1.Id,
                Id = 1,
                PublishedTimestamp = publishTime,
                Target             = target1,
                Checksum           = GenerateChecksum(mof1)
            };

            var target2         = "target 2";
            var mof2            = "Mof Document 2";
            var configDocument2 = new ConfigurationDocument {
                Document = mof2, Id = 2
            };

            this.configDocuments.Add(configDocument2);
            this.TestConfigT2C1 = new Configuration
            {
                ConfigurationDocument   = configDocument2,
                ConfigurationDocumentId = configDocument2.Id,
                Id = 2,
                PublishedTimestamp = publishTime,
                Target             = target2,
                Checksum           = GenerateChecksum(mof2)
            };

            var mof3            = "Mof Document 3";
            var configDocument3 = new ConfigurationDocument {
                Document = mof3, Id = 3
            };

            this.configDocuments.Add(configDocument3);
            this.TestConfigT1C2 = new Configuration
            {
                ArchiveTimestamp        = archiveTime,
                ConfigurationDocument   = configDocument3,
                ConfigurationDocumentId = configDocument3.Id,
                Id = 1,
                PublishedTimestamp = publishTime,
                Target             = target1,
                Checksum           = GenerateChecksum(mof1)
            };

            var mof4            = "Mof Document 4";
            var configDocument4 = new ConfigurationDocument {
                Document = mof4, Id = 4
            };

            this.configDocuments.Add(configDocument4);
            this.TestConfigT2C2 = new Configuration
            {
                ArchiveTimestamp        = archiveTime,
                ConfigurationDocument   = configDocument4,
                ConfigurationDocumentId = configDocument4.Id,
                Id = 2,
                PublishedTimestamp = publishTime,
                Target             = target2,
                Checksum           = GenerateChecksum(mof2)
            };

            this.configs.Add(this.TestConfigT1C1);
            this.configs.Add(this.TestConfigT1C2);
            this.configs.Add(this.TestConfigT2C1);
            this.configs.Add(this.TestConfigT2C2);
        }
示例#15
0
        public void TestOdbcLoad2()
        {
            var conf = ConfigurationDocument.LoadXml(Utils.ReadAllText($"UserTestData{System.IO.Path.DirectorySeparatorChar}odbc_example_config2.xml")) as OdbcConfigurationDocument;

            Assert.NotNull(conf);
        }
示例#16
0
        /// <summary>
        /// Validats the specified resources for common issues associated with this
        /// resource type
        /// </summary>
        /// <param name="context"></param>
        /// <param name="resource"></param>
        /// <param name="recurse"></param>
        /// <returns></returns>
        public ValidationIssue[] Validate(ResourceValidationContext context, IResource resource, bool recurse)
        {
            Check.ArgumentNotNull(context, nameof(context));

            if (context.IsAlreadyValidated(resource.ResourceID))
            {
                return(null);
            }

            if (resource.ResourceType != ResourceTypes.FeatureSource.ToString())
            {
                return(null);
            }

            List <ValidationIssue> issues = new List <ValidationIssue>();

            IFeatureSource  feature = (IFeatureSource)resource;
            IFeatureService featSvc = this.Connection.FeatureService;

            //Feature Join Optimization check
            foreach (var ext in feature.Extension)
            {
                foreach (var rel in ext.AttributeRelate)
                {
                    if (string.IsNullOrEmpty(rel.Name))
                    {
                        issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_EmptyJoinPrefix, string.Format(Strings.FS_EmptyJoinPrefix, ext.Name)));
                    }

                    if (rel.RelatePropertyCount > 0)
                    {
                        if (rel.RelatePropertyCount == 1)
                        {
                            var srcFs = feature;
                            var dstFs = (IFeatureSource)context.GetResource(rel.ResourceId);

                            var leftProvider  = srcFs.Provider.ToUpper();
                            var rightProvider = dstFs.Provider.ToUpper();

                            //FDO Join optimization check
                            if (leftProvider.Contains("OSGEO.SQLITE") && rightProvider.Contains("OSGEO.SQLITE") && srcFs.ResourceID == rel.ResourceId) //NOXLATE
                            {
                                continue;
                            }

                            //FDO Join optimization check
                            if (leftProvider.Contains("OSGEO.SQLSERVERSPATIAL") && rightProvider.Contains("OSGEO.SQLSERVERSPATIAL") && srcFs.ResourceID == rel.ResourceId) //NOXLATE
                            {
                                continue;
                            }

                            //TODO: Fix the capabilities response. Because it's not telling us enough information!
                            //Anyways, these are the providers known to provide sorted query results.
                            bool bLeftSortable = leftProvider.Contains("OSGEO.SDF") ||               //NOXLATE
                                                 leftProvider.Contains("OSGEO.SHP") ||               //NOXLATE
                                                 leftProvider.Contains("OSGEO.SQLITE") ||            //NOXLATE
                                                 leftProvider.Contains("OSGEO.ODBC") ||              //NOXLATE
                                                 leftProvider.Contains("OSGEO.SQLSERVERSPATIAL") ||  //NOXLATE
                                                 leftProvider.Contains("OSGEO.MYSQL") ||             //NOXLATE
                                                 leftProvider.Contains("OSGEO.POSTGRESQL");          //NOXLATE

                            bool bRightSortable = leftProvider.Contains("OSGEO.SDF") ||              //NOXLATE
                                                  leftProvider.Contains("OSGEO.SHP") ||              //NOXLATE
                                                  leftProvider.Contains("OSGEO.SQLITE") ||           //NOXLATE
                                                  leftProvider.Contains("OSGEO.ODBC") ||             //NOXLATE
                                                  leftProvider.Contains("OSGEO.SQLSERVERSPATIAL") || //NOXLATE
                                                  leftProvider.Contains("OSGEO.MYSQL") ||            //NOXLATE
                                                  leftProvider.Contains("OSGEO.POSTGRESQL");         //NOXLATE

                            if (!bLeftSortable || !bRightSortable)
                            {
                                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_Potential_Bad_Join_Performance, string.Format(Strings.FS_PotentialBadJoinPerformance, ext.Name, bLeftSortable, bRightSortable)));
                            }
                        }
                        else
                        {
                            issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_Potential_Bad_Join_Performance, string.Format(Strings.FS_PotentialBadJoinPerformance2, ext.Name)));
                        }
                    }
                }
            }

            //Plaintext credential check
            string providerNameUpper = feature.Provider.ToUpper();
            string fsXml             = feature.Serialize().ToUpper();

            //You'll get warnings either way
            if (providerNameUpper == "OSGEO.SQLSERVERSPATIAL" || //NOXLATE
                providerNameUpper == "OSGEO.MYSQL" ||            //NOXLATE
                providerNameUpper == "OSGEO.POSTGRESQL" ||       //NOXLATE
                providerNameUpper == "OSGEO.ODBC" ||             //NOXLATE
                providerNameUpper == "OSGEO.ARCSDE" ||           //NOXLATE
                providerNameUpper == "OSGEO.WFS" ||              //NOXLATE
                providerNameUpper == "OSGEO.WMS" ||              //NOXLATE
                providerNameUpper == "KING.ORACLE" ||            //NOXLATE
                providerNameUpper == "AUTODESK.ORACLE")          //NOXLATE
            {
                //Fortunately, all the above providers are universal in the naming choice of credential connection parameters
                if ((fsXml.Contains("<NAME>USERNAME</NAME>") && !fsXml.Contains(StringConstants.MgUsernamePlaceholder)) || (fsXml.Contains("<NAME>PASSWORD</NAME>") && !fsXml.Contains(StringConstants.MgPasswordPlaceholder))) //NOXLATE
                {
                    issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_Plaintext_Credentials, Strings.FS_PlaintextCredentials));
                }
                else
                {
                    issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_Cannot_Package_Secured_Credentials, Strings.FS_CannotPackageSecuredCredentials));
                }

                //Has the placeholder token(s)
                if (fsXml.Contains(StringConstants.MgUsernamePlaceholder) || fsXml.Contains(StringConstants.MgPasswordPlaceholder))
                {
                    //Find the MG_USER_CREDENTIALS resource data item
                    bool bFound  = false;
                    var  resData = this.Connection.ResourceService.EnumerateResourceData(feature.ResourceID);
                    foreach (var data in resData.ResourceData)
                    {
                        if (data.Name == StringConstants.MgUserCredentialsResourceData)
                        {
                            bFound = true;
                        }
                    }

                    if (!bFound)
                    {
                        issues.Add(new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_SecuredCredentialTokensWithoutSecuredCredentialData, Strings.FS_SecuredCredentialTokensWithoutSecuredCredentialData));
                    }
                }
            }

            //Note: Must be saved!
            string s = featSvc.TestConnection(feature.ResourceID);

            if (s.Trim().ToUpper() != true.ToString().ToUpper())
            {
                issues.Add(new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_ConnectionTestFailed, string.Format(Strings.FS_ConnectionTestFailed, s)));
                return(issues.ToArray());
            }

            try
            {
                System.Globalization.CultureInfo ci  = System.Globalization.CultureInfo.InvariantCulture;
                FdoSpatialContextList            lst = context.GetSpatialContexts(feature.ResourceID);
                if (lst == null || lst.SpatialContext == null || lst.SpatialContext.Count == 0)
                {
                    issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_NoSpatialContext, Strings.FS_NoSpatialContextWarning));
                }
                else
                {
                    foreach (FdoSpatialContextListSpatialContext c in lst.SpatialContext)
                    {
                        if (c.Extent == null || c.Extent.LowerLeftCoordinate == null || c.Extent.UpperRightCoordinate == null)
                        {
                            issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_EmptySpatialContext, Strings.FS_EmptySpatialContextWarning));
                        }
                        else if (double.Parse(c.Extent.LowerLeftCoordinate.X, ci) <= -1000000 && double.Parse(c.Extent.LowerLeftCoordinate.Y, ci) <= -1000000 && double.Parse(c.Extent.UpperRightCoordinate.X, ci) >= 1000000 && double.Parse(c.Extent.UpperRightCoordinate.Y, ci) >= 1000000)
                        {
                            issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_DefaultSpatialContext, Strings.FS_DefaultSpatialContextWarning));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                issues.Add(new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_SpatialContextReadError, string.Format(Strings.FS_SpatialContextReadError, msg)));
            }

            List <string> classes = new List <string>();

            try
            {
                var schemaNames = featSvc.GetSchemas(feature.ResourceID);
                if (schemaNames.Length == 0)
                {
                    issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_NoSchemasFound, Strings.FS_SchemasMissingWarning));
                }
            }
            catch (Exception ex)
            {
                var wex = ex as System.Net.WebException;
                if (wex != null) //Most likely timeout due to really large schema
                {
                    string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                    issues.Add(new ValidationIssue(feature, ValidationStatus.Warning, ValidationStatusCode.Warning_FeatureSource_Validation_Timeout, string.Format(Strings.FS_ValidationTimeout, msg)));
                }
                else
                {
                    string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
                    issues.Add(new ValidationIssue(feature, ValidationStatus.Error, ValidationStatusCode.Error_FeatureSource_SchemaReadError, string.Format(Strings.FS_SchemaReadError, msg)));
                }
            }

            string configDocXml = feature.GetConfigurationContent(Connection);

            if (!string.IsNullOrEmpty(configDocXml))
            {
                var doc     = ConfigurationDocument.LoadXml(configDocXml);
                var odbcDoc = doc as OdbcConfigurationDocument;
                if (odbcDoc != null)
                {
                    issues.AddRange(ValidateOdbcDoc(feature, odbcDoc));
                }
            }

            context.MarkValidated(resource.ResourceID);

            return(issues.ToArray());
        }
示例#17
0
        public void TestWmsSaveLoad()
        {
            var conf = new WmsConfigurationDocument();

            var schema = new FeatureSchema("WMS", "WMS Test Schema");
            var cls    = new ClassDefinition("NASAWMSGlobalPan", "WMS Test Class");

            cls.AddProperty(new DataPropertyDefinition("Id", "ID Property")
            {
                DataType   = DataPropertyType.String,
                Length     = 256,
                IsNullable = false
            }, true);
            cls.AddProperty(new RasterPropertyDefinition("Image", "Raster Property")
            {
                DefaultImageXSize = 800,
                DefaultImageYSize = 800
            });

            schema.AddClass(cls);
            conf.AddSchema(schema);

            var item = new RasterWmsItem(schema.Name, cls.Name, "Image");

            item.ImageFormat        = RasterWmsItem.WmsImageFormat.PNG;
            item.IsTransparent      = true;
            item.BackgroundColor    = ColorTranslator.FromHtml("#FFFFFF");
            item.Time               = "current";
            item.ElevationDimension = "0";
            item.SpatialContextName = "EPSG:4326";

            for (int i = 0; i < 5; i++)
            {
                item.AddLayer(new WmsLayerDefinition("Layer" + i));
            }

            conf.AddRasterItem(item);

            string path = "WmsConfigTest.xml";

            Utils.WriteAllText(path, conf.ToXml());

            conf = null;
            string xml = Utils.ReadAllText(path);

            conf = ConfigurationDocument.LoadXml(xml) as WmsConfigurationDocument;
            Assert.NotNull(conf);

            Assert.AreEqual(1, conf.RasterOverrides.Length);

            var ritem = conf.RasterOverrides[0];

            cls = conf.GetClass("WMS", "NASAWMSGlobalPan");

            Assert.NotNull(cls);
            Assert.NotNull(cls.Parent);
            Assert.AreEqual("WMS", cls.Parent.Name);
            Assert.AreEqual("WMS Test Schema", cls.Parent.Description);
            Assert.AreEqual("NASAWMSGlobalPan", cls.Name);
            Assert.AreEqual("WMS Test Class", cls.Description);
            var prop = cls.FindProperty("Id");

            Assert.NotNull(prop);
            Assert.AreEqual("Id", prop.Name);
            Assert.AreEqual("ID Property", prop.Description);
            prop = cls.FindProperty("Image");
            Assert.NotNull(prop);
            Assert.AreEqual("Image", prop.Name);
            Assert.AreEqual("Raster Property", prop.Description);

            Assert.AreEqual(item.ImageFormat, ritem.ImageFormat);
            Assert.AreEqual(item.IsTransparent, ritem.IsTransparent);
            Assert.AreEqual(item.BackgroundColor, ritem.BackgroundColor);
            Assert.AreEqual(item.Time, ritem.Time);
            Assert.AreEqual(item.ElevationDimension, ritem.ElevationDimension);
            Assert.AreEqual(item.SpatialContextName, ritem.SpatialContextName);

            Assert.AreEqual(5, item.Layers.Length);
        }
示例#18
0
        public void TestWmsLoad3()
        {
            var conf = ConfigurationDocument.LoadXml(Utils.ReadAllText("UserTestData\\wms_config_example2.xml")) as WmsConfigurationDocument;

            Assert.NotNull(conf);
        }
示例#19
0
        public void TestWmsLoad()
        {
            var conf = ConfigurationDocument.LoadXml(Utils.ReadAllText("UserTestData\\NASA_WMS_config_doc.xml")) as WmsConfigurationDocument;

            Assert.NotNull(conf);
        }
示例#20
0
        public void TestOdbcSaveLoad()
        {
            var schema = new FeatureSchema("Default", "Test schema");
            var cls    = new ClassDefinition("Cities", "Cities class");

            cls.AddProperty(new DataPropertyDefinition("ID", "Primary Key")
            {
                DataType        = DataPropertyType.Int64,
                IsNullable      = false,
                IsAutoGenerated = true
            }, true);

            cls.AddProperty(new DataPropertyDefinition("Name", "City Name")
            {
                DataType        = DataPropertyType.String,
                IsNullable      = true,
                IsAutoGenerated = false,
                Length          = 255
            });

            cls.AddProperty(new GeometricPropertyDefinition("Geometry", "Geometry property")
            {
                GeometricTypes            = FeatureGeometricType.Point,
                SpecificGeometryTypes     = new SpecificGeometryType[] { SpecificGeometryType.Point },
                HasElevation              = false,
                HasMeasure                = false,
                SpatialContextAssociation = "Default"
            });

            cls.AddProperty(new DataPropertyDefinition("Population", "Population")
            {
                DataType        = DataPropertyType.Int32,
                IsNullable      = true,
                IsAutoGenerated = false
            });

            cls.DefaultGeometryPropertyName = "Geometry";

            schema.AddClass(cls);

            var sc = new FdoSpatialContextListSpatialContext();

            sc.CoordinateSystemName = "LL84";
            sc.CoordinateSystemWkt  = "";
            sc.Description          = "Default Spatial Context";
            sc.Extent = new FdoSpatialContextListSpatialContextExtent()
            {
                LowerLeftCoordinate = new FdoSpatialContextListSpatialContextExtentLowerLeftCoordinate()
                {
                    X = "-180.0",
                    Y = "-180.0"
                },
                UpperRightCoordinate = new FdoSpatialContextListSpatialContextExtentUpperRightCoordinate()
                {
                    X = "180.0",
                    Y = "180.0"
                }
            };
            sc.ExtentType  = FdoSpatialContextListSpatialContextExtentType.Static;
            sc.Name        = "Default";
            sc.XYTolerance = 0.0001;
            sc.ZTolerance  = 0.0001;

            var conf = new OdbcConfigurationDocument();

            conf.AddSchema(schema);
            conf.AddSpatialContext(sc);

            var ov = new OdbcTableItem();

            ov.SchemaName         = schema.Name;
            ov.ClassName          = cls.Name;
            ov.SpatialContextName = sc.Name;
            ov.XColumn            = "Lon";
            ov.YColumn            = "Lat";

            conf.AddOverride(ov);

            string path = "OdbcConfigTest.xml";

            Utils.WriteAllText(path, conf.ToXml());

            conf = null;
            string xml = Utils.ReadAllText(path);

            conf = ConfigurationDocument.LoadXml(xml) as OdbcConfigurationDocument;
            Assert.NotNull(conf);

            ov = conf.GetOverride("Default", "Cities");
            Assert.NotNull(ov);
            Assert.AreEqual("Default", ov.SchemaName);
            Assert.AreEqual("Cities", ov.ClassName);
            Assert.AreEqual(sc.Name, ov.SpatialContextName);
            Assert.AreEqual("Lon", ov.XColumn);
            Assert.AreEqual("Lat", ov.YColumn);
        }