-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclsInputFile.vb
215 lines (180 loc) · 7.15 KB
/
clsInputFile.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
Imports System.IO
Public MustInherit Class clsInputFile
Shared Function GetFileOpenFilter() As String
Dim alInputFileTypes As ArrayList = New ArrayList
Dim ift As clsInputFileTypes
'Visiontac
ift = New clsInputFileTypes
ift.FileTypeDisplay = "Visiontac"
ift.FileType = "visiontac"
ift.AddFileExtension("csv")
alInputFileTypes.Add(ift)
'G21App
ift = New clsInputFileTypes
ift.FileTypeDisplay = "Gilbert 21 App sound files"
ift.FileType = "G21App"
ift.AddFileExtension("wav")
ift.AddFileExtension("3gp")
alInputFileTypes.Add(ift)
'Evernote export file
ift = New clsInputFileTypes
ift.FileTypeDisplay = "Evernote export file"
ift.FileType = "evernoteexport"
ift.AddFileExtension("enex")
alInputFileTypes.Add(ift)
'Images
ift = New clsInputFileTypes
ift.FileTypeDisplay = "Images"
ift.FileType = "image"
ift.AddFileExtension("bmp")
ift.AddFileExtension("jpg")
ift.AddFileExtension("jpeg")
ift.AddFileExtension("gif")
ift.AddFileExtension("tif")
ift.AddFileExtension("tiff")
alInputFileTypes.Add(ift)
'Return file open dialog string
Dim strFilter As String = ""
Dim i As Integer
Dim j As Integer
For i = 0 To alInputFileTypes.Count - 1
ift = alInputFileTypes(i)
If i > 0 Then
strFilter = strFilter & "|"
End If
strFilter = strFilter & ift.FileTypeDisplay & " (*."
For j = 0 To ift.FileExtensions.Count - 1
If j > 0 Then
strFilter = strFilter & "; *."
End If
strFilter = strFilter & ift.FileExtensions(j)
Next
strFilter = strFilter & ")|*."
For j = 0 To ift.FileExtensions.Count - 1
If j > 0 Then
strFilter = strFilter & "; *."
End If
strFilter = strFilter & ift.FileExtensions(j)
Next
Next
Return strFilter & "|All files (*.*)|*.*"
End Function
Public Function SearchFolderForFile(ByVal strFolder As String, ByVal strFile As String) As String
Dim strSubFolder As String
Dim strFoundFile As String
Dim strFileName = Path.GetFileName(strFile)
If Directory.Exists(strFolder) Then
For Each strFoundFile In Directory.GetFiles(strFolder)
If Path.GetFileName(strFoundFile).ToLower = strFileName.ToLower Then
Return strFoundFile
End If
Next
For Each strSubFolder In Directory.GetDirectories(strFolder)
strFoundFile = SearchFolderForFile(strSubFolder, strFile)
If strFoundFile <> "" Then
Return strFoundFile
End If
Next
End If
Return ""
End Function
Public Function GetEmptyRecordsDatatable() As DataTable
'####
'objRecordMapping(0) = New clsRecordMapping("ID", "ID", OleDb.OleDbType.Integer, 0, False, False, False)
'objRecordMapping(1) = New clsRecordMapping("GUID", "GUID", OleDb.OleDbType.VarWChar, 36, False, False, False)
'bjRecordMapping(6) = New clsRecordMapping("Entered", "Entered", OleDb.OleDbType.Date, 0, False, False, False)
'objRecordMapping(7) = New clsRecordMapping("Modified", "Modified", OleDb.OleDbType.Date, 0, False, False, False)
'objRecordMapping(8) = New clsRecordMapping("NoExport", "NoExport", OleDb.OleDbType.Boolean, 0, False, True, False)
'objRecordMapping(21) = New clsRecordMapping("Lon", "Lon", OleDb.OleDbType.Double, 0, False, False, False)
'objRecordMapping(22) = New clsRecordMapping("Lat", "Lat", OleDb.OleDbType.Double, 0, False, False, False)
'objRecordMapping(25) = New clsRecordMapping("TimeZone", "TimeZone", OleDb.OleDbType.VarWChar, 50, False, False, False)
'#####
Dim dt As DataTable = New DataTable
dt.Columns.Add("GUID")
dt.Columns.Add("FileLon")
dt.Columns.Add("FileLat")
dt.Columns.Add("Filename")
dt.Columns.Add("FileIndex")
dt.Columns.Add("DateTimeKey")
dt.Columns.Add("RecDate")
dt.Columns.Add("RecTime")
dt.Columns.Add("VoiceFile")
dt.Columns.Add("MediaFile")
dt.Columns.Add("Recorder")
dt.Columns.Add("Determiner")
dt.Columns.Add("Confirmer")
dt.Columns.Add("GridRef")
dt.Columns.Add("Location")
dt.Columns.Add("Town")
dt.Columns.Add("ScientificName")
dt.Columns.Add("CommonName")
dt.Columns.Add("TaxonGroup")
dt.Columns.Add("Abundance")
dt.Columns.Add("Units")
dt.Columns.Add("Comment")
dt.Columns.Add("PersonalNotes")
Return dt
End Function
Public Function GetEmptyTrackDatatable() As DataTable
Dim dt As DataTable = New DataTable
dt.Columns.Add("TrackID")
dt.Columns.Add("Lon")
dt.Columns.Add("Lat")
dt.Columns.Add("Date")
dt.Columns.Add("Time")
Return dt
End Function
Private strErrorMessage As String = ""
Public Property ErrorMessage() As String
Get
Return strErrorMessage
End Get
Set(ByVal value As String)
strErrorMessage = value
End Set
End Property
Private strFilePath As String = ""
Public Property FilePath() As String
Get
Return strFilePath
End Get
Set(ByVal value As String)
strFilePath = value
End Set
End Property
Public MustOverride Function GetTracks() As DataTable()
Public MustOverride Function AllTrackPoints() As DataTable
Public MustOverride Function GetPotentialRecords() As DataTable
Public MustOverride Function LocationFromTime(ByVal dtetim As DateTime) As DataTable
Public MustOverride Function TimeFromLocation(ByVal lat As Double, ByVal lon As Double) As DataTable
Public MustOverride Function TrackToPoint(ByVal ref As String, ByVal dte As String, ByVal time As String, ByVal intPoints As Integer) As DataTable
Public Class clsInputFileTypes
Private strFileType As String = ""
Public Property FileType() As String
Get
Return strFileTypeDisplay
End Get
Set(ByVal value As String)
strFileType = value
End Set
End Property
Private strFileTypeDisplay As String = ""
Public Property FileTypeDisplay() As String
Get
Return strFileTypeDisplay
End Get
Set(ByVal value As String)
strFileTypeDisplay = value
End Set
End Property
Private alFileExtensions As ArrayList = New ArrayList
Public ReadOnly Property FileExtensions() As ArrayList
Get
Return alFileExtensions
End Get
End Property
Public Sub AddFileExtension(ByVal strExtension)
alFileExtensions.Add(strExtension)
End Sub
End Class
End Class