Example #1
0
        public async Task <IActionResult> GetEM300LRData(string name, bool update = false)
        {
            if (string.IsNullOrEmpty(name))
            {
                _logger?.LogDebug($"GetEM300LRData() invalid property.");
                return(StatusCode(StatusCodes.Status400BadRequest, $"Property is invalid."));
            }

            try
            {
                _logger?.LogDebug($"GetEM300LRData({name})...");

                if (EM300LR.IsProperty(name))
                {
                    if (!_em300lr.IsLocked)
                    {
                        return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished."));
                    }

                    if (update)
                    {
                        var status = await _em300lr.ReadAllAsync();

                        if (!status.IsGood)
                        {
                            return(StatusCode(StatusCodes.Status502BadGateway, status));
                        }
                    }

                    return(Ok(_em300lr.GetPropertyValue(name)));
                }
                else
                {
                    _logger?.LogDebug($"GetEM300LRData('{name}') property not found.");
                    return(NotFound($"Property '{name}' not found."));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
Example #2
0
 public void TestProperty(string property)
 {
     Assert.True(EM300LR.IsProperty(property));
     Assert.NotNull(_em300lr.GetPropertyValue(property));
 }