Skip to content

Commit

Permalink
Send system details to server
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie committed Jul 9, 2024
1 parent e0a5b43 commit 96af8b8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.7")]
[assembly: AssemblyFileVersion("1.0.0.7")]
[assembly: AssemblyVersion("1.0.0.8")]
[assembly: AssemblyFileVersion("1.0.0.8")]
2 changes: 1 addition & 1 deletion XRFAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>7</ApplicationRevision>
<ApplicationRevision>8</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
35 changes: 22 additions & 13 deletions modSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static string GetSystemDetails()
string SystemDetailsJSON = "{\"systemdetails\":[";
modDatabase.Config ConfigObj;

ConfigObj = new modDatabase.Config { Key = "System_Hostname", Value = Environment.MachineName.ToString() };
ConfigObj = new modDatabase.Config { Key = "System_Hostname", Value = Environment.MachineName };
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";

Expand Down Expand Up @@ -128,25 +128,34 @@ public static string GetSystemDetails()
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";

SystemDetailsJSON = SystemDetailsJSON.Substring(0, SystemDetailsJSON.Length - 1) + "]}";
modLogging.LogEvent(SystemDetailsJSON, EventLogEntryType.Information, 9999);

int uptimeMilliseconds = Environment.TickCount;

DriveInfo[] allDrives = DriveInfo.GetDrives();
string dLetter;
foreach (DriveInfo d in allDrives)
{
if (d.IsReady == true)
{
modLogging.LogEvent(d.Name + " Label: " + d.VolumeLabel + " Type: " + d.DriveType + " Free: " + d.TotalFreeSpace + " Total: " + d.TotalSize, EventLogEntryType.Information, 9999);
} else
dLetter = d.Name.Substring(0, 1);
ConfigObj = new modDatabase.Config { Key = "System_Drive_" + dLetter + "_Type", Value = d.DriveType.ToString() };
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";
if (d.IsReady == true && d.DriveType == DriveType.Fixed)
{
modLogging.LogEvent(d.Name + " Type: " + d.DriveType, EventLogEntryType.Information, 9999);
ConfigObj = new modDatabase.Config { Key = "System_Drive_" + dLetter + "_Label", Value = d.VolumeLabel };
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";

ConfigObj = new modDatabase.Config { Key = "System_Drive_" + dLetter + "_TotalSize", Value = d.TotalSize.ToString() };
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";

ConfigObj = new modDatabase.Config { Key = "System_Drive_" + dLetter + "_TotalFreeSpace", Value = d.TotalFreeSpace.ToString() };
modDatabase.AddOrUpdateConfig(ConfigObj);
SystemDetailsJSON = SystemDetailsJSON + JsonSerializer.Serialize(ConfigObj) + ",";
}

}

return "System details in event log";
SystemDetailsJSON = SystemDetailsJSON.Substring(0, SystemDetailsJSON.Length - 1) + "]}";
modSync.SendMessage("server", "nodedata", "systemdetails", SystemDetailsJSON);

return "System details updated";
}
catch (Exception err)
{
Expand Down

0 comments on commit 96af8b8

Please sign in to comment.