예제 #1
0
        private void updateTableAndChart()
        {
            tableView1.DataTable             = null;
            outputDisplayChart1.ObservedData = null;
            yearCtrl1.ObservedData           = null;
            _observedData = null;
            _statistics   = "";

            if (_col != null && _id > 0)
            {
                _observedData = _prj.Observation(_interval).getObservedData(_unitType, _id, _col);
                if (_observedData != null)
                {
                    //show the data
                    ArcSWAT.SWATUnitColumnYearObservationData observedData = _observedData.getObservedData(_year);
                    tableView1.ObservedData          = observedData;
                    outputDisplayChart1.ObservedData = observedData;
                    yearCtrl1.ObservedData           = _observedData.getObservedData(-1);

                    if (onDataStatisticsChanged != null)
                    {
                        _statistics = observedData.Statistics.ToString();
                        onDataStatisticsChanged(this, new EventArgs());
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Used to get observed data corresponding to specific result
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public SWATUnitColumnYearObservationData getObservedData(SWATUnitColumnYearResult result)
        {
            //check if the database is there
            if (!_exist)
            {
                return(null);
            }

            //see if the column has correponding observed data
            string[] columns = getObservationDataColumns(result.UnitResult.Unit.Type);
            if (columns == null)
            {
                return(null);
            }
            if (System.Array.IndexOf(columns, getObservationColumnFromSWAT(result.Column)) == -1)
            {
                return(null);
            }

            //find the data
            string uniqueID = getUniqueId(result.UnitResult.Unit.Type, result.UnitResult.Unit.ID, result.Column);

            if (_allData.ContainsKey(uniqueID))
            {
                uniqueID = getUniqueId(result);
                if (!_allData.ContainsKey(uniqueID))
                {
                    _allData.Add(uniqueID, new SWATUnitObservationData(result, this));
                }
                SWATUnitObservationData unitData = _allData[uniqueID];
                return(unitData.getObservedData(result.Year));
            }
            return(null);
        }
예제 #3
0
        private void loadData(SWATUnitType type, int id, string col)
        {
            if (!_exist)
            {
                return;
            }

            string    tableName = getTableName(type, id, col);
            DataTable dt        = GetDataTable(
                string.Format("select name from sqlite_master where type = 'table' and name = '{0}'", tableName));

            if (dt.Rows.Count > 0)
            {
                //see if there are some data
                //don't consider empty tables
                dt = GetDataTable(
                    string.Format("select count(*) from [{0}]", tableName));
                if (dt.Rows.Count == 0)
                {
                    return;
                }
                RowItem item = new RowItem(dt.Rows[0]);
                if (item.getColumnValue_Int(0) == 0)
                {
                    return;
                }

                //read data
                string dataUniqueId = getUniqueId(type, id, col);

                //remove previous one
                _allData.Remove(dataUniqueId);
                _allData_display.Remove(dataUniqueId);

                //add new one
                SWATUnitObservationData data =
                    new SWATUnitObservationData(
                        id, type, col,
                        -1, -1,
                        this);

                //add to all data
                _allData.Add(dataUniqueId, data);

                //add to display data
                string display_id = string.Format("{0}_{1}", type, id);
                if (!_allData_display.ContainsKey(display_id))
                {
                    _allData_display.Add(display_id, new List <SWATUnitObservationData>());
                }
                _allData_display[display_id].Add(data);
            }
        }
예제 #4
0
        private void loadData(SWATUnitType type)
        {
            if (!_exist) return;

            DataTable dt = GetDataTable("select name from sqlite_master where type = 'table'");
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow r in dt.Rows)
                {
                    //get table name
                    string tableName = r[0].ToString();
                    if(!tableName.Contains(type.ToString())) continue;

                    //see if there are some data
                    //don't consider empty tables
                    dt = GetDataTable(
                        string.Format("select count(*) from [{0}]", tableName));
                    RowItem item = new RowItem(dt.Rows[0]);
                    if (item.getColumnValue_Int(0) == 0) continue;

                    //extract the id from table name
                    string[] all_in_tableName = tableName.Split(OBSERVATION_TABLE_NAME_DELIMITER);
                    if (all_in_tableName.Length < 3) continue;

                    int id = -1;
                    if (int.TryParse(all_in_tableName[1], out id))
                    {
                        string col = all_in_tableName[2];

                        string dataUniqueId = getUniqueId(type, id, col);

                        if (!_allData.ContainsKey(dataUniqueId))
                        {
                            SWATUnitObservationData data =
                                new SWATUnitObservationData(
                                    id, type, col,
                                    -1, -1,
                                    this);

                            //add to all data
                            _allData.Add(dataUniqueId,data);

                            //add to display data
                            string display_id = string.Format("{0}_{1}",type,id);
                            if (!_allData_display.ContainsKey(display_id))
                                _allData_display.Add(display_id, new List<SWATUnitObservationData>());
                            _allData_display[display_id].Add(data);
                        }
                    }
                }
            }
        }
예제 #5
0
        private void loadData(SWATUnitType type, int id, string col)
        {
            if (!_exist) return;

            string tableName = getTableName(type, id, col);
            DataTable dt = GetDataTable(
                string.Format("select name from sqlite_master where type = 'table' and name = '{0}'", tableName));
            if (dt.Rows.Count > 0)
            {
                //see if there are some data
                //don't consider empty tables
                dt = GetDataTable(
                    string.Format("select count(*) from [{0}]", tableName));
                if (dt.Rows.Count == 0) return;
                RowItem item = new RowItem(dt.Rows[0]);
                if (item.getColumnValue_Int(0) == 0) return;

                //read data
                string dataUniqueId = getUniqueId(type, id, col);

                //remove previous one
                _allData.Remove(dataUniqueId);
                _allData_display.Remove(dataUniqueId);

                //add new one
                SWATUnitObservationData data =
                    new SWATUnitObservationData(
                        id, type, col,
                        -1, -1,
                        this);

                //add to all data
                _allData.Add(dataUniqueId, data);

                //add to display data
                string display_id = string.Format("{0}_{1}", type, id);
                if (!_allData_display.ContainsKey(display_id))
                    _allData_display.Add(display_id, new List<SWATUnitObservationData>());
                _allData_display[display_id].Add(data);
            }
        }
예제 #6
0
 public SWATUnitColumnYearObservationData(string col, int year, SWATUnitObservationData data) : base(col, year)
 {
     _parentData = data;
     _colCompare = string.Format("{0}_Observed", _col);
 }
예제 #7
0
        private void loadData(SWATUnitType type)
        {
            if (!_exist)
            {
                return;
            }

            DataTable dt = GetDataTable("select name from sqlite_master where type = 'table'");

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow r in dt.Rows)
                {
                    //get table name
                    string tableName = r[0].ToString();
                    if (!tableName.Contains(type.ToString()))
                    {
                        continue;
                    }

                    //see if there are some data
                    //don't consider empty tables
                    dt = GetDataTable(
                        string.Format("select count(*) from [{0}]", tableName));
                    RowItem item = new RowItem(dt.Rows[0]);
                    if (item.getColumnValue_Int(0) == 0)
                    {
                        continue;
                    }

                    //extract the id from table name
                    string[] all_in_tableName = tableName.Split(OBSERVATION_TABLE_NAME_DELIMITER);
                    if (all_in_tableName.Length < 3)
                    {
                        continue;
                    }

                    int id = -1;
                    if (int.TryParse(all_in_tableName[1], out id))
                    {
                        string col = all_in_tableName[2];

                        string dataUniqueId = getUniqueId(type, id, col);

                        if (!_allData.ContainsKey(dataUniqueId))
                        {
                            SWATUnitObservationData data =
                                new SWATUnitObservationData(
                                    id, type, col,
                                    -1, -1,
                                    this);

                            //add to all data
                            _allData.Add(dataUniqueId, data);

                            //add to display data
                            string display_id = string.Format("{0}_{1}", type, id);
                            if (!_allData_display.ContainsKey(display_id))
                            {
                                _allData_display.Add(display_id, new List <SWATUnitObservationData>());
                            }
                            _allData_display[display_id].Add(data);
                        }
                    }
                }
            }
        }
 public SWATUnitColumnYearObservationData(string col, int year,SWATUnitObservationData data)
     : base(col,year)
 {
     _parentData = data;
     _colCompare = string.Format("{0}_Observed", _col);
 }