How does it work?
Lets assume the Montreal FoxPro User Group. There Web site is at http://www.mfug.ca. In their default page, they list the upcoming meetings. For that area, they can bind it to the Universal Thread and pull the data from here. The benefits of that is that is allows a centralization of the data gathering so Universal Thread members know about your user group and meetings. That increases the exposure of your meeting announcements. It also allows the user group Webmaster to save some time by using existing code for a pre-defined format which can easily be adapted. That also still allows you to modify your Web site in any way you want which is one of the benefits of using Web Services. The data entry has to be done presently here but there are plans to ease that part as well.
So, here's a picture of the Montreal FoxPro User Group default page:
As you can see, they are listing the upcoming meeting (the September 2003 one) of Drew Speedie.
Basically, once that page is updated to an ASP.NET aspx page, there would then be the ability to replace the meeting section with the necessary code to grab it from the Universal Thread.
So, the following can then be obtained:
Use it from ASP.NET
Here are the steps to use it:
1. Adding a reference to the Universal Thread Web Service
- Under Web References, select Add Web Reference.
- The URL is http://www.universalthread.com/WebService/UniversalThread.asmx.
- Right click on the Web Reference and rename it UserGroupMeetingTracker.
2. Adding the Label control
- In your ASP.NET aspx page, in the Design window, add a Label control.
- Place it where you want to display the list of meetings.
- Change its name to UpcomingMeeting.
3. Adding the Page_Load() event code
In your ASP.NET aspx page, in the Code Behind file, add the following code in the Page_Load() event:
'Instantiate Web service
Dim loUT As UserGroupMeetingTracker.UniversalThread = New UserGroupMeetingTracker.UniversalThread
Dim llLogged As Boolean
Dim lnCompteur As Integer
Dim lcHtml As String
Dim ldDate As DateTime
Dim lcDay As String
Dim lnSpeaker1 As Integer
Dim lnSpeaker2 As Integer
Dim lnSpeaker3 As Integer
Dim lcUsername As String
Dim lcPassword As String
Dim lnDaysBack As Integer
Dim lnDaysNext As Integer
Dim lnUserGroupID As Integer
' Web Service authentication
lcUsername = ""
lcPassword = ""
' Number of days to go back to retrieve the user group meetings
lnDaysBack = 150
' Number of days to go next to retrieve the user group meetings
lnDaysNext = 300
' User group ID to retrieve the user group meetings
lnUserGroupID = 12198
' Create the cookie container
loUT.CookieContainer = New System.Net.CookieContainer
' Do the login
llLogged = loUT.Login(lcUsername, lcPassword)
If Not llLogged Then
UpcomingMeeting.Text = "The Universal Thread authentication failed!"
Return
End If
Dim loData As DataSet
loData = New DataSet
' Read the user group meetings
lnDaysBack = lnDaysBack * -1
loData = loUT.GetUserGroupMeetingDataSet(DateAdd("d", lnDaysBack, Date.Today), _
DateAdd("d", lnDaysNext, Date.Today), lnUserGroupID)
' Display the user group meetings
lcHtml = ""
For lnCompteur = 0 To loData.Tables("Temp").Rows.Count - 1 Step lnCompteur + 1
ldDate = loData.Tables("Temp").Rows(lnCompteur)("MeetingDate")
' Calculate the day in Monday format such as M in uppercase
' and the rest in lowercase for the related day of the week.
lcDay = ldDate.ToString("dddd")
lcDay = lcDay.Substring(0, 1).ToUpper + lcDay.Substring(1)
lcHtml = lcHtml + "<B><FONT COLOR=GREEN>" + lcDay + " " + _
ldDate.ToString("dd MMMM, yyyy HH:mm") + "</FONT>"
lcHtml = lcHtml + "<P>"
lcHtml = lcHtml + loData.Tables("Temp").Rows(lnCompteur)("Title") + "</B>"
lcHtml = lcHtml + "<P>"
lcHtml = lcHtml + loData.Tables("Temp").Rows(lnCompteur)("Summary")
' Speaker(s)
lnSpeaker1 = loData.Tables("Temp").Rows(lnCompteur)("SpeakerID1")
lnSpeaker2 = loData.Tables("Temp").Rows(lnCompteur)("SpeakerID2")
lnSpeaker3 = loData.Tables("Temp").Rows(lnCompteur)("SpeakerID3")
If lnSpeaker1 > 0 Or lnSpeaker2 > 0 Or lnSpeaker3 > 0 Then
lcHtml = lcHtml + "<P>"
lcHtml = lcHtml + "<B>"
If lnSpeaker1 > 0 And lnSpeaker2 = 0 Then
lcHtml = lcHtml + "Speaker:"
Else
lcHtml = lcHtml + "Speakers:"
End If
lcHtml = lcHtml + "</B>"
lcHtml = lcHtml + "<P>"
' Speaker 1
lcHtml = lcHtml + AddSpeaker(lnSpeaker1, _
loData.Tables("Temp").Rows(lnCompteur)("SpeakerPicture1"), _
loData.Tables("Temp").Rows(lnCompteur)("Speaker1"), _
loData.Tables("Temp").Rows(lnCompteur)("SpeakerBio1"))
' Speaker 2
lcHtml = lcHtml + AddSpeaker(lnSpeaker2, _
loData.Tables("Temp").Rows(lnCompteur)("SpeakerPicture2"), _
loData.Tables("Temp").Rows(lnCompteur)("Speaker2"), _
loData.Tables("Temp").Rows(lnCompteur)("SpeakerBio2"))
' Speaker 3
lcHtml = lcHtml + AddSpeaker(lnSpeaker3, _
loData.Tables("Temp").Rows(lnCompteur)("SpeakerPicture3"), _
loData.Tables("Temp").Rows(lnCompteur)("Speaker3"), _
loData.Tables("Temp").Rows(lnCompteur)("SpeakerBio3"))
End If
lcHtml = lcHtml + "<P>"
lcHtml = lcHtml + "<HR>"
lcHtml = lcHtml + "<P>"
Next
lcHtml = lcHtml + "</TABLE>"
UpcomingMeeting.Text = lcHtml
4. Customizing the environment
- Adjust the lcUsername and lcPassword variables with your Universal Thread username and password.
- Adjust the lnDaysBack and lnDaysNext for the user group meetings criteria.
- Adjust the lnUserGroupID to match the User Group ID you wish to use.
5. Adding the AddSpeaker() function
In the code behind file, add the following function:
' Add a speaker
' expN1 Speaker ID
' expL1 If the speaker picture is available
' expC1 Speaker name
' expM1 Speaker bio
Private Function AddSpeaker(ByVal tnSpeakerID, ByVal tlPicture, ByVal tcName, ByVal tmBio)
Dim lcHtml As String
Dim lcUniversalThread As String
lcHtml = ""
' Universal Thread url
lcUniversalThread = "http://www.universalthread.com/"
If tnSpeakerID > 0 Then
lcHtml = lcHtml + "<TABLE CELLSPACING=0 CELLPADDING=0>"
lcHtml = lcHtml + "<TR VALIGN=TOP>"
lcHtml = lcHtml + "<
If tlPicture Then
lcHtml = lcHtml + "<IMG SRC=" + lcUniversalThread + "Photo/" + _
tnSpeakerID.ToString().PadLeft(6, "0") + ".jpg>"
Else
lcHtml = lcHtml + "<IMG SRC=" + lcUniversalThread + "Photo/PictureNotAvailable.jpg>"
End If
lcHtml = lcHtml + "<BR>"
lcHtml = lcHtml + tcName
lcHtml = lcHtml + "<TD WIDTH=4>"
lcHtml = lcHtml + "<TD>"
lcHtml = lcHtml + tmBio
lcHtml = lcHtml + "</TABLE>"
End If
lcHtml = lcHtml + "<P>"
Return lcHtml
End Function
Use it from a Windows Service
This approach is an interesting one and probably the best if you want to minimize the risk of connection failure of the related page and if you wish to improve the speed access of the data. This approach limits the number of server ops so there would be less chance of connection failure across the net. As the data would come locally, the speed should also be faster.
The concept relates to use a Windows Service to poll the data at specific interval from the Universal Thread server. The polled data is then stored locally into an XML file. You can then update your existing ASP.NET which displays the list of meetings to grab the data from that file.
- Download the installation file - Size: 224k, Date: October 21, 2003
- Unzip it
- Execute Setup.exe
- Update the Poller.config file
- Right click on My Computer
- Select Manage
- Go in Services and Application
- Click on Services
- Locate "Universal Thread UGMT Poller"
- Define how you want it to start
- Update your related user group meeting page to read the XML data in the way you wish to display it
This service has been built in C# by Morgan Everett, a regular Universal Thread .NET forum contributers.