mirror of
https://github.com/MistWeatherMedia/i2ME.git
synced 2026-11-28 22:30:55 -08:00
Attempt fixing Alerts
This commit is contained in:
1 parent
f49e4dc23b
commit
fbbfc33197
3 files changed
+50
-25
No files matched your search
@@ -5,6 +5,7 @@ using MistWX_i2Me.Schema.ibm;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Data.SQLite;
|
||||
using MistWX_i2Me.Schema.System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MistWX_i2Me.API.Products;
|
||||
|
||||
@@ -42,7 +43,7 @@ public class AlertDetailsProduct : Base
|
||||
|
||||
using (var stream = StreamFromString(res))
|
||||
{
|
||||
AlertDetailResponse? response = await JsonSerializer.DeserializeAsync<AlertDetailResponse?>(stream);
|
||||
AlertDetailResponse? response = await JsonSerializer.DeserializeAsync<AlertDetailResponse?>(stream, new JsonSerializerOptions() {DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull});
|
||||
if (response != null)
|
||||
{
|
||||
results.Add(new GenericResponse<AlertDetailResponse>(headline.Location, res, response));
|
||||
|
||||
@@ -352,6 +352,7 @@ public class AlertBulletin : I2Record
|
||||
{ "WV", "West Virginia" },
|
||||
{ "WI", "Wisconsin" },
|
||||
{ "WY", "Wyoming" },
|
||||
{ "INTL", "International" },
|
||||
};
|
||||
|
||||
|
||||
@@ -362,10 +363,19 @@ public class AlertBulletin : I2Record
|
||||
/// <returns>The vocal code as a string</returns>
|
||||
private string? MapVocalCode(string vocalCheck)
|
||||
{
|
||||
string? output = "";
|
||||
try
|
||||
{
|
||||
string vocalKey = _vocalCodes[vocalCheck];
|
||||
return vocalKey;
|
||||
if (_vocalCodes.TryGetValue(vocalCheck, out output))
|
||||
{
|
||||
string vocalKey = output;
|
||||
return vocalKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"Vocal check failed for key {vocalCheck}.");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -404,12 +414,12 @@ public class AlertBulletin : I2Record
|
||||
// Timestamp parsing
|
||||
if (detail != null)
|
||||
{
|
||||
string endTime = DateTimeOffset.FromUnixTimeSeconds(detail.endTimeUTC).ToString("yyyy MM dd HH mm").Replace(" ", "");
|
||||
string expireTime = DateTimeOffset.FromUnixTimeSeconds(detail.expireTimeUTC).ToString("yyyy MM dd HH mm").Replace(" ", "");
|
||||
string endTime = DateTimeOffset.FromUnixTimeSeconds((int)(detail.expireTimeUTC ?? 0)).ToString("yyyy MM dd HH mm").Replace(" ", "");
|
||||
string expireTime = DateTimeOffset.FromUnixTimeSeconds((int)(detail.expireTimeUTC?? 0)).ToString("yyyy MM dd HH mm").Replace(" ", "");
|
||||
string issueTime = DateTime.Parse(detail.issueTimeLocal ?? "").ToString("yyyy MM dd HH mm").Replace(" ", "");
|
||||
string processTime = DateTimeOffset.FromUnixTimeSeconds(detail.processTimeUTC).ToString("yyyy MM dd HH mm ss").Replace(" ", "");
|
||||
string processTime = DateTimeOffset.FromUnixTimeSeconds((int)(detail.processTimeUTC ?? 0)).ToString("yyyy MM dd HH mm ss").Replace(" ", "");
|
||||
|
||||
EActionCd eActionCd = new() {EActionPriority = detail.messageTypeCode};
|
||||
EActionCd eActionCd = new() {EActionPriority = (int)(detail.messageTypeCode ?? 0)};
|
||||
|
||||
switch (detail.messageType)
|
||||
{
|
||||
@@ -433,16 +443,31 @@ public class AlertBulletin : I2Record
|
||||
EETN = detail.eventTrackingNumber,
|
||||
EDesc = detail.eventDescription,
|
||||
EEndTmUTC = endTime,
|
||||
ESvrty = detail.severityCode,
|
||||
ESvrty = (int)(detail.severityCode ?? 0),
|
||||
EExpTmUTC = expireTime,
|
||||
EStTmUTC = locationInfo.gmtDiff ?? ""
|
||||
};
|
||||
|
||||
BStCd stateInfo = new()
|
||||
{
|
||||
BSt = _states["INTL"],
|
||||
Text = "INTL"
|
||||
};
|
||||
try
|
||||
{
|
||||
BSt = _states[locationInfo.stCd],
|
||||
Text = locationInfo.stCd
|
||||
};
|
||||
stateInfo = new()
|
||||
{
|
||||
BSt = _states[locationInfo.stCd],
|
||||
Text = locationInfo.stCd
|
||||
};
|
||||
} catch
|
||||
{
|
||||
stateInfo = new()
|
||||
{
|
||||
BSt = _states["INTL"],
|
||||
Text = "INTL"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
BLocCd loc = new()
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace MistWX_i2Me.Schema.ibm;
|
||||
public class AlertDetail
|
||||
{
|
||||
public string? detailKey { get; set; }
|
||||
public int messageTypeCode { get; set; }
|
||||
public long? messageTypeCode { get; set; }
|
||||
public string? messageType { get; set; }
|
||||
public string? productIdentifier { get; set; }
|
||||
public string? phenomena { get; set; }
|
||||
@@ -15,20 +15,20 @@ public class AlertDetail
|
||||
public string? officeAdminDistrictCode { get; set; }
|
||||
public string? officeCountryCode { get; set; }
|
||||
public string? eventDescription { get; set; }
|
||||
public int severityCode { get; set; }
|
||||
public long? severityCode { get; set; }
|
||||
public string? severity { get; set; }
|
||||
public List<Category>? categories { get; set; }
|
||||
public List<ResponseType>? responseTypes { get; set; }
|
||||
public string? urgency { get; set; }
|
||||
public string? urgencyCode { get; set; }
|
||||
public long? urgencyCode { get; set; }
|
||||
public string? certainty { get; set; }
|
||||
public string? certaintyCode { get; set; }
|
||||
public DateTime? effectiveTimeLocal { get; set; }
|
||||
public long? certaintyCode { get; set; }
|
||||
public string? effectiveTimeLocal { get; set; }
|
||||
public string? effectiveTimeLocalTimeZone { get; set; }
|
||||
public DateTime? expireTimeLocal { get; set; }
|
||||
public string? expireTimeLocal { get; set; }
|
||||
public string? expireTimeLocalTimeZone { get; set; }
|
||||
public long expireTimeUTC { get; set; }
|
||||
public DateTime? onsetTimeLocal { get; set; }
|
||||
public long? expireTimeUTC { get; set; }
|
||||
public string? onsetTimeLocal { get; set; }
|
||||
public string? onsetTimeLocalTimeZone { get; set; }
|
||||
public Flood? flood { get; set; }
|
||||
public string? areaTypeCode { get; set; }
|
||||
@@ -47,10 +47,9 @@ public class AlertDetail
|
||||
public string? issueTimeLocal { get; set; }
|
||||
public string? issueTimeLocalTimeZone { get; set; }
|
||||
public string? identifier { get; set; }
|
||||
public long processTimeUTC { get; set; }
|
||||
public DateTime? endTimeLocal { get; set; }
|
||||
public long? processTimeUTC { get; set; }
|
||||
public string? endTimeLocal { get; set; }
|
||||
public string? endTimeLocalTimeZone { get; set; }
|
||||
public long endTimeUTC { get; set; }
|
||||
public List<Text>? texts { get; set; }
|
||||
public List<Polygon>? polygon { get; set; }
|
||||
public string? synopsis { get; set; }
|
||||
@@ -60,7 +59,7 @@ public class AlertDetail
|
||||
public class Category
|
||||
{
|
||||
public string? category { get; set; }
|
||||
public int? categoryCode { get; set; }
|
||||
public long? categoryCode { get; set; }
|
||||
}
|
||||
|
||||
public class Flood
|
||||
@@ -90,7 +89,7 @@ public class Polygon
|
||||
public class ResponseType
|
||||
{
|
||||
public string? responseType { get; set; }
|
||||
public int? responseTypeCode { get; set; }
|
||||
public long? responseTypeCode { get; set; }
|
||||
}
|
||||
|
||||
public class AlertDetailResponse
|
||||
|
||||
Reference in new issue
Block a user