internal void AddFlowMultiplier(FlowMultiplier multiplier)
        {
            if (multiplier.FlowMultiplierTypeId != this.m_FlowMultiplierTypeId)
            {
                throw new ArgumentException("The flow multiplier type is not correct.");
            }

            this.m_FlowMultipliers.Add(multiplier);
        }
Exemple #2
0
        private void FillFlowMultipliers()
        {
            Debug.Assert(this.m_FlowMultipliers.Count == 0);
            DataSheet ds = this.ResultScenario.GetDataSheet(Constants.DATASHEET_FLOW_MULTIPLIER_NAME);

            foreach (DataRow dr in ds.GetData().Rows)
            {
                int?   Iteration            = null;
                int?   Timestep             = null;
                int?   StratumId            = null;
                int?   SecondaryStratumId   = null;
                int?   TertiaryStratumId    = null;
                int?   StateClassId         = null;
                int    AgeMinimum           = 0;
                int    AgeMaximum           = int.MaxValue;
                int?   FlowMultiplierTypeId = null;
                int    FlowGroupId          = 0;
                double?MultiplierAmount     = null;
                int?   DistributionTypeId   = null;
                DistributionFrequency?DistributionFrequency = null;
                double?DistributionSD  = null;
                double?DistributionMin = null;
                double?DistributionMax = null;

                if (dr[Constants.ITERATION_COLUMN_NAME] != DBNull.Value)
                {
                    Iteration = Convert.ToInt32(dr[Constants.ITERATION_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.TIMESTEP_COLUMN_NAME] != DBNull.Value)
                {
                    Timestep = Convert.ToInt32(dr[Constants.TIMESTEP_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.STRATUM_ID_COLUMN_NAME] != DBNull.Value)
                {
                    StratumId = Convert.ToInt32(dr[Constants.STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.SECONDARY_STRATUM_ID_COLUMN_NAME] != DBNull.Value)
                {
                    SecondaryStratumId = Convert.ToInt32(dr[Constants.SECONDARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.TERTIARY_STRATUM_ID_COLUMN_NAME] != DBNull.Value)
                {
                    TertiaryStratumId = Convert.ToInt32(dr[Constants.TERTIARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.STATECLASS_ID_COLUMN_NAME] != DBNull.Value)
                {
                    StateClassId = Convert.ToInt32(dr[Constants.STATECLASS_ID_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.AGE_MIN_COLUMN_NAME] != DBNull.Value)
                {
                    AgeMinimum = Convert.ToInt32(dr[Constants.AGE_MIN_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.AGE_MAX_COLUMN_NAME] != DBNull.Value)
                {
                    AgeMaximum = Convert.ToInt32(dr[Constants.AGE_MAX_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.FLOW_MULTIPLIER_TYPE_ID_COLUMN_NAME] != DBNull.Value)
                {
                    FlowMultiplierTypeId = Convert.ToInt32(dr[Constants.FLOW_MULTIPLIER_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                FlowGroupId = Convert.ToInt32(dr[Constants.FLOW_GROUP_ID_COLUMN_NAME], CultureInfo.InvariantCulture);

                if (dr[Constants.VALUE_COLUMN_NAME] != DBNull.Value)
                {
                    MultiplierAmount = Convert.ToDouble(dr[Constants.VALUE_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.DISTRIBUTIONTYPE_COLUMN_NAME] != DBNull.Value)
                {
                    DistributionTypeId = Convert.ToInt32(dr[Constants.DISTRIBUTIONTYPE_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.DISTRIBUTION_FREQUENCY_COLUMN_NAME] != DBNull.Value)
                {
                    DistributionFrequency = (DistributionFrequency)(long)dr[Constants.DISTRIBUTION_FREQUENCY_COLUMN_NAME];
                }

                if (dr[Constants.DISTRIBUTIONSD_COLUMN_NAME] != DBNull.Value)
                {
                    DistributionSD = Convert.ToDouble(dr[Constants.DISTRIBUTIONSD_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.DISTRIBUTIONMIN_COLUMN_NAME] != DBNull.Value)
                {
                    DistributionMin = Convert.ToDouble(dr[Constants.DISTRIBUTIONMIN_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                if (dr[Constants.DISTRIBUTIONMAX_COLUMN_NAME] != DBNull.Value)
                {
                    DistributionMax = Convert.ToDouble(dr[Constants.DISTRIBUTIONMAX_COLUMN_NAME], CultureInfo.InvariantCulture);
                }

                try
                {
                    FlowMultiplier Item = new FlowMultiplier(
                        Iteration, Timestep,
                        StratumId, SecondaryStratumId, TertiaryStratumId,
                        StateClassId, AgeMinimum, AgeMaximum,
                        FlowMultiplierTypeId, FlowGroupId, MultiplierAmount,
                        DistributionTypeId, DistributionFrequency, DistributionSD, DistributionMin, DistributionMax);

                    Item.IsDisabled = (!Item.DistributionValue.HasValue && !Item.DistributionTypeId.HasValue);

                    if (!Item.IsDisabled)
                    {
                        this.m_STSimTransformer.DistributionProvider.Validate(
                            Item.DistributionTypeId, Item.DistributionValue, Item.DistributionSD,
                            Item.DistributionMin, Item.DistributionMax);
                    }

                    this.m_FlowMultipliers.Add(Item);
                }
                catch (Exception ex)
                {
                    throw new ArgumentException(ds.DisplayName + " -> " + ex.Message);
                }
            }
        }