Level Extreme .NET Magazine April 2008 issue

Universal Thread Magazine March 2007 issue


News
Links
Downloads
Articles
Book references
Conferences
Magazines
Training
Jobs
Consultants
Companies
Blogs
FAQ
Applications
What's new

User groups

Next meetings
Past meetings
User groups
Available speakers
Tips
User group leaders
Subscribe

Miscellaneous

Personalities

Universal Thread documentation

Acronyms
Affiliates
Support area
Team
Troubleshooting
Time zones
Web Service
Terms & Conditions
Copyright

Manage your account for the messages area options, your subscription information, your invoicing, youir banners and your pictures Subscribe to the Universal Thread and get all the benefits related to the messages area A corporate subscription is needed for companies that have more than one developer Access the Universal Thread store to purchase your subscription, corporate subscriptions and banners The Universal Thread is covering several conferences per year. On site, reporters cover the technical aspect of the conference as well as making interviews, taking pictures and videos and other related content. Get all the reports from our coverages site. Universal Thread home page Level Extreme .NET Magazine, a newly published online magazine by Level Extreme about Microsoft .NET technology and its community Universal Thread Magazine, a magazine dedicated to the Visual FoxPro community Web Service

The Web Service allows any user group to use the User Group Meeting Tracker to hold their data and for its display. The following Web Service sample is done for an ASP.NET application. We provide the sample. The only think you need to do is to place the required code within your actual ASP.NET project and a few other simple things. That would then allow you to benefit of the Universal Thread data within your existing user group Web site whereas needed.


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:


Benefits of using this approach

There are many benefits of using the Universal Thread Web Service for your user group Web site:

  • Increase the exposure of your meetings to Universal Thread members
  • Become part of the User Group Meeting Tracker entity
  • No need to store the speaker's picture locally (dynamically updated once the speaker update it on UT)
  • No need to store the speaker's bio locally (dynamically updated once the speaker update it on UT)
  • Data entry is done on the Universal Thread only (the use of WS useful so you can have the data displayed on your Web site)
  • Save some time by using a pre-defined display layout which can easily be adapted to fit your own needs
This data is public so at any time you can retrieve them and store them locally for backup purposes. The same applies to the speakers bios and the speakers pictures.


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
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.

 
Morgan Everett, Tiburon Inc. 
Morgan Everett has been doing .NET development for last year and a half. He has also has over four years of Web Development experience with a variety of languages (PHP, Java, Perl), and is very familiar with XML/XSLT and system administration on Windows and Unix Machines.



Copyright © 1993-2008, Level Extreme Inc., All Rights Reserved
62 Rue Doucet, Petit-Rocher, New Brunswick, E8J 1L3
Telephone: 1-506-783-9007 Email: mfournier@levelextreme.com