I'm working on a web service using asp.net. I'm creating a timetable display board like you see in airports, bus stations or train stations. I am in charge of creating the services for 1 station, and there are other people in charge of the other stations.
I have created my web services and now im trying to consume the others. I can consume them but everyone else has got their web services returning different values, for example, I'm returning route id, journey id, start location, end location, stops, days running, times. but other peoples web services may return data like route id, start, end, stops, times, platform, journey status. in one table, and the other data that matches up with mine in another web service.
So how do i filter out the data that i do not need, like platform and journey status in the example. Also, how would I merge everyone's data from web services into 1 grid view so i can display all the trains that pass through my station.
I'm quite new to web services, but I am trying and I have got quite a bit done by myself, im just stuck on this bit.
I hope this isn't a stupid question
Dim allStations As New List(Of ScheduleEntry)
Dim ws1 As New Hull.ArrivaServices()
For Each u1 As Hull.Result In ws1.ShowRouteByStation("hrw")
Dim s As New ScheduleEntry
s.StartTime = u1.Departure
s.StopTime = u1.Arrival
allStations.Add(s)
Next
Dim ws2 As New Heathrow.Heathrow_Airport()
For Each u2 As Heathrow.Result In ws2.GetHeathrowTrains
Dim s As New ScheduleEntry
s.StartTime = u2.BeginTime
s.StopTime = u2.EndTime
allStations.Add(s)
Next
GridView1.DataSource = allStations
GridView1.DataBind()
I converted the datasets to datatables to make it compatible with each other.
DatatableA.Merge(DatatableB)
So now DatatableA also contains all the DatatableB columns and rows. If the column names are the same and the data type is the same, the 2 columns become 1.
So I made sure the data types were the same, if they weren't I converted them, then renamed the column name in DatatableB to the column name in DatatableA.
DatatableA.Columns(columnnumber).ColumnName = "NewName"
Remember when counting the columnnumber, its left to right and the first column is 0
If I had to convert the datatype, I made a new column in DatatableB (same name as corresponding column in DatatableA)
DatatableB.Columns.Add("NewColumnName", GetType(DataType))
Then I created a loop to go through the datatable rows of the column with the data I want to convert
Dim i as integer
Dim z as integer
i = 0
z = DatatableB.Rows.Count`
and putting the new converted data in the NewColumn by using
Do until i = z
DatatableB.Rows(i)("ColumnName") = "ConvertedData)
Next
Hope this helps someone