Skip to content

Commit c391b3a

Browse files
authored
Merge pull request #775 from climsoft/UbuntuFTPplus
Upgrade to align with Ubutu and varying FTP ports
2 parents a7ed71c + ce671f7 commit c391b3a

32 files changed

+1458
-399
lines changed

ClimsoftVer4/ClimsoftVer4/Common.vb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Imports Microsoft.Win32
2+
Imports MySql.Data.MySqlClient
23
Module CommonModules
34

45
Function ViewFile(flname As String) As Boolean
@@ -39,4 +40,35 @@ errhandler:
3940

4041
End Function
4142

43+
Function Load_Files(flname As String, tblname As String, skplines As Integer, fldsep As String, Optional fldquotechar As String = "") As Boolean
44+
Dim lconn As New MySql.Data.MySqlClient.MySqlConnection
45+
' Dim cmd As MySqlConnector.MySqlCommand
46+
Dim fl As MySql.Data.MySqlClient.MySqlBulkLoader
47+
' Dim rws As Long
48+
lconn.ConnectionString = frmLogin.txtusrpwd.Text & ";AllowLoadLocalInfile=true"
49+
50+
Try
51+
lconn.Open()
52+
fl = New MySql.Data.MySqlClient.MySqlBulkLoader(lconn)
53+
54+
fl.FileName = flname
55+
fl.TableName = tblname
56+
fl.EscapeCharacter = "UTFB"
57+
fl.NumberOfLinesToSkip = skplines
58+
fl.FieldTerminator = fldsep
59+
fl.FieldQuotationCharacter = fldquotechar
60+
'fl.FieldQuotationOptional ='True',
61+
fl.Local = True
62+
63+
fl.Load()
64+
lconn.Close()
65+
Return True
66+
Catch ex As Exception
67+
lconn.Close()
68+
MsgBox(ex.Message)
69+
Return False
70+
End Try
71+
72+
End Function
73+
4274
End Module

ClimsoftVer4/ClimsoftVer4/dataEntryGlobalRoutines.vb

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
' You should have received a copy of the GNU General Public License
1515
' along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17+
Imports MySql.Data.MySqlClient
18+
1719
Public Class dataEntryGlobalRoutines
1820

1921
Public Sub messageBoxNoPreviousRecord()
@@ -67,7 +69,7 @@ Public Class dataEntryGlobalRoutines
6769
'Dim Tp As Object
6870
Dim Tp_Fahrenheit As Object
6971
Dim Tp_Celcius As Object
70-
72+
7173
Td_Fahrenheit = 9 / 5 * dryBulb + 32
7274
'2.71828183= natural number (e)
7375
Ed = 6.1078 * 2.71828183 ^ ((9.5939 * [Td_Fahrenheit] - 307.004) / (0.556 * [Td_Fahrenheit] + 219.522))
@@ -76,7 +78,7 @@ Public Class dataEntryGlobalRoutines
7678
Ea = [Ew] - 0.35 * ([Td_Fahrenheit] - [Tw_Fahrenheit])
7779
Tp_Fahrenheit = -1 * (Math.Log([Ea] / 6.1078) * 219.522 + 307.004) / (Math.Log([Ea] / 6.1078) * 0.556 - 9.59539)
7880
Tp_Celcius = 5 / 9 * ([Tp_Fahrenheit] - 32)
79-
81+
8082
'* Td in this case is Temperature drybulb,Tw wetbulb and Tp is dewpoint temperature
8183
'E is saturation vapour pressure(s.v.p.), hence Ed is s.v.p. over drybulb and Ew s.v.p. over wetbulb, Ea actual s.v.p.
8284

@@ -109,7 +111,7 @@ Public Class dataEntryGlobalRoutines
109111
End Function
110112
Public Function calculateMSLppp(ppp As String, dryBulb As String, elevation As String) As String
111113
Dim MSLppp As VariantType
112-
114+
113115
MSLppp = (ppp * (1 - 0.0065 * elevation / (dryBulb + 0.0065 * elevation + 273.15)) ^ -5.257) * 10
114116
'0.0065 is dry adiabatic lapse rate
115117
calculateMSLppp = MSLppp
@@ -125,7 +127,7 @@ Public Class dataEntryGlobalRoutines
125127
ctl.BackColor = Color.Red
126128
ctl.Focus()
127129
tabNext = False
128-
MsgBox("Number expected!", MsgBoxStyle.Critical)
130+
MsgBox("Number expected!", MsgBoxStyle.Critical)
129131
End If
130132
End Function
131133
Public Function checkLowerLimit(ctl As Control, ByVal obsVal As String, ByVal valLowerLimit As String) As Boolean
@@ -198,7 +200,7 @@ Public Class dataEntryGlobalRoutines
198200
MsgBox("Invalid month!", MsgBoxStyle.Critical)
199201
End If
200202
End Function
201-
203+
202204
Public Function checkValidYear(ByVal strVal As String, ctl As Control) As Boolean
203205
If Val(strVal) >= 1000 And Val(strVal) <= 9999 Then
204206
checkValidYear = True
@@ -773,7 +775,7 @@ Public Class dataEntryGlobalRoutines
773775
conn.ConnectionString = dbConnectionString
774776
conn.Open()
775777
sql = "SELECT * FROM regkeys"
776-
dar = New MySql.Data.MySqlClient.MySqlDataAdapter(Sql, conn)
778+
dar = New MySql.Data.MySqlClient.MySqlDataAdapter(sql, conn)
777779
dar.Fill(dsr, "regkeys")
778780

