Esempio n. 1
0
        public override void DeleteRows(IEnumerable <DataRow> rows)
        {
            List <DataRow> DeleteRows = new List <DataRow>();
            Dictionary <string, DataRow> GroupRows = this.CreateFlowGroupRowDictionary();

            foreach (DataRow dr in rows)
            {
                string AutoGroupName = GetAutoGeneratedGroupName(dr);

                if (!GroupRows.ContainsKey(AutoGroupName))
                {
                    continue;
                }

                Debug.Assert(DataTableUtilities.GetDataBool(GroupRows[AutoGroupName], Constants.IS_AUTO_COLUMN_NAME));
                DeleteRows.Add(GroupRows[AutoGroupName]);
            }

            if (DeleteRows.Count > 0)
            {
                ((FlowGroupDataSheet)this.m_FlowGroupDataSheet).DeleteAutoGeneratedRows(DeleteRows);
            }

            base.DeleteRows(rows);
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the Flow Order Options
        /// </summary>
        /// <remarks></remarks>
        private void InitializeFlowOrderOptions()
        {
            DataRow dr = this.ResultScenario.GetDataSheet(Constants.DATASHEET_FLOW_ORDER_OPTIONS).GetDataRow();

            if (dr != null)
            {
                this.m_ApplyBeforeTransitions           = DataTableUtilities.GetDataBool(dr, "ApplyBeforeTransitions");
                this.m_ApplyEquallyRankedSimultaneously = DataTableUtilities.GetDataBool(dr, "ApplyEquallyRankedSimultaneously");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the flags for controlling SecondaryStratum and TertiaryStratum output
        /// </summary>
        private void Initialize_SS_TS_Flags()
        {
            DataRow dr = this.ResultScenario.GetDataSheet(Constants.DATASHEET_STSIM_OUTPUT_OPTIONS).GetDataRow();

            if (dr != null)
            {
                this.m_SummaryOmitSecondaryStrata = DataTableUtilities.GetDataBool(dr, "SummaryOutputOmitSS");
                this.m_SummaryOmitTertiaryStrata  = DataTableUtilities.GetDataBool(dr, "SummaryOutputOmitTS");
            }
        }
Esempio n. 4
0
        public override void Validate(DataTable proposedData, DataTransferMethod transferMethod)
        {
            base.Validate(proposedData, transferMethod);

            foreach (DataRow dr in proposedData.Rows)
            {
                if (!DataTableUtilities.GetDataBool(dr, Constants.IS_AUTO_COLUMN_NAME))
                {
                    ValidateName(Convert.ToString(dr[Constants.NAME_COLUMN_NAME], CultureInfo.InvariantCulture));
                }
            }
        }
Esempio n. 5
0
        public override void DeleteRows(IEnumerable <DataRow> rows)
        {
            List <DataRow> l = new List <DataRow>();

            foreach (DataRow dr in rows)
            {
                if (!DataTableUtilities.GetDataBool(dr, Constants.IS_AUTO_COLUMN_NAME))
                {
                    l.Add(dr);
                }
            }

            if (l.Count > 0)
            {
                base.DeleteRows(l);
            }
        }
Esempio n. 6
0
        protected bool AnyOutputOptionsSelected()
        {
            DataRow dr = this.ResultScenario.GetDataSheet(Constants.DATASHEET_OO_NAME).GetDataRow();

            if (dr == null)
            {
                return(false);
            }

            if (DataTableUtilities.GetDataBool(
                    dr, Constants.DATASHEET_OO_SUMMARY_OUTPUT_ST_COLUMN_NAME) ||
                DataTableUtilities.GetDataBool(dr, Constants.DATASHEET_OO_SUMMARY_OUTPUT_FL_COLUMN_NAME) ||
                DataTableUtilities.GetDataBool(dr, Constants.DATASHEET_OO_SPATIAL_OUTPUT_ST_COLUMN_NAME) ||
                DataTableUtilities.GetDataBool(dr, Constants.DATASHEET_OO_SPATIAL_OUTPUT_FL_COLUMN_NAME) ||
                DataTableUtilities.GetDataBool(dr, Constants.DATASHEET_OO_LATERAL_OUTPUT_FL_COLUMN_NAME))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes the output options
        /// </summary>
        /// <remarks></remarks>
        private void InitializeOutputOptions()
        {
            DataRow droo = this.ResultScenario.GetDataSheet(Constants.DATASHEET_OO_NAME).GetDataRow();

            Func <object, int> SafeInt = (object o) =>
            {
                if (o == DBNull.Value)
                {
                    return(0);
                }
                else
                {
                    return(Convert.ToInt32(o, CultureInfo.InvariantCulture));
                }
            };

            this.m_CreateSummaryStockOutput                   = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_SUMMARY_OUTPUT_ST_COLUMN_NAME]);
            this.m_SummaryStockOutputTimesteps                = SafeInt(droo[Constants.DATASHEET_OO_SUMMARY_OUTPUT_ST_TIMESTEPS_COLUMN_NAME]);
            this.m_CreateSummaryFlowOutput                    = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_SUMMARY_OUTPUT_FL_COLUMN_NAME]);
            this.m_SummaryFlowOutputTimesteps                 = SafeInt(droo[Constants.DATASHEET_OO_SUMMARY_OUTPUT_FL_TIMESTEPS_COLUMN_NAME]);
            this.m_CreateSpatialStockOutput                   = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_SPATIAL_OUTPUT_ST_COLUMN_NAME]);
            this.m_SpatialStockOutputTimesteps                = SafeInt(droo[Constants.DATASHEET_OO_SPATIAL_OUTPUT_ST_TIMESTEPS_COLUMN_NAME]);
            this.m_CreateSpatialFlowOutput                    = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_SPATIAL_OUTPUT_FL_COLUMN_NAME]);
            this.m_SpatialFlowOutputTimesteps                 = SafeInt(droo[Constants.DATASHEET_OO_SPATIAL_OUTPUT_FL_TIMESTEPS_COLUMN_NAME]);
            this.m_CreateLateralFlowOutput                    = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_LATERAL_OUTPUT_FL_COLUMN_NAME]);
            this.m_LateralFlowOutputTimesteps                 = SafeInt(droo[Constants.DATASHEET_OO_LATERAL_OUTPUT_FL_TIMESTEPS_COLUMN_NAME]);
            this.m_CreateAvgSpatialStockOutput                = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_ST_COLUMN_NAME]);
            this.m_AvgSpatialStockOutputTimesteps             = SafeInt(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_ST_TIMESTEPS_COLUMN_NAME]);
            this.m_AvgSpatialStockOutputAcrossTimesteps       = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_ST_ACROSS_TIMESTEPS_COLUMN_NAME]);
            this.m_CreateAvgSpatialFlowOutput                 = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_FL_COLUMN_NAME]);
            this.m_AvgSpatialFlowOutputTimesteps              = SafeInt(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_FL_TIMESTEPS_COLUMN_NAME]);
            this.m_AvgSpatialFlowOutputAcrossTimesteps        = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_FL_ACROSS_TIMESTEPS_COLUMN_NAME]);
            this.m_CreateAvgSpatialLateralFlowOutput          = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_LFL_COLUMN_NAME]);
            this.m_AvgSpatialLateralFlowOutputTimesteps       = SafeInt(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_LFL_TIMESTEPS_COLUMN_NAME]);
            this.m_AvgSpatialLateralFlowOutputAcrossTimesteps = DataTableUtilities.GetDataBool(droo[Constants.DATASHEET_OO_AVG_SPATIAL_OUTPUT_LFL_ACROSS_TIMESTEPS_COLUMN_NAME]);
        }
