コード例 #1
0
ファイル: GridTableHelper.cs プロジェクト: sybrix/EdFi-App
        private static object CreateMetricCell(MetadataColumn column, StudentWithMetrics.Metric m)
        {
            if (column.MetricListCellType == MetricListCellType.AssessmentMetric)
            {
                var assessmentMetric = m as StudentWithMetrics.IndicatorMetric;
                if (assessmentMetric != null)
                {
                    if (assessmentMetric.Value != null)
                    {
                        var assessmentCellType = typeof(AssessmentMetricCellItem<>).MakeGenericType(GetTypeArray(assessmentMetric.Value.GetType()));
                        dynamic cellForMetricValue = Activator.CreateInstance(assessmentCellType);
                        cellForMetricValue.V = assessmentMetric.Value;
                        cellForMetricValue.DV = assessmentMetric.DisplayValue;
                        cellForMetricValue.A = (int)assessmentMetric.MetricIndicator;
                        cellForMetricValue.S = (int)assessmentMetric.State;
                        return cellForMetricValue;
                    }

                    return new AssessmentMetricCellItem<double?>
                               {
                                   DV = assessmentMetric.DisplayValue,
                                   V = assessmentMetric.Value,
                                   A = (int)assessmentMetric.MetricIndicator,
                                   S = (int)assessmentMetric.State,
                               };
                }
                return new AssessmentMetricCellItem<string>();
            }

            //Trend Metric
            if (column.MetricListCellType == MetricListCellType.TrendMetric)
            {
                var trendMetric = m as StudentWithMetrics.TrendMetric;
                if (trendMetric != null)
                {
                    if (trendMetric.Value != null)
                    {
                        var trendCellType = typeof(TrendMetricCellItem<>).MakeGenericType(GetTypeArray(trendMetric.Value.GetType()));
                        dynamic trendCellForMetricValue = Activator.CreateInstance(trendCellType);
                        trendCellForMetricValue.V = trendMetric.Value;
                        trendCellForMetricValue.DV = trendMetric.DisplayValue;
                        trendCellForMetricValue.T = trendMetric.Trend.ToString();
                        trendCellForMetricValue.S = (int)trendMetric.State;
                        return trendCellForMetricValue;
                    }

                    return new TrendMetricCellItem<double?>
                               {
                                   DV = trendMetric.DisplayValue,
                                   V = trendMetric.Value,
                                   T = trendMetric.Trend.ToString(),
                                   S = (int)trendMetric.State,
                               };
                }
                return new TrendMetricCellItem<string>();
            }

            if (m != null)
            {
                if (m.Value != null)
                {
                    var metricCellType =
                        typeof(MetricCellItem<>).MakeGenericType(GetTypeArray(m.Value.GetType()));
                    dynamic metricCellForMetricValue = Activator.CreateInstance(metricCellType);
                    metricCellForMetricValue.V = m.Value;
                    metricCellForMetricValue.DV = m.DisplayValue;
                    metricCellForMetricValue.S = (int)m.State;
                    return metricCellForMetricValue;
                }

                return new MetricCellItem<double?>
                           {
                               DV = m.DisplayValue,
                               V = m.Value,
                               S = (int)m.State,
                           };
            }

            return new MetricCellItem<string>();
        }
コード例 #2
0
        protected void PrepareMetric(StudentWithMetrics.Metric additionalMetric, int uniqueIdentifier, int? metricVariantId, string metricValue, int? stateTypeId, string valueType, string displayValueFormat)
        {
            if (metricVariantId == null)
                return;

            additionalMetric.UniqueIdentifier = uniqueIdentifier;
            additionalMetric.MetricVariantId = metricVariantId.Value;
            additionalMetric.Value = InstantiateValue.FromValueType(metricValue, valueType);
            if (additionalMetric.Value == null)
                additionalMetric.DisplayValue = String.Empty;
            else if (displayValueFormat != null)
                additionalMetric.DisplayValue = String.Format(displayValueFormat, additionalMetric.Value);
            else
                additionalMetric.DisplayValue = String.Format("{0}", additionalMetric.Value);

            if (stateTypeId.HasValue)
                additionalMetric.State = (MetricStateType)stateTypeId.Value;
            else
            {
                var metricId = metricNodeResolver.ResolveMetricId(metricVariantId.Value);
                additionalMetric.State = metricStateProvider.GetState(metricId, metricValue, valueType).StateType;
            }
        }
コード例 #3
0
ファイル: GridTableHelper.cs プロジェクト: sybrix/EdFi-App
        private static object CreateEntityInformationCell(MetadataColumn column, StudentWithMetrics s, string uniqueListId)
        {
            if (string.Equals(column.ColumnName, "Flag", StringComparison.OrdinalIgnoreCase))
                return new FlagCellItem<bool> { V = s.IsFlagged, F = s.IsFlagged, };

            if (string.Equals(column.ColumnName, "Student", StringComparison.OrdinalIgnoreCase))
                return new StudentCellItem<string>(s.StudentUSI)
                {
                    V = s.Name,
                    DV = s.Name,
                    I = s.ThumbNail,
                    LUId = uniqueListId,
                    CId = s.SchoolId,
                    //Lets go and resolve the metric to a child one...
                    Url = s.Href != null ? s.Href.Href : null,
                    Links = s.Links
                };

            if (string.Equals(column.ColumnName, "Designations", StringComparison.OrdinalIgnoreCase))
            {
                var studentMetricWithAccommodations = (StudentWithMetricsAndAccommodations)s;
                return new DesignationsCellItem<string> { V = studentMetricWithAccommodations.Accommodations.Count.ToString(), D = studentMetricWithAccommodations.Accommodations };
            }

            if (string.Equals(column.ColumnName, "Grade Level", StringComparison.OrdinalIgnoreCase))
            {
                return new CellItem<int> { DV = s.GradeLevelDisplayValue, V = s.GradeLevel };
            }

            if (string.Equals(column.ColumnName, "School", StringComparison.OrdinalIgnoreCase))
            {
                return new CellItem<string> { DV = s.SchoolName };
            }

            if (string.Equals(column.ColumnName, "Metric Value", StringComparison.OrdinalIgnoreCase)
                || string.Equals(column.ColumnName, "Demographic", StringComparison.OrdinalIgnoreCase)
                || column.MetricListCellType == MetricListCellType.MetricValue)
            {
                var studentMetricWithPrimaryMetric = s as StudentWithMetricsAndPrimaryMetric ?? new StudentWithMetricsAndPrimaryMetric(s.StudentUSI);
                var cellType = (studentMetricWithPrimaryMetric.PrimaryMetricValue == null) ? typeof(CellItem<string>) : typeof(CellItem<>).MakeGenericType(GetTypeArray(studentMetricWithPrimaryMetric.PrimaryMetricValue.GetType()));
                dynamic cellForMetricValue = Activator.CreateInstance(cellType);
                cellForMetricValue.V = studentMetricWithPrimaryMetric.PrimaryMetricValue;
                cellForMetricValue.DV = studentMetricWithPrimaryMetric.PrimaryMetricDisplayValue;
                return cellForMetricValue;
            }

            return new CellItem<string> { DV = "New Entity information. Missing Logic." };
        }