コード例 #1
0
        /// <summary>
        /// If the URL doesn't match DefaultTenantCanonicalHostName do a redirect. Otherwise do nothing. This is especially important for sites using SSL to get certificate to match up
        /// </summary>
        private void RedirectToCanonicalHostnameIfNeeded()
        {
            if (String.IsNullOrWhiteSpace(Request.Url.Host))
            {
                return;
            }

            if (!FirmaWebConfiguration.RedirectToDefaultTenantCanonicalHostName)
            {
                return;
            }

            var canonicalHostName = FirmaWebConfiguration.GetCanonicalHost(Request.Url.Host, true);

            Check.RequireNotNullThrowNotFound(canonicalHostName, "Domain", Request.Url.Host);
            // Check for hostname match (deliberately case-insensitive, DNS is case-insensitive and so is SSL Cert for common name) against the canonical host name as specified in the configuration
            if (!String.Equals(Request.Url.Host, canonicalHostName, StringComparison.InvariantCultureIgnoreCase))
            {
                var builder = new UriBuilder(Request.Url)
                {
                    Host = canonicalHostName
                };
                var newUri = builder.Uri;

                // Signal this as a permanent redirect 301 HTTP status not 302 since we'd want to update bad URLs
                Response.RedirectPermanent(newUri.AbsoluteUri);
            }
        }
コード例 #2
0
        private MailMessage GenerateReminderForPerson(Person person, List <Project> projects)
        {
            var projectListAsHtmlStrings =
                GenerateProjectListAsHtmlStrings(
                    projects);
            var projectsRequiringAnUpdateUrl =
                SitkaRoute <ProjectUpdateController> .BuildAbsoluteUrlHttpsFromExpression(x =>
                                                                                          x.MyProjectsRequiringAnUpdate());

            var tenantCanonicalHostUrl = FirmaWebConfiguration.GetCanonicalHostForBackgroundJob(TenantID);

            projectsRequiringAnUpdateUrl =
                SitkaRoute <ProjectUpdateController> .ReplaceHostNameForBackgroundJob(projectsRequiringAnUpdateUrl,
                                                                                      tenantCanonicalHostUrl);

            var emailContent = GetEmailContentWithGeneratedSignature(projectsRequiringAnUpdateUrl,
                                                                     person.GetFullNameFirstLast(), String.Join("<br/>", projectListAsHtmlStrings));

            var htmlView = AlternateView.CreateAlternateViewFromString(emailContent, null, "text/html");

            htmlView.LinkedResources.Add(
                new LinkedResource(new MemoryStream(ToolLogo.FileResourceData.Data), "img/jpeg")
            {
                ContentId = "tool-logo"
            });
            var mailMessage = new MailMessage {
                Subject = ReminderEmailSubject, IsBodyHtml = true
            };

            mailMessage.AlternateViews.Add(htmlView);

            return(mailMessage);
        }
コード例 #3
0
 public ProjectLocationDetailViewDataForAngular(MapInitJson mapInitJson, LayerGeoJson editableLayerGeoJson, LayerGeoJson arcGisLayerGeoJson, int annotationMaxLength)
 {
     MapInitJson          = mapInitJson;
     EditableLayerGeoJson = editableLayerGeoJson;
     ArcGisLayerGeoJson   = arcGisLayerGeoJson;
     AnnotationMaxLength  = annotationMaxLength;
     GeospatialAreaMapServiceLayerNames = FirmaWebConfiguration.GetWmsLayerNames();
     ProjectLocationTypeJsons           = ProjectLocationType.GetAllProjectLocationTypeJsons();
 }
        public EditProjectPriorityLandscapesViewDataForAngular(MapInitJson mapInitJson, List <Models.PriorityLandscape> priorityLandscapesInViewModel)
        {
            MapInitJson = mapInitJson;
            FindPriorityLandscapeByNameUrl = SitkaRoute <ProjectPriorityLandscapeController> .BuildUrlFromExpression(c => c.FindPriorityLandscapeByName(null));

            TypeAheadInputId                     = "priorityLandscapeSearch";
            PriorityLandscapeNameByID            = priorityLandscapesInViewModel.ToDictionary(x => x.PriorityLandscapeID, x => x.PriorityLandscapeName);
            PriorityLandscapeMapServiceLayerName = FirmaWebConfiguration.GetPriorityLandscapeWmsLayerName();
            MapServiceUrl = FirmaWebConfiguration.WebMapServiceUrl;
        }
