Example #1
0
        public void AddValue(EPDistributionValue value)
        {
            SortedKeyMap2 <DistributionValueCollection> m = this.m_Map.GetItemExact(
                value.JurisdictionId, value.DistributionTypeId);

            if (m == null)
            {
                m = new SortedKeyMap2 <DistributionValueCollection>(SearchMode.ExactPrevNext);
                this.m_Map.AddItem(value.JurisdictionId, value.DistributionTypeId, m);
            }

            DistributionValueCollection c = m.GetItemExact(value.Iteration, value.Timestep);

            if (c == null)
            {
                c = new DistributionValueCollection();
                m.AddItem(value.Iteration, value.Timestep, c);
            }

            c.Add(value);
        }
        private void FillDistributionValueCollection()
        {
            Debug.Assert(this.m_DistributionValues.Count == 0);
            DataSheet ds = this.Scenario.GetDataSheet(Shared.DISTRIBUTION_VALUE_DATASHEET_NAME);

            foreach (DataRow dr in ds.GetData().Rows)
            {
                try
                {
                    DistributionFrequency?ValueDistributionFrequency = null;

                    if (dr[Shared.DISTRIBUTION_VALUE_VALUE_DIST_FREQUENCY_COLUMN_NAME] != DBNull.Value)
                    {
                        ValueDistributionFrequency = (DistributionFrequency)(long)dr[Shared.DISTRIBUTION_VALUE_VALUE_DIST_FREQUENCY_COLUMN_NAME];
                    }

                    EPDistributionValue Item = new EPDistributionValue(
                        Shared.GetNullableInt(dr, Shared.ITERATION_COLUMN_NAME),
                        Shared.GetNullableInt(dr, Shared.TIMESTEP_COLUMN_NAME),
                        Shared.GetNullableInt(dr, Shared.JURISDICTION_COLUMN_NAME),
                        Convert.ToInt32(dr[Shared.DISTRIBUTION_VALUE_DIST_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture),
                        Shared.GetNullableInt(dr, Shared.DISTRIBUTION_VALUE_EXTVAR_TYPE_ID_COLUMN_NAME),
                        Shared.GetNullableDouble(dr, Shared.DISTRIBUTION_VALUE_EXTVAR_MIN_COLUMN_NAME),
                        Shared.GetNullableDouble(dr, Shared.DISTRIBUTION_VALUE_EXTVAR_MAX_COLUMN_NAME),
                        Shared.GetNullableDouble(dr, Shared.DISTRIBUTION_VALUE_DIST_VALUE_COLUMN_NAME),
                        Shared.GetNullableInt(dr, Shared.DISTRIBUTION_VALUE_VALUE_DIST_TYPE_ID_COLUMN_NAME), ValueDistributionFrequency,
                        Shared.GetNullableDouble(dr, Shared.DISTRIBUTION_VALUE_VALUE_DIST_SD_COLUMN_NAME),
                        Shared.GetNullableDouble(dr, Shared.DISTRIBUTION_VALUE_VALUE_DIST_MIN_COLUMN_NAME),
                        Shared.GetNullableDouble(dr, Shared.DISTRIBUTION_VALUE_VALUE_DIST_MAX_COLUMN_NAME),
                        Shared.GetNullableDouble(dr, Shared.DISTRIBUTION_VALUE_VALUE_DIST_RELATIVE_FREQUENCY_COLUMN_NAME));

                    this.Validate(Item.ValueDistributionTypeId, Item.Value, Item.ValueDistributionSD, Item.ValueDistributionMin, Item.ValueDistributionMax);
                    this.m_DistributionValues.Add(Item);
                }
                catch (Exception ex)
                {
                    throw new ArgumentException(ds.DisplayName + " -> " + ex.Message);
                }
            }
        }