Exemplo n.º 1
0
        public override void Validate(DataRow proposedRow, DataTransferMethod transferMethod)
        {
            base.Validate(proposedRow, transferMethod);

            List <string> ColNames = new List <string>();

            ColNames.Add(Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);
            ColNames.Add(Strings.DATASHEET_SPIC_SECONDARY_STRATUM_FILE_COLUMN_NAME);
            ColNames.Add(Strings.DATASHEET_SPIC_STATE_CLASS_FILE_COLUMN_NAME);
            ColNames.Add(Strings.DATASHEET_SPIC_AGE_FILE_COLUMN_NAME);

            DataTable            ThisData    = this.GetData();
            StochasticTimeRaster FirstRaster = null;

            if (ThisData.DefaultView.Count == 0)
            {
                FirstRaster = this.LoadRaster(proposedRow, Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);
            }
            else
            {
                FirstRaster = this.LoadRaster(ThisData.DefaultView[0].Row, Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);
            }

            try
            {
                ValidatingRasters?.Invoke(this, new EventArgs());

                foreach (string s in ColNames)
                {
                    if (proposedRow[s] != DBNull.Value)
                    {
                        StochasticTimeRaster rast = this.LoadRaster(proposedRow, s);

                        try
                        {
                            this.ValidateRaster(rast, FirstRaster.Height, FirstRaster.Width, s);
                        }
                        catch (Exception)
                        {
                            proposedRow[s] = DBNull.Value;
                            throw;
                        }
                    }
                }
            }
            finally
            {
                RastersValidated?.Invoke(this, new EventArgs());
            }
        }
Exemplo n.º 2
0
        protected override void BeforeImportData(DataTable proposedData, string importFileName)
        {
            base.BeforeImportData(proposedData, importFileName);

            if (proposedData.Rows.Count == 0)
            {
                return;
            }

            List <string> ColNames = new List <string>();

            ColNames.Add(Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);
            ColNames.Add(Strings.DATASHEET_SPIC_SECONDARY_STRATUM_FILE_COLUMN_NAME);
            ColNames.Add(Strings.DATASHEET_SPIC_STATE_CLASS_FILE_COLUMN_NAME);
            ColNames.Add(Strings.DATASHEET_SPIC_AGE_FILE_COLUMN_NAME);

            DataTable            ThisData    = this.GetData();
            StochasticTimeRaster FirstRaster = null;

            if (ThisData.DefaultView.Count == 0)
            {
                FirstRaster = this.LoadRaster(proposedData.Rows[0], Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);
            }
            else
            {
                FirstRaster = this.LoadRaster(ThisData.DefaultView[0].Row, Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);
            }

            try
            {
                ValidatingRasters?.Invoke(this, new EventArgs());

                foreach (DataRow dr in proposedData.Rows)
                {
                    if (dr.RowState != DataRowState.Deleted)
                    {
                        foreach (string s in ColNames)
                        {
                            if (dr[s] != DBNull.Value)
                            {
                                StochasticTimeRaster rast = this.LoadRaster(dr, s);

                                try
                                {
                                    this.ValidateRaster(rast, FirstRaster.Height, FirstRaster.Width, s);
                                }
                                catch (Exception)
                                {
                                    dr[s] = DBNull.Value;
                                    throw;
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                RastersValidated?.Invoke(this, new EventArgs());
            }
        }