예제 #1
0
        private void AddAttributeValue(TransitionAttributeValue item)
        {
            AttributeValueAgeBinCollection AgeBins = this.GetItemExact(
                item.TransitionAttributeTypeId, item.TransitionGroupId,
                item.StratumId, item.SecondaryStratumId, item.TertiaryStratumId,
                item.StateClassId, item.Iteration, item.Timestep);

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

                this.AddItem(
                    item.TransitionAttributeTypeId, item.TransitionGroupId,
                    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 Transition Attribute value has been created. More information:" +
                                  Environment.NewLine + "Transition Attribute={0}, Transition Group={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 Transition Attributes when the model is run.";

                ExceptionUtils.ThrowArgumentException(template,
                                                      this.GetTransitionAttributeTypeName(item.TransitionAttributeTypeId),
                                                      this.GetTransitionGroupName(item.TransitionGroupId),
                                                      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));
            }

            if (!this.m_TypeGroupMap.ContainsKey(item.TransitionGroupId))
            {
                this.m_TypeGroupMap.Add(item.TransitionGroupId, new Dictionary <int, bool>());
            }

            Dictionary <int, bool> d = TypeGroupMap[item.TransitionGroupId];

            if (!d.ContainsKey(item.TransitionAttributeTypeId))
            {
                d.Add(item.TransitionAttributeTypeId, true);
            }

            Debug.Assert(this.HasItems);
        }
예제 #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);
        }