Esempio n. 8
0
        protected override void OnRowsModified(object sender, DataSheetRowEventArgs e)
        {
            List <DataRow> ModifyRows = new List <DataRow>();
            string         IdColName  = this.PrimaryKeyColumn.Name;
            Dictionary <string, DataRow> GroupRows     = this.CreateFlowGroupRowDictionary();
            Dictionary <string, bool>    ExistingNames = new Dictionary <string, bool>();

            foreach (string k in GroupRows.Keys)
            {
                ExistingNames.Add(k, true);
            }

            foreach (DataRow dr in this.m_FlowTypeDataTable.Rows)
            {
                if (dr.RowState == DataRowState.Deleted)
                {
                    continue;
                }

                int id = Convert.ToInt32(dr[IdColName], CultureInfo.InvariantCulture);

                if (!this.m_PrevNames.ContainsKey(id))
                {
                    continue;
                }

                string OldName          = this.m_PrevNames[id];
                string OldAutoGroupName = GetAutoGeneratedGroupName(OldName);

                if (!GroupRows.ContainsKey(OldAutoGroupName))
                {
                    continue;
                }

                string NewName = Convert.ToString(dr[Constants.NAME_COLUMN_NAME], CultureInfo.InvariantCulture);

                Debug.Assert(DataTableUtilities.GetDataBool(GroupRows[OldAutoGroupName], Constants.IS_AUTO_COLUMN_NAME));

                if (OldName != NewName)
                {
                    ModifyRows.Add(dr);
                }
            }

            if (ModifyRows.Count > 0)
            {
                this.m_FlowGroupDataSheet.BeginModifyRows();

                foreach (DataRow dr in ModifyRows)
                {
                    string OldName = this.m_PrevNames[Convert.ToInt32(dr[IdColName], CultureInfo.InvariantCulture)];
                    string NewName = Convert.ToString(dr[Constants.NAME_COLUMN_NAME], CultureInfo.InvariantCulture);

                    Debug.Assert(OldName != NewName);
                    Debug.Assert(!GroupRows.ContainsKey(GetAutoGeneratedGroupName(NewName)));

                    string OldAutoGroupName = GetAutoGeneratedGroupName(OldName);
                    string NewAutoGroupName = GetAutoGeneratedGroupName(NewName);

                    GroupRows[OldAutoGroupName][Constants.NAME_COLUMN_NAME] = NewAutoGroupName;
                }

                this.m_FlowGroupDataSheet.EndModifyRows();
            }

            base.OnRowsModified(sender, e);
        }
Esempio n. 9
0
        /// <summary>
        /// Sets whether or not this is a spatial model run
        /// </summary>
        /// <remarks></remarks>
        private void InitializeSpatialRunFlag()
        {
            DataRow drrc = this.ResultScenario.GetDataSheet(Constants.DATASHEET_STSIM_RUN_CONTROL).GetDataRow();

            this.m_IsSpatial = DataTableUtilities.GetDataBool(drrc["IsSpatial"]);
        }