Exemplo n.º 1
0
        private void AddAttributeValue(StateAttributeValue item)
        {
            AttributeValueAgeBinCollection AgeBins = this.GetItemExact(
                item.StateAttributeTypeId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId,
                item.StateClassId, item.Iteration, item.Timestep);

            if (AgeBins == null)
            {
                AgeBins = new AttributeValueAgeBinCollection(this.m_Project);

                this.AddItem(
                    item.StateAttributeTypeId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId,
                    item.StateClassId, item.Iteration, item.Timestep, AgeBins);
            }

            try
            {
                AttributeValueAgeBin Bin = AgeBins.GetOrCreateAgeBin(item.MinimumAge, item.MaximumAge);
                Bin.AddReference(new AttributeValueReference(item.TSTGroupId, item.TSTMin, item.TSTMax, item));
            }
            catch (STSimMapDuplicateItemException)
            {
                string template = "A duplicate State Attribute value has been created. More information:" +
                                  Environment.NewLine + "State Attribute={0}, State Class={1}, {2}={3}, {4}={5}, {6}={7}, MinAge={8}, MaxAge={9}, TSTMin={10}, TSTMax={11}, TSTGroup={12}, Iteration={13}, Timestep={14}." +
                                  Environment.NewLine + "NOTE: A user defined distribution can result in additional State Attributes when the model is run.";

                ExceptionUtils.ThrowArgumentException(template,
                                                      this.GetStateAttributeTypeName(item.StateAttributeTypeId),
                                                      this.GetStateClassName(item.StateClassId),
                                                      this.PrimaryStratumLabel,
                                                      this.GetStratumName(item.StratumId),
                                                      this.SecondaryStratumLabel,
                                                      this.GetSecondaryStratumName(item.SecondaryStratumId),
                                                      this.TertiaryStratumLabel,
                                                      this.GetTertiaryStratumName(item.TertiaryStratumId),
                                                      item.MinimumAge,
                                                      item.MaximumAge == int.MaxValue ? "NULL" : item.MaximumAge.ToString(),
                                                      STSimMapBase.FormatValue(item.TSTMin),
                                                      (!item.TSTMax.HasValue || item.TSTMax.Value == int.MaxValue) ? "NULL" : item.TSTMax.ToString(),
                                                      this.GetTSTGroupString(item.TSTGroupId),
                                                      STSimMapBase.FormatValue(item.Iteration),
                                                      STSimMapBase.FormatValue(item.Timestep));
            }

            Debug.Assert(this.HasItems);
        }
Exemplo n.º 2
0
        private void AddAttributeValue(StateAttributeValue item)
        {
            AttributeValueAgeBinCollection AgeBins = this.GetItemExact(
                item.StateAttributeTypeId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId,
                item.StateClassId, item.Iteration, item.Timestep);

            if (AgeBins == null)
            {
                AgeBins = new AttributeValueAgeBinCollection(this.m_Project);

                this.AddItem(
                    item.StateAttributeTypeId, item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId,
                    item.StateClassId, item.Iteration, item.Timestep, AgeBins);
            }

            try
            {
                AttributeValueAgeBin Bin = AgeBins.GetOrCreateAgeBin(item.MinimumAge, item.MaximumAge);
                Bin.AddReference(new AttributeValueReference(item.TSTGroupId, item.TSTMin, item.TSTMax, item));
            }
            catch (STSimMapDuplicateItemException ex)
            {
                string template = ex.Message + ".  More information:" +
                                  Environment.NewLine + "State Attribute={0}, {1}={2}, {3}={4}, {5}={6}, Iteration={7}, Timestep={8}." +
                                  Environment.NewLine + "NOTE: A user defined distribution can result in additional State Attributes when the model is run.";

                ExceptionUtils.ThrowArgumentException(template,
                                                      this.GetStateAttributeTypeName(item.StateAttributeTypeId),
                                                      this.PrimaryStratumLabel,
                                                      this.GetStratumName(item.StratumId),
                                                      this.SecondaryStratumLabel,
                                                      this.GetSecondaryStratumName(item.SecondaryStratumId),
                                                      this.TertiaryStratumLabel,
                                                      this.GetTertiaryStratumName(item.TertiaryStratumId),
                                                      STSimMapBase.FormatValue(item.Iteration),
                                                      STSimMapBase.FormatValue(item.Timestep));
            }

            Debug.Assert(this.HasItems);
        }