CISC 186
Fall 2011

Week 14 Assignment

Professor John J. Couture - Email: FALL11@JCouture.net

(Pending) Ref# A186-14
Week of 11/28/2011


Internet Data

Summary

The purpose of this assignment is to demonstrate the use of the webBrowser control and merging it with skills we have learned this semester like writing to a text file and extracting data from an XML file.  Please note that the events below are purposely separated so that it is easier to grade.  In a production program, a programmer would typically combine some events under a single button.

Reference Links:

Specification:

  1. Using the form below as your guide, create the form.  Add the listbox, buttons and labels as needed.
     
    Object Type Object Name Comments
    button btnClearDB Clear the Database
    button btnDownloadFB Download Winds Aloft / Save to Disk
    button btnUpdateDBFB Update DB with Winds Aloft Data
    button btnUpdateDBNames Update DB Station Names
    button btnLoadCombo Clear and Load ComboBox from DB
    picturebox picWeather Load with logo from NWS site
    webbrowser webbrowser1  
    StatusStrip StatusStrip1  
    ToolStripStatusLabel1 statusmsg (inside status strip)
    form icon   Load with favicon.ico from NWS
    combo box cboLocations Select Location
    label lblDate  
    list box lstWeather  

     

  2. Add a StatusStrip control to your form. 
    1. Using the dropdown box on the control, select "Status Label".
    2. Rename the status label to "statusMsg"
    3. Below, after each operation there is a "Status Message=".  What that means is I want you to update this status box using a method called Status(strMsg)
       
  3. Add a WebBrowser control to your form.  You can leave the name as WebBrowser1.  The browser control is just used in the background so you will want to detach it from the parent container (see tutorial above) and during run make it invisible.
     
  4. Set the form icon to the favicon.ico from the NWS site (probably easiest to download the icon and save it locally)
     
  5. Set the initial picture in the picWeather control to the NWS logo.  I downloaded mine from Wikipedia (search Weather Service Logo) and set the picturebox control to 150 x 150.
     
  6. Clear the Database
    1. Clear the combobox.
    2. Delete all the records in the database
    3. Status Message = "Database Has Been Cleared"
       
  7. Download Winds Aloft / Save to Disk (and the Document Complete event)
    1. Using your webbrowser control, download the winds aloft for the Continental United States (link is above)
    2. Get the data from between the PRE tags in the web page (see Downloading ... Internet Tutorial above).  Lately we have been having trouble with the NWS data being in there twice.  In class we figured out a clever way to eliminate the second set using a DO WHILE loop and checking the length of the line.  See if you can do the same.
    3. Extract the "Data Based On ..." line from the file and display it in lblDate.
    4. Save the data to a file called FBIN.txt.
    5. Status Message = "Winds Aloft Data saved to file"
       
  8. Update DB with Winds Aloft Data
    1. For each station in the FBIN.txt file, add a record to the database using the stationID as the key.  Save the entire station weather record to the "windsaloft" field in the database.
    2. Status Message = "Database Updated - Winds Aloft"
       
  9. Update DB Station Names (Updated)
    1. For each record in the database, create an XML url to look up the surface weather (see Assignment 11)  Download the surface weather and extract the station name, latitude and longitude.  Update those fields in the database. If a station cannot be found, add a try/catch so your program does not bomb.  Put "not found" in the station name.
    2. Note: You will need to use two db objects (i.e. dbRead and dbWrite).  One will be used to go down through the database and the other will be used to update fields in the database. 
    3. Note: This event will take a long time so you might want to add some code in there so that it only updates about 20 records.  There have been times when the Internet was so slow that it took over a half hour to update the 150+ records.
    4. Note: Remember, your PROGRAM is supposed to do the update to the database (i.e. update the station name, etc).  You are not supposed to do the data entry into the database by hand.  Having said that, if you do, I will give you a zero for the assignment.
    5. Status Message = "DB Station Names Updated"
       
  10. Clear and Load the ComboBox from DB
    1. Clear the Combo box
    2. for each record in the database, load the stationID (and station name if you did the Update DB Station Names code) into the combo box
    3. Status Message = "Combo Box Updated"
       
  11. Combo Box click event
    1. Ok, pay attention!  This is an important event and constitutes a large portion of your grade!
    2. Clear the list box
    3. Add the "Data Based On ..." to the listbox
    4. Determine the stationID from the ComboBox
    5. try  (as some locations do not have surface weather, you may need to have a try/catch structure here)
      • Download the XML surface weather
      • Build the weather report (see sample below) and add it to the listbox
      • Construct the Picture URL (see assignment #11), download it and replace the NWS logo.
    6. Lookup the station record in the database and extract the winds aloft field
    7. Create a NWSFB object using the winds aloft (station weather)
    8. for each of the nine altitudes, show the wind speed, direction and temperature and add it to the listbox (see below)
    9. Status Message = "List Box Updated"
       
  12. Status method
    1. Create a method called status that accepts a string parameter
    2. Update the statusMsg object with the string parameter
    3. Refresh the screen (this is done by adding a single line as follows:
      Me.Refresh
  13. NWSFB class
    1. Make sure the NWSFB class has all of the exceptions in it from assignment #6 and #9.
       
  14. Add XML comments to all your code files. 
     
  15. Add regular comments WITHIN your subroutines and functions which explain what your code is doing.
     
  16. Create an HTML file from your XML comments using your Transform program.

What to Upload (6 files)

  1. (50 points) Form1.vb - make a copy of the code file and rename it to A186-14.txt
  2. (5 points) Form1.Designer.vb - make a copy of the file and rename it to A186-14.Designer.txt
  3. (10 points) The XML documentation file named A186-14.htm
  4. (5 points) dbUpdt.vb - make a copy of the file and rename it to dbUpdt.txt
  5. (5 points) NWSFB.vb - make a copy of the file and rename it to NWSFB14.txt
  6. (25 points) Weather.mdb

Sample Output

Sample Listbox Contents:

DATA BASED ON 021800Z 
location: San Diego/Lindbergh, CA
observation_time: Last Updated on Dec 2 2009, 2:51 pm PST
latitude: 32.73
longitude: -117.17
weather: Mostly Cloudy
temperature_string: 60.0 F (15.6 C)
relative_humidity: 60
wind_string: West at 11.5 MPH (10 KT)
pressure_string: 1013.6 mb
dewpoint_string: 46.0 F (7.8 C)
windchill_string: 58 F (14 C)
visibility_mi: 10.00
Altitude Weather at 03,000 feet: Dir Calm Speed Calm Temperature N/A
Altitude Weather at 06,000 feet: Dir 320 Speed 6 Temperature +09
Altitude Weather at 09,000 feet: Dir 320 Speed 10 Temperature +05
Altitude Weather at 12,000 feet: Dir 320 Speed 12 Temperature -03
Altitude Weather at 18,000 feet: Dir 310 Speed 19 Temperature -18
Altitude Weather at 24,000 feet: Dir 290 Speed 20 Temperature -31
Altitude Weather at 30,000 feet: Dir 310 Speed 16 Temperature -47
Altitude Weather at 36,000 feet: Dir 310 Speed 18 Temperature -55
Altitude Weather at 39,000 feet: Dir 290 Speed 58 Temperature -55