public GXDeviceProfilesDataResponse Post(GXDeviceProfilesDataRequest request) { lock (Db) { byte[] data = null; if (request.DeviceId != 0) { List <GXAmiDevice> devices = Db.Select <GXAmiDevice>(q => q.Id == request.DeviceId); if (devices.Count != 1) { throw new ArgumentException("Access denied."); } data = JoinPackets(Db, devices[0].ProfileId); } else if (request.DeviceProfilesGuid != Guid.Empty) { List <GXAmiDeviceProfile> templates = Db.Select <GXAmiDeviceProfile>(q => q.Guid == request.DeviceProfilesGuid); ulong id = 0; int ver = 0; if (templates.Count != 1) { foreach (GXAmiDeviceProfile it in templates) { //Get wanted versiom. if (it.ProfileVersion == request.ProfileVersion || //Get newest version. (request.ProfileVersion == 0 && it.ProfileVersion > ver)) { id = it.Id; ver = it.ProfileVersion; } } } else { id = templates[0].Id; } data = JoinPackets(Db, id); } else { throw new ArgumentException("Access denied."); } return(new GXDeviceProfilesDataResponse(data)); } }
public GXDeviceProfilesDataResponse Post(GXDeviceProfilesDataRequest request) { lock (Db) { byte[] data = null; if (request.DeviceId != 0) { List<GXAmiDevice> devices = Db.Select<GXAmiDevice>(q => q.Id == request.DeviceId); if (devices.Count != 1) { throw new ArgumentException("Access denied."); } data = JoinPackets(Db, devices[0].ProfileId); } else if (request.DeviceProfilesGuid != Guid.Empty) { List<GXAmiDeviceProfile> templates = Db.Select<GXAmiDeviceProfile>(q => q.Guid == request.DeviceProfilesGuid); ulong id = 0; int ver = 0; if (templates.Count != 1) { foreach (GXAmiDeviceProfile it in templates) { //Get wanted versiom. if (it.ProfileVersion == request.ProfileVersion || //Get newest version. (request.ProfileVersion == 0 && it.ProfileVersion > ver)) { id = it.Id; ver = it.ProfileVersion; } } } else { id = templates[0].Id; } data = JoinPackets(Db, id); } else { throw new ArgumentException("Access denied."); } return new GXDeviceProfilesDataResponse(data); } }