Fix build errors: FrozenDictionary (.NET 8) and Flurl 3.x API compatibility
- Replace FrozenDictionary with IReadOnlyDictionary for .NET 6 compat - Use WithHeader instead of SetHeader for Flurl.Http 3.2.4 - Fix FlurlHttpException error logging for Flurl 3.x Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2da2ded84c
commit
0c918e86ae
|
|
@ -1,5 +1,3 @@
|
||||||
using System.Collections.Frozen;
|
|
||||||
|
|
||||||
namespace InnovEnergy.App.Backend.Services;
|
namespace InnovEnergy.App.Backend.Services;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -43,7 +41,7 @@ public static class AlarmKnowledgeBase
|
||||||
// Register addresses: 0x1048 - 0x10D5
|
// Register addresses: 0x1048 - 0x10D5
|
||||||
// Recovery types: AUTO (wait), MANUAL (fix and restart), SERVICE (contact service)
|
// Recovery types: AUTO (wait), MANUAL (fix and restart), SERVICE (contact service)
|
||||||
|
|
||||||
private static readonly FrozenDictionary<string, DiagnosticResponse> SinexcelAlarms = new Dictionary<string, DiagnosticResponse>
|
private static readonly IReadOnlyDictionary<string, DiagnosticResponse> SinexcelAlarms = new Dictionary<string, DiagnosticResponse>
|
||||||
{
|
{
|
||||||
// Grid-related alarms
|
// Grid-related alarms
|
||||||
["Abnormal grid voltage"] = new()
|
["Abnormal grid voltage"] = new()
|
||||||
|
|
@ -958,12 +956,12 @@ public static class AlarmKnowledgeBase
|
||||||
Causes = new[] { "Load exceeds generator capacity" },
|
Causes = new[] { "Load exceeds generator capacity" },
|
||||||
NextSteps = new[] { "Reduce load", "Fix the cause, then restart" }
|
NextSteps = new[] { "Reduce load", "Fix the cause, then restart" }
|
||||||
},
|
},
|
||||||
}.ToFrozenDictionary();
|
};
|
||||||
|
|
||||||
// ── Growatt Alarms ───────────────────────────────────────────────────────
|
// ── Growatt Alarms ───────────────────────────────────────────────────────
|
||||||
// Format: "Warning XXX" or "Error XXX" or descriptive text
|
// Format: "Warning XXX" or "Error XXX" or descriptive text
|
||||||
|
|
||||||
private static readonly FrozenDictionary<string, DiagnosticResponse> GrowattAlarms = new Dictionary<string, DiagnosticResponse>
|
private static readonly IReadOnlyDictionary<string, DiagnosticResponse> GrowattAlarms = new Dictionary<string, DiagnosticResponse>
|
||||||
{
|
{
|
||||||
// Warnings (200-series: PV/String)
|
// Warnings (200-series: PV/String)
|
||||||
["Warning 200"] = new()
|
["Warning 200"] = new()
|
||||||
|
|
@ -1510,5 +1508,5 @@ public static class AlarmKnowledgeBase
|
||||||
Causes = new[] { "Too many PV modules in series", "Cold temperature increasing Voc" },
|
Causes = new[] { "Too many PV modules in series", "Cold temperature increasing Voc" },
|
||||||
NextSteps = new[] { "Disconnect DC switch immediately", "Check voltage", "Reconfigure strings if needed" }
|
NextSteps = new[] { "Disconnect DC switch immediately", "Check voltage", "Reconfigure strings if needed" }
|
||||||
},
|
},
|
||||||
}.ToFrozenDictionary();
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,7 @@ Reply with ONLY valid JSON, no markdown:
|
||||||
};
|
};
|
||||||
|
|
||||||
var responseText = await MistralUrl
|
var responseText = await MistralUrl
|
||||||
.SetHeader("Authorization", $"Bearer {_apiKey}")
|
.WithHeader("Authorization", $"Bearer {_apiKey}")
|
||||||
.SetHeader("Content-Type", "application/json")
|
|
||||||
.PostJsonAsync(requestBody)
|
.PostJsonAsync(requestBody)
|
||||||
.ReceiveString();
|
.ReceiveString();
|
||||||
|
|
||||||
|
|
@ -147,7 +146,7 @@ Reply with ONLY valid JSON, no markdown:
|
||||||
}
|
}
|
||||||
catch (FlurlHttpException httpEx)
|
catch (FlurlHttpException httpEx)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"[DiagnosticService] HTTP error {httpEx.Response?.StatusCode}: {await httpEx.Response?.GetStringAsync()}");
|
Console.Error.WriteLine($"[DiagnosticService] HTTP error {httpEx.StatusCode}: {httpEx.Message}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue