public override void Build(IEnumerable <IParameter> parameters, OSPSuiteTracker buildTracker) { var listToReport = new List <object>(); var sortedParameters = parameters.OrderBy(x => x.Name).ToList(); var parameterConstantsTable = tableForConstants(sortedParameters, buildTracker.Settings.Verbose); if (parameterConstantsTable.Rows.Count > 0) { listToReport.Add(new SubParagraph(Constants.CONSTANTS)); listToReport.Add(parameterConstantsTable); } if (sortedParameters.Count > parameterConstantsTable.Rows.Count) { listToReport.Add(new SubParagraph(Constants.PARAMETERS)); foreach (var parameter in sortedParameters) { var constant = parameter.Formula as ConstantFormula; if (constant != null) { continue; } listToReport.Add(new SubParagraph(parameter.Name)); var distributedParameter = parameter as DistributedParameter; if (distributedParameter != null) { listToReport.Add(new Par()); listToReport.Add(String.Format(Constants.PROPERTY_PROMPT_FORMAT, Constants.BUILD_MODE, distributedParameter.BuildMode)); listToReport.Add(String.Format(Constants.PROPERTY_PROMPT_FORMAT, Constants.PERCENTILE, distributedParameter.Percentile)); listToReport.Add(String.Format(Constants.PROPERTY_PROMPT_FORMAT, Constants.CAN_BE_VARIED, distributedParameter.CanBeVaried)); listToReport.Add(String.Format(Constants.PROPERTY_PROMPT_FORMAT, Constants.VISIBLE, distributedParameter.Visible)); listToReport.Add(String.Format(Constants.PROPERTY_PROMPT_FORMAT, Constants.VALUE, String.Format("{0} {1}", _reportingHelper.ConvertToDisplayUnit( distributedParameter.DisplayUnit, distributedParameter.Dimension, (float)distributedParameter.Value), _reportingHelper.GetDisplayUnitFor(distributedParameter).Name))); } listToReport.Add(parameter.Formula); listToReport.Add(new Par()); listToReport.Add(parameter.RHSFormula); if (parameter.Tags.Any()) { listToReport.Add(new Par()); listToReport.Add(parameter.Tags); } } } _builderRepository.Report(listToReport, buildTracker); }
private IEnumerable <DataTable> tablesFor(DataRepository dataRepository) { var tableList = new List <DataTable>(); foreach (var col in dataRepository.AllButBaseGrid()) { if (col.DataInfo.AuxiliaryType != AuxiliaryType.Undefined) { continue; } var table = new DataTable(col.Name); table.AddColumn <float>(col.BaseGrid.Name).SetUnit(col.BaseGrid.DataInfo.DisplayUnitName); var column = table.AddColumn <float>(col.Name); column.SetUnit(col.DataInfo.DisplayUnitName); addMolWeight(col, column); var geometricMeanPopError = createRelatedColumnFor(table, col, AuxiliaryType.GeometricMeanPop, Constants.GEOMETRIC_MEAN_POP); var arithmeticMeanPopError = createRelatedColumnFor(table, col, AuxiliaryType.ArithmeticMeanPop, Constants.ARITHMETRIC_MEAN_POP); var geometricStdDevError = createRelatedColumnFor(table, col, AuxiliaryType.GeometricStdDev, Constants.GEOMETRIC_STD_DEV); var arithmeticStdDevError = createRelatedColumnFor(table, col, AuxiliaryType.ArithmeticStdDev, Constants.ARITHMETRIC_STD_DEV); var dimension = _dimensionFactory.MergedDimensionFor(col); var baseGridUnit = _reportingHelper.GetDisplayUnitFor(col.BaseGrid.Dimension.Unit(col.BaseGrid.DataInfo.DisplayUnitName), col.BaseGrid.Dimension); var colUnit = _reportingHelper.GetDisplayUnitFor(dimension.Unit(col.DataInfo.DisplayUnitName), dimension); table.BeginLoadData(); for (var i = 0; i < col.BaseGrid.InternalValues.Count(); i++) { var newRow = table.NewRow(); newRow[col.BaseGrid.Name] = _reportingHelper.ConvertToDisplayUnit(baseGridUnit, col.BaseGrid.Dimension, col.BaseGrid.Values[i]); newRow[col.Name] = _reportingHelper.ConvertToDisplayUnit(colUnit, col.Dimension, col.Values[i]); updateRelateColumnValue(newRow, geometricMeanPopError, i); updateRelateColumnValue(newRow, arithmeticMeanPopError, i); updateRelateColumnValue(newRow, geometricStdDevError, i); updateRelateColumnValue(newRow, arithmeticStdDevError, i); table.Rows.Add(newRow); } table.EndLoadData(); table.AcceptChanges(); tableList.Add(table); } return(tableList); }
private DataTable tableFor(IEnumerable <IParameterStartValue> parameterStartValues, bool verbose) { var parameterStartValueTable = new DataTable(Constants.PARAMETER_START_VALUES); parameterStartValueTable.Columns.Add(Constants.ID, typeof(string)).AsHidden(); parameterStartValueTable.Columns.Add(Constants.PARAMETER, typeof(string)); parameterStartValueTable.Columns.Add(Constants.CONTAINER_PATH, typeof(string)).AsHidden(); parameterStartValueTable.Columns.Add(Constants.LEVELS, typeof(int)).AsHidden(); parameterStartValueTable.Columns.Add(Constants.START_VALUE, typeof(double)); parameterStartValueTable.Columns.Add(Constants.UNIT, typeof(string)); parameterStartValueTable.Columns.Add(Constants.FORMULA, typeof(string)); var descriptionTable = new DataTable(); descriptionTable.Columns.Add(Constants.ID, typeof(string)); descriptionTable.Columns.Add(Constants.DESCRIPTION, typeof(string)); parameterStartValueTable.BeginLoadData(); descriptionTable.BeginLoadData(); foreach (var parameterStartValue in parameterStartValues) { var newParameterStartValueRow = parameterStartValueTable.NewRow(); var levels = parameterStartValue.Path.PathAsString.Split('|'); newParameterStartValueRow[Constants.ID] = parameterStartValue.Id; newParameterStartValueRow[Constants.PARAMETER] = levels[levels.Length - 1]; newParameterStartValueRow[Constants.CONTAINER_PATH] = String.Join("|", levels.Take(levels.Length - 1)); newParameterStartValueRow[Constants.LEVELS] = levels.Length; if (parameterStartValue.StartValue != null) { newParameterStartValueRow[Constants.START_VALUE] = _reportingHelper.ConvertToDisplayUnit(parameterStartValue, parameterStartValue.StartValue); } newParameterStartValueRow[Constants.UNIT] = _reportingHelper.GetDisplayUnitFor(parameterStartValue); newParameterStartValueRow[Constants.FORMULA] = (parameterStartValue.Formula == null) ? (object)DBNull.Value : parameterStartValue.Formula.Name; parameterStartValueTable.Rows.Add(newParameterStartValueRow); if (String.IsNullOrEmpty(parameterStartValue.Description)) { continue; } var newDescriptionRow = descriptionTable.NewRow(); newDescriptionRow[Constants.ID] = parameterStartValue.Id; newDescriptionRow[Constants.DESCRIPTION] = parameterStartValue.Description; descriptionTable.Rows.Add(newDescriptionRow); } descriptionTable.EndLoadData(); parameterStartValueTable.EndLoadData(); if (verbose) { var ds = new DataSet(); ds.Tables.Add(parameterStartValueTable); ds.Tables.Add(descriptionTable); ds.Relations.Add(parameterStartValueTable.Columns[Constants.ID], descriptionTable.Columns[Constants.ID]); } return(parameterStartValueTable); }
private DataTable tableFor(IEnumerable <IMoleculeStartValue> moleculeStartValues, bool verbose) { var moleculeStartValueTable = new DataTable(Constants.MOLECULE_START_VALUES); moleculeStartValueTable.Columns.Add(Constants.MOLECULE_PATH, typeof(string)).AsHidden(); moleculeStartValueTable.Columns.Add(Constants.CONTAINER_PATH, typeof(string)).AsHidden(); moleculeStartValueTable.Columns.Add(Constants.MOLECULE_NAME, typeof(string)); moleculeStartValueTable.Columns.Add(Constants.START_VALUE, typeof(float)); moleculeStartValueTable.Columns.Add(Constants.FORMULA, typeof(string)); moleculeStartValueTable.Columns.Add(Constants.UNIT, typeof(string)); moleculeStartValueTable.Columns.Add(Constants.IS_PRESENT, typeof(string)); moleculeStartValueTable.Columns.Add(Constants.SCALE_DIVISOR, typeof(double)); var descriptionTable = new DataTable(); descriptionTable.Columns.Add(Constants.MOLECULE_PATH, typeof(string)); descriptionTable.Columns.Add(Constants.DESCRIPTION, typeof(string)); moleculeStartValueTable.BeginLoadData(); descriptionTable.BeginLoadData(); foreach (var moleculeStartValue in moleculeStartValues) { var newMoleculeStartValueRow = moleculeStartValueTable.NewRow(); newMoleculeStartValueRow[Constants.MOLECULE_PATH] = moleculeStartValue.Path; newMoleculeStartValueRow[Constants.CONTAINER_PATH] = moleculeStartValue.ContainerPath; newMoleculeStartValueRow[Constants.MOLECULE_NAME] = moleculeStartValue.MoleculeName; if (moleculeStartValue.StartValue != null) { newMoleculeStartValueRow[Constants.START_VALUE] = _reportingHelper.ConvertToDisplayUnit(moleculeStartValue, moleculeStartValue.StartValue); } newMoleculeStartValueRow[Constants.UNIT] = _reportingHelper.GetDisplayUnitFor(moleculeStartValue); newMoleculeStartValueRow[Constants.IS_PRESENT] = moleculeStartValue.IsPresent; newMoleculeStartValueRow[Constants.SCALE_DIVISOR] = moleculeStartValue.ScaleDivisor; if (moleculeStartValue.Formula != null) { newMoleculeStartValueRow[Constants.FORMULA] = moleculeStartValue.Formula.Name; } moleculeStartValueTable.Rows.Add(newMoleculeStartValueRow); if (String.IsNullOrEmpty(moleculeStartValue.Description)) { continue; } var newDescriptionRow = descriptionTable.NewRow(); newDescriptionRow[Constants.MOLECULE_PATH] = moleculeStartValue.Path; newDescriptionRow[Constants.DESCRIPTION] = moleculeStartValue.Description; descriptionTable.Rows.Add(newDescriptionRow); } descriptionTable.EndLoadData(); moleculeStartValueTable.EndLoadData(); if (verbose) { var ds = new DataSet(); ds.Tables.Add(moleculeStartValueTable); ds.Tables.Add(descriptionTable); ds.Relations.Add(moleculeStartValueTable.Columns[Constants.MOLECULE_PATH], descriptionTable.Columns[Constants.MOLECULE_PATH]); } return(moleculeStartValueTable); }