コード例 #1
0
 internal static bool ShowDownloadService(SimpleDistribution simpleMetadataDistribution)
 {
     if (System.Web.Configuration.WebConfigurationManager.AppSettings["DownloadServiceEnabled"] != "true")
     {
         return(false);
     }
     return(!string.IsNullOrWhiteSpace(simpleMetadataDistribution?.Protocol) && simpleMetadataDistribution.Protocol.Contains("GEONORGE:DOWNLOAD"));
 }
コード例 #2
0
        internal List <SimpleDistribution> GetDistributionsFormats()
        {
            List <SimpleDistribution> distributionsFormats = new List <SimpleDistribution>();

            if (DistributionsFormats != null)
            {
                for (int d = 0; d < DistributionsFormats.Count; d++)
                {
                    SimpleDistribution distributionFormat = new SimpleDistribution();
                    distributionFormat.Organization        = DistributionsFormats[d].Organization;
                    distributionFormat.FormatName          = DistributionsFormats[d].FormatName;
                    distributionFormat.FormatVersion       = DistributionsFormats[d].FormatVersion;
                    distributionFormat.Protocol            = DistributionsFormats[d].Protocol;
                    distributionFormat.URL                 = DistributionsFormats[d].URL;
                    distributionFormat.Name                = DistributionsFormats[d].Name;
                    distributionFormat.UnitsOfDistribution = DistributionsFormats[d].UnitsOfDistribution;
                    distributionsFormats.Add(distributionFormat);
                }
            }
            return(distributionsFormats);
        }
コード例 #3
0
 internal static bool ShowMapLink(SimpleDistribution simpleMetadataDistribution, string hierarchyLevel)
 {
     return(!string.IsNullOrWhiteSpace(simpleMetadataDistribution?.URL) && !string.IsNullOrWhiteSpace(simpleMetadataDistribution.Protocol) && (simpleMetadataDistribution.Protocol.Contains("OGC:WMS") || (!MapOnlyWms && simpleMetadataDistribution.Protocol.Contains("OGC:WFS"))) && (hierarchyLevel == "service" || hierarchyLevel == "servicelayer"));
 }
コード例 #4
0
 internal static bool ShowDownloadLink(SimpleDistribution simpleMetadataDistribution, string hierarchyLevel)
 {
     return(!string.IsNullOrWhiteSpace(simpleMetadataDistribution?.URL) && !string.IsNullOrWhiteSpace(simpleMetadataDistribution.Protocol) && (simpleMetadataDistribution.Protocol.Contains("WWW:DOWNLOAD") || simpleMetadataDistribution.Protocol.Contains("GEONORGE:FILEDOWNLOAD") || simpleMetadataDistribution.Protocol.Contains("OPENDAP:OPENDAP")) && (hierarchyLevel == "dataset" || hierarchyLevel == "series"));
 }
コード例 #5
0
 internal static string MapUrl(SimpleDistribution simpleMetadataDistribution, string hierarchyLevel)
 {
     return(simpleMetadataDistribution != null?MapUrl(simpleMetadataDistribution.URL, hierarchyLevel, simpleMetadataDistribution.Protocol, simpleMetadataDistribution.Name) : "");
 }
