Exemple #1
0
        //查询所有水库站点信息
        public void GetAllReservoirStation()
        {
            var collection = mySession.CreateCriteria <Hydrologicalstation>()
                             .Add(Restrictions.Eq("Type", "水库站"))
                             .List <Hydrologicalstation>();

            foreach (Hydrologicalstation station in collection)
            {
                ReservoirHydrologyRecord rhr = new ReservoirHydrologyRecord();
                rhr.StationId       = station.Uid;
                rhr.StationName     = station.Name;
                rhr.StationLocation = station.Administrativeregion;
                rhr.RiverName       = station.River;
                reservoirList.Add(rhr);
            }
        }
Exemple #2
0
        //获取数据到List中
        public void FecthData()
        {
            /* Hydrologicaldata data = null;
             * Hydrologicalstation station = null;*/

            var datas    = mySession.Query <Hydrologicaldata>();
            var stations = mySession.Query <Hydrologicalstation>();
            var query    = from d in datas
                           join s in stations
                           on d.Stationid equals s.Uid
                           select new
            {
                RecordId        = d.Recordid,
                StationId       = d.Stationid,
                StationName     = s.Name,
                StationLocation = s.Address,
                RiverName       = s.River,
                Level           = d.L,
                Pondage         = d.Q,
                Time            = d.Time,
                WarningLevel    = d.Wl1,
                Longitude       = s.Longitude,
                Latitude        = s.Latitude
            };


            if (isSetDuration == true)
            {
                query = query.Where(d => d.Time <this.to && d.Time> this.from);
            }

            if (isSetStation == true)
            {
                if (stationList.Count > 0)
                {
                    query = query.Where(s => stationList.Contains(s.StationId));
                }
            }

            foreach (var data in query)
            {
                ReservoirHydrologyRecord record = new ReservoirHydrologyRecord();
                record.RecordId        = data.RecordId;
                record.StationId       = data.StationId;
                record.StationName     = data.StationName;
                record.StationLocation = data.StationLocation;
                record.RiverName       = data.RiverName;
                try
                {
                    record.Level = double.Parse(data.Level);
                }
                catch (ArgumentNullException)
                {
                    record.Level = 0.0;
                }
                try
                {
                    record.Pondage = double.Parse(data.Pondage);
                }
                catch (ArgumentNullException)
                {
                    record.Pondage = 0.0;
                }
                record.Time = (DateTime)data.Time;
                try
                {
                    record.WarningLevel = double.Parse(data.WarningLevel);
                }
                catch (ArgumentNullException)
                {
                    record.WarningLevel = 0.0;
                }
                try
                {
                    record.Longitude = double.Parse(data.Longitude);
                }
                catch (ArgumentNullException)
                {
                    record.Longitude = 0.0;
                }
                try
                {
                    record.Latitude = double.Parse(data.Latitude);
                }
                catch (ArgumentNullException)
                {
                    record.Latitude = 0.0;
                }
                reservoirList.Add(record);
            }
        }