예제 #1
0
        public override void Validate(DataTable proposedData, DataTransferMethod transferMethod)
        {
            base.Validate(proposedData, transferMethod);

            DataSheet StockTypeSheet          = this.Project.GetDataSheet(Constants.DATASHEET_STOCK_TYPE_NAME);
            DataSheet DiagramSheet            = this.GetDataSheet(Constants.DATASHEET_FLOW_PATHWAY_DIAGRAM_NAME);
            Dictionary <int, bool> StockTypes = LookupKeyUtilities.CreateRecordLookup(DiagramSheet, Constants.STOCK_TYPE_ID_COLUMN_NAME);

            foreach (DataRow dr in proposedData.Rows)
            {
                if (dr[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value)
                {
                    int FromStockTypeId = Convert.ToInt32(dr[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture);

                    if (!StockTypes.ContainsKey(FromStockTypeId))
                    {
                        string StockTypeName = Convert.ToString(DataTableUtilities.GetTableValue(StockTypeSheet.GetData(), StockTypeSheet.ValueMember, FromStockTypeId, StockTypeSheet.DisplayMember), CultureInfo.InvariantCulture);
                        throw new DataException(string.Format(CultureInfo.InvariantCulture, "Cannot import flow pathways because the 'From Stock' does not exist in this scenario: {0}", StockTypeName));
                    }
                }

                if (dr[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value)
                {
                    int ToStockTypeId = Convert.ToInt32(dr[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture);

                    if (!StockTypes.ContainsKey(ToStockTypeId))
                    {
                        string StockTypeName = Convert.ToString(DataTableUtilities.GetTableValue(StockTypeSheet.GetData(), StockTypeSheet.ValueMember, ToStockTypeId, StockTypeSheet.DisplayMember), CultureInfo.InvariantCulture);
                        throw new DataException(string.Format(CultureInfo.InvariantCulture, "Cannot import flow pathways because the 'To Stock' does not exist in this scenario: {0}", StockTypeName));
                    }
                }
            }
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
        public override void Validate(DataRow proposedRow, DataTransferMethod transferMethod)
        {
            base.Validate(proposedRow, transferMethod);

            DataSheet DiagramSheet            = this.GetDataSheet(Constants.DATASHEET_FLOW_PATHWAY_DIAGRAM_NAME);
            Dictionary <int, bool> StockTypes = LookupKeyUtilities.CreateRecordLookup(DiagramSheet, Constants.STOCK_TYPE_ID_COLUMN_NAME);

            if (proposedRow[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value)
            {
                int FromStockTypeId = Convert.ToInt32(proposedRow[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture);

                if (!StockTypes.ContainsKey(FromStockTypeId))
                {
                    throw new DataException("The 'From Stock' does not exist for this scenario.");
                }
            }

            if (proposedRow[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value)
            {
                int ToStockTypeId = Convert.ToInt32(proposedRow[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture);

                if (!StockTypes.ContainsKey(ToStockTypeId))
                {
                    throw new DataException("The 'To Stock' does not exist for this scenario.");
                }
            }
        }
예제 #4
0
        public override void Validate(DataRow proposedRow, DataTransferMethod transferMethod)
        {
            bool ResetNull = false;

            //It's not possible to have NULL for a display member, but we want the user to be able to
            //have this name be auto-generated.  To avoid a validation failure because of a NULL here
            //we are going to fix up the Name with a default value until the validation is done and then
            //set it back to NULL.  The OnRowsAdded() override will auto-generate the name.  Note that
            //this should only be done for detached rows (i.e. rows that are being editing by a control
            //such as the DataGridView...)

            if (proposedRow[Strings.DATASHEET_NAME_COLUMN_NAME] == DBNull.Value &&
                proposedRow.RowState == DataRowState.Detached)
            {
                proposedRow[Strings.DATASHEET_NAME_COLUMN_NAME] = TEMP_NAME_VALUE;
                ResetNull = true;
            }

            try
            {
                base.Validate(proposedRow, transferMethod);
            }
            finally
            {
                if (ResetNull)
                {
                    proposedRow[Strings.DATASHEET_NAME_COLUMN_NAME] = DBNull.Value;
                }
            }
        }
예제 #5
0
        public override void Validate(DataTable proposedData, DataTransferMethod transferMethod)
        {
            base.Validate(proposedData, transferMethod);

            foreach (DataRow dr in proposedData.Rows)
            {
                if (!DataTableUtilities.GetDataBool(dr, Strings.IS_AUTO_COLUMN_NAME))
                {
                    ValidateName(Convert.ToString(dr[Strings.DATASHEET_NAME_COLUMN_NAME], CultureInfo.InvariantCulture));
                }
            }
        }
예제 #6
0
        public static DataTransferMethodExt ConvertIntToExt(this DataTransferMethod obj)
        {
            var convert = new DataTransferMethodExt()
            {
                SubmittedTaskId = obj.SubmittedTaskId,
                Port            = obj.Port,
                NodeIPAddress   = obj.NodeIPAddress,
                NodePort        = obj.NodePort
            };

            return(convert);
        }
예제 #7
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());
            }
        }
예제 #8
0
 public DataTransferMethodExt GetDataTransferMethod(string nodeIPAddress, int nodePort, long submittedTaskInfoId, string sessionCode)
 {
     try
     {
         using (IUnitOfWork unitOfWork = UnitOfWorkFactory.GetUnitOfWorkFactory().CreateUnitOfWork())
         {
             AdaptorUser        loggedUser         = UserAndLimitationManagementService.GetValidatedUserForSessionCode(sessionCode, unitOfWork, UserRoleType.Submitter);
             IDataTransferLogic dataTransferLogic  = LogicFactory.GetLogicFactory().CreateDataTransferLogic(unitOfWork);
             DataTransferMethod dataTransferMethod = dataTransferLogic.GetDataTransferMethod(nodeIPAddress, nodePort, submittedTaskInfoId, loggedUser);
             return(dataTransferMethod.ConvertIntToExt());
         }
     }
     catch (Exception exc)
     {
         ExceptionHandler.ThrowProperExternalException(exc);
         return(default);
        /// <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);
                }
            }
        }
예제 #10
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);
            }
        }
        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);
            }
        }
예제 #12
0
 public override void Validate(DataRow proposedRow, DataTransferMethod transferMethod)
 {
     base.Validate(proposedRow, transferMethod);
     ValidateName(Convert.ToString(proposedRow[Strings.DATASHEET_NAME_COLUMN_NAME], CultureInfo.InvariantCulture));
 }