Skip to content

Commit

Permalink
Merge pull request #205 from mcrossley/main
Browse files Browse the repository at this point in the history
v4.1.3 - b4028
  • Loading branch information
mcrossley authored Aug 20, 2024
2 parents de21df5 + 0846c46 commit e521632
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 108 deletions.
7 changes: 6 additions & 1 deletion CumulusMX.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
Expand All @@ -13,13 +12,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Debug|x86.ActiveCfg = Debug|x86
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Debug|x86.Build.0 = Debug|x86
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Release|Any CPU.Build.0 = Release|Any CPU
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Release|x86.ActiveCfg = Release|x86
{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
101 changes: 67 additions & 34 deletions CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

using Swan;

using static System.Net.WebRequestMethods;
using static CumulusMX.EmailSender;

using File = System.IO.File;
Expand Down Expand Up @@ -589,6 +588,8 @@ public void Initialise(int HTTPport, bool DebugEnabled, string startParms)

boolWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

LogMessage("Dotnet Version: " + RuntimeInformation.FrameworkDescription);

// Some .NET 8 clutures use a non-"standard" minus symbol, this causes all sorts of parsing issues down the line and for external scripts
// the simplest solution is to override this and set all cultures to use the hypen-minus
if (CultureInfo.CurrentCulture.NumberFormat.NegativeSign != "-")
Expand Down Expand Up @@ -3911,6 +3912,7 @@ private void ReadIniFile()
WllApiKey = ini.GetValue("WLL", "WLv2ApiKey", string.Empty);
WllApiSecret = ini.GetValue("WLL", "WLv2ApiSecret", string.Empty);
WllStationId = ini.GetValue("WLL", "WLStationId", -1, -1);
WllStationUuid = ini.GetValue("WLL", "WLStationUuid", "");
WllTriggerDataStoppedOnBroadcast = ini.GetValue("WLL", "DataStoppedOnBroadcast", true);
WLLAutoUpdateIpAddress = ini.GetValue("WLL", "AutoUpdateIpAddress", true);
WllBroadcastDuration = ini.GetValue("WLL", "BroadcastDuration", WllBroadcastDuration);
Expand Down Expand Up @@ -5608,6 +5610,7 @@ internal void WriteIniFile()
ini.SetValue("WLL", "WLv2ApiKey", Crypto.EncryptString(WllApiKey, Program.InstanceId, "WllApiKey"));
ini.SetValue("WLL", "WLv2ApiSecret", Crypto.EncryptString(WllApiSecret, Program.InstanceId, "WllApiSecret"));
ini.SetValue("WLL", "WLStationId", WllStationId);
ini.SetValue("WLL", "WLStationUuid", WllStationUuid);
ini.SetValue("WLL", "DataStoppedOnBroadcast", WllTriggerDataStoppedOnBroadcast);
ini.SetValue("WLL", "PrimaryRainTxId", WllPrimaryRain);
ini.SetValue("WLL", "PrimaryTempHumTxId", WllPrimaryTempHum);
Expand Down Expand Up @@ -7301,6 +7304,7 @@ public void WriteStringsFile()
internal string WllApiKey;
internal string WllApiSecret;
internal int WllStationId;
internal string WllStationUuid;
internal int WllParentId;
internal bool WllTriggerDataStoppedOnBroadcast; // trigger a data stopped state if broadcasts stop being received but current data is OK
/// <value>Read-only setting, default 20 minutes (1200 sec)</value>
Expand Down Expand Up @@ -11140,17 +11144,17 @@ private async Task<bool> UploadString(HttpClient httpclient, bool incremental, s
if (FtpOptions.PhpCompression == "gzip")
{
using var zipped = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Compress, true);
await zipped.WriteAsync(byteData, 0, byteData.Length, cancellationToken);
await zipped.WriteAsync(byteData.AsMemory(0, byteData.Length), cancellationToken);
}
else if (FtpOptions.PhpCompression == "deflate")
{
using var zipped = new System.IO.Compression.DeflateStream(ms, System.IO.Compression.CompressionMode.Compress, true);
await zipped.WriteAsync(byteData, 0, byteData.Length, cancellationToken);
await zipped.WriteAsync(byteData.AsMemory(0, byteData.Length), cancellationToken);
}

ms.Position = 0;
byte[] compressed = new byte[ms.Length];
await ms.ReadAsync(compressed, 0, compressed.Length, cancellationToken);
await ms.ReadAsync(compressed.AsMemory(0, compressed.Length), cancellationToken);

outStream = new MemoryStream(compressed);
streamContent = new StreamContent(outStream);
Expand Down Expand Up @@ -12498,7 +12502,6 @@ public void RealtimeFTPLogin()
Credentials = new NetworkCredential(FtpOptions.Username, FtpOptions.Password),
};

