public static ThrowInvalidOperationException ( string message ) : void | ||
message | string | |
리턴 | void |
private List <int> GetApplicableSecondaryStrata() { List <int> l = new List <int>(); string psl = null; string ssl = null; string tsl = null; TerminologyUtilities.GetStratumLabelTerminology(this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref psl, ref ssl, ref tsl); DataSheet ds = this.ResultScenario.GetDataSheet(Strings.DATASHEET_NSIC_DISTRIBUTION_NAME); foreach (DataRow dr in ds.GetData().Rows) { if (dr[Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME] == DBNull.Value) { ExceptionUtils.ThrowInvalidOperationException( "Cannot split by '{0}' because '{1}' is not specified for all records in Initial Conditions Distribution.", ssl, ssl); } int id = Convert.ToInt32(dr[Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); if (!l.Contains(id)) { l.Add(id); } } Debug.Assert(l.Count > 0); return(l); }
private void ThrowNoValuesException(string message, int distributionTypeId, int iteration, int timestep, int?stratumId, int?secondaryStratumId) { string StratumName = "NULL"; string SecondaryStratumName = "NULL"; if (stratumId.HasValue) { StratumName = this.GetProjectItemName(Strings.DATASHEET_STRATA_NAME, stratumId.Value); } if (secondaryStratumId.HasValue) { SecondaryStratumName = this.GetProjectItemName(Strings.DATASHEET_SECONDARY_STRATA_NAME, secondaryStratumId.Value); } ExceptionUtils.ThrowInvalidOperationException(message, this.GetProjectItemName(Strings.DISTRIBUTION_TYPE_DATASHEET_NAME, distributionTypeId), iteration, timestep, StratumName, SecondaryStratumName); }
private void ValidateNormalSplit() { string psl = null; string ssl = null; string tsl = null; string aml = null; TerminologyUnit amu = 0; DataSheet tds = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME); TerminologyUtilities.GetStratumLabelTerminology(tds, ref psl, ref ssl, ref tsl); TerminologyUtilities.GetAmountLabelTerminology(tds, ref aml, ref amu); //We don't support splits by secondary strata for spatial runs as this time if (this.IsSpatial) { ExceptionUtils.ThrowInvalidOperationException("Cannot split by '{0}' for a spatial model run.", ssl); } //If there are less than 2 secondary strata records referenced by //Initial Conditions Distribution we cannot do a split by secondary strata List <int> l = this.GetApplicableSecondaryStrata(); if (l.Count < 2) { ExceptionUtils.ThrowInvalidOperationException("Cannot split by '{0}' because there are fewer than two references to '{1}' in Initial Conditions Distribution.", ssl, ssl); } //If there are Transition Targets with NULL secondary stata then add a warning if (NullValueExists(this.ResultScenario.GetDataSheet(Strings.DATASHEET_TRANSITION_TARGET_NAME).GetData(), Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME)) { this.RecordStatus(StatusType.Warning, string.Format(CultureInfo.InvariantCulture, "Run is splitting by '{0}' but Transition Targets are not specified by '{1}'. Allocating targets in proportion to '{2}'.", ssl, ssl, aml)); } //If there are Transition Attribute Targets with NULL secondary stata then add a warning if (NullValueExists(this.ResultScenario.GetDataSheet(Strings.DATASHEET_TRANSITION_ATTRIBUTE_TARGET_NAME).GetData(), Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME)) { this.RecordStatus(StatusType.Warning, string.Format(CultureInfo.InvariantCulture, "Run is splitting by '{0}' but Transition Attribute Targets are not specified by '{1}'. Allocating targets in proportion to '{2}'.", ssl, ssl, aml)); } }