コード例 #5
0
        public EditProjectRegionsViewDataForAngular(MapInitJson mapInitJson, List <Models.DNRUplandRegion> dnrUplandRegionsInViewModel)
        {
            MapInitJson         = mapInitJson;
            FindRegionByNameUrl = SitkaRoute <ProjectRegionController> .BuildUrlFromExpression(c => c.FindRegionByName(null));

            TypeAheadInputId          = "regionSearch";
            RegionNameByID            = dnrUplandRegionsInViewModel.ToDictionary(x => x.DNRUplandRegionID, x => x.DNRUplandRegionName);
            RegionMapServiceLayerName = FirmaWebConfiguration.GetDNRUplandRegionWmsLayerName();
            MapServiceUrl             = FirmaWebConfiguration.WebMapServiceUrl;
        }
コード例 #6
0
        private IEnumerable <string> GenerateProjectListAsHtmlStrings(
            IReadOnlyCollection <Project> projects)
        {
            var projectsRemaining        = projects;
            var tenantCanonicalHostName  = FirmaWebConfiguration.GetCanonicalHostForBackgroundJob(TenantID);
            var projectListAsHtmlStrings = projectsRemaining.OrderBy(project => project.GetDisplayName()).Select(project =>
            {
                var projectUrl =
                    SitkaRoute <ProjectController> .BuildAbsoluteUrlHttpsFromExpression(controller =>
                                                                                        controller.Detail(project));
                projectUrl = SitkaRoute <ProjectController> .ReplaceHostNameForBackgroundJob(projectUrl, tenantCanonicalHostName);
                return($@"<div style=""font-size:smaller""><a href=""{projectUrl}"">{project.ProjectName}</a></div>");
            }).ToList();

            return(projectListAsHtmlStrings);
        }
コード例 #7
0
        private PartialViewResult ViewEditInteractionEventLocationSimple(EditInteractionEventLocationSimpleViewModel viewModel, InteractionEvent interactionEvent)
        {
            var layerGeoJsons = MapInitJson.GetAllGeospatialAreaMapLayers(LayerInitialVisibility.Hide);
            var mapInitJson   = new MapInitJson($"interactionEvent_{interactionEvent.InteractionEventID}_EditMap", 10, layerGeoJsons, BoundingBox.MakeNewDefaultBoundingBox(), false)
            {
                AllowFullScreen = false, DisablePopups = true
            };

            var mapPostUrl = SitkaRoute <InteractionEventController> .BuildUrlFromExpression(c => c.EditInteractionEventLocation(interactionEvent.PrimaryKey, null));

            var mapFormID     = GetMapLocationFormID(interactionEvent.PrimaryKey);
            var wmsLayerNames = FirmaWebConfiguration.GetWmsLayerNames();
            var mapServiceUrl = FirmaWebConfiguration.WebMapServiceUrl;

            var viewData = new EditInteractionEventLocationSimpleViewData(CurrentPerson, mapInitJson, wmsLayerNames, null, mapPostUrl, mapFormID, mapServiceUrl);

            return(RazorPartialView <EditInteractionEventLocationSimple, EditInteractionEventLocationSimpleViewData, EditInteractionEventLocationSimpleViewModel>(viewData, viewModel));
        }
コード例 #8
0
 public static LayerGeoJson GetPriorityLandscapeWmsLayerGeoJson(string layerColor, decimal layerOpacity, LayerInitialVisibility layerInitialVisibility)
 {
     return(new LayerGeoJson("20-Year Plan for eastern WA", FirmaWebConfiguration.WebMapServiceUrl,
                             FirmaWebConfiguration.GetPriorityLandscapeWmsLayerName(), layerColor, layerOpacity,
                             layerInitialVisibility, "/Content/leaflet/images/washington_priority_landscape.png"));
 }
