public async Task <ActionResult> Index() { string deviceId; DashboardModel model; DeviceListQuery query; DeviceListQueryResult queryResult; model = new DashboardModel(); query = new DeviceListQuery() { Skip = 0, Take = MaxDevicesToDisplayOnDashboard, SortColumn = "DeviceID" }; //The results of this query are used for populating the dropdown //As well as extracting location data. We want to include disabled //devices on the map, but not in the dropdown. The filters used //IN the query are apply additively to a "column". As a result, we //cannot filter on enabled AND disabled because the filters are //mutually exclusive. Also we cannot filter on !Pending. So to get //all that we need for both uses we need to just get all devices up //to the Take value and filter manually in the loop. The map will //filter out unregistered devices by virtue of their not having //location data. queryResult = await _deviceLogic.GetDevices(query); if ((queryResult != null) && (queryResult.Results != null)) { string enabledState = ""; dynamic props = null; foreach (dynamic devInfo in queryResult.Results) { try { deviceId = DeviceSchemaHelper.GetDeviceID(devInfo); props = DeviceSchemaHelper.GetDeviceProperties(devInfo); enabledState = props.HubEnabledState; } catch (DeviceRequiredPropertyNotFoundException) { continue; } if (!string.IsNullOrEmpty(deviceId) && !string.IsNullOrWhiteSpace(enabledState) && enabledState.ToLower() == "true") { model.DeviceIdsForDropdown.Add(new StringPair(deviceId, deviceId)); } } } model.DeviceLocations = _deviceLogic.ExtractLocationsData(queryResult.Results); model.MapApiQueryKey = _configProvider.GetConfigurationSettingValue("MapApiQueryKey"); return(View(model)); }
private async Task <List <DeviceModel> > GetDevices() { var filter = new DeviceListFilter { Take = 1000 }; var devices = await _deviceLogic.GetDevices(filter); return(devices.Results); }
private async Task <List <DeviceModel> > GetDevices() { var query = new DeviceListQuery { Take = 1000 }; var devices = await _deviceLogic.GetDevices(query); return(devices.Results); }
public async Task <HttpResponseMessage> GetDevicesAsync( [FromUri] string search = null, [FromUri] string sortColumn = null, [FromUri] QuerySortOrder sortOrder = QuerySortOrder.Ascending, [FromUri] int skip = 0, [FromUri] int take = 50, [FromUri] string[] filterColumn = null, [FromUri] ClauseType[] clauseType = null, [FromUri] string[] clauseValue = null) { var clauses = new List <Clause>(); if (filterColumn != null && clauseType != null && clauseValue != null) { // valid filters must send ALL three values--ignore unmatched extras int validFiltersCount = Math.Min(filterColumn.Length, Math.Min(clauseType.Length, clauseValue.Length)); for (int i = 0; i < validFiltersCount; ++i) { var clause = new Clause() { ColumnName = filterColumn[i], ClauseType = clauseType[i], ClauseValue = clauseValue[i] }; clauses.Add(clause); } } var filter = new DeviceListFilter() { SearchQuery = search, SortColumn = sortColumn, SortOrder = sortOrder, Skip = skip, Take = take, Clauses = clauses }; return(await GetServiceResponseAsync(async() => (await _deviceLogic.GetDevices(filter)).Results)); }
private async Task <List <DeviceModel> > LoadAllDevicesAsync() { var filter = new DeviceListFilter() { Skip = 0, Take = MAX_DEVICES_TO_DISPLAY_ON_DASHBOARD, SortColumn = "twin.deviceId" }; string deviceId; var devices = new List <DeviceModel>(); DeviceListFilterResult filterResult = await _deviceLogic.GetDevices(filter); if ((filterResult != null) && (filterResult.Results != null)) { bool? enabledState; DeviceProperties props; foreach (var devInfo in filterResult.Results) { try { deviceId = devInfo.DeviceProperties.DeviceID; props = devInfo.DeviceProperties; enabledState = props.HubEnabledState; } catch (NullReferenceException) { continue; } if (!string.IsNullOrWhiteSpace(deviceId)) { devices.Add(devInfo); } } } return(devices); }
private async Task <List <dynamic> > LoadAllDevicesAsync() { var query = new DeviceListQuery() { Skip = 0, Take = MAX_DEVICES_TO_DISPLAY_ON_DASHBOARD, SortColumn = "DeviceID" }; string deviceId; var devices = new List <dynamic>(); DeviceListQueryResult queryResult = await _deviceLogic.GetDevices(query); if ((queryResult != null) && (queryResult.Results != null)) { string enabledState = ""; dynamic props = null; foreach (dynamic devInfo in queryResult.Results) { try { deviceId = DeviceSchemaHelper.GetDeviceID(devInfo); props = DeviceSchemaHelper.GetDeviceProperties(devInfo); enabledState = props.HubEnabledState; } catch (DeviceRequiredPropertyNotFoundException) { continue; } if (!string.IsNullOrWhiteSpace(deviceId)) { devices.Add(devInfo); } } } return(devices); }
//[RequirePermission(Permission.ViewTelemetry)] public async Task <ActionResult> Index() { var name = User.Identity.Name; var model = new DashboardModel(); var filters = new List <Infrastructure.Models.FilterInfo> { new Infrastructure.Models.FilterInfo() { ColumnName = "status", FilterType = FilterType.Status, FilterValue = "Running" } }; var query = new DeviceListQuery() { Skip = 0, Take = MaxDevicesToDisplayOnDashboard, SortColumn = "DeviceID", Filters = filters }; DeviceListQueryResult queryResult = await _deviceLogic.GetDevices(query); if ((queryResult != null) && (queryResult.Results != null)) { foreach (DeviceModel devInfo in queryResult.Results) { string deviceId; try { deviceId = devInfo.DeviceProperties.DeviceID; } catch (DeviceRequiredPropertyNotFoundException) { continue; } model.DeviceIdsForDropdown.Add(new StringPair(deviceId, deviceId)); } } // Set key to empty if passed value 0 from arm template string key = _configProvider.GetConfigurationSettingValue("MapApiQueryKey"); model.MapApiQueryKey = key.Equals("0") ? string.Empty : key; return(View(model)); }
public async Task <ActionResult> Index() { var model = new DashboardModel(); var clauses = new List <Infrastructure.Models.Clause> { new Clause() { ColumnName = "tags.HubEnabledState", ClauseType = ClauseType.EQ, ClauseValue = "Running" } }; var query = new DeviceListFilter() { Skip = 0, Take = MaxDevicesToDisplayOnDashboard, SortColumn = "twin.deviceId", Clauses = clauses }; DeviceListFilterResult filterResult = await _deviceLogic.GetDevices(query); if ((filterResult != null) && (filterResult.Results != null)) { foreach (DeviceModel devInfo in filterResult.Results) { string deviceId; try { deviceId = devInfo.DeviceProperties.DeviceID; } catch (DeviceRequiredPropertyNotFoundException) { continue; } model.DeviceIdsForDropdown.Add(new StringPair(deviceId, deviceId)); } } // Set key to empty if passed value 0 from arm template string key = _configProvider.GetConfigurationSettingValue("MapApiQueryKey"); model.MapApiQueryKey = key.Equals("0") ? string.Empty : key; AddDefaultCultureIntoCookie(); return(View(model)); }
public async Task <ActionResult> Index() { var model = new DashboardModel(); List <Infrastructure.Models.FilterInfo> filters = new List <Infrastructure.Models.FilterInfo>(); filters.Add(new Infrastructure.Models.FilterInfo() { ColumnName = "status", FilterType = FilterType.Status, FilterValue = "Running" }); var query = new DeviceListQuery() { Skip = 0, Take = MaxDevicesToDisplayOnDashboard, SortColumn = "DeviceID", Filters = filters }; DeviceListQueryResult queryResult = await _deviceLogic.GetDevices(query); if ((queryResult != null) && (queryResult.Results != null)) { foreach (dynamic devInfo in queryResult.Results) { string deviceId; try { deviceId = DeviceSchemaHelper.GetDeviceID(devInfo); } catch (DeviceRequiredPropertyNotFoundException) { continue; } model.DeviceIdsForDropdown.Add(new StringPair(deviceId, deviceId)); } } model.MapApiQueryKey = _configProvider.GetConfigurationSettingValue("MapApiQueryKey"); return(View(model)); }
public IEnumerable <Device> GetDevices() => _deviceLogic.GetDevices("", false, true);