コード例 #6
0
        public Task UpdateMetadata()
        {
            var datasetList = GetDatasets();

            var datasets = datasetList.OrderBy(x => x.Uuid)
                           .GroupBy(x => x.Uuid)
                           .Select(g => new {
                Uuid     = g.Key,
                Datasets = g.Select(dataset => new {
                    dataset.Url,
                    dataset.Organization,
                    dataset.LastUpdated,
                    dataset.DistributionsFormats,
                    dataset.ReferenceSystems
                })
            }).ToList();

            foreach (var dataset in datasets)
            {
                try
                {
                    var metadataInfo = new UpdateMetadataInformation();
                    metadataInfo.Uuid          = dataset.Uuid.Trim();
                    metadataInfo.Distributions = new List <SimpleDistribution>();


                    foreach (var item in dataset.Datasets)
                    {
                        try
                        { metadataInfo.DatasetDateUpdated = DateTime.Parse(item.LastUpdated, System.Globalization.CultureInfo.InvariantCulture); }
                        catch (Exception e)
                        {
                            Log.Error("Error with LastUpdated: " + item.LastUpdated, e);
                        }

                        foreach (var distribution in item.DistributionsFormats)
                        {
                            SimpleDistribution simpleDistribution = new SimpleDistribution();
                            simpleDistribution.Organization = distribution.Organization;
                            simpleDistribution.Protocol     = "W3C:AtomFeed";
                            simpleDistribution.URL          = item.Url;
                            simpleDistribution.FormatName   = distribution.FormatName;

                            metadataInfo.Distributions.Add(simpleDistribution);
                        }

                        metadataInfo.Projections = new List <SimpleReferenceSystem>();

                        foreach (var projection in item.ReferenceSystems)
                        {
                            SimpleReferenceSystem simpleReferenceSystem = new SimpleReferenceSystem();
                            simpleReferenceSystem.CoordinateSystem = projection.CoordinateSystem;


                            metadataInfo.Projections.Add(simpleReferenceSystem);
                        }
                    }

                    System.Collections.Specialized.NameValueCollection settings = System.Web.Configuration.WebConfigurationManager.AppSettings;
                    string server             = settings["GeoNetworkUrl"];
                    string usernameGeonetwork = settings["GeoNetworkUsername"];
                    string password           = settings["GeoNetworkPassword"];
                    string geonorgeUsername   = settings["GeonorgeUsername"];


                    GeoNorge api = new GeoNorge(usernameGeonetwork, password, server);
                    api.OnLogEventDebug += new GeoNorgeAPI.LogEventHandlerDebug(LogEventsDebug);
                    api.OnLogEventError += new GeoNorgeAPI.LogEventHandlerError(LogEventsError);

                    var metadata = api.GetRecordByUuid(metadataInfo.Uuid);

                    SimpleMetadata simpleMetadata = new SimpleMetadata(metadata);

                    List <SimpleDistribution> distributionFormats = simpleMetadata.DistributionsFormats;

                    List <SimpleDistribution> distributionFormatsUpdated = new List <SimpleDistribution>();

                    if (HasAtomFeed(metadataInfo.Distributions))
                    {
                        foreach (var distribution in distributionFormats)
                        {
                            if (distribution.Protocol != "W3C:AtomFeed")
                            {
                                distributionFormatsUpdated.Add(distribution);
                            }
                        }
                    }
                    else
                    {
                        distributionFormatsUpdated = distributionFormats;
                    }

                    distributionFormatsUpdated.AddRange(metadataInfo.Distributions);

                    simpleMetadata.DistributionsFormats = distributionFormatsUpdated;
                    simpleMetadata.DistributionDetails  = new SimpleDistributionDetails
                    {
                        URL                 = distributionFormatsUpdated[0].URL,
                        Protocol            = distributionFormatsUpdated[0].Protocol,
                        UnitsOfDistribution = distributionFormatsUpdated[0].UnitsOfDistribution
                    };

                    List <SimpleReferenceSystem> simpleReferenceSystems = new List <SimpleReferenceSystem>();
                    foreach (var projection in metadataInfo.Projections)
                    {
                        SimpleReferenceSystem refsys = new SimpleReferenceSystem();
                        refsys.CoordinateSystem = projection.CoordinateSystem;
                        simpleReferenceSystems.Add(refsys);
                    }
                    if (simpleMetadata.ReferenceSystems == null ||
                        (simpleMetadata.ReferenceSystems != null && simpleMetadata.ReferenceSystems.Count == 0))
                    {
                        simpleMetadata.ReferenceSystems = simpleReferenceSystems;
                    }

                    simpleMetadata.DateMetadataUpdated = DateTime.Now;

                    if (metadataInfo.DatasetDateUpdated.HasValue)
                    {
                        simpleMetadata.DateUpdated = metadataInfo.DatasetDateUpdated;
                    }

                    api.MetadataUpdate(simpleMetadata.GetMetadata(), CreateAdditionalHeadersWithUsername(geonorgeUsername, "true"));
                    Log.Info($"Metadata updated for uuid: {metadataInfo.Uuid}");
                }
                catch (Exception ex)
                {
                    Log.Error("Error updating metadata uuid: " + dataset.Uuid + ", error: " + ex);
                }
            }

            return(Task.CompletedTask);
        }
コード例 #7
0
 public DistributionRow(SimpleDistribution distribution)
 {
     Organization = distribution.Organization;
     Protocol     = distribution.Protocol;
     Url          = distribution.URL;
 }