diff --git a/CumulusMX/Api.cs b/CumulusMX/Api.cs
index 6e23eca6..6f88668a 100644
--- a/CumulusMX/Api.cs
+++ b/CumulusMX/Api.cs
@@ -115,14 +115,14 @@ public async Task GetEditData(string req)
await writer.WriteAsync(dataEditor.GetRecordsLogFile("thisyear"));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/edit: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -178,14 +178,14 @@ public async Task PostEditData(string req)
await writer.WriteAsync(dataEditor.EditDatalog(HttpContext));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/edit: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -247,13 +247,13 @@ public async Task GetData(string req)
await writer.WriteAsync(Station.GetDiarySummary());
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
} }
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/data: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -286,15 +286,15 @@ public async Task PostTags(string req)
await writer.WriteAsync(tagProcessor.ProcessText(HttpContext.Request));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/tags: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -322,14 +322,14 @@ public async Task GetTags(string req)
await writer.WriteAsync(tagProcessor.ProcessJson(Request));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/tags: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -403,13 +403,13 @@ public async Task GetGraphData(string req)
await writer.WriteAsync(Station.GetSelectaChartOptions());
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
} }
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/graphdata: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -437,15 +437,15 @@ public async Task SetGraphData(string req)
await writer.WriteAsync(stationSettings.SetSelectaChartOptions(HttpContext));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/graphdata: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -481,9 +481,9 @@ public async Task GetDailyGraphData(string req)
case "pressdata.json":
await writer.WriteAsync(Station.GetAllDailyPressGraphData());
break;
- //case "wdirdata.json":
- //await writer.WriteAsync(Station.GetAllDailyWindDirGraphData());
- //break;
+ case "wdirdata.json":
+ await writer.WriteAsync(Station.GetAllDailyWindDirGraphData());
+ break;
case "humdata.json":
await writer.WriteAsync(Station.GetAllDailyHumGraphData());
break;
@@ -503,14 +503,14 @@ public async Task GetDailyGraphData(string req)
await writer.WriteAsync(Station.GetGraphConfig());
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/dailygraphdata: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -553,14 +553,14 @@ public async Task GetAlltimeData(string req)
await writer.WriteAsync(EscapeUnicode(Station.GetRainRecords()));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/records/alltime: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -608,14 +608,14 @@ public async Task GetMonthlyRecordData(string mon, string req)
await writer.WriteAsync(EscapeUnicode(Station.GetMonthlyRainRecords(month)));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/records/month: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -655,14 +655,14 @@ public async Task GetThisMonthRecordData(string req)
await writer.WriteAsync(EscapeUnicode(Station.GetThisMonthRainRecords()));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/records/thismonth: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -701,14 +701,14 @@ public async Task GetThisYearRecordData(string req)
await writer.WriteAsync(EscapeUnicode(Station.GetThisYearRainRecords()));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/records/thisyear: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -755,14 +755,14 @@ public async Task GetYesterdayData(string req)
await writer.WriteAsync(Station.GetTodayYestSolar());
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/todayyest: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -847,14 +847,14 @@ public async Task GetExtraData(string req)
await writer.WriteAsync(Station.GetCO2sensor());
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/extra: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -940,14 +940,14 @@ public async Task SettingsGet(string req)
await writer.WriteAsync(wizard.GetAlpacaFormData());
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/settings: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -1012,14 +1012,14 @@ public async Task SettingsSet(string req)
await writer.WriteAsync(wizard.UpdateConfig(HttpContext));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/setsettings: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -1034,13 +1034,10 @@ public async Task GetData(string req)
NOAAReports noaarpts = new NOAAReports(Program.cumulus);
try
{
- // read the last segment of the URL to determine what data the caller wants
- var lastSegment = Request.Url.Segments.Last();
-
var query = HttpUtility.ParseQueryString(Request.Url.Query);
int month, year;
- Response.ContentType = "application/json";
+ Response.ContentType = "text/plain";
using (var writer = HttpContext.OpenResponseText())
{
@@ -1055,7 +1052,7 @@ public async Task GetData(string req)
switch (req)
{
case "noaayear":
- await writer.WriteAsync(Json.Serialize(noaarpts.GetNoaaYearReport(year)));
+ await writer.WriteAsync(String.Join("\n", noaarpts.GetNoaaYearReport(year).ToArray()));
break;
case "noaamonth":
if (!Int32.TryParse(query["month"], out month) || month < 1 || month > 12)
@@ -1064,17 +1061,17 @@ public async Task GetData(string req)
Response.StatusCode = 406;
return;
}
- await writer.WriteAsync(Json.Serialize(noaarpts.GetNoaaMonthReport(year, month)));
+ await writer.WriteAsync(String.Join("\n", noaarpts.GetNoaaMonthReport(year, month).ToArray()));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/reports: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -1087,7 +1084,7 @@ public async Task GenReports(string req)
{
var query = HttpUtility.ParseQueryString(Request.Url.Query);
int month, year;
- Response.ContentType = "application/json";
+ Response.ContentType = "text/plain";
using (var writer = HttpContext.OpenResponseText())
{
@@ -1101,7 +1098,7 @@ public async Task GenReports(string req)
switch (req)
{
case "noaayear":
- await writer.WriteAsync(Json.Serialize(noaarpts.GenerateNoaaYearReport(year)));
+ await writer.WriteAsync(String.Join("\n", noaarpts.GenerateNoaaYearReport(year).ToArray()));
break;
case "noaamonth":
if (!Int32.TryParse(query["month"], out month) || month < 1 || month > 12)
@@ -1110,18 +1107,21 @@ public async Task GenReports(string req)
Response.StatusCode = 406;
return;
}
- await writer.WriteAsync(Json.Serialize(noaarpts.GenerateNoaaMonthReport(year, month)));
+ await writer.WriteAsync(String.Join("\n", noaarpts.GenerateNoaaMonthReport(year, month).ToArray()));
break;
default:
- throw new KeyNotFoundException("Key Not Found: " + req);
+ Response.StatusCode = 404;
+ throw new Exception();
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ //using (var writer = HttpContext.OpenResponseText())
+ // await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
Response.StatusCode = 500;
+ Program.cumulus.LogMessage($"api/genreports: Unexpected Error, ErrorCode: {ex.GetType().Name}, Description: \"{ex.Message}\"");
}
}
}
@@ -1162,13 +1162,15 @@ public async Task PostTags(string req)
await writer.WriteAsync("{\"Error\":\"HTTP Station (Ecowitt) is not running}\"");
}
break;
+ default:
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/httpstation: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
@@ -1220,13 +1222,15 @@ public async Task GetStation(string req)
await writer.WriteAsync("HTTP Station (Ambient) is not running");
}
break;
+ default:
+ Response.StatusCode = 404;
+ break;
}
}
}
catch (Exception ex)
{
- using (var writer = HttpContext.OpenResponseText())
- await writer.WriteAsync($"{{\"Title\":\"Unexpected Error\",\"ErrorCode\":\"{ex.GetType().Name}\",\"Description\":\"{ex.Message}\"}}");
+ Program.cumulus.LogMessage($"api/httpstation: Unexpected Error, Description: \"{ex.Message}\"");
Response.StatusCode = 500;
}
}
diff --git a/CumulusMX/ApiTagProcessor.cs b/CumulusMX/ApiTagProcessor.cs
index 35003543..c4ef777f 100644
--- a/CumulusMX/ApiTagProcessor.cs
+++ b/CumulusMX/ApiTagProcessor.cs
@@ -67,7 +67,7 @@ public string ProcessJson(IHttpRequest request)
// remove trailing ","
output.Remove(output.Length - 1, 1);
}
- output.Append("}");
+ output.Append('}');
cumulus.LogDataMessage("API tag: Output string = " + output);
}
diff --git a/CumulusMX/App.config b/CumulusMX/App.config
index 6996fdc6..3ae0a98a 100644
--- a/CumulusMX/App.config
+++ b/CumulusMX/App.config
@@ -4,6 +4,7 @@
+
@@ -25,6 +26,10 @@
-
+
+
+
+
+
diff --git a/CumulusMX/Cumulus.cs b/CumulusMX/Cumulus.cs
index 2aa1c65e..64ab61d2 100644
--- a/CumulusMX/Cumulus.cs
+++ b/CumulusMX/Cumulus.cs
@@ -18,7 +18,6 @@
using MySqlConnector;
using FluentFTP;
using FluentFTP.Helpers;
-using LinqToTwitter;
using ServiceStack.Text;
using EmbedIO;
using EmbedIO.WebApi;
@@ -466,9 +465,6 @@ public struct TExtraFiles
//private const int VP2USBCONNECTION = 1;
//private const int VP2TCPIPCONNECTION = 2;
- private readonly string twitterKey = "lQiGNdtlYUJ4wS3d7souPw";
- private readonly string twitterSecret = "AoB7OqimfoaSfGQAd47Hgatqdv3YeTTiqpinkje6Xg";
-
public string AlltimeIniFile;
public string Alltimelogfile;
public string MonthlyAlltimeIniFile;
@@ -545,9 +541,6 @@ public struct TExtraFiles
public bool RealtimeIntervalEnabled; // The timer is to be started
private int realtimeFTPRetries; // Count of failed realtime FTP attempts
- // Twitter settings
- public WebUploadTwitter Twitter = new WebUploadTwitter();
-
// Wunderground settings
public WebUploadWund Wund = new WebUploadWund();
@@ -770,7 +763,6 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
DirectorySeparator = Path.DirectorySeparatorChar;
AppDir = Directory.GetCurrentDirectory() + DirectorySeparator;
- TwitterTxtFile = AppDir + "twitter.txt";
WebTagFile = AppDir + "WebTags.txt";
//b3045>, use same port for WS... WS port = HTTPS port
@@ -1107,7 +1099,7 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
if (ProgramOptions.StartupDelaySecs > 0)
{
// Check uptime
- double ts = 0;
+ double ts = -1;
if (Platform.Substring(0, 3) == "Win" && UpTime != null)
{
UpTime.NextValue();
@@ -1121,7 +1113,7 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
}
// Only delay if the delay uptime is undefined (0), or the current uptime is less than the user specified max uptime to apply the delay
- LogMessage($"System uptime = {(int)ts} secs");
+ LogMessage($"System uptime = {ts:F0} secs");
if (ProgramOptions.StartupDelayMaxUptime == 0 || (ts > -1 && ProgramOptions.StartupDelayMaxUptime > ts))
{
var msg1 = $"Delaying start for {ProgramOptions.StartupDelaySecs} seconds";
@@ -1709,6 +1701,9 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)
station.StartLoop();
}
+ // let the web socket know about the station
+ WebSock.SetStation = station;
+
// If enabled generate the daily graph data files, and upload at first opportunity
LogDebugMessage("Generating the daily graph data files");
station.CreateEodGraphDataFiles();
@@ -2160,103 +2155,6 @@ private void WebTimerTick(object sender, ElapsedEventArgs e)
}
}
- internal async void UpdateTwitter()
- {
- if (station.DataStopped)
- {
- // No data coming in, do nothing
- return;
- }
-
- LogDebugMessage("Starting Twitter update");
- var auth = new XAuthAuthorizer
- {
- CredentialStore = new XAuthCredentials { ConsumerKey = twitterKey, ConsumerSecret = twitterSecret, UserName = Twitter.ID, Password = Twitter.PW }
- };
-
- if (Twitter.OauthToken == "unknown")
- {
- // need to get tokens using xauth
- LogDebugMessage("Obtaining Twitter tokens");
- await auth.AuthorizeAsync();
-
- Twitter.OauthToken = auth.CredentialStore.OAuthToken;
- Twitter.OauthTokenSecret = auth.CredentialStore.OAuthTokenSecret;
- //LogDebugMessage("Token=" + TwitterOauthToken);
- //LogDebugMessage("TokenSecret=" + TwitterOauthTokenSecret);
- LogDebugMessage("Tokens obtained");
- }
- else
- {
- auth.CredentialStore.OAuthToken = Twitter.OauthToken;
- auth.CredentialStore.OAuthTokenSecret = Twitter.OauthTokenSecret;
- }
-
- using (var twitterCtx = new TwitterContext(auth))
- {
- StringBuilder status = new StringBuilder(1024);
-
- if (File.Exists(TwitterTxtFile))
- {
- // use twitter.txt file
- LogDebugMessage("Using twitter.txt file");
- var twitterTokenParser = new TokenParser();
- var utf8WithoutBom = new UTF8Encoding(false);
- var encoding = utf8WithoutBom;
- twitterTokenParser.Encoding = encoding;
- twitterTokenParser.SourceFile = TwitterTxtFile;
- twitterTokenParser.OnToken += TokenParserOnToken;
- status.Append(twitterTokenParser);
- }
- else
- {
- // default message
- status.Append($"Wind {station.WindAverage.ToString(WindAvgFormat)} {Units.WindText} {station.AvgBearingText}.");
- status.Append($" Barometer {station.Pressure.ToString(PressFormat)} {Units.PressText}, {station.Presstrendstr}.");
- status.Append($" Temperature {station.OutdoorTemperature.ToString(TempFormat)} {Units.TempText}.");
- status.Append($" Rain today {station.RainToday.ToString(RainFormat)}{Units.RainText}.");
- status.Append($" Humidity {station.OutdoorHumidity}%");
- }
-
- LogDebugMessage($"Updating Twitter: {status}");
-
- var statusStr = status.ToString();
-
- try
- {
- Status tweet;
-
- if (Twitter.SendLocation)
- {
- tweet = await twitterCtx.TweetAsync(statusStr, (decimal)Latitude, (decimal)Longitude);
- }
- else
- {
- tweet = await twitterCtx.TweetAsync(statusStr);
- }
-
- if (tweet == null)
- {
- LogDebugMessage("Null Twitter response");
- }
- else
- {
- LogDebugMessage($"Status returned: ({tweet.StatusID}) {tweet.User.Name}, {tweet.Text}, {tweet.CreatedAt}");
- }
-
- HttpUploadAlarm.Triggered = false;
- }
- catch (Exception ex)
- {
- LogMessage($"UpdateTwitter: {ex.Message}");
- HttpUploadAlarm.LastError = "Twitter: " + ex.Message;
- HttpUploadAlarm.Triggered = true;
- }
- //if (tweet != null)
- // Console.WriteLine("Status returned: " + "(" + tweet.StatusID + ")" + tweet.User.Name + ", " + tweet.Text + "\n");
- }
- }
-
private void WundTimerTick(object sender, ElapsedEventArgs e)
{
if (!string.IsNullOrWhiteSpace(Wund.ID))
@@ -4026,6 +3924,7 @@ private void ReadIniFile()
StationOptions.Humidity98Fix = ini.GetValue("Station", "Humidity98Fix", false);
StationOptions.UseWind10MinAvg = ini.GetValue("Station", "Wind10MinAverage", false);
StationOptions.UseSpeedForAvgCalc = ini.GetValue("Station", "UseSpeedForAvgCalc", false);
+ StationOptions.UseSpeedForLatest = ini.GetValue("Station", "UseSpeedForLatest", false);
StationOptions.AvgBearingMinutes = ini.GetValue("Station", "AvgBearingMinutes", 10);
if (StationOptions.AvgBearingMinutes > 120)
@@ -4655,19 +4554,6 @@ private void ReadIniFile()
WCloud.SendLeafWetness = ini.GetValue("WeatherCloud", "SendLeafWetness", false);
WCloud.LeafWetnessSensor = ini.GetValue("WeatherCloud", "LeafWetnessSensor", 1);
- Twitter.ID = ini.GetValue("Twitter", "User", "");
- Twitter.PW = ini.GetValue("Twitter", "Password", "");
- Twitter.Enabled = ini.GetValue("Twitter", "Enabled", false);
- Twitter.Interval = ini.GetValue("Twitter", "Interval", 60);
- if (Twitter.Interval < 1)
- {
- Twitter.Interval = 1;
- rewriteRequired = true;
- }
- Twitter.OauthToken = ini.GetValue("Twitter", "OauthToken", "unknown");
- Twitter.OauthTokenSecret = ini.GetValue("Twitter", "OauthTokenSecret", "unknown");
- Twitter.SendLocation = ini.GetValue("Twitter", "SendLocation", true);
-
//if HTTPLogging then
// MainForm.WUHTTP.IcsLogger = MainForm.HTTPlogger;
@@ -5672,14 +5558,6 @@ internal void WriteIniFile()
ini.SetValue("WeatherCloud", "SendLeafWetness", WCloud.SendLeafWetness);
ini.SetValue("WeatherCloud", "LeafWetnessSensor", WCloud.LeafWetnessSensor);
- ini.SetValue("Twitter", "User", Twitter.ID);
- ini.SetValue("Twitter", "Password", Twitter.PW);
- ini.SetValue("Twitter", "Enabled", Twitter.Enabled);
- ini.SetValue("Twitter", "Interval", Twitter.Interval);
- ini.SetValue("Twitter", "OauthToken", Twitter.OauthToken);
- ini.SetValue("Twitter", "OauthTokenSecret", Twitter.OauthTokenSecret);
- ini.SetValue("Twitter", "TwitterSendLocation", Twitter.SendLocation);
-
ini.SetValue("PWSweather", "ID", PWS.ID);
ini.SetValue("PWSweather", "Password", PWS.PW);
ini.SetValue("PWSweather", "Enabled", PWS.Enabled);
@@ -6700,7 +6578,6 @@ private void ReadStringsFile()
public DateTime defaultRecordTS = DateTime.MinValue;
public string WxnowFile = "wxnow.txt";
private readonly string RealtimeFile = "realtime.txt";
- private readonly string TwitterTxtFile;
private readonly FtpClient RealtimeFTP = new FtpClient();
private SftpClient RealtimeSSH;
private volatile bool RealtimeFtpInProgress;
@@ -7061,7 +6938,7 @@ public async void DoLogFile(DateTime timestamp, bool live)
values.Append(station.CompassPoint(station.Bearing) + "',");
values.Append(station.FeelsLike.ToString(TempFormat, InvC) + ",");
values.Append(station.Humidex.ToString(TempFormat, InvC));
- values.Append(")");
+ values.Append(')');
string queryString = values.ToString();
@@ -7371,7 +7248,7 @@ public async void DoAirLinkLogFile(DateTime timestamp)
{
sb.Append("0" + ListSeparator);
}
- sb.Append("0");
+ sb.Append('0');
}
var success = false;
@@ -8333,8 +8210,6 @@ public void DoFTPLogin()
}
// Extra files
- LogFtpDebugMessage("SFTP[Int]: Uploading extra files");
- var cnt = 0;
for (int i = 0; i < numextrafiles; i++)
{
var uploadfile = ExtraFiles[i].local;
@@ -8353,7 +8228,8 @@ public void DoFTPLogin()
if (File.Exists(uploadfile))
{
- cnt++;
+ LogFtpDebugMessage("FTP[Int]: Uploading Extra file: " + uploadfile);
+
remotefile = GetRemoteFileName(remotefile, logDay);
// all checks OK, file needs to be uploaded
@@ -8383,20 +8259,18 @@ public void DoFTPLogin()
{
EODfilesNeedFTP = false;
}
- LogFtpDebugMessage($"SFTP[Int]: Done uploading {cnt} extra files");
// standard files
- LogFtpDebugMessage("SFTP[Int]: Uploading standard web files");
- cnt = 0;
for (var i = 0; i < StdWebFiles.Length; i++)
{
if (StdWebFiles[i].FTP && StdWebFiles[i].FtpRequired)
{
try
{
- cnt++;
var localFile = StdWebFiles[i].LocalPath + StdWebFiles[i].LocalFileName;
var remotefile = remotePath + StdWebFiles[i].RemoteFileName;
+ LogFtpDebugMessage("FTP[Int]: Uploading standard Data file: " + localFile);
+
UploadFile(conn, localFile, remotefile, -1);
}
catch (Exception e)
@@ -8406,9 +8280,6 @@ public void DoFTPLogin()
}
}
}
- LogFtpDebugMessage($"SFTP[Int]: Done uploading {0} standard web files");
-
- LogFtpDebugMessage("SFTP[Int]: Uploading graph data files");
for (int i = 0; i < GraphDataFiles.Length; i++)
{
@@ -8419,6 +8290,8 @@ public void DoFTPLogin()
try
{
+ LogFtpDebugMessage("FTP[Int]: Uploading graph data file: " + uploadfile);
+
UploadFile(conn, uploadfile, remotefile, -1);
// The config files only need uploading once per change
if (GraphDataFiles[i].LocalFileName == "availabledata.json" ||
@@ -8434,19 +8307,17 @@ public void DoFTPLogin()
}
}
}
- LogFtpDebugMessage("SFTP[Int]: Done uploading graph data files");
- LogFtpMessage("SFTP[Int]: Uploading daily graph data files");
- cnt = 0;
for (int i = 0; i < GraphDataEodFiles.Length; i++)
{
if (GraphDataEodFiles[i].FTP && GraphDataEodFiles[i].FtpRequired)
{
- cnt++;
var uploadfile = GraphDataEodFiles[i].LocalPath + GraphDataEodFiles[i].LocalFileName;
var remotefile = remotePath + GraphDataEodFiles[i].RemoteFileName;
try
{
+ LogFtpMessage("FTP[Int]: Uploading daily graph data file: " + uploadfile);
+
UploadFile(conn, uploadfile, remotefile, -1);
// Uploaded OK, reset the upload required flag
GraphDataEodFiles[i].FtpRequired = false;
@@ -8458,7 +8329,6 @@ public void DoFTPLogin()
}
}
}
- LogFtpMessage($"SFTP[Int]: Done uploading {cnt} daily graph data files");
if (MoonImage.Ftp && MoonImage.ReadyToFtp)
{
@@ -9163,7 +9033,7 @@ public void MySqlRealtimeFile(int cycle, bool live, DateTime? logdate = null)
values.Append(((int)Math.Round(station.CurrentSolarMax)).ToString() + ",'");
values.Append((station.IsSunny ? "1" : "0") + "',");
values.Append(station.FeelsLike.ToString(TempFormat, InvC));
- values.Append(")");
+ values.Append(')');
string valuesString = values.ToString();
List cmds = new List() { valuesString };
@@ -9657,6 +9527,10 @@ private void RealtimeFTPLogin()
RealtimeFTP.DataConnectionType = FtpDataConnectionType.PASV;
LogDebugMessage("RealtimeFTPLogin: Disabling EPSV mode");
}
+ else
+ {
+ RealtimeFTP.DataConnectionType = FtpDataConnectionType.EPSV;
+ }
if (FtpOptions.Enabled)
{
@@ -10743,6 +10617,7 @@ public class StationOptions
public bool UseZeroBearing { get; set; }
public bool UseWind10MinAvg { get; set; }
public bool UseSpeedForAvgCalc { get; set; }
+ public bool UseSpeedForLatest { get; set; }
public bool Humidity98Fix { get; set; }
public bool CalculatedDP { get; set; }
public bool CalculatedWC { get; set; }
@@ -11043,13 +10918,6 @@ public class WebUploadService
public bool Updating;
}
- public class WebUploadTwitter : WebUploadService
- {
- public string OauthToken;
- public string OauthTokenSecret;
- public bool SendLocation;
- }
-
public class WebUploadWund : WebUploadService
{
public bool RapidFireEnabled;
diff --git a/CumulusMX/CumulusMX.csproj b/CumulusMX/CumulusMX.csproj
index 9efb51fb..666dd0a7 100644
--- a/CumulusMX/CumulusMX.csproj
+++ b/CumulusMX/CumulusMX.csproj
@@ -11,7 +11,8 @@
CumulusMX
v4.8
512
- 8de6c3ed
+
+
false
C:\Users\mcrossley\Code\CumulusMX-Dist\
@@ -102,28 +103,20 @@
..\packages\HidSharp.2.1.0\lib\net35\HidSharp.dll
-
- False
- ..\packages\linqtotwitter.3.1.1\lib\net45\LinqToTwitter.AspNet.dll
-
-
- False
- ..\packages\linqtotwitter.3.1.1\lib\net45\LinqToTwitterPcl.dll
-
-
- ..\packages\MailKit.3.2.0\lib\net48\MailKit.dll
+
+ ..\packages\MailKit.3.3.0\lib\net48\MailKit.dll
-
- ..\packages\MimeKit.3.2.0\lib\net48\MimeKit.dll
+
+ ..\packages\MimeKit.3.3.0\lib\net48\MimeKit.dll
-
- ..\packages\MQTTnet.3.1.2\lib\net461\MQTTnet.dll
+
+ ..\packages\MQTTnet.4.0.1.184\lib\net461\MQTTnet.dll
- ..\packages\MySqlConnector.2.1.9\lib\net471\MySqlConnector.dll
+ ..\packages\MySqlConnector.2.1.10\lib\net471\MySqlConnector.dll
-
- ..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll
+
+ ..\packages\SSH.NET.2020.0.2\lib\net40\Renci.SshNet.dll
..\packages\ServiceStack.Text.6.1.0\lib\net472\ServiceStack.Text.dll
@@ -143,16 +136,10 @@
-
- ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
+
+ ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
-
- ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll
-
-
- ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll
-
False
@@ -296,13 +283,6 @@
-
-
-
- This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-