I have the below working code, but I would rather pull everything into a class then be able to work on it that way vs the way I have it.
Any thoughts or guidance on a better way to code this would be great!
'get all of the stop address details - move them into a in memory clone to stop it from going back to the database for each search later
Dim stopAddressList = From s In db.stop_address_details Select s
Dim searchAddressList = stopAddressList.ToArray
DataGridView1.DataSource=stopAddressList.ToArray ' debug code - remove
command.CommandText="select distinct on (customer_reference) customer_reference, stop_name, stop_address, actual_service_date, Actual_arrival_time, stop_signature " & _
"from cops_reporting.distribution_stop_information " & _
"where customer_no = '91000' and stop_signature <> '' and datetime_updated > '"& lastDatetimeUpdated & "' and datetime_updated < '" & endDate &"'"
PgSqlConnection1.Open ' opens the connection to the postgresql server
Label1.Text = "opening reader..."
Using reader As PgSqlDataReader =command.ExecuteReader()
Label1.Text = "starting"
Dim customerReferenceNo, stopName, recBy As String
'go see if this is one of the sites we are monitoring
Dim searchfor = From f In searchAddressList Where f.customer_reference_no = customerReferenceNo Select f
label1.text = totalRecordCount.ToString
If searchfor.Count>0 ' found it, now see if we already have this POD in our database - the below code will be replaced with a more through routine
Dim dateOfStop As Date = reader.GetValue(3)
Dim timeOfStop As TimeSpan = reader.GetValue(4)
Dim datetimeOfStop As Date = dateOfStop.Add(timeOfStop)
TextBox1.AppendText ("Stop at " & customerReferenceNo & " for " & stopName & " signed for by " & recBy & " at " & datetimeOfStop.ToString & " - " & timeOfStop.ToString & vbCrLf)
Label1.Text = "record count: " & foundRecordCount & " out of " & totalRecordCount