private void OnCLEMValidate(object sender, EventArgs e) { // validation is performed here // this event fires after Activity and Resource validation so that resources are available to check in the validation. // commencing is too early as Summary has not been created for reporting. // some values assigned in commencing will not be checked before processing, but will be caught here // each ZoneCLEM and Market will call this validation for all children // CLEM components above ZoneCLEM (e.g. RandomNumberGenerator) needs to validate itself if (!ZoneCLEM.Validate(this, "", this, Summary)) { string error = "@i:Invalid parameters in model"; // get all validations if (Summary.Messages() != null) { foreach (DataRow item in Summary.Messages().Rows) { if (item[3].ToString().StartsWith("Invalid")) { error += "\r\n" + item[3].ToString(); } } } throw new ApsimXException(this, error.Replace("­", ".")); } }
private void OnCLEMValidate(object sender, EventArgs e) { // validation is performed here // this event fires after Activity and Resource validation so that resources are available to check in the validation. // commencing is too early as Summary has not been created for reporting. // some values assigned in commencing will not be checked before processing, but will be caught here // each ZoneCLEM and Market will call this validation for all children // CLEM components above ZoneCLEM (e.g. RandomNumberGenerator) needs to validate itself if (!ZoneCLEM.Validate(this, "", this, Summary)) { string error = "@i:Invalid parameters in model"; // find IStorageReader of simulation IModel parentSimulation = FindAncestor <Simulation>(); IStorageReader ds = DataStore.Reader; if (ds.GetData(simulationName: parentSimulation.Name, tableName: "_Messages") != null) { DataRow[] dataRows = ds.GetData(simulationName: parentSimulation.Name, tableName: "_Messages").Select().OrderBy(a => a[7].ToString()).ToArray(); // all all current errors and validation problems to error string. foreach (DataRow dr in dataRows) { error += "\n" + dr[6].ToString(); } } throw new ApsimXException(this, error); } }
private void OnCLEMValidate(object sender, EventArgs e) { // validation is performed here // see ZoneCLEM OnCLEMValidate for more details if (!ZoneCLEM.Validate(this, "", this, summary)) { ZoneCLEM.ReportInvalidParameters(this); } }