Example #1
0
        public object GetBySensorAndDate(string sensors, DateTime startdate, DateTime enddate, int interval, string datename)
        {
            var list =
                new DAL.Data().GetMonitorData(sensors, startdate, enddate, interval, datename).OrderBy(d => d.SensorId);

            return
                (new JArray(list.GroupBy(l => new { l.SensorId, l.Location, l.Columns, l.Unit }).Select(d =>
                                                                                                        new JObject(
                                                                                                            new JProperty("sensorid", d.Key.SensorId),
                                                                                                            new JProperty("location", d.Key.Location),
                                                                                                            new JProperty("columns", d.Key.Columns),
                                                                                                            new JProperty("unit", d.Key.Unit),
                                                                                                            new JProperty(
                                                                                                                "data",
                                                                                                                new JArray(d.Select(v =>
                                                                                                                                    new JObject(
                                                                                                                                        new JProperty("value", v.Values),
                                                                                                                                        new JProperty("acquisitiontime", v.AcquisitionTime)))))))));
        }
Example #2
0
        public object GetLastBySensor(string sensors)
        {
            string[] sens        = sensors.Split(',');
            int[]    sensorArray = sens.Select(s => Convert.ToInt32(s)).ToArray();
            var      list        = new DAL.Data().GetLastMonitorData(sensorArray).OrderBy(d => d.SensorId);

            return
                (new JArray(list.GroupBy(l => new { l.SensorId, l.Location, l.Columns, l.Unit }).Select(d =>
                                                                                                        new JObject(
                                                                                                            new JProperty("sensorid", d.Key.SensorId),
                                                                                                            new JProperty("location", d.Key.Location),
                                                                                                            new JProperty("columns", d.Key.Columns),
                                                                                                            new JProperty("unit", d.Key.Unit),
                                                                                                            new JProperty(
                                                                                                                "data",
                                                                                                                new JArray(d.Select(v =>
                                                                                                                                    new JObject(
                                                                                                                                        new JProperty("value", v.Values),
                                                                                                                                        new JProperty("acquisitiontime", v.AcquisitionTime)))))))));
        }