Beispiel #1
0
        //查询所有河流站点信息
        public void GetAllRiverStation()
        {
            var collection = mySession.CreateCriteria <Hydrologicalstation>()
                             .Add(Restrictions.Eq("Type", "河道站"))
                             .List <Hydrologicalstation>();

            foreach (Hydrologicalstation station in collection)
            {
                RiverHydrologyRecord rhr = new RiverHydrologyRecord();
                rhr.StationId       = station.Uid;
                rhr.StationName     = station.Name;
                rhr.StationLocation = station.Administrativeregion;
                rhr.RiverName       = station.River;
                riverList.Add(rhr);
            }
        }
Beispiel #2
0
        //获取数据到List中
        public void FecthData()
        {
            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,
                Flow            = d.Q,
                Time            = d.Time,
                WarningLevel    = d.Wl1,
                SafetyLevel     = d.Wl2,
                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)
            {
                RiverHydrologyRecord record = new RiverHydrologyRecord();
                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.Flow = double.Parse(data.Flow);
                }
                catch (ArgumentNullException)
                {
                    record.Flow = 0.0;
                }
                record.Time = (DateTime)data.Time;
                try
                {
                    record.WarningLevel = double.Parse(data.WarningLevel);
                }
                catch (ArgumentNullException)
                {
                    record.WarningLevel = 0.0;
                }

                try
                {
                    record.SafetyLevel = double.Parse(data.SafetyLevel);
                }
                catch (ArgumentNullException)
                {
                    record.SafetyLevel = 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;
                }
                riverList.Add(record);
            }
        }