示例#1
0
        private static Channel DataRowToChannel(DataRow r)
        {
            int id = 0;
            if (!(r.IsNull("ch_id")))
            {
                id = Convert.ToInt32(r["ch_id"]);
            }
            int stationId = Convert.ToInt32(r["st_id"]);
            int variableId = Convert.ToInt32(r["var_id"]);
            string stName = Convert.ToString(r["st_name"]);
            string stUrl = Convert.ToString(r["st_uri"]);
            long riverId = 0;
            if (!(r.IsNull("riv_id")))
            {
                riverId = Convert.ToInt64(r["riv_id"]);
            }
            string op = Convert.ToString(r["operator_name"]);

            Channel ch = new Channel(id, stationId, variableId, TimeInterval.Missing);
            Station st = new Station(stationId, stName, stUrl, riverId, op);
            Variable v = VariableManager.GetItemById(variableId);

            ch.Station = st;
            ch.Variable = v;

            //also load river for hydrologic stations
            if (riverId > 0)
            {
                st.River = RiverManager.GetItemByStation(st.Id, true);
            }

            return ch;
        }
示例#2
0
 public Channel(int id, Station st, Variable var, TimeInterval availableData)
 {
     _id = id;
     _station = st;
     _variable = var;
     _availableData = availableData;
     _stId = _station.Id;
     _varId = _variable.Id;
 }
示例#3
0
        private void ValidateStation()
        {
            string stUrl;
            if ( _isValidVariable )
            {
                if ( _queryString["st"] != null )
                {
                    stUrl = _queryString["st"];
                }
                else
                {
                    stUrl = getDefaultStationUrl(_variable);
                }

                Station st = StationManager.GetItemByUrlAndVariable(stUrl, _variable.Id, false);
                if ( st.Loaded )
                {
                    _station = st;
                    _isValidStation = true;
                    _isValidStationVariable = true;
                }
                else
                {
                    st = StationManager.GetItemByUrl(stUrl, false);
                    if ( st.Loaded )
                    {
                        _station = st;
                        _isValidStation = true;
                        _errorMessage =
                            _writer.WriteErrorMessage(MessageType.NoStationVariable);
                    }
                    else
                    {
                        _errorMessage = _writer.WriteErrorMessage(MessageType.NoStation);
                        _station = new Station(0, stUrl, stUrl);
                    }
                }
            }
        }
示例#4
0
 private void DrawTitle(GraphPane myPane, Variable var, Station st, DateTime minDate, DateTime maxDate)
 {
     string title;
     string stName;
     if ( var.VarEnum == VariableEnum.Discharge || var.VarEnum == VariableEnum.Stage )
     {
         stName = string.Format("{0} ({1})", st.Name, st.River.Name);
     }
     else
     {
         stName = st.Name;
     }
     title = String.Format("{0} - {1} {2} - {3}",
         var.Name, stName, minDate.ToShortDateString(),
         maxDate.ToShortDateString());
     myPane.Title.Text = title;
     myPane.Title.FontSpec.Size = 18;
     myPane.Title.FontSpec.IsBold = false;
 }
示例#5
0
        private static Station DataRowToStation(DataRow r)
        {
            int id = Convert.ToInt32(r["st_id"]);
            string name = Convert.ToString(r["st_name"]);
            string url = Convert.ToString(r["st_uri"]);
            string op = Convert.ToString(r["operator_name"]);
            long riverId = -1;
            if (!r.IsNull("riv_id"))
            {
                riverId = Convert.ToInt64(r["riv_id"]);
            }
            int locationId = -1;
            if (!r.IsNull("location_id"))
            {
                locationId = Convert.ToInt32(r["location_id"]);
            }

            Station st = new Station(id, name, url, riverId, op);
            st.LocationId = locationId;
            return st;
        }
示例#6
0
 private static void AddStationLocation(Station st)
 {
     if (st.LocationId > 0)
     {
         DataTable locTable = StationDS.GetLocationTable((int)st.LocationId);
         if (locTable.Rows.Count > 0)
         {
             st.Latitude = Convert.ToDouble(locTable.Rows[0][0]);
             st.Longitude = Convert.ToDouble(locTable.Rows[0][1]);
         }
     }
 }
示例#7
0
 /// <summary>
 /// Loads the station, variables and channels info for the station
 /// </summary>
 /// <param name="st"></param>
 private static void AddStationDetails(Station st)
 {
     st.River = RiverManager.GetItemByStation(st.Id, true);
     st.Variables = VariableManager.GetListByStation(st.Id);
     st.Channels = ChannelManager.GetListByStation(st.Id);
 }