public ActionResult Support(SupportFormViewModel viewModel) { if (!ModelState.IsValid) { return(ViewSupportImpl(viewModel, string.Empty)); } var supportRequestLog = SupportRequestLogModelExtensions.Create(CurrentFirmaSession); viewModel.UpdateModel(supportRequestLog, CurrentFirmaSession); HttpRequestStorage.DatabaseEntities.AllSupportRequestLogs.Add(supportRequestLog); SupportRequestLogModelExtensions.SendMessage(supportRequestLog, Request.UserHostAddress, Request.UserAgent, viewModel.CurrentPageUrl, supportRequestLog.SupportRequestType, HttpRequestStorage.DatabaseEntities, FirmaWebConfiguration.DefaultSupportPersonID); SetMessageForDisplay("Support request sent."); if (CurrentFirmaSession.IsAnonymousUser()) { // This is a rare place in the system where an anonymous user writes to the DB. // If this becomes more commonplace we can work out a more general solution. HttpRequestStorage.DatabaseEntities.SaveChangesWithNoAuditing(CurrentFirmaSession.TenantID); } else { // Logged in user, normal audit trail on save SitkaDbContext.SaveChanges(); } return(new ModalDialogFormJsonResult()); }
public ActionResult Edit(FieldDefinitionPrimaryKey fieldDefinitionPrimaryKey, EditViewModel viewModel) { if (!ModelState.IsValid) { return(ViewEdit(fieldDefinitionPrimaryKey, viewModel)); } var fieldDefinitionData = HttpRequestStorage.DatabaseEntities.FieldDefinitionDatas.GetFieldDefinitionDataByFieldDefinition(fieldDefinitionPrimaryKey); if (fieldDefinitionData == null) { fieldDefinitionData = new FieldDefinitionData(fieldDefinitionPrimaryKey.EntityObject); HttpRequestStorage.DatabaseEntities.AllFieldDefinitionDatas.Add(fieldDefinitionData); } var fieldDefinitionDefault = CurrentFirmaSession.IsSitkaAdministrator() ? HttpRequestStorage.DatabaseEntities.FieldDefinitionDefaults.GetFieldDefinitionDefaultByFieldDefinition(fieldDefinitionPrimaryKey) : null; if (CurrentFirmaSession.IsSitkaAdministrator() && fieldDefinitionDefault == null) { // need to insert a default fieldDefinitionDefault = new FieldDefinitionDefault(fieldDefinitionData.FieldDefinition, "<p><em>not defined</em></p>"); HttpRequestStorage.DatabaseEntities.FieldDefinitionDefaults.Add(fieldDefinitionDefault); } viewModel.UpdateModel(fieldDefinitionData, fieldDefinitionDefault, HttpRequestStorage.DatabaseEntities); SetMessageForDisplay("Field Definition successfully saved."); return(RedirectToAction(new SitkaRoute <FieldDefinitionController>(x => x.Edit(fieldDefinitionData.FieldDefinition)))); }
private PartialViewResult ViewEditProjectLocationDetailed(Project project, ProjectLocationDetailViewModel viewModel) { var mapDivID = $"project_{project.GetEntityID()}_EditDetailedMap"; var detailedLocationGeoJsonFeatureCollection = project.DetailedLocationToGeoJsonFeatureCollection(true); var editableLayerGeoJson = new LayerGeoJson($"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabel()} Detail", detailedLocationGeoJsonFeatureCollection, "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var layers = MapInitJson.GetConfiguredGeospatialAreaMapLayers(); var userCanViewPrivateLocations = CurrentFirmaSession.UserCanViewPrivateLocations(project); layers.AddRange(MapInitJson.GetProjectLocationSimpleMapLayer(project, userCanViewPrivateLocations)); var boundingBox = ProjectLocationSummaryMapInitJson.GetProjectBoundingBox(project, userCanViewPrivateLocations); var mapInitJson = new MapInitJson(mapDivID, 10, layers, MapInitJson.GetExternalMapLayers(), boundingBox) { AllowFullScreen = false, DisablePopups = true }; var mapFormID = GenerateEditProjectLocationFormID(project.GetEntityID()); var uploadGisFileUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(c => c.ImportGdbFile(project.GetEntityID())); var saveFeatureCollectionUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(x => x.EditProjectLocationDetailed(project.GetEntityID(), null)); var hasSimpleLocationPoint = project.HasProjectLocationPoint(userCanViewPrivateLocations); var viewData = new ProjectLocationDetailViewData(project.GetEntityID(), mapInitJson, editableLayerGeoJson, uploadGisFileUrl, mapFormID, saveFeatureCollectionUrl, ProjectLocation.FieldLengths.Annotation, hasSimpleLocationPoint, project.LocationIsPrivate); return(RazorPartialView <ProjectLocationDetail, ProjectLocationDetailViewData, ProjectLocationDetailViewModel>(viewData, viewModel)); }
private PartialViewResult ViewEditProjectBoundingBox(Project project, EditProjectBoundingBoxViewModel viewModel) { var userCanViewPrivateLocations = CurrentFirmaSession.UserCanViewPrivateLocations(project); var layerGeoJsons = new List <LayerGeoJson> { project.HasProjectLocationPoint(userCanViewPrivateLocations) ? new LayerGeoJson("Simple Location", project.SimpleLocationToGeoJsonFeatureCollection(userCanViewPrivateLocations, true), FirmaHelpers.DefaultColorRange[1], 0.8m, LayerInitialVisibility.LayerInitialVisibilityEnum.Show) : null, project.HasProjectLocationDetailed(userCanViewPrivateLocations) ? new LayerGeoJson("Detailed Location", project.DetailedLocationToGeoJsonFeatureCollection(userCanViewPrivateLocations), FirmaHelpers.DefaultColorRange[1], 0.8m, LayerInitialVisibility.LayerInitialVisibilityEnum.Show) : null } .Where(x => x != null) .ToList(); foreach (var geospatialAreaType in HttpRequestStorage.DatabaseEntities.GeospatialAreaTypes.ToList().OrderBy(x => x.GeospatialAreaTypeName).ToList()) { layerGeoJsons.Add(geospatialAreaType.GetGeospatialAreaWmsLayerGeoJson("#90C3D4", 0.1m, LayerInitialVisibility.LayerInitialVisibilityEnum.Hide)); } var boundingBox = BoundingBox.MakeBoundingBoxFromProject(project, userCanViewPrivateLocations); var mapInitJson = new MapInitJson("EditProjectBoundingBoxMap", 10, layerGeoJsons, MapInitJson.GetExternalMapLayers(), boundingBox) { AllowFullScreen = false, DisablePopups = true }; var editProjectBoundingBoxUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(c => c.EditProjectBoundingBox(project)); var viewData = new EditProjectBoundingBoxViewData(mapInitJson, editProjectBoundingBoxUrl, EditProjectBoundingBoxFormID); return(RazorPartialView <EditProjectBoundingBox, EditProjectBoundingBoxViewData, EditProjectBoundingBoxViewModel>(viewData, viewModel)); }
private PartialViewResult ViewEditProjectGeospatialAreas(EditProjectGeospatialAreasViewModel viewModel, Project project, GeospatialAreaType geospatialAreaType) { var userCanViewPrivateLocations = CurrentFirmaSession.UserCanViewPrivateLocations(project); var boundingBox = ProjectLocationSummaryMapInitJson.GetProjectBoundingBox(project, userCanViewPrivateLocations); var layers = MapInitJson.GetGeospatialAreaMapLayersForGeospatialAreaType(geospatialAreaType); layers.AddRange(MapInitJson.GetProjectLocationSimpleAndDetailedMapLayers(project, CurrentFirmaSession)); var mapInitJson = new MapInitJson("projectGeospatialAreaMap", 0, layers, MapInitJson.GetExternalMapLayers(), boundingBox) { AllowFullScreen = false, DisablePopups = true }; var geospatialAreaIDs = viewModel.GeospatialAreaIDs ?? new List <int>(); var geospatialAreasInViewModel = HttpRequestStorage.DatabaseEntities.GeospatialAreas.Where(x => geospatialAreaIDs.Contains(x.GeospatialAreaID)).ToList(); var editProjectGeospatialAreasPostUrl = SitkaRoute <ProjectGeospatialAreaController> .BuildUrlFromExpression(c => c.EditProjectGeospatialAreas(project, geospatialAreaType, null)); var editProjectGeospatialAreasFormID = GetEditProjectGeospatialAreasFormID(); var geospatialAreasContainingProjectSimpleLocation = GeospatialAreaModelExtensions.GetGeospatialAreasContainingProjectLocation(project, geospatialAreaType.GeospatialAreaTypeID).ToList(); var viewData = new EditProjectGeospatialAreasViewData(CurrentFirmaSession, mapInitJson, geospatialAreasInViewModel, editProjectGeospatialAreasPostUrl, editProjectGeospatialAreasFormID, project.HasProjectLocationPoint(userCanViewPrivateLocations), project.HasProjectLocationDetailed(userCanViewPrivateLocations), geospatialAreaType, geospatialAreasContainingProjectSimpleLocation, null); return(RazorPartialView <EditProjectGeospatialAreas, EditProjectGeospatialAreasViewData, EditProjectGeospatialAreasViewModel>(viewData, viewModel)); }
public JsonNetJArrayResult FilteredProjectsWithLocationAreas(ProjectMapCustomization projectMapCustomization) { if (projectMapCustomization.FilterPropertyValues == null || !projectMapCustomization.FilterPropertyValues.Any()) { return(new JsonNetJArrayResult(new List <object>())); } var projectLocationFilterTypeFromFilterPropertyName = projectMapCustomization .GetProjectLocationFilterTypeFromFilterPropertyName(); var filterFunction = projectLocationFilterTypeFromFilterPropertyName.GetFilterFunction(projectMapCustomization .FilterPropertyValues); var allProjectsForMap = ProjectMapCustomization.ProjectsForMap(CurrentFirmaSession.CanViewProposals(), CurrentFirmaSession); var filteredProjects = allProjectsForMap.Where(filterFunction.Compile()) .ToList(); var filteredProjectsWithLocationAreas = filteredProjects.Where(x => !x.HasProjectLocationPoint(false)).ToList(); // Add projects where locations are private filteredProjectsWithLocationAreas.AddRange(ProjectMapCustomization.GetProjectsWithPrivateLocations()); var taxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel(); var taxonomyTiersAsFancyTreeNodes = taxonomyLevel .GetTaxonomyTiers(HttpRequestStorage.DatabaseEntities).OrderBy(x => x.SortOrder) .ThenBy(x => x.DisplayName, StringComparer.InvariantCultureIgnoreCase) .Select(x => x.ToFancyTreeNode(CurrentFirmaSession)) .ToList(); var projectsIDsThatDoNotHaveSimpleLocation = filteredProjectsWithLocationAreas .Select(project => project.ProjectID.ToString()).ToList(); switch (taxonomyLevel.ToEnum) { case TaxonomyLevelEnum.Leaf: PruneProjectsFromTaxonomyLeaves(taxonomyTiersAsFancyTreeNodes, projectsIDsThatDoNotHaveSimpleLocation); break; case TaxonomyLevelEnum.Branch: PruneTaxonomyBranchesWithNoProjects(taxonomyTiersAsFancyTreeNodes, projectsIDsThatDoNotHaveSimpleLocation); break; case TaxonomyLevelEnum.Trunk: foreach (var taxonomyTrunkNode in taxonomyTiersAsFancyTreeNodes) { var taxonomyBranchNodes = taxonomyTrunkNode.Children.ToList(); PruneTaxonomyBranchesWithNoProjects(taxonomyBranchNodes, projectsIDsThatDoNotHaveSimpleLocation); taxonomyTrunkNode.Children = taxonomyBranchNodes; } taxonomyTiersAsFancyTreeNodes.RemoveAll(x => !x.Children.Any()); break; default: throw new ArgumentOutOfRangeException(); } return(new JsonNetJArrayResult(taxonomyTiersAsFancyTreeNodes)); }
public ViewResult Index() { var firmaPage = FirmaPageTypeEnum.WebServicesIndex.GetFirmaPage(); var webServicesListUrl = SitkaRoute <WebServicesController> .BuildUrlFromExpression(x => x.List()); var getWebServiceAccessTokenUrl = !CurrentFirmaSession.IsAnonymousOrUnassigned() ? SitkaRoute <WebServicesController> .BuildUrlFromExpression(x => x.GetWebServiceAccessToken(CurrentPerson)) : null; var viewData = new IndexViewData(CurrentFirmaSession, CurrentPerson?.WebServiceAccessToken, webServicesListUrl, getWebServiceAccessTokenUrl, firmaPage); return(RazorView <Index, IndexViewData>(viewData)); }
public ViewResult Detail(ClassificationPrimaryKey classificationPrimaryKey) { var classification = classificationPrimaryKey.EntityObject; var mapDivID = $"classification_{classification.ClassificationID}_Map"; var associatedProjects = classification.GetAssociatedProjects(CurrentFirmaSession); var currentPersonCanViewProposals = CurrentFirmaSession.CanViewProposals(); var projectMapCustomization = ProjectMapCustomization.CreateDefaultCustomization(associatedProjects, currentPersonCanViewProposals); var projectLocationsLayerGeoJson = new LayerGeoJson($"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabelPluralized()}", associatedProjects.MappedPointsToGeoJsonFeatureCollection(false, true, false), "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var projectLocationsMapInitJson = new ProjectLocationsMapInitJson(projectLocationsLayerGeoJson, projectMapCustomization, mapDivID, false) { AllowFullScreen = true, }; // Add Organization Type boundaries according to configuration projectLocationsMapInitJson.Layers.AddRange(HttpRequestStorage.DatabaseEntities.Organizations.GetConfiguredBoundaryLayersGeoJson(). Where(x => x.LayerInitialVisibility == LayerInitialVisibility.LayerInitialVisibilityEnum.Show)); var filteredProjectList = associatedProjects.Where(x1 => x1.HasProjectLocationPointViewableByUser(CurrentFirmaSession)). Where(x => x.ProjectStage.ShouldShowOnMap()).ToList(); // filteredProjectList only contains project location points the user has permission to see projectLocationsMapInitJson.BoundingBox = new BoundingBox(filteredProjectList.Select(x => x.GetProjectLocationPoint(true)).ToList()); var projectLocationsMapViewData = new ProjectLocationsMapViewData(projectLocationsMapInitJson.MapDivID, ProjectColorByType.ProjectStage.GetDisplayNameFieldDefinition(), MultiTenantHelpers.GetTopLevelTaxonomyTiers(), currentPersonCanViewProposals); var projectFundingSourceExpenditures = associatedProjects.SelectMany(x => x.ProjectFundingSourceExpenditures); var organizationTypes = HttpRequestStorage.DatabaseEntities.OrganizationTypes.ToList(); const string chartTitle = "Reported Expenditures By Organization Type"; var chartContainerID = chartTitle.Replace(" ", ""); var googleChart = projectFundingSourceExpenditures.ToGoogleChart(x => x.FundingSource.Organization.OrganizationType.OrganizationTypeName, organizationTypes.Select(x => x.OrganizationTypeName).ToList(), x => x.FundingSource.Organization.OrganizationType.OrganizationTypeName, chartContainerID, chartTitle, organizationTypes.ToDictionary(x => x.OrganizationTypeName, x => x.LegendColor)); var viewGoogleChartViewData = new ViewGoogleChartViewData(googleChart, chartTitle, 405, true); var performanceMeasures = associatedProjects .SelectMany(x => x.PerformanceMeasureActuals) .Select(x => x.PerformanceMeasure).Distinct(new HavePrimaryKeyComparer <PerformanceMeasure>()) .OrderBy(x => x.PerformanceMeasureDisplayName) .ToList(); var projectCustomDefaultGridConfigurations = HttpRequestStorage.DatabaseEntities.ProjectCustomGridConfigurations.Where(x => x.IsEnabled && x.ProjectCustomGridTypeID == ProjectCustomGridType.Default.ProjectCustomGridTypeID).OrderBy(x => x.SortOrder).ToList(); var viewData = new DetailViewData(CurrentFirmaSession, classification, projectLocationsMapViewData, projectLocationsMapInitJson, viewGoogleChartViewData, performanceMeasures, projectCustomDefaultGridConfigurations); return(RazorView <Detail, DetailViewData>(viewData)); }
public ViewResult Detail(TaxonomyTrunkPrimaryKey taxonomyTrunkPrimaryKey) { var taxonomyTrunk = taxonomyTrunkPrimaryKey.EntityObject; var taxonomyTrunkProjects = taxonomyTrunk.GetAssociatedProjects(CurrentFirmaSession).ToList(); var projectMapCustomization = new ProjectMapCustomization(ProjectLocationFilterType.TaxonomyTrunk, new List <int> { taxonomyTrunk.TaxonomyTrunkID }, ProjectColorByType.ProjectStage); var projectLocationsLayerGeoJson = new LayerGeoJson($"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabel()}", taxonomyTrunkProjects.MappedPointsToGeoJsonFeatureCollection(false, true, true), "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var projectLocationsMapInitJson = new ProjectLocationsMapInitJson(projectLocationsLayerGeoJson, projectMapCustomization, "TaxonomyTrunkProjectMap", false); var projectLocationsMapViewData = new ProjectLocationsMapViewData(projectLocationsMapInitJson.MapDivID, ProjectColorByType.ProjectStage.GetDisplayNameFieldDefinition(), MultiTenantHelpers.GetTopLevelTaxonomyTiers(), CurrentFirmaSession.CanViewProposals()); var associatePerformanceMeasureTaxonomyLevel = MultiTenantHelpers.GetAssociatePerformanceMeasureTaxonomyLevel(); var canHaveAssociatedPerformanceMeasures = associatePerformanceMeasureTaxonomyLevel == TaxonomyLevel.Trunk; var taxonomyTierPerformanceMeasures = taxonomyTrunk.GetTaxonomyTierPerformanceMeasures(); var relatedPerformanceMeasuresViewData = new RelatedPerformanceMeasuresViewData( associatePerformanceMeasureTaxonomyLevel, true, taxonomyTierPerformanceMeasures, canHaveAssociatedPerformanceMeasures); List <PerformanceMeasureChartViewData> performanceMeasureChartViewDatas = null; if (canHaveAssociatedPerformanceMeasures) { performanceMeasureChartViewDatas = taxonomyTierPerformanceMeasures.Select(x => new PerformanceMeasureChartViewData(x.Key, CurrentFirmaSession, false, new List <Project>())).ToList(); } var taxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel(); var projectCustomDefaultGridConfigurations = HttpRequestStorage.DatabaseEntities.ProjectCustomGridConfigurations.Where(x => x.IsEnabled && x.ProjectCustomGridTypeID == ProjectCustomGridType.Default.ProjectCustomGridTypeID).OrderBy(x => x.SortOrder).ToList(); var viewData = new DetailViewData(CurrentFirmaSession, taxonomyTrunk, projectLocationsMapInitJson, projectLocationsMapViewData, canHaveAssociatedPerformanceMeasures, relatedPerformanceMeasuresViewData, performanceMeasureChartViewDatas, taxonomyLevel, projectCustomDefaultGridConfigurations); return(RazorView <Detail, DetailViewData>(viewData)); }
public ViewResult Index(GeospatialAreaTypePrimaryKey geospatialAreaTypePrimaryKey) { var geospatialAreaType = geospatialAreaTypePrimaryKey.EntityObject; var layerGeoJsons = new List <LayerGeoJson> { geospatialAreaType.GetGeospatialAreaWmsLayerGeoJson("#59ACFF", 0.2m, LayerInitialVisibility.LayerInitialVisibilityEnum.Show) }; var currentPersonCanViewProposals = CurrentFirmaSession.CanViewProposals(); var projectsToShow = ProjectMapCustomization.ProjectsForMap(currentPersonCanViewProposals, CurrentFirmaSession); var projectLocationsLayerGeoJson = new LayerGeoJson($"Mapped {FieldDefinitionEnum.Project.ToType().GetFieldDefinitionLabelPluralized()}", projectsToShow.MappedPointsToGeoJsonFeatureCollection(false, true, true), "#80b2ff", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); layerGeoJsons.Add(projectLocationsLayerGeoJson); var mapInitJson = new MapInitJson("geospatialAreaIndex", 10, layerGeoJsons, MapInitJson.GetExternalMapLayers(), BoundingBox.MakeNewDefaultBoundingBox()); var viewData = new IndexViewData(CurrentFirmaSession, geospatialAreaType, mapInitJson); return(RazorView <Index, IndexViewData>(viewData)); }
public ViewResult Index() { var firmaPageByPageTypeHomePage = FirmaPageTypeEnum.HomePage.GetFirmaPage(); var firmaPageByPageTypeHomePageAdditionalInfo = FirmaPageTypeEnum.HomeAdditionalInfo.GetFirmaPage(); var firmaPageByPageTypeHomePageMapInfo = FirmaPageTypeEnum.HomeMapInfo.GetFirmaPage(); var firmaHomePageImages = HttpRequestStorage.DatabaseEntities.FirmaHomePageImages.ToList().OrderBy(x => x.SortOrder).ToList(); var currentPersonCanViewProposals = CurrentFirmaSession.CanViewProposals(); var projectsToShow = ProjectMapCustomization.ProjectsForMap(currentPersonCanViewProposals); var projectMapCustomization = ProjectMapCustomization.CreateDefaultCustomization(projectsToShow, currentPersonCanViewProposals); var projectLocationsLayerGeoJson = new LayerGeoJson( $"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabelPluralized()}", projectsToShow.MappedPointsToGeoJsonFeatureCollection(false, false, true), "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var projectLocationsMapInitJson = new ProjectLocationsMapInitJson(projectLocationsLayerGeoJson, projectMapCustomization, "ProjectLocationsMap", false) { AllowFullScreen = false, // Add Organization Type boundaries according to configuration Layers = HttpRequestStorage.DatabaseEntities.Organizations.GetConfiguredBoundaryLayersGeoJson(). Where(x => x.LayerInitialVisibility == LayerInitialVisibility.LayerInitialVisibilityEnum.Show).ToList() }; var projectLocationsMapViewData = new ProjectLocationsMapViewData( projectLocationsMapInitJson.MapDivID, ProjectColorByType.ProjectStage.GetDisplayNameFieldDefinition(), MultiTenantHelpers.GetTopLevelTaxonomyTiers(), currentPersonCanViewProposals ); var activeFeaturedProjects = HttpRequestStorage.DatabaseEntities.Projects.Where(x => x.IsFeatured).ToList().GetActiveProjects(); var featuredProjectsViewData = new FeaturedProjectsViewData(this.CurrentFirmaSession, activeFeaturedProjects); var viewData = new IndexViewData(CurrentFirmaSession, firmaPageByPageTypeHomePage, firmaPageByPageTypeHomePageAdditionalInfo, firmaPageByPageTypeHomePageMapInfo, featuredProjectsViewData, projectLocationsMapViewData, projectLocationsMapInitJson, firmaHomePageImages); return(RazorView <Index, IndexViewData>(viewData)); }
public ViewResult Detail(TaxonomyLeafPrimaryKey taxonomyLeafPrimaryKey) { var taxonomyLeaf = taxonomyLeafPrimaryKey.EntityObject; var currentPersonCanViewProposals = CurrentFirmaSession.CanViewProposals(); var primaryTaxonomyLeafProjects = taxonomyLeaf.GetProjects().ToList() .GetActiveProjectsAndProposals(currentPersonCanViewProposals) .Where(x => x.ProjectStage.ShouldShowOnMap()) .ToList(); var secondaryTaxonomyLeafProjects = primaryTaxonomyLeafProjects.Union( taxonomyLeaf.SecondaryProjectTaxonomyLeafs.Select(x => x.Project) .ToList() .GetActiveProjectsAndProposals(currentPersonCanViewProposals) .Where(x => x.ProjectStage.ShouldShowOnMap())) .ToList(); // This page supports two maps for cases where secondary taxonomy leafs are supported var primaryProjectMapCustomization = new ProjectMapCustomization(ProjectLocationFilterType.TaxonomyLeaf, new List <int> { taxonomyLeaf.TaxonomyLeafID }, ProjectColorByType.ProjectStage); var secondaryProjectMapCustomization = new ProjectMapCustomization(ProjectLocationFilterType.TaxonomyLeaf, secondaryTaxonomyLeafProjects.Select(x => x.GetTaxonomyLeaf().TaxonomyLeafID).Union(new List <int> { taxonomyLeaf.TaxonomyLeafID }).ToList(), ProjectColorByType.ProjectStage); var primaryProjectLocationsLayerGeoJson = new LayerGeoJson($"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabel()}", primaryTaxonomyLeafProjects.MappedPointsToGeoJsonFeatureCollection(false, true, false), "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var secondaryProjectLocationsLayerGeoJson = new LayerGeoJson($"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabel()}", secondaryTaxonomyLeafProjects.MappedPointsToGeoJsonFeatureCollection(false, true, false), "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); // Add Organization Type boundaries according to configuration var configuredOrganizationBoundariesMapInitJson = HttpRequestStorage.DatabaseEntities.Organizations.GetConfiguredBoundaryLayersGeoJson(); var primaryProjectLocationsMapInitJson = new ProjectLocationsMapInitJson(primaryProjectLocationsLayerGeoJson, primaryProjectMapCustomization, "TaxonomyLeafProjectMap", false); primaryProjectLocationsMapInitJson.Layers.AddRange(configuredOrganizationBoundariesMapInitJson); var secondaryProjectLocationsMapInitJson = new ProjectLocationsMapInitJson(secondaryProjectLocationsLayerGeoJson, secondaryProjectMapCustomization, "SecondaryTaxonomyLeafProjectMap", false); secondaryProjectLocationsMapInitJson.Layers.AddRange(configuredOrganizationBoundariesMapInitJson); var primaryProjectLocationsMapViewData = new ProjectLocationsMapViewData(primaryProjectLocationsMapInitJson.MapDivID, ProjectColorByType.ProjectStage.GetDisplayNameFieldDefinition(), MultiTenantHelpers.GetTopLevelTaxonomyTiers(), CurrentFirmaSession.CanViewProposals()); var secondaryProjectLocationsMapViewData = new ProjectLocationsMapViewData(secondaryProjectLocationsMapInitJson.MapDivID, ProjectColorByType.ProjectStage.GetDisplayNameFieldDefinition(), MultiTenantHelpers.GetTopLevelTaxonomyTiers(), CurrentFirmaSession.CanViewProposals()); var associatePerformanceMeasureTaxonomyLevel = MultiTenantHelpers.GetAssociatePerformanceMeasureTaxonomyLevel(); var canHaveAssociatedPerformanceMeasures = associatePerformanceMeasureTaxonomyLevel == TaxonomyLevel.Leaf; var taxonomyTierPerformanceMeasures = taxonomyLeaf.GetTaxonomyTierPerformanceMeasures(); var relatedPerformanceMeasuresViewData = new RelatedPerformanceMeasuresViewData( associatePerformanceMeasureTaxonomyLevel, true, taxonomyTierPerformanceMeasures, canHaveAssociatedPerformanceMeasures); var taxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel(); var tenantAttribute = MultiTenantHelpers.GetTenantAttributeFromCache(); var performanceMeasures = taxonomyLeaf.TaxonomyLeafPerformanceMeasures.Select(x => x.PerformanceMeasure) .ToList(); var primaryPerformanceMeasureChartViewDataByPerformanceMeasure = performanceMeasures.ToDictionary( x => x.PerformanceMeasureID, x => new PerformanceMeasureChartViewData(x, CurrentFirmaSession, false, primaryTaxonomyLeafProjects, $"primary{x.GetJavascriptSafeChartUniqueName()}")); var secondaryPerformanceMeasureChartViewDataByPerformanceMeasure = performanceMeasures.ToDictionary( x => x.PerformanceMeasureID, x => new PerformanceMeasureChartViewData(x, CurrentFirmaSession, false, secondaryTaxonomyLeafProjects, $"secondary{x.GetJavascriptSafeChartUniqueName()}")); var projectCustomDefaultGridConfigurations = HttpRequestStorage.DatabaseEntities.ProjectCustomGridConfigurations.Where(x => x.IsEnabled && x.ProjectCustomGridTypeID == ProjectCustomGridType.Default.ProjectCustomGridTypeID).OrderBy(x => x.SortOrder).ToList(); var viewData = new DetailViewData(CurrentFirmaSession, taxonomyLeaf, primaryProjectLocationsMapInitJson, secondaryProjectLocationsMapInitJson, primaryProjectLocationsMapViewData, secondaryProjectLocationsMapViewData, canHaveAssociatedPerformanceMeasures, relatedPerformanceMeasuresViewData, taxonomyLevel, tenantAttribute, performanceMeasures, primaryPerformanceMeasureChartViewDataByPerformanceMeasure, secondaryPerformanceMeasureChartViewDataByPerformanceMeasure, projectCustomDefaultGridConfigurations); return(RazorView <Summary, DetailViewData>(viewData)); }
public ViewResult ProjectMap() { List <int> filterValues; ProjectLocationFilterType projectLocationFilterType; ProjectColorByType colorByValue; var currentPersonCanViewProposals = CurrentFirmaSession.CanViewProposals(); if (!String.IsNullOrEmpty(Request.QueryString[ProjectMapCustomization.FilterByQueryStringParameter])) { projectLocationFilterType = ProjectLocationFilterType.ToType(Request .QueryString[ProjectMapCustomization.FilterByQueryStringParameter] .ParseAsEnum <ProjectLocationFilterTypeEnum>()); } else { projectLocationFilterType = ProjectMapCustomization.DefaultLocationFilterType; } if (!String.IsNullOrEmpty(Request.QueryString[ProjectMapCustomization.FilterValuesQueryStringParameter])) { var filterValuesAsString = Request.QueryString[ProjectMapCustomization.FilterValuesQueryStringParameter] .Split(','); filterValues = filterValuesAsString.Select(Int32.Parse).ToList(); } else { filterValues = GetDefaultFilterValuesForFilterType(projectLocationFilterType.ToEnum, currentPersonCanViewProposals); } if (!String.IsNullOrEmpty(Request.QueryString[ProjectMapCustomization.ColorByQueryStringParameter])) { colorByValue = ProjectColorByType.ToType(Request .QueryString[ProjectMapCustomization.ColorByQueryStringParameter] .ParseAsEnum <ProjectColorByTypeEnum>()); } else { colorByValue = ProjectMapCustomization.DefaultColorByType; } var firmaPage = FirmaPageTypeEnum.ProjectMap.GetFirmaPage(); var projectsToShow = ProjectMapCustomization.ProjectsForMap(currentPersonCanViewProposals, CurrentFirmaSession); var initialCustomization = new ProjectMapCustomization(projectLocationFilterType, filterValues, colorByValue); var projectLocationsLayerGeoJson = new LayerGeoJson($"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabel()}", projectsToShow.MappedPointsToGeoJsonFeatureCollection(false, true, true), "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show); var projectLocationsMapInitJson = new ProjectLocationsMapInitJson(projectLocationsLayerGeoJson, initialCustomization, "ProjectLocationsMap", true); // Add Organization Type boundaries according to configuration projectLocationsMapInitJson.Layers.AddRange(HttpRequestStorage.DatabaseEntities.Organizations.GetConfiguredBoundaryLayersGeoJson()); var projectLocationsMapViewData = new ProjectLocationsMapViewData(projectLocationsMapInitJson.MapDivID, null, MultiTenantHelpers.GetTopLevelTaxonomyTiers(), currentPersonCanViewProposals, true); var projectLocationFilterTypesAndValues = CreateProjectLocationFilterTypesAndValuesDictionary(currentPersonCanViewProposals); var projectLocationsUrl = SitkaRoute <ResultsController> .BuildAbsoluteUrlHttpsFromExpression(x => x.ProjectMap()); var filteredProjectsWithLocationAreasUrl = SitkaRoute <ResultsController> .BuildUrlFromExpression(x => x.FilteredProjectsWithLocationAreas(null)); var projectColorByTypes = new List <ProjectColorByType> { ProjectColorByType.ProjectStage }; if (MultiTenantHelpers.IsTaxonomyLevelTrunk()) { projectColorByTypes.Add(ProjectColorByType.TaxonomyTrunk); } else if (MultiTenantHelpers.IsTaxonomyLevelBranch()) { projectColorByTypes.Add(ProjectColorByType.TaxonomyBranch); } var viewData = new ProjectMapViewData(CurrentFirmaSession, firmaPage, projectLocationsMapInitJson, projectLocationsMapViewData, projectLocationFilterTypesAndValues, projectLocationsUrl, filteredProjectsWithLocationAreasUrl, projectColorByTypes, ProjectColorByType.ProjectStage.GetDisplayNameFieldDefinition()); return(RazorView <ProjectMap, ProjectMapViewData>(viewData)); }
public GridJsonNetJObjectResult <GeospatialAreaIndexGridSimple> IndexGridJsonData(GeospatialAreaTypePrimaryKey geospatialAreaTypePrimaryKey) { var geospatialAreaType = geospatialAreaTypePrimaryKey.EntityObject; var gridSpec = new IndexGridSpec(CurrentFirmaSession, geospatialAreaType); var projectIDsViewableByUser = HttpRequestStorage.DatabaseEntities.Projects.ToList().GetActiveProjectsAndProposals(CurrentFirmaSession.CanViewProposals(), CurrentFirmaSession).Select(x => x.ProjectID).ToList(); var geospatialAreaIndexGridSimples = GeospatialAreaModelExtensions.GetGeospatialAreaIndexGridSimples(geospatialAreaType, projectIDsViewableByUser).OrderByDescending(x => x.ProjectViewableByUserCount).ToList(); var gridJsonNetJObjectResult = new GridJsonNetJObjectResult <GeospatialAreaIndexGridSimple>(geospatialAreaIndexGridSimples, gridSpec); return(gridJsonNetJObjectResult); }
public ExcelResult IndexExcelDownload() { var projects = HttpRequestStorage.DatabaseEntities.Projects.ToList().GetActiveProjectsAndProposals(CurrentFirmaSession.CanViewProposals(), CurrentFirmaSession); var projectsSpec = new ProjectAssessmentExcelSpec(); var wsProjects = ExcelWorkbookSheetDescriptorFactory.MakeWorksheet("Projects", projectsSpec, projects); var questionsSpec = new QuestionsExcelSpec(); var wsQuestions = ExcelWorkbookSheetDescriptorFactory.MakeWorksheet("Questions", questionsSpec, HttpRequestStorage.DatabaseEntities.AssessmentQuestions.ToList()); var workSheets = new List <IExcelWorkbookSheetDescriptor> { wsProjects, wsQuestions }; var wbm = new ExcelWorkbookMaker(workSheets); var excelWorkbook = wbm.ToXLWorkbook(); return(new ExcelResult(excelWorkbook, $" Assessment as of {DateTime.Now.ToStringDateTime()}")); }
protected override bool IsCurrentUserAnonymous() { return(CurrentFirmaSession == null || CurrentFirmaSession.IsAnonymousUser()); }