RealtimeFTP.Config.SocketPollInterval = 20000; // increase beyond the timeout value
RealtimeFTP.Config.LogPassword = false;

SetRealTimeFtpLogging(FtpOptions.Logging);
Expand Down Expand Up @@ -12908,50 +12911,80 @@ public async Task GetLatestVersion()
var body = await retval.Content.ReadAsStringAsync();
var releases = body.FromJson<List<GithubRelease>>();

var latestBuild = releases.Find(x => !x.draft && x.prerelease == beta);
var latestBeta = releases.Find(x => !x.draft && x.prerelease);
var latestLive = releases.Find(x => !x.draft && !x.prerelease);
var cmxBuild = int.Parse(Build);
var veryLatest = Math.Max(int.Parse(latestBuild.tag_name[1..]), int.Parse(latestLive.tag_name[1..]));
int veryLatest;
if (latestBeta == null)
veryLatest = int.Parse(latestLive.tag_name[1..]);
else
veryLatest = Math.Max(int.Parse(latestBeta.tag_name[1..]), int.Parse(latestLive.tag_name[1..]));

if (string.IsNullOrEmpty(latestLive.name))
{
if (releases.Count == 0)
{
LogMessage("Failed to get the latest build version from GitHub");
}
return;
}
else if (string.IsNullOrEmpty(latestBuild.name))
{
LogMessage($"Failed to get the latest {(beta ? "beta" : "release")} build version from GitHub");
}
else if (beta && int.Parse(latestLive.tag_name[1..]) > cmxBuild)
{
var msg = $"You are running a beta version of Cumulus MX, and a later release build {latestLive.name} is available.";
LogConsoleMessage(msg, ConsoleColor.Cyan);
LogWarningMessage(msg);
UpgradeAlarm.LastMessage = $"Release build {latestLive.name} is available";
UpgradeAlarm.Triggered = true;
LatestBuild = latestLive.tag_name[1..];
}
else if (int.Parse(latestBuild.tag_name[1..]) > cmxBuild)
else if (latestBeta != null && string.IsNullOrEmpty(latestBeta.name))
{
var msg = $"You are not running the latest {(beta ? "beta" : "release")} version of Cumulus MX, build {latestBuild.name} is available.";
LogConsoleMessage(msg, ConsoleColor.Cyan);
LogWarningMessage(msg);
UpgradeAlarm.LastMessage = $"{(beta ? "Beta" : "Release")} build {latestBuild.name} is available";
UpgradeAlarm.Triggered = true;
LatestBuild = latestBuild.tag_name[1..];
LogMessage("Failed to get the latest beta build version from GitHub");
return;
}
else if (int.Parse(latestBuild.tag_name[1..]) == cmxBuild)

