Пример #1
0
        private void AddProjectCustomGridCustomAttributeField(ProjectCustomGridConfiguration projectCustomGridConfiguration, Dictionary <int, List <vProjectCustomAttributeValue> > projectCustomAttributeDictionary)
        {
            var projectCustomAttributeType = projectCustomGridConfiguration.ProjectCustomAttributeType;
            var isCurrency           = projectCustomGridConfiguration.ProjectCustomAttributeType.MeasurementUnitTypeID == MeasurementUnitType.Dollars.MeasurementUnitTypeID;
            var gridHeaderHtmlString = ("<div>"
                                        + LabelWithSugarForExtensions.GenerateHelpIconImgTag(projectCustomAttributeType.ProjectCustomAttributeTypeName, projectCustomAttributeType.ProjectCustomAttributeTypeDescription.ToHTMLFormattedString(), projectCustomAttributeType.GetDescriptionUrl(), 300, LabelWithSugarForExtensions.DisplayStyle.HelpIconOnly)
                                        + projectCustomAttributeType.ProjectCustomAttributeTypeName
                                        + "</div>").ToHTMLFormattedString();

            if (isCurrency)
            {
                Add($"{gridHeaderHtmlString}", a => TryParseDecimalCustomAttributeValue(a, projectCustomAttributeType, projectCustomAttributeDictionary), 150, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
            }
            else
            {
                Add($"{gridHeaderHtmlString}", a => a.GetProjectCustomAttributesValue(projectCustomAttributeType, projectCustomAttributeDictionary), 150, DhtmlxGridColumnFilterType.Text);
            }
        }
Пример #2
0
        private void AddProjectCustomGridField(FirmaSession currentFirmaSession
                                               , ProjectCustomGridConfiguration projectCustomGridConfiguration
                                               , bool userHasEditProjectAsAdminPermissions
                                               , Dictionary <int, vProjectDetail> projectDetailsDictionary
                                               , Dictionary <int, ProjectFirmaModels.Models.TaxonomyLeaf> taxonomyLeafDictionary
                                               , string projectLabel
                                               , bool hasProjectApprovalPermissionBySession
                                               , string statusUpdateLabel
                                               , List <int> sitkaAdminPersonIDs)
        {
            switch (projectCustomGridConfiguration.ProjectCustomGridColumn.ToEnum)
            {
            // Non-optional fields
            // Project Name
            case ProjectCustomGridColumnEnum.ProjectName:
                Add(FieldDefinitionEnum.ProjectName.ToType().ToGridHeaderString(), x => UrlTemplate.MakeHrefString(x.GetDetailUrl(), x.ProjectName), 300, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.PrimaryContactOrganization:
                Add(FieldDefinitionEnum.IsPrimaryContactOrganization.ToType().ToGridHeaderString(),
                    x => OrganizationModelExtensions.GetShortNameAsUrl(projectDetailsDictionary[x.ProjectID].PrimaryContactOrganizationID, projectDetailsDictionary[x.ProjectID].PrimaryContactOrganizationDisplayName), 150, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.ProjectStage:
                Add(FieldDefinitionEnum.ProjectStage.ToType().ToGridHeaderString(), x => x.ProjectStage.ProjectStageDisplayName, 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.NumberOfExpectedPerformanceMeasureRecords:
                Add($"# Of Expected {MultiTenantHelpers.GetPerformanceMeasureName()} Records", x => projectDetailsDictionary[x.ProjectID].PerformanceMeasureExpectedCount, 100);
                break;

            case ProjectCustomGridColumnEnum.NumberOfReportedPerformanceMeasures:
                Add($"# Of Reported {MultiTenantHelpers.GetPerformanceMeasureName()} Records", x => projectDetailsDictionary[x.ProjectID].PerformanceMeasureActualCount, 100);
                break;

            case ProjectCustomGridColumnEnum.ProjectsStewardOrganizationRelationshipToProject:
                if (MultiTenantHelpers.HasCanStewardProjectsOrganizationRelationship())
                {
                    Add(FieldDefinitionEnum.ProjectsStewardOrganizationRelationshipToProject.ToType().ToGridHeaderString(), x => OrganizationModelExtensions.GetShortNameAsUrl(projectDetailsDictionary[x.ProjectID].CanStewardProjectsOrganizationID, projectDetailsDictionary[x.ProjectID].CanStewardProjectsOrganizationDisplayName), 150, DhtmlxGridColumnFilterType.Html);
                }
                break;

            case ProjectCustomGridColumnEnum.ProjectPrimaryContact:
                Add(FieldDefinitionEnum.ProjectPrimaryContact.ToType().ToGridHeaderString(),
                    x => projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.HasValue ?
                    new UserViewFeature().HasPermissionForPersonID(currentFirmaSession, projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.Value, sitkaAdminPersonIDs).HasPermission ? UrlTemplate.MakeHrefString(PersonModelExtensions.DetailUrlTemplate.ParameterReplace(projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.Value), projectDetailsDictionary[x.ProjectID].PrimaryContactPersonFullNameFirstLast) : new HtmlString(projectDetailsDictionary[x.ProjectID].PrimaryContactPersonFullNameFirstLast) : new HtmlString(""),
                    150, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.ProjectPrimaryContactEmail:
                var userHasEmailViewingPermissions = new LoggedInAndNotUnassignedRoleUnclassifiedFeature().HasPermissionByFirmaSession(currentFirmaSession);
                if (userHasEmailViewingPermissions)
                {
                    Add(FieldDefinitionEnum.ProjectPrimaryContactEmail.ToType().ToGridHeaderString(),
                        x => projectDetailsDictionary[x.ProjectID].PrimaryContactPersonID.HasValue ? new HtmlString($"<a href='mailto:{projectDetailsDictionary[x.ProjectID].PrimaryContactPersonEmail}'> {projectDetailsDictionary[x.ProjectID].PrimaryContactPersonEmail}</a>") : new HtmlString(""),
                        200, DhtmlxGridColumnFilterType.SelectFilterHtmlStrict);
                }
                break;

            case ProjectCustomGridColumnEnum.PlanningDesignStartYear:
                Add(FieldDefinitionEnum.PlanningDesignStartYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetPlanningDesignStartYear(x), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.ImplementationStartYear:
                Add(FieldDefinitionEnum.ImplementationStartYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetImplementationStartYear(x), 115, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.CompletionYear:
                Add(FieldDefinitionEnum.CompletionYear.ToType().ToGridHeaderString(), x => ProjectModelExtensions.GetCompletionYear(x), 90, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.PrimaryTaxonomyLeaf:
                var gridHeaderString = MultiTenantHelpers.GetTenantAttributeFromCache().EnableSecondaryProjectTaxonomyLeaf
                        ? FieldDefinitionEnum.TaxonomyLeafDisplayNameForProject.ToType().ToGridHeaderString()
                        : FieldDefinitionEnum.TaxonomyLeaf.ToType().ToGridHeaderString();
                Add(gridHeaderString, x => UrlTemplate.MakeHrefString(TaxonomyLeafModelExtensions.DetailUrlTemplate.ParameterReplace(projectDetailsDictionary[x.ProjectID].TaxonomyLeafID), projectDetailsDictionary[x.ProjectID].TaxonomyLeafDisplayName), 240, DhtmlxGridColumnFilterType.Html);
                break;

            case ProjectCustomGridColumnEnum.SecondaryTaxonomyLeaf:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().EnableSecondaryProjectTaxonomyLeaf)
                {
                    Add(FieldDefinitionEnum.SecondaryProjectTaxonomyLeaf.ToType().ToGridHeaderStringPlural()
                        , x => new HtmlString(string.Join(", ", x.SecondaryProjectTaxonomyLeafs.Select(y => taxonomyLeafDictionary[y.TaxonomyLeafID].GetDisplayNameAsUrl().ToString()))), 300, DhtmlxGridColumnFilterType.Html);
                }
                break;

            case ProjectCustomGridColumnEnum.NumberOfReportedExpenditures:
                Add($"# Of {FieldDefinitionEnum.ReportedExpenditure.ToType().GetFieldDefinitionLabel()} Records", x => projectDetailsDictionary[x.ProjectID].ProjectFundingSourceExpenditureCount, 100);
                break;

            case ProjectCustomGridColumnEnum.FundingType:
                Add(FieldDefinitionEnum.FundingType.ToType().ToGridHeaderString(), x => x.FundingType != null ? x.FundingType.FundingTypeDisplayName : "", 300, DhtmlxGridColumnFilterType.SelectFilterStrict);
                break;

            case ProjectCustomGridColumnEnum.EstimatedTotalCost:
                Add(FieldDefinitionEnum.EstimatedTotalCost.ToType().ToGridHeaderString(), x => x.GetEstimatedTotalRegardlessOfFundingType(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.SecuredFunding:
                Add(FieldDefinitionEnum.SecuredFunding.ToType().ToGridHeaderString(), x => x.GetSecuredFunding(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.TargetedFunding:
                Add(FieldDefinitionEnum.TargetedFunding.ToType().ToGridHeaderString(), x => x.GetTargetedFunding(), 100, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.NoFundingSourceIdentified:
                Add(FieldDefinitionEnum.NoFundingSourceIdentified.ToType().ToGridHeaderString(), x => x.GetNoFundingSourceIdentifiedAmount(), 110, DhtmlxGridColumnFormatType.Currency, DhtmlxGridColumnAggregationType.Total);
                break;

            case ProjectCustomGridColumnEnum.ProjectDescription:
                Add(FieldDefinitionEnum.ProjectDescription.ToType().ToGridHeaderString(), x => x.ProjectDescription, 200);
                break;

            case ProjectCustomGridColumnEnum.NumberOfPhotos:
                Add("# of Photos", x => projectDetailsDictionary[x.ProjectID].ProjectImageCount, 60);
                break;

            case ProjectCustomGridColumnEnum.ProjectID:
                Add(FieldDefinitionEnum.ProjectID.ToType().ToGridHeaderString(), x => x.ProjectID.ToString(), 140);
                break;

            case ProjectCustomGridColumnEnum.ProjectLastUpdated:
                Add(FieldDefinitionEnum.ProjectLastUpdated.ToType().ToGridHeaderString(), x => x.LastUpdatedDate, 140);
                break;

            case ProjectCustomGridColumnEnum.ProjectStatus:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().UseProjectTimeline&& userHasEditProjectAsAdminPermissions)
                {
                    Add(FieldDefinitionEnum.Status.ToType().ToGridHeaderString()
                        , x => MakeProjectStatusAddLinkAndText(x, currentFirmaSession, projectDetailsDictionary[x.ProjectID], projectLabel, hasProjectApprovalPermissionBySession, statusUpdateLabel)
                        , 100
                        , DhtmlxGridColumnFilterType.SelectFilterHtmlStrict
                        );
                }
                break;

            case ProjectCustomGridColumnEnum.FinalStatusUpdateStatus:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().UseProjectTimeline&& userHasEditProjectAsAdminPermissions)
                {
                    Add(FieldDefinitionEnum.FinalStatusUpdateStatus.ToType().ToGridHeaderString()
                        , x => projectDetailsDictionary[x.ProjectID].FinalStatusReportStatusDescription
                        , 100
                        , DhtmlxGridColumnFilterType.SelectFilterStrict
                        );
                }
                break;

            case ProjectCustomGridColumnEnum.GeospatialAreaName:
                break;

            case ProjectCustomGridColumnEnum.CustomAttribute:
                break;

            case ProjectCustomGridColumnEnum.ProjectCategory:
                if (MultiTenantHelpers.GetTenantAttributeFromCache().EnableProjectCategories)
                {
                    Add(FieldDefinitionEnum.ProjectCategory.ToType().ToGridHeaderString(), x => x.ProjectCategory.ProjectCategoryDisplayName, 140, DhtmlxGridColumnFilterType.SelectFilterStrict);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #3
0
        private void AddProjectCustomGridGeospatialAreaField(ProjectCustomGridConfiguration projectCustomGridConfiguration, Dictionary <int, vGeospatialArea> geospatialAreas, Dictionary <int, List <ProjectGeospatialArea> > projectGeospatialAreaDictionary)
        {
            var geospatialAreaType = projectCustomGridConfiguration.GeospatialAreaType;

            Add($"{geospatialAreaType.GeospatialAreaTypeNamePluralized}", a => a.GetProjectGeospatialAreaNamesAsHyperlinks(geospatialAreaType, geospatialAreas, projectGeospatialAreaDictionary), 350, DhtmlxGridColumnFilterType.Html);
        }