Esempio n. 1
0
        public DTOs.Data GetReportByDeviceIdAndPropertyId(Guid DeviceId, int PropertyId)
        {
            tKovanContext ctx = new tKovanContext();


            Models.EntityClass.Device   Device   = ctx.Device.Single(x => x.Id == DeviceId);
            Models.EntityClass.Property Property = ctx.Property.Single(x => x.Id == PropertyId);

            DTOs.Data Data = new DTOs.Data();
            Data.type         = "line";
            Data.name         = Device.Name + "/" + Property.Name;
            Data.showInLegend = true;
            Data.dataPoints   = new List <DTOs.DataPoint>();

            List <Models.EntityClass.DeviceValue> DeviceValues = ctx.DeviceValue.Where(x => x.DeviceId == DeviceId && x.PropertyId == PropertyId).ToList();
            int sayac = 0;

            foreach (Models.EntityClass.DeviceValue DeviceValue in DeviceValues)
            {
                DTOs.DataPoint dp = new DTOs.DataPoint();
                dp.x     = sayac;
                dp.y     = DeviceValue.Value;
                dp.label = DeviceValue.DataDeviceTime.ToString("dd.MM.yyyy HH:mm");
                Data.dataPoints.Add(dp);
                sayac++;
            }
            return(Data);
        }
Esempio n. 2
0
        public List <DTOs.Data> GetReportByDeviceId(Guid DeviceId)
        {
            List <DTOs.Data> DataList = new List <DTOs.Data>();
            tKovanContext    ctx      = new tKovanContext();

            Models.EntityClass.Device device = ctx.Device.Include("Profile").Include("Profile.SensorProfiles").Include("Profile.SensorProfiles.Sensor").Include("Profile.SensorProfiles.Sensor.Properties").Where(x => x.Id == DeviceId).FirstOrDefault();

            List <DTOs.DevicePropertyInfo> DpiList = new List <DTOs.DevicePropertyInfo>();


            if (device.Profile.SensorProfiles != null)
            {
                foreach (Models.EntityClass.SensorProfile itemSensorProfile in device.Profile.SensorProfiles.ToList())
                {
                    if (itemSensorProfile.Sensor.Properties != null)
                    {
                        foreach (Models.EntityClass.Property itemProperty in itemSensorProfile.Sensor.Properties)
                        {
                            DTOs.DevicePropertyInfo Dpi = new DTOs.DevicePropertyInfo();
                            Dpi.DeviceId     = device.Id;
                            Dpi.DeviceName   = device.Name;
                            Dpi.PropertyId   = itemProperty.Id;
                            Dpi.PropertyName = itemProperty.Name;
                            DpiList.Add(Dpi);
                        }
                    }
                }
            }

            foreach (DTOs.DevicePropertyInfo dpi in DpiList)
            {
                DTOs.Data Data = new DTOs.Data();
                Data.type         = "line";
                Data.name         = dpi.DeviceName + "/" + dpi.PropertyName;
                Data.showInLegend = true;
                Data.dataPoints   = new List <DTOs.DataPoint>();
                List <Models.EntityClass.DeviceValue> DeviceValues = ctx.DeviceValue.Where(x => x.DeviceId == DeviceId && x.PropertyId == dpi.PropertyId).ToList();
                int sayac = 0;
                foreach (Models.EntityClass.DeviceValue DeviceValue in DeviceValues)
                {
                    DTOs.DataPoint dp = new DTOs.DataPoint();
                    dp.x     = sayac;
                    dp.y     = DeviceValue.Value;
                    dp.label = DeviceValue.DataDeviceTime.ToString("dd.MM.yyyy HH:mm");
                    Data.dataPoints.Add(dp);
                    sayac++;
                }
                DataList.Add(Data);
            }

            return(DataList);
        }