if (beta)
{
LogMessage($"This Cumulus MX instance is running the latest {(beta ? "beta" : "release")} version");
UpgradeAlarm.Triggered = false;
LatestBuild = latestBuild.tag_name[1..];
if (int.Parse(latestLive.tag_name[1..]) > cmxBuild)
{
var msg = $"You are running a beta version of Cumulus MX, and a later release build {latestLive.name} is available.";
LogConsoleMessage(msg, ConsoleColor.Cyan);
LogWarningMessage(msg);
UpgradeAlarm.LastMessage = $"Release build {latestLive.name} is available";
UpgradeAlarm.Triggered = true;
LatestBuild = latestLive.tag_name[1..];
}
else if (latestBeta != null && int.Parse(latestBeta.tag_name[1..]) == cmxBuild)
{
LogMessage($"This Cumulus MX instance is running the latest beta version");
UpgradeAlarm.Triggered = false;
LatestBuild = latestLive.tag_name[1..];
}
else if (latestBeta != null && int.Parse(latestBeta.tag_name[1..]) > cmxBuild)
{
LogMessage($"This Cumulus MX beta instance is not running the latest beta version of Cumulsus MX, build {latestBeta.name} is available.");
UpgradeAlarm.Triggered = false;
LatestBuild = latestLive.tag_name[1..];
}
else
{
LogWarningMessage($"This Cumulus MX instance appears to be running a beta test version. This build={Build}, latest available build={veryLatest}");
LatestBuild = veryLatest.ToString();
}
}
else if (int.Parse(latestBuild.tag_name[1..]) < cmxBuild)
else // Live release
{
LogWarningMessage($"This Cumulus MX instance appears to be running a test version. This build={Build}, latest available build={veryLatest}");
LatestBuild = veryLatest.ToString();
if (int.Parse(latestLive.tag_name[1..]) > cmxBuild)
{
var msg = $"You are not running the latest version of Cumulus MX, build {latestLive.name} is available.";
LogConsoleMessage(msg, ConsoleColor.Cyan);
LogWarningMessage(msg);
UpgradeAlarm.LastMessage = $"Release build {latestLive.name} is available";
UpgradeAlarm.Triggered = true;
LatestBuild = latestBeta != null ? latestBeta.tag_name[1..] : latestLive.tag_name[1..];
}
else if (int.Parse(latestLive.tag_name[1..]) == cmxBuild)
{
LogMessage($"This Cumulus MX instance is running the latest release version");
UpgradeAlarm.Triggered = false;
LatestBuild = latestBeta != null ? latestBeta.tag_name[1..] : latestLive.tag_name[1..];
}
else
{
LogWarningMessage($"This Cumulus MX instance appears to be running a test version. This build={Build}, latest available build={veryLatest}");
LatestBuild = veryLatest.ToString();
}
}
}
catch (Exception ex)
Expand Down
33 changes: 26 additions & 7 deletions CumulusMX/CumulusMX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<IsPublishable>False</IsPublishable>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<Nullable>annotations</Nullable>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -25,6 +26,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<OutputPath />
<DefineConstants>TRACE;DEBUG;USE_SQLITEPCL_RAW</DefineConstants>
<NoWarn>1701;1702</NoWarn>
<WarningsAsErrors>NU1605</WarningsAsErrors>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath></OutputPath>
<DebugType>none</DebugType>
Expand All @@ -35,8 +44,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<OutputPath />
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<DefineConstants>TRACE;USE_SQLITEPCL_RAW</DefineConstants>
<NoWarn>1701;1702</NoWarn>
<WarningsAsErrors>NU1605</WarningsAsErrors>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<PropertyGroup>
<Version>4.1.2.4027</Version>
<Version>4.1.3.4028</Version>
<Copyright>Copyright © 2015-$([System.DateTime]::Now.ToString('yyyy')) Cumulus MX</Copyright>
</PropertyGroup>

Expand Down Expand Up @@ -69,19 +88,19 @@
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="FluentFTP.Logging" Version="1.0.0" />
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
<PackageReference Include="NReco.Logging.File" Version="1.2.0" />
<PackageReference Include="NReco.Logging.File" Version="1.2.1" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.8" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.9" />
<PackageReference Include="System.CodeDom" Version="8.0.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
<PackageReference Include="EmbedIO" Version="3.5.2" />
<PackageReference Include="FluentFTP" Version="50.0.1" />
<PackageReference Include="FluentFTP" Version="51.0.0" />
<PackageReference Include="HidSharp" Version="2.1.0" />
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="MailKit" Version="4.7.1.1" />
<PackageReference Include="MQTTnet" Version="4.3.6.1152" />
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="ServiceStack.Text" Version="8.2.2" />
<PackageReference Include="SSH.NET" Version="2024.0.0" />
<PackageReference Include="ServiceStack.Text" Version="8.3.0" />
<PackageReference Include="SSH.NET" Version="2024.1.0" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
</ItemGroup>
Expand Down
Loading

0 comments on commit e521632

Please sign in to comment.