March 2008 - Posts

Today I've created my first bona fide mashup using the Yahoo! Maps API and the Twitter API to map my friends' location. Although I've been playing around with many Web 2.0 APIs, this is the first time I've combined any of them in true mashup fashion.

This was all done in JavaScript without resorting to any C# or VB.NET code. I've started to use Twitter a lot more after discovering that many of my YouTube vlogger friends are using it. There are also many prominent ASP.NET developers using Twitter so I'm following them as well. Unfortunately, not everyone I'm following has entered their location in a sensible format so I needed to create a regular expression to filter out anyone who did not use their city and state. I was only able to map four friends. I used their actual profile images as the marker images and their name as the marker tooltip that appears when you mouse over the marker. As you can see in the screenshot below, there is also a neat logging window that you can display to help you troubleshoot the Yahoo! Maps API.

Yahoo! Map Twitter

I've been reading the book "Amazon.com Mashups" by Francis Shanahan which provided some sample code for using the Yahoo! Map API. This book covers more than the Amazon APIs and it uses C# for its example web applications so you may want to read it. I've been working on a Demand Responsive Transport application so I even wrote some code to display pickup and destination addresses on a map.

You can find the live version here: http://www.williamsportwebdeveloper.com/yahoo-map-twitter.html Just view source to get the JavaScript source code.

Over the long weekend I made some excellent progress in my online video production work. I managed to significantly improve the quality of my YouTube videos and I explored Microsoft Expression Encoder and Silverlight Streaming.

I found some excellent tips on how to improve the quality of my videos for YouTube on the WordPress blog of Kevin Nalts. Nalts is one of the major vloggers on YouTube. He is very popular in the community because his videos are really funny and often clever. He is a marketing professional and does not try to hide it. That should have really worked against him because the community does not like corporate marketing but Nalts manages to get away with it. Nalts really knows what he is doing so I've found it a good idea to follow his lead. For example, I bought a similar camcorder to the one he sold on eBay, the Panasonic PVGS120 MiniDV Camcorder with 3CCD, and this proved to be an excellent camcorder that can handle any lighting conditions unlike my cheap SONY HandyCam.

I put some more time into studying the Video.Show open sourced web application for online video sharing. First, I looked into how it was using Microsoft Expression Encoder. I examined the XML job file and saw that it uses a template that ships with Microsoft Expression Encoder. I created my own job to see how changing the output settings would modify this XML file. I discovered that Microsoft Expression Encoder can actually output an entire Silverlight application including a video player for your video. This doesn't leave anything for the programmer to do! There was even a Visual C# project file. Microsoft Expression Encoder has several templates so I don't see much point in trying to roll your own video player.

Next I turned my attention to the Silverlight Streaming video hosting service. My account did not list any videos so I uploaded one of my vacation videos. It gave me the HTML for an iframe but I noted the web address of the WMV video file and plugged that into the mediaUrl in the StartPlayer.js file of the Silverlight application created by Microsoft Expression Encoder. This converted the local video source into a hosted streaming media source. I then customized the web page for my web site and changed the background color of the canvas. (I was going to link to this page on my web site but now it cannot find the media file for some reason).

Next weekend I'll try to spend more time on Video.Show. I need to determine how to log encoding and upload errors and look into replacing the encoding application with an open source alternative, VLC or MediaCoder.

Today I've just realized that the vast majority of my work has been customizing shipping rules. You'll never be out of work if you specialize in shipping rules. Businesses can never seem to accept the default shipping options and software cannot be designed with a fully configurable shipping rule system. All ecommerce shopping carts try to make the shipping options configurable but they simply can't accommodate all the special needs for pricing and shipping a wide variety of products.

My work experience has shown me many scenarios where shipping rules will probably need to be enforced through custom code. For example, if you are shipping hazardous chemicals you will need to apply extra shipping charges for the special handling. Most ecommerce shopping carts do not provide any options for hazardous products. Food items are another product type that often has complicated shipping rules to apply. A food item may require refrigerated shipping or it may need to be sent on a particular day of the week after certain hours. International shipping often creates headaches as companies can lose a lot of money if they don't charge enough.

Given the vast amount of work to be had in enforcing shipping rules, what can you do to grab some of it? There is actually a lot of preparation you should do. Most shipping carriers offer web services for acquiring shipping rates. You should teach yourself how to use those web services. If you specialize in ASP.NET then you should know how send a request and process the response using ASP.NET. You should request developer or business accounts from USPS, UPS, FreightQuote, FedEx, and any other shipping carrier that offers free access to registered users.

In regards to ASP.NET, there are many specific programming tasks that you'll want to learn. For example, if a product can only be shipped on a particular day of the week then you need to be familiar with the DayOfWeek property for a DateTime object. The TimeSpan object is another important structure to get familiar with. If you have a requirement to ship within 10 business days then you need to exclude weekends from a time span. It can get surprisingly complicated. You might even need to look up US holidays so you don't try to ship on a holiday.

Then you need to study the shipping options and shipping code for many popular ecommerce shopping carts. I have the shipping methods for Storefront extensively documented. I should probably leverage my expertise by studying OsCommerce and a few other shopping carts, restricting myself to their shipping modules.

In addition to all that work there are other considerations. You need to understand UPS zones and be able to desk check shipping charges when a client claims the calculated shipping is way off. It can get very confusing and you'll need to act as a shipping department specialist. :)

I'm back from a fantastic vacation, the first YouCruise, a Carnival cruise organized by YouTube vloggers. I will blog about the cruise extensively elsewhere but I do think it is appropriate to write about the social computing aspects here.

