private void VALIDATE_PROBABILISTIC_TRANSITIONS() { DTAnalyzer Analyzer = new DTAnalyzer(this.GetDataSheet(Strings.DATASHEET_DT_NAME).GetData(), this.Project); DataTable ptdata = this.GetDataSheet(Strings.DATASHEET_PT_NAME).GetData(); foreach (DataRow dr in ptdata.Rows) { if (dr.RowState == DataRowState.Deleted) { continue; } int?StratumIdSource = null; int StateClassIdSource = 0; int?StratumIdDest = null; int?StateClassIdDest = null; DTAnalyzer.GetPTFieldValues(dr, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); Debug.Assert(Analyzer.CanResolveStateClass(StratumIdSource, StratumIdSource, StateClassIdSource)); if (StateClassIdDest.HasValue) { Debug.Assert(Analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value)); } } }
public override void Validate(DataRow proposedRow, DataTransferMethod transferMethod) { base.Validate(proposedRow, transferMethod); DataTable dt = this.GetDataSheet(Strings.DATASHEET_DT_NAME).GetData(); DTAnalyzer Analyzer = new DTAnalyzer(dt, this.Project); int? StratumIdSource = null; int StateClassIdSource = 0; int? StratumIdDest = null; int? StateClassIdDest = null; DTAnalyzer.GetPTFieldValues(proposedRow, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); if (!Analyzer.CanResolveStateClass(StratumIdSource, StratumIdSource, StateClassIdSource)) { Analyzer.ThrowDataException(StateClassIdSource, false); } if (StateClassIdDest.HasValue) { if (!Analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value)) { Analyzer.ThrowDataException(StateClassIdDest.Value, true); } } }
private void VALIDATE_DETERMINISTIC_TRANSITIONS() { DataTable dtdata = this.GetData(); DTAnalyzer Analyzer = new DTAnalyzer(dtdata, this.Project); foreach (DataRow dr in dtdata.Rows) { if (dr.RowState == DataRowState.Deleted) { continue; } int?StratumIdSource = null; int StateClassIdSource = 0; int?StratumIdDest = null; int?StateClassIdDest = null; DTAnalyzer.GetDTFieldValues(dr, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); if (StateClassIdDest.HasValue) { Debug.Assert(Analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value)); } } }
public override void Validate(System.Data.DataTable proposedData, DataTransferMethod transferMethod) { base.Validate(proposedData, transferMethod); DataSheet DeterministicSheet = this.GetDataSheet(Strings.DATASHEET_DT_NAME); DTAnalyzer Analyzer = new DTAnalyzer(DeterministicSheet.GetData(), this.Project); const string IMPORT_ERROR = "Error importing transitions." + "\r\n" + "\r\n" + "Note that each probabilistic transition's source and destination state class must exist in " + "this scenario's deterministic transition records. More information:" + "\r\n" + "\r\n"; try { foreach (DataRow dr in proposedData.Rows) { int?StratumIdSource = null; int StateClassIdSource = 0; int?StratumIdDest = null; int?StateClassIdDest = null; DTAnalyzer.GetPTFieldValues(dr, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); if (!Analyzer.CanResolveStateClass(StratumIdSource, StratumIdSource, StateClassIdSource)) { Analyzer.ThrowDataException(StateClassIdSource, false); } if (StateClassIdDest.HasValue) { if (!Analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value)) { Analyzer.ThrowDataException(StateClassIdDest.Value, true); } } } } catch (DataException ex) { throw new DataException(IMPORT_ERROR + ex.Message); } }
/// <summary> /// Overrides Validate /// </summary> /// <param name="data"></param> /// <param name="transferMethod"></param> /// <returns></returns> /// <remarks> /// While the incoming state class Ids can themselves be valid, they must also be valid within the context of the union of the /// incoming data and the existing data. In other words, each destination state class must point to a source state class within /// the same stratum. /// </remarks> public override void Validate(System.Data.DataTable proposedData, DataTransferMethod transferMethod) { base.Validate(proposedData, transferMethod); DataTable dtdata = this.GetData(); DTAnalyzer AnalyzerExisting = new DTAnalyzer(dtdata, this.Project); DTAnalyzer AnalyzerProposed = new DTAnalyzer(proposedData, this.Project); foreach (DataRow ProposedRow in proposedData.Rows) { int?StratumIdSource = null; int StateClassIdSource = 0; int?StratumIdDest = null; int?StateClassIdDest = null; DTAnalyzer.GetDTFieldValues(ProposedRow, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); if (!StateClassIdDest.HasValue) { return; } //If the state class is not part of the incoming data then we need to see if it is part of the existing data, and //if it isn't then we can't continue. Note that if the import option is 'Overwrite' then the state class //will not appear in the existing data! bool ClassInClip = AnalyzerProposed.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value); bool ClassInExisting = AnalyzerExisting.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value); bool IsOverwrite = (transferMethod == SyncroSim.Core.DataTransferMethod.Overwrite); if (!ClassInClip) { if (IsOverwrite || (!ClassInExisting)) { AnalyzerExisting.ThrowDataException(StateClassIdDest.Value, true); } } //Also validate the location if (!DTAnalyzer.IsValidLocation(ProposedRow[Strings.DATASHEET_DT_LOCATION_COLUMN_NAME])) { throw new DataException(MessageStrings.ERROR_INVALID_CELL_ADDRESS); } } }
private bool ResolveProbabilisticTransitions(DTAnalyzer analyzer) { bool HasChanges = false; DataTable dt = this.GetDataSheet(Strings.DATASHEET_PT_NAME).GetData(); for (int Index = dt.Rows.Count - 1; Index >= 0; Index--) { DataRow dr = dt.Rows[Index]; if (dr.RowState == DataRowState.Deleted) { continue; } int?StratumIdSource = null; int StateClassIdSource = 0; int?StratumIdDest = null; int?StateClassIdDest = null; DTAnalyzer.GetDTFieldValues(dr, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); if (!analyzer.StateClassExists(StratumIdSource, StateClassIdSource)) { DataTableUtilities.DeleteTableRow(dt, dr); HasChanges = true; continue; } if (!StateClassIdDest.HasValue) { continue; } if (!analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value)) { DataTableUtilities.DeleteTableRow(dt, dr); HasChanges = true; } } return(HasChanges); }
private bool ResolveDeterministicTransitions(DTAnalyzer analyzer) { bool HasChanges = false; DataTable dt = this.GetData(); for (int Index = dt.Rows.Count - 1; Index >= 0; Index--) { DataRow dr = dt.Rows[Index]; if (dr.RowState == DataRowState.Deleted) { continue; } int?StratumIdSource = null; int StateClassIdSource = 0; int?StratumIdDest = null; int?StateClassIdDest = null; DTAnalyzer.GetDTFieldValues(dr, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); if (!StateClassIdDest.HasValue) { continue; } if (!analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value)) { dr[Strings.DATASHEET_DT_STRATUMIDDEST_COLUMN_NAME] = DBNull.Value; dr[Strings.DATASHEET_DT_STATECLASSIDDEST_COLUMN_NAME] = DBNull.Value; HasChanges = true; } } return(HasChanges); }
public override void Validate(DataRow proposedRow, DataTransferMethod transferMethod) { base.Validate(proposedRow, transferMethod); int?StratumIdSource = null; int StateClassIdSource = 0; int?StratumIdDest = null; int?StateClassIdDest = null; DTAnalyzer.GetDTFieldValues(proposedRow, ref StratumIdSource, ref StateClassIdSource, ref StratumIdDest, ref StateClassIdDest); if (!StateClassIdDest.HasValue) { return; } if (StateClassIdDest.Value == StateClassIdSource) { if (!StratumIdDest.HasValue) { return; } if (NullableUtilities.NullableIdsEqual(StratumIdSource, StratumIdDest)) { return; } } DTAnalyzer Analyzer = new DTAnalyzer(this.GetData(), this.Project); if (!Analyzer.CanResolveStateClass(StratumIdSource, StratumIdDest, StateClassIdDest.Value)) { Analyzer.ThrowDataException(StateClassIdDest.Value, true); } }