internal async Task <List <NotificationAction> > GetNotificationActionsInternalAsync(NotificationActionParameters parameters) { var response = await requestEngine.ExecuteRequestAsync(XmlFunction.TableData, parameters).ConfigureAwait(false); var items = response.Descendants("item").ToList(); foreach (var item in items) { var id = Convert.ToInt32(item.Element("objid").Value); var properties = await GetNotificationActionPropertiesAsync(id).ConfigureAwait(false); item.Add(properties.Nodes()); } return(XmlDeserializer <NotificationAction> .DeserializeList(response).Items); }
internal async Task <List <Channel> > GetChannelsInternalAsync(int sensorId, Func <string, bool> nameFilter = null, Func <int, bool> idFilter = null) { if (nameFilter == null) { nameFilter = n => true; } if (idFilter == null) { idFilter = i => true; } var response = await RequestEngine.ExecuteRequestAsync(new ChannelParameters(sensorId)).ConfigureAwait(false); response.Descendants("item").Where(item => item.Element("objid").Value == "-4").Remove(); var items = response.Descendants("item").ToList(); items.Where(e => !nameFilter(e.Element("name").Value?.ToString()) || !idFilter(Convert.ToInt32(e.Element("objid").Value.ToString())) ).Remove(); items = response.Descendants("item").ToList(); await Task.WhenAll(items.Select(async item => { var id = Convert.ToInt32(item.Element("objid").Value); var properties = await GetChannelPropertiesAsync(sensorId, id).ConfigureAwait(false); item.Add(properties.Nodes()); item.Add(new XElement("injected_sensorId", sensorId)); })).ConfigureAwait(false); if (items.Count > 0) { return(XmlDeserializer <Channel> .DeserializeList(response).Items); } return(new List <Channel>()); }
//###################################### // GetChannelsInternal //###################################### internal List <Channel> GetChannelsInternal(int sensorId, Func <string, bool> nameFilter = null, Func <int, bool> idFilter = null) { if (nameFilter == null) { nameFilter = n => true; } if (idFilter == null) { idFilter = i => true; } var response = RequestEngine.ExecuteRequest(new ChannelParameters(sensorId)); response.Descendants("item").Where(item => item.Element("objid").Value == "-4").Remove(); var items = response.Descendants("item").ToList(); items.Where(e => !nameFilter(e.Element("name").Value?.ToString()) || !idFilter(Convert.ToInt32(e.Element("objid").Value.ToString())) ).Remove(); items = response.Descendants("item").ToList(); foreach (var item in items) { var id = Convert.ToInt32(item.Element("objid").Value); var properties = GetChannelProperties(sensorId, id); item.Add(properties.Nodes()); item.Add(new XElement("injected_sensorId", sensorId)); } if (items.Count > 0) { return(XmlDeserializer <Channel> .DeserializeList(response).Items); } return(new List <Channel>()); }
internal async Task <List <NotificationAction> > GetNotificationActionsInternalAsync(NotificationActionParameters parameters) { var response = await RequestEngine.ExecuteRequestAsync(parameters).ConfigureAwait(false); var items = response.Descendants("item").ToList(); await Task.WhenAll(items.Select(async item => { var id = Convert.ToInt32(item.Element("objid").Value); var properties = await GetNotificationActionPropertiesAsync(id).ConfigureAwait(false); item.Add(properties.Nodes()); })).ConfigureAwait(false); var actions = XmlDeserializer <NotificationAction> .DeserializeList(response).Items; var actionsWithSchedules = ResponseParser.GroupActionSchedules(actions).ToList(); await UpdateActionSchedulesAsync(actionsWithSchedules).ConfigureAwait(false); return(actions); }
//###################################### // GetNotificationActionsInternal //###################################### internal List <NotificationAction> GetNotificationActionsInternal(NotificationActionParameters parameters) { var response = RequestEngine.ExecuteRequest(parameters); var items = response.Descendants("item").ToList(); foreach (var item in items) { var id = Convert.ToInt32(item.Element("objid").Value); var properties = GetNotificationActionProperties(id); item.Add(properties.Nodes()); } var actions = XmlDeserializer <NotificationAction> .DeserializeList(response).Items; var actionsWithSchedules = ResponseParser.GroupActionSchedules(actions).ToList(); UpdateActionSchedules(actionsWithSchedules); return(actions); }
internal async Task <XmlDeserializer <T> > GetObjectsRawAsync <T>(IXmlParameters parameters, Action <string> responseValidator = null, bool deserializeAll = true) { var response = await requestEngine.ExecuteRequestAsync(parameters, responseValidator).ConfigureAwait(false); return(SetVersion(XmlDeserializer <T> .DeserializeList(response, deserializeAll))); }
internal XmlDeserializer <T> GetObjectsRaw <T>(IXmlParameters parameters, Action <string> responseValidator = null, bool deserializeAll = true) { var response = requestEngine.ExecuteRequest(parameters, responseValidator); return(SetVersion(XmlDeserializer <T> .DeserializeList(response, deserializeAll))); }