コード例 #9
0
 public static LayerGeoJson GetAllSimpleProjectLocations()
 {
     return(new LayerGeoJson($"All {FieldDefinition.ProjectLocation.GetFieldDefinitionLabelPluralized()} - Simple", FirmaWebConfiguration.WebMapServiceUrl,
                             FirmaWebConfiguration.GetAllProjectLocationsSimpleWmsLayerName(), "orange", .2m,
                             LayerInitialVisibility.Hide));
 }
コード例 #10
0
 public static LayerGeoJson GetWashingtonLegislativeDistrictLayer()
 {
     return(new LayerGeoJson($"Washington Legislative Districts", FirmaWebConfiguration.WebMapServiceUrl,
                             FirmaWebConfiguration.GetWashingtonLegislativeDistrictWmsLayerName(), "orange", .2m,
                             LayerInitialVisibility.Hide, "/Content/leaflet/images/washington_legislative_district.png"));
 }
コード例 #11
0
 public static LayerGeoJson GetWashingtonCountyLayer()
 {
     return(new LayerGeoJson($"Washington Counties", FirmaWebConfiguration.WebMapServiceUrl,
                             FirmaWebConfiguration.GetWashingtonCountyWmsLayerName(), "orange", .2m,
                             LayerInitialVisibility.Hide, "/Content/leaflet/images/washington_county.png"));
 }
コード例 #12
0
 public static LayerGeoJson GetAllProjectTreatments()
 {
     return(new LayerGeoJson($"All Project Treatment Areas", FirmaWebConfiguration.WebMapServiceUrl,
                             FirmaWebConfiguration.GetAllProjectTreatmentAreasWmsLayerName(), "orange", .2m,
                             LayerInitialVisibility.Hide, "/Content/leaflet/images/washington_project_treatment.png"));
 }
コード例 #13
0
 public static LayerGeoJson GetAllDetailedProjectLocations()
 {
     return(new LayerGeoJson($"All {FieldDefinition.ProjectLocation.GetFieldDefinitionLabelPluralized()} - Detail", FirmaWebConfiguration.WebMapServiceUrl,
                             FirmaWebConfiguration.GetAllProjectLocationsDetailedWmsLayerName(), "orange", .2m,
                             LayerInitialVisibility.Hide, "/Content/leaflet/images/washington_location_detailed.png"));
 }
コード例 #14
0
 public static LayerGeoJson GetRegionWmsLayerGeoJson(string layerColor, decimal layerOpacity, LayerInitialVisibility layerInitialVisibility)
 {
     return(new LayerGeoJson("All DNR Upland Regions", FirmaWebConfiguration.WebMapServiceUrl,
                             FirmaWebConfiguration.GetDNRUplandRegionWmsLayerName(), layerColor, layerOpacity,
                             layerInitialVisibility, "/Content/leaflet/images/washington_upland_region.png"));
 }
コード例 #15
0
        private PartialViewResult ViewEditProjectLocationSummaryPoint(Project project, ProjectLocationSimpleViewModel viewModel)
        {
            var layerGeoJsons = MapInitJson.GetAllGeospatialAreaMapLayers(LayerInitialVisibility.Hide);
            var mapInitJson   = new MapInitJson($"project_{project.ProjectID}_EditMap", 10, layerGeoJsons, BoundingBox.MakeNewDefaultBoundingBox(), false)
            {
                AllowFullScreen = false, DisablePopups = true
            };
            var mapPostUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(c => c.EditProjectLocationSimple(project, null));

            var mapFormID = GenerateEditProjectLocationFormID(project.ProjectID);
            var viewData  = new ProjectLocationSimpleViewData(CurrentPerson, mapInitJson, FirmaWebConfiguration.GetWmsLayerNames(), null, mapPostUrl, mapFormID, FirmaWebConfiguration.WebMapServiceUrl);

            return(RazorPartialView <ProjectLocationSimple, ProjectLocationSimpleViewData, ProjectLocationSimpleViewModel>(viewData, viewModel));
        }