예제 #1
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]);
        }
예제 #2
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);
        }
예제 #3
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"]);
        }