There is a lot of industry buzz about social networking. Some trade magazines even suggest it is relevant to enterprise IT. I didn't take it seriously until I got heavily involved in the YouTube community where it is possible to actually get to know people quite well and make a lot of friends. Unlike any other web site I've known, YouTube inspires a significant emotional investment in the site. I've seen a grown man cry when his account got suspended due to terms of service violations. Being banished from your community is cruel. I've seen entrepreneurs get wildly excited about the YouTube community and become self-appointed technology evangelists just to express their enthusiasm for the site. In fact, there is a group of vloggers currently scheming to create something to address the shortcomings of YouTube's messaging system and various interpersonal communication issues. Although LiveVideo is now a technically superior vlogging platform, the fierce loyalty to YouTube has prevented that site from attracting much interest.

The technology media have somehow managed to completely overlook the YouTube craze. I still find a lot of articles that only treat YouTube as a video sharing site with no mention of the social networking community that thrives there. Even vloggers are conscious that many people still "do not get it".

The YouCruise was an interesting development because it was not organized by the YouTube staff. I don't even think they knew about it. The YouCruise was just an idea for a gathering put forth by one of my favorite vloggers. I never would have considered going on a Carnival cruise without this enticement. If I had won a cruise in a contest, I probably would have given it away because I'm not adventurous. But this Carnival cruise was a truly awe inspiring experience and it has drastically heightened my appreciation for the YouTube community which led to it. In July, I hope to attend the Yo'Tube gathering in Philadelphia which promises to be a huge event.

Computing is changing from an impersonal, anti-social activity to highly social interaction that forms real community. I've seen ample evidence that this will change people's lives.

 

I've been struggling to solve a file lock problem with some files I send as email attachments. I finally solved the problem by creating my documents in memory and sending the email attachment from a memory stream. This eliminated the need to write a file to disk and delete it later. I didn't find any sample code that did exactly what I wanted so I'll share the code I finally came up with.

   1: Imports System.Net.Mail
   2: Imports System.IO
   3:  
   4: Partial Class MemoryStreamAttachment
   5:     Inherits System.Web.UI.Page
   6:  
   7:     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   8:         Dim strMailServer As String = "mail.williamsportwebdeveloper.com"
   9:         Dim fs As New FileStream("C:\Documents and Settings\Robert Robbins\My Documents\Visual Studio 2008\WebSites\dev35\documents\Fax Cover Letter.rtf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
  10:         Dim srTemplateReader As New StreamReader(fs)
  11:         Dim objMemoryStreamCoverLetter As New MemoryStream()
  12:         Dim strCoverLetter As New System.Text.StringBuilder("")
  13:         Dim strLine As String
  14:  
  15:         '--read through template form, replace variables and add lines to string builder
  16:         Do While srTemplateReader.Peek() >= 0
  17:             strLine = srTemplateReader.ReadLine()
  18:             '--replace [Date_Time]
  19:             strLine = strLine.Replace("[Date_Time]", Now())
  20:             '--replace [Recipient_Name]
  21:             strLine = strLine.Replace("[Recipient_Name]", "John Smith")
  22:             '--replace [Recipient_Fax]
  23:             strLine = strLine.Replace("[Recipient_Fax]", "1-555-555-5320")
  24:             '--replace [Applicant_Name]
  25:             strLine = strLine.Replace("[Applicant_Name]", "Robert S. Robbins")
  26:             strCoverLetter.Append(strLine)
  27:         Loop
  28:  
  29:         Dim enc As New UTF8Encoding
  30:         Dim arrBytData() As Byte = enc.GetBytes(strCoverLetter.ToString())
  31:         objMemoryStreamCoverLetter.Write(arrBytData, 0, arrBytData.Length)
  32:         objMemoryStreamCoverLetter.Position = 0
  33:  
  34:         '--release file system resources
  35:         srTemplateReader.Close()
  36:         srTemplateReader.Dispose()
  37:         fs.Close()
  38:         fs.Dispose()
  39:  
  40:         Dim objMM As New MailMessage
  41:         Dim objSMTP As New SmtpClient
  42:         Dim toAddress As New MailAddress("robert_robbins@verizon.net", "Robert S. Robbins")
  43:         objMM.To.Add(toAddress)
  44:         Dim fromAddress As New MailAddress("robert@williamsportwebdeveloper.com", "Robert S. Robbins")
  45:         objMM.From = fromAddress
  46:         objMM.IsBodyHtml = False
  47:         objMM.Priority = MailPriority.Normal
  48:         objMM.Subject = "Memory Stream Email Attachment"
  49:         objMM.Body = "See email attachment. Sent: " & Now()
  50:         ' add fax cover page as first file attachment
  51:         objMM.Attachments.Add(New Attachment(objMemoryStreamCoverLetter, "Fax Cover Letter.rtf"))
  52:  
  53:         Try
  54:             objSMTP.Host = strMailServer
  55:             objSMTP.DeliveryMethod = SmtpDeliveryMethod.Network
  56:             objSMTP.Credentials = New System.Net.NetworkCredential("robert@williamsportwebdeveloper.com", "******")
  57:             objSMTP.Send(objMM)
  58:             lblMessage.Text = "Mail Sent"
  59:         Catch ex As Exception
  60:             lblErrorMessage.Text = ex.Message & "<br />" & ex.StackTrace
  61:         End Try
  62:     End Sub
  63: End Class
More Posts