Skip to content

Commit

Permalink
Merge pull request #182 from mcrossley/master
Browse files Browse the repository at this point in the history
v3.27.1
  • Loading branch information
mcrossley authored Nov 20, 2023
2 parents 5816539 + 0d0e534 commit 627026b
Show file tree
Hide file tree
Showing 32 changed files with 2,241 additions and 1,729 deletions.
10 changes: 5 additions & 5 deletions CumulusMX/Alarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public virtual bool Enabled
{
enabled = value;

// if we are disabled, clear any exisitng alarms
// if we are disabled, clear any existing alarms
if (!value)
{
triggered = false;
Expand Down Expand Up @@ -131,7 +131,7 @@ private void doTriggered(bool value)
}
catch (Exception ex)
{
cumulus.LogMessage($"Alarm ({Name}): Error executing external program '{Action}': {ex.Message}");
cumulus.LogErrorMessage($"Alarm ({Name}): Error executing external program '{Action}': {ex.Message}");
}
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public override bool Enabled
{
enabled = value;

// if we are disabled, clear any exisitng alarms
// if we are disabled, clear any existing alarms
if (!value)
{
upTriggered = false;
Expand Down Expand Up @@ -297,7 +297,7 @@ private void doUpTriggered(bool value)
}
catch (Exception ex)
{
cumulus.LogMessage($"Alarm: Error executing external program '{Action}': {ex.Message}");
cumulus.LogErrorMessage($"Alarm: Error executing external program '{Action}': {ex.Message}");
}
}
}
Expand Down Expand Up @@ -371,7 +371,7 @@ private void doDownTriggered(bool value)
}
catch (Exception ex)
{
cumulus.LogMessage($"Alarm: Error executing external program '{Action}': {ex.Message}");
cumulus.LogErrorMessage($"Alarm: Error executing external program '{Action}': {ex.Message}");
}
}
}
Expand Down
72 changes: 38 additions & 34 deletions CumulusMX/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public async Task GetEditData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -137,9 +137,9 @@ public async Task PostEditData(string req)
{
if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -236,9 +236,9 @@ public async Task GetData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -313,9 +313,9 @@ public async Task PostTags(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand All @@ -340,6 +340,8 @@ public async Task PostTags(string req)
{
cumulus.LogErrorMessage($"api/tags: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"{ex.Message}\"}}");
}
}

Expand All @@ -352,9 +354,9 @@ public async Task GetTags(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand All @@ -375,6 +377,8 @@ public async Task GetTags(string req)
{
cumulus.LogErrorMessage($"api/tags: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"{ex.Message}\"}}");
}
}
}
Expand All @@ -389,9 +393,9 @@ public async Task GetGraphData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -488,13 +492,13 @@ public async Task GetGraphData(string req)
await writer.WriteAsync(Station.GetIntervalTempGraphData(true, start, end));
break;
case "intvwind.json":
await writer.WriteAsync(Station.GetIntervalWindGraphData(true, start, end));
await writer.WriteAsync(Station.GetIntervalWindGraphData(start, end));
break;
case "intvrain.json":
await writer.WriteAsync(Station.GetIntervalRainGraphData(true, start, end));
await writer.WriteAsync(Station.GetIntervalRainGraphData(start, end));
break;
case "intvpress.json":
await writer.WriteAsync(Station.GetIntervaPressGraphData(true, start, end));
await writer.WriteAsync(Station.GetIntervalPressGraphData(start, end));
break;
case "intvhum.json":
await writer.WriteAsync(Station.GetIntervalHumGraphData(true, start, end));
Expand Down Expand Up @@ -563,9 +567,9 @@ public async Task SetGraphData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -602,9 +606,9 @@ public async Task GetDailyGraphData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -717,9 +721,9 @@ public async Task GetMonthlyRecordData(string mon, string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -772,9 +776,9 @@ public async Task GetThisMonthRecordData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -970,9 +974,9 @@ public async Task GetYesterdayData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -1024,9 +1028,9 @@ public async Task GetExtraData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"500\",\"Description\":\"The station is not running\"}}");
Response.StatusCode = 500;
await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"503\",\"Description\":\"The station is not running\"}}");
return;
}

Expand Down Expand Up @@ -1413,7 +1417,7 @@ public async Task PostTags(string req)
}
else
{
Response.StatusCode = 500;
Response.StatusCode = 503;
await writer.WriteAsync("{\"Error\":\"HTTP Station (Ecowitt) is not running}\"");
}
break;
Expand All @@ -1424,7 +1428,7 @@ public async Task PostTags(string req)
}
else
{
Response.StatusCode = 500;
Response.StatusCode = 503;
await writer.WriteAsync("{\"Error\":\"HTTP Station (Ecowitt) is not running}\"");
}
break;
Expand Down Expand Up @@ -1460,7 +1464,7 @@ public async Task GetStation(string req)
}
else
{
Response.StatusCode = 500;
Response.StatusCode = 503;
await writer.WriteAsync("HTTP Station (Wunderground) is not running");
}
break;
Expand All @@ -1472,7 +1476,7 @@ public async Task GetStation(string req)
}
else
{
Response.StatusCode = 500;
Response.StatusCode = 503;
await writer.WriteAsync("HTTP Station (Ambient) is not running");
}
break;
Expand All @@ -1484,7 +1488,7 @@ public async Task GetStation(string req)
}
else
{
Response.StatusCode = 500;
Response.StatusCode = 503;
await writer.WriteAsync("HTTP Station (Ambient) is not running");
}
break;
Expand Down Expand Up @@ -1512,9 +1516,9 @@ public async Task GetUtilData(string req)

if (Station == null)
{
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync("The station is not running");
Response.StatusCode = 500;
return;
}

Expand Down Expand Up @@ -1568,7 +1572,7 @@ public async Task PostUtilsData(string req)
{
if (Station == null)
{
Response.StatusCode = 500;
Response.StatusCode = 503;
using (var writer = HttpContext.OpenResponseText(new UTF8Encoding(false)))
await writer.WriteAsync("The station is not running");
return;
Expand Down
Loading

0 comments on commit 627026b

Please sign in to comment.