Ejemplo n.º 1
0
        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_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));
                }
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }