Migration to a ServiceWorker for most tasks.
Implementation of basic PatchComplianceTask. First real iteration, basic/raw asf.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user