Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes importing of Climsoft observation data using station names #9137

Merged
merged 8 commits into from
Sep 18, 2024
Merged
30 changes: 15 additions & 15 deletions instat/dlgClimSoft.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions instat/dlgClimSoft.vb
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ Public Class dlgClimSoft
Dim strTableName As String = dctTables.Item(ucrCboTable.GetText).Trim("""")
Dim strStationColumn As String = dctStationCols.Item(ucrCboStations.GetText).Trim("""")
Dim strElementsColumn As String = dctElementsCols.Item(ucrCboElements.GetText).Trim("""")
Dim strStationsValues As String = String.Join(",", ucrReceiverMultipleStations.GetVariableNamesList(bWithQuotes:=True, strQuotes:="'"))
Dim strElementsValues As String = String.Join(",", ucrReceiverMultipleElements.GetVariableNamesList(bWithQuotes:=True, strQuotes:="'"))
Dim strStationsValues As String = GetSQLArrayFilter(ucrReceiverMultipleStations.GetVariableNamesList(bWithQuotes:=False))
Dim strElementsValues As String = GetSQLArrayFilter(ucrReceiverMultipleElements.GetVariableNamesList(bWithQuotes:=False))
Dim strQueryCondition As String = " INNER JOIN station ON " & strTableName & ".recordedFrom = station.stationId" &
" INNER JOIN obselement ON " & strTableName & ".describedBy = obselement.elementId WHERE" &
" station." & strStationColumn & " IN (" & strStationsValues & ")" &
Expand Down Expand Up @@ -308,6 +308,18 @@ Public Class dlgClimSoft
End Try
End Sub

Private Function GetSQLArrayFilter(values() As String) As String
Dim strSQL As String = ""
For index As Integer = 0 To values.Length - 1
If index = 0 Then
strSQL = "'" & values(index).Replace("'", "''") & "'"
Else
strSQL = strSQL & "," & "'" & values(index).Replace("'", "''") & "'"
End If
Next
Return strSQL
End Function

Private Sub ucrControlsContents_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverMultipleStations.ControlContentsChanged, ucrReceiverMultipleElements.ControlContentsChanged, ucrCboTable.ControlContentsChanged, ucrCboQCStatus.ControlContentsChanged, ucrDtpStartDataDate.ControlContentsChanged, ucrDtpEndDataDate.ControlContentsChanged, ucrPnlOptions.ControlContentsChanged, ucrChkImportStationsMetadata.ControlContentsChanged, ucrChkImportElementsMetadata.ControlContentsChanged, ucrChkImportFlagsMetadata.ControlContentsChanged
Dim bValid As Boolean = False
If rdoData.Checked Then
Expand Down
Loading
Loading