779781
regmax = dsr.Tables("regkeys").Rows.Count
@@ -816,7 +818,7 @@ Public Class dataEntryGlobalRoutines
816818
End If
817819
FileOpen(16, outDataFile, OpenMode.Output)
818820

819-
connstr = frmLogin.txtusrpwd.Text
821+
connstr = frmLogin.txtusrpwd.Text & ";Convert Zero Datetime=True;AllowLoadLocalInfile=true" ' & ";AllowLoadLocalInfile=true;SslMode=VerifyCA"
820822
con0.ConnectionString = connstr
821823
con0.Open()
822824

@@ -861,7 +863,7 @@ Public Class dataEntryGlobalRoutines
861863
' Push data to the remote server
862864
Dim conn0 As New MySql.Data.MySqlClient.MySqlConnection
863865
Dim builder As New Common.DbConnectionStringBuilder()
864-
'Dim a As MySql.Data.MySqlClient.MySqlDataAdapter
866+
'Dim a As MySqlConnector.MySqlDataAdapter
865867
'Dim s As New DataSet
866868

867869
Try
@@ -873,7 +875,7 @@ Public Class dataEntryGlobalRoutines
873875
builder("uid") = frmLogin.txtUsername.Text
874876
builder("pwd") = frmLogin.txtPassword.Text
875877

876-
connstr = builder.ConnectionString & ";Convert Zero Datetime=True"
878+
connstr = builder.ConnectionString & ";Convert Zero Datetime=True;AllowLoadLocalInfile=true" ';SslMode=VerifyCA"
877879
'MsgBox(connstr)
878880
conn0.ConnectionString = connstr
879881
conn0.Open()
@@ -890,6 +892,10 @@ Public Class dataEntryGlobalRoutines
890892
Next
891893
End With
892894
outDataFile = Strings.Replace(outDataFile, "\", "/")
895+
896+
'MsgBox(outDataFile)
897+
'Load_Files(outDataFile, tbl, 0, ",")
898+
893899
sql = "LOAD DATA LOCAL INFILE '" & outDataFile & "' REPLACE INTO TABLE " & tbl & " FIELDS TERMINATED BY ',' (" & flds & ");"
894900

895901
qry = New MySql.Data.MySqlClient.MySqlCommand(sql, conn0)
@@ -1105,4 +1111,35 @@ Public Class dataEntryGlobalRoutines
11051111
Return False
11061112
End Try
11071113
End Function
1114+
1115+
Function Load_Files(flname As String, tblname As String, skplines As Integer, fldsep As String, Optional fldquotechar As String = "") As Boolean
1116+
Dim lconn As New MySql.Data.MySqlClient.MySqlConnection
1117+
' Dim cmd As MySqlConnector.MySqlCommand
1118+
Dim fl As MySql.Data.MySqlClient.MySqlBulkLoader
1119+
' Dim rws As Long
1120+
lconn.ConnectionString = frmLogin.txtusrpwd.Text & ";AllowLoadLocalInfile=true"
1121+
1122+
Try
1123+
lconn.Open()
1124+
fl = New MySql.Data.MySqlClient.MySqlBulkLoader(lconn)
1125+
1126+
fl.FileName = flname
1127+
fl.TableName = tblname
1128+
fl.EscapeCharacter = "UTFB"
1129+
fl.NumberOfLinesToSkip = skplines
1130+
fl.FieldTerminator = fldsep
1131+
fl.FieldQuotationCharacter = fldquotechar
1132+
'fl.FieldQuotationOptional ='True',
1133+
fl.Local = True
1134+
1135+
fl.Load()
1136+
lconn.Close()
1137+
Return True
1138+
Catch ex As Exception
1139+
lconn.Close()
1140+
MsgBox(ex.Message)
1141+
Return False
1142+
End Try
1143+
1144+
End Function
11081145
End Class

ClimsoftVer4/ClimsoftVer4/formAWSRealTime.Designer.vb

Lines changed: 43 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)