Example #1
0
 public PdfGenerator(ProductSheet productSheet, string imagePath, string logoPath)
 {
     this.productsheet = productSheet;
     this.imagePath    = imagePath;
     this.logoPath     = logoPath;
 }
        public ProductSheet UpdateProductSheetFromMetadata(string uuid, ProductSheet productSheet)
        {
            register = new RegisterFetcher();
            MD_Metadata_Type metadata = _geonorge.GetRecordByUuid(uuid);

            if (metadata == null)
            {
                throw new InvalidOperationException("Metadata not found for uuid: " + uuid);
            }

            var simpleMetadata = new SimpleMetadata(metadata);

            dynamic metedataExtended = register.GetMetadataExtended(simpleMetadata.Uuid);


            productSheet.Uuid                          = simpleMetadata.Uuid;
            productSheet.Title                         = simpleMetadata.Title;
            productSheet.Description                   = simpleMetadata.Abstract;
            productSheet.SupplementalDescription       = simpleMetadata.SupplementalDescription;
            productSheet.Purpose                       = simpleMetadata.Purpose;
            productSheet.SpecificUsage                 = simpleMetadata.SpecificUsage;
            productSheet.UseLimitations                = simpleMetadata.Constraints != null ? simpleMetadata.Constraints.UseLimitations : null;
            productSheet.UseConstraintsLicenseLink     = simpleMetadata.Constraints != null ? simpleMetadata.Constraints.UseConstraintsLicenseLink : null;
            productSheet.UseConstraintsLicenseLinkText = simpleMetadata.Constraints != null ? simpleMetadata.Constraints.UseConstraintsLicenseLinkText : null;
            productSheet.ContactMetadata               = simpleMetadata.ContactMetadata != null?CreateContact(simpleMetadata.ContactMetadata) : new Contact();

            productSheet.ContactPublisher = simpleMetadata.ContactPublisher != null?CreateContact(simpleMetadata.ContactPublisher) : new Contact();

            productSheet.ContactOwner = simpleMetadata.ContactOwner != null?CreateContact(simpleMetadata.ContactOwner) : new Contact();

            productSheet.ResolutionScale      = simpleMetadata.ResolutionScale;
            productSheet.KeywordsPlace        = CreateKeywords(SimpleKeyword.Filter(simpleMetadata.Keywords, SimpleKeyword.TYPE_PLACE, null));
            productSheet.ProcessHistory       = simpleMetadata.ProcessHistory;
            productSheet.MaintenanceFrequency = simpleMetadata.MaintenanceFrequency;
            productSheet.Status = simpleMetadata.Status;
            productSheet.DistributionFormatName    = simpleMetadata.DistributionFormat != null ? simpleMetadata.DistributionFormat.Name : null;
            productSheet.DistributionFormatVersion = simpleMetadata.DistributionFormat != null ? simpleMetadata.DistributionFormat.Version : null;
            productSheet.DistributionFormats       = GetDistributionFormats(simpleMetadata.DistributionFormats);
            productSheet.AccessConstraints         = simpleMetadata.Constraints != null?register.GetRestriction(simpleMetadata.Constraints.AccessConstraints, simpleMetadata.Constraints.OtherConstraintsAccess) : null;

            productSheet.LegendDescriptionUrl    = simpleMetadata.LegendDescriptionUrl;
            productSheet.ProductPageUrl          = simpleMetadata.ProductPageUrl;
            productSheet.ProductSpecificationUrl = simpleMetadata.ProductSpecificationUrl;
            foreach (var thumbnail in simpleMetadata.Thumbnails)
            {
                productSheet.Thumbnail = thumbnail.URL;
                if (!thumbnail.URL.StartsWith("http"))
                {
                    productSheet.Thumbnail = "https://www.geonorge.no/geonetwork/srv/nor/resources.get?uuid=" + simpleMetadata.Uuid + "&access=public&fname=" + thumbnail.URL;
                }
                if (thumbnail.Type == "large_thumbnail")
                {
                    break;
                }
            }
            //productSheet.CoverageArea = !string.IsNullOrWhiteSpace(simpleMetadata.CoverageUrl) ? GetCoverageLink(simpleMetadata.CoverageUrl, uuid) : "";
            productSheet.CoverageArea = metedataExtended.CoverageUrl;
            productSheet.Projections  = simpleMetadata.ReferenceSystems != null?getProjections(simpleMetadata.ReferenceSystems) : "";


            return(productSheet);
        }
 public PdfHeaderFooter(ProductSheet productsheet, string imagePath, string imagePathLogo)
 {
     this._productsheet  = productsheet;
     this._imagePath     = imagePath;
     this._imagePathLogo = imagePathLogo;
 }