コード例 #1
0
        /// <summary>
        /// Retrieve data columns from table name
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        /// <remarks>Only float columns are return</remarks>
        public StringCollection getDataColumns(string tableName)
        {
            StringCollection cols = new StringCollection();

            if (tableName == null)
            {
                return(cols);
            }

            tableName = tableName.Trim();
            if (tableName.Length == 0)
            {
                return(cols);
            }

            if (!_columns.ContainsKey(tableName))
            {
                if (_scenario == null)
                {
                    return(cols);
                }

                DataTable dt = _scenario.GetDataTable(
                    string.Format("PRAGMA table_info({0})", tableName));
                foreach (DataRow r in dt.Rows)
                {
                    RowItem item = new RowItem(r);
                    if (item.getColumnValue_String("type").ToLower().Equals("float"))
                    {
                        cols.Add(item.getColumnValue_String("name"));
                    }
                }
                if (cols.Count > 0)
                {
                    _columns.Add(tableName, cols);
                }
                else
                {
                    return(new StringCollection());
                }
            }
            return(_columns[tableName]);
        }
コード例 #2
0
        /// <summary>
        /// Retrieve data columns from table name
        /// </summary>
        /// <param name="tableName"></param>
        /// <returns></returns>
        /// <remarks>Only float columns are return</remarks>
        public StringCollection getDataColumns(string tableName)
        {
            StringCollection cols = new StringCollection();

            if (tableName == null)
            {
                return(cols);
            }

            tableName = tableName.Trim();
            if (tableName.Length == 0)
            {
                return(cols);
            }

            if (!_columns.ContainsKey(tableName))
            {
                if (_scenario == null)
                {
                    return(cols);
                }

                DataTable dt = _scenario.GetDataTable(
                    string.Format("PRAGMA table_info({0})", tableName));
                foreach (DataRow r in dt.Rows)
                {
                    RowItem item = new RowItem(r);
                    if (item.getColumnValue_String("type").ToLower().Equals("float"))
                    {
                        cols.Add(item.getColumnValue_String("name"));
                    }
                }
                if (cols.Count > 0)
                {
                    //add TN and TP option for subbasin
                    //they will be calculated in the interface
                    //all the N/P columns should exist to calculte TN/TP
                    if (tableName.Equals(TABLE_NAME_SUB))
                    {
                        int i = 0;
                        for (; i < SUBBAIN_NITROGEN_COLUMNS.Length; i++)
                        {
                            if (!cols.Contains(SUBBAIN_NITROGEN_COLUMNS[i]))
                            {
                                break;
                            }
                        }
                        if (i == SUBBAIN_NITROGEN_COLUMNS.Length)
                        {
                            cols.Add(SUBBAIN_TOTAL_NITROGEN_COLUMN);
                        }

                        i = 0;
                        for (; i < SUBBAIN_PHOSPHORUS_COLUMNS.Length; i++)
                        {
                            if (!cols.Contains(SUBBAIN_PHOSPHORUS_COLUMNS[i]))
                            {
                                break;
                            }
                        }
                        if (i == SUBBAIN_PHOSPHORUS_COLUMNS.Length)
                        {
                            cols.Add(SUBBAIN_TOTAL_PHOSPHORUS_COLUMN);
                        }
                    }

                    _columns.Add(tableName, cols);
                }
                else
                {
                    return(new StringCollection());
                }
            }
            return(_columns[tableName]);
        }