private static IPTVLib.RequestModel.Response ProcessDevicesRequest(Request request, List<Device> devices, IPTVLib.RequestModel.Response response, IPTVLib.RequestModel.Request responseRequest) { var hosts = devices.Where(d => d.Mode == DeviceMode.Host).ToList(); var remotes = devices.Where(d => d.Mode == DeviceMode.Remote).ToList(); responseRequest.AccountName = request.AccountName; responseRequest.Action = RequestAction.DeviceInfo; responseRequest.DeviceGuid = request.DeviceGuid; responseRequest.FriendlyName = request.FriendlyName; responseRequest.RelatedHostIds = Device.GetDeviceIds(hosts); responseRequest.RelatedRemoteIds = Device.GetDeviceIds(remotes); responseRequest.CurrentOperationMode = request.CurrentOperationMode; response.ActionDevices = devices.Where(d => d.Id.ToString() == request.DeviceGuid).ToList(); response.DataToSend = responseRequest; response.Successful = true; return response; }
private static IPTVLib.RequestModel.Response PassThroughRequest(Request request, List<Device> devices, IPTVLib.RequestModel.Request responseRequest, IPTVLib.RequestModel.Response response) { responseRequest.AccountName = request.AccountName; responseRequest.Action = request.Action; responseRequest.DeviceGuid = request.DeviceGuid; responseRequest.FriendlyName = request.FriendlyName; responseRequest.Message = request.Message; responseRequest.CurrentOperationMode = request.CurrentOperationMode; response.DataToSend = responseRequest; //Find all devices that the alert has been targeted at. var devicesToNotify = new List<string>(); //Ids only if (request.RelatedRemoteIds != null) { foreach (var remote in request.RelatedRemoteIds) devicesToNotify.Add(remote.Key); //devicesToNotify.AddRange(request.RelatedRemoteIds.Select(rri => rri.Key)); }//if if (request.RelatedHostIds != null) { foreach (var remote in request.RelatedHostIds) devicesToNotify.Add(remote.Key); }//if if (request.IncludeAllHosts) { var hosts = devices.Where(d => d.Mode == DeviceMode.Host); devicesToNotify.AddRange(hosts.Select(r => r.Id.ToString())); }//if if (request.IncludeAllRemotes) { var remotes = devices.Where(d => d.Mode == DeviceMode.Remote); devicesToNotify.AddRange(remotes.Select(r => r.Id.ToString())); }//if response.ActionDevices = devices.Where(d => devicesToNotify.Contains(d.Id.ToString())).ToList(); return response; }