Migration to a ServiceWorker for most tasks.

Implementation of basic PatchComplianceTask. First real iteration, basic/raw asf.
This commit is contained in:
2025-11-04 13:55:04 +08:00
parent aacd8e0293
commit d880ebeedb
23 changed files with 1527 additions and 6 deletions

View File

@@ -264,6 +264,44 @@ namespace LD_SysInfo.Services
return response;
}
/// <summary>
/// Sends Windows update history (patch compliance data) to the backend API
/// </summary>
public async Task<bool> PostPatchComplianceAsync(object patchData)
{
try
{
if (string.IsNullOrEmpty(jwtToken))
{
Console.WriteLine("❌ Not authenticated. Cannot send patch compliance data.");
return false;
}
var jsonContent = JsonConvert.SerializeObject(patchData);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
var response = await SendWithAutoReauthAsync(() =>
httpClient.PostAsync(BuildUrl("/api/patch-compliance"), content)
);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("✅ Patch compliance data sent successfully.");
return true;
}
else
{
Console.WriteLine($"❌ Failed to send patch compliance data: {response.StatusCode}");
return false;
}
}
catch (Exception ex)
{
Console.WriteLine($"❌ Exception sending patch compliance data: {ex.Message}");
return false;
}
}
}
}