news
This commit is contained in:
@@ -77,12 +77,21 @@ Public Class frmNewsletter
|
||||
Public Function IsValidEmail(email As String) As Boolean
|
||||
If String.IsNullOrWhiteSpace(email) Then Return True
|
||||
|
||||
Try
|
||||
Dim addr = New System.Net.Mail.MailAddress(email)
|
||||
Return addr.Address = email.Trim()
|
||||
Catch
|
||||
Return False
|
||||
End Try
|
||||
Dim parts = email.Split({";"c, ","c}, StringSplitOptions.RemoveEmptyEntries)
|
||||
|
||||
For Each part In parts
|
||||
Dim addrText = part.Trim()
|
||||
If addrText = "" Then Continue For
|
||||
|
||||
Try
|
||||
Dim addr As New System.Net.Mail.MailAddress(addrText)
|
||||
If addr.Address <> addrText Then Return False
|
||||
Catch
|
||||
Return False
|
||||
End Try
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
|
||||
|
||||
@@ -63,13 +63,29 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
|
||||
Dim url = $"{_baseUrl}/carbon-cost/cn-code-defaults?cn_code={cn_code}&country_code={country_code}"
|
||||
If year.HasValue Then url &= $"&year={year.Value}"
|
||||
|
||||
Console.WriteLine($"[GetCnCodeDefaults] Request URL: {url}")
|
||||
|
||||
Dim resp = _http.QuickGetObj(url)
|
||||
If resp Is Nothing Then Throw New Exception(_http.LastErrorText)
|
||||
If resp Is Nothing Then
|
||||
Console.WriteLine("[GetCnCodeDefaults] HTTP request failed: " & _http.LastErrorText)
|
||||
Throw New Exception(_http.LastErrorText)
|
||||
End If
|
||||
|
||||
Console.WriteLine("[GetCnCodeDefaults] HTTP response received.")
|
||||
If resp.BodyStr IsNot Nothing Then
|
||||
Console.WriteLine("[GetCnCodeDefaults] Response body length: " & resp.BodyStr.Length)
|
||||
Console.WriteLine("[GetCnCodeDefaults] Body: " & resp.BodyStr)
|
||||
Else
|
||||
Console.WriteLine("[GetCnCodeDefaults] Response body is empty.")
|
||||
End If
|
||||
|
||||
Dim json As New JsonObject()
|
||||
json.Load(resp.BodyStr)
|
||||
|
||||
Dim r As New cCBAM_CnCodeDefaults_Response With {.success = json.BoolOf("success")}
|
||||
Dim successFlag = json.BoolOf("success")
|
||||
Console.WriteLine($"[GetCnCodeDefaults] JSON 'success' flag: {successFlag}")
|
||||
|
||||
Dim r As New cCBAM_CnCodeDefaults_Response With {.success = successFlag}
|
||||
|
||||
If r.success Then
|
||||
Dim d = json.ObjectOf("data")
|
||||
@@ -77,8 +93,10 @@ Public Class cATEZ_Greenpulse_CBAM_CostCalculation
|
||||
.default_emission = GetDec(d, "default_emission"),
|
||||
.benchmark = GetNullableDec(d, "benchmark")
|
||||
}
|
||||
Console.WriteLine($"[GetCnCodeDefaults] Parsed defaults: default_emission={r.data.default_emission}, benchmark={(If(r.data.benchmark.HasValue, r.data.benchmark.Value.ToString(), "null"))}")
|
||||
Else
|
||||
r.error = ParseError(json)
|
||||
Console.WriteLine($"[GetCnCodeDefaults] API error: code={r.error.code}, message={r.error.message}, statusCode={r.error.statusCode}")
|
||||
End If
|
||||
|
||||
Return r
|
||||
|
||||
Reference in New Issue
Block a user