/// <summary> /// /// </summary> /// <param name="logger"></param> /// <param name="options"></param> public HomeDataHub(ILogger <HomeDataHub> logger, IOptions <AppSettings> options) : base(logger, new HubSettings() { Uri = options.Value.HomeData }) { _logger.LogDebug("HomeDataHub()"); _hub.On <HomeValues>("UpdateData", async(data) => { _logger.LogDebug("On<HomeValues>()"); await CoreApplication.MainView .Dispatcher .RunAsync(CoreDispatcherPriority.Normal, () => Data = data); }); }
public IActionResult GetHomeData(string name) { if (string.IsNullOrEmpty(name)) { _logger?.LogDebug($"GetHomeData() invalid property."); return(StatusCode(StatusCodes.Status400BadRequest, $"Property is invalid.")); } try { _logger?.LogDebug($"GetHomeData({name})..."); if (HomeValues.IsProperty(name)) { if (!_homedata.IsLocked) { return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished.")); } if (!_homedata.Data.IsGood) { return(StatusCode(StatusCodes.Status502BadGateway, _homedata.Data.Status)); } return(Ok(_homedata.GetPropertyValue(name))); } else { _logger?.LogDebug($"GetHomeData('{name}') property not found."); return(NotFound($"Property '{name}' not found.")); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }