Steve Trefethen
Contact me Send mail to the author(s)
About Me
View my LinkedIn profile


Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?

Archives
Tags
Disclaimer
The posts on this weblog are provided �AS IS� with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer�s view in any way.
# Tuesday, November 11, 2008

Adding XFBML support to the Facebook Starter Kit

Posted @ 9:59AM

Categories: Facebook

Tags:

I’ve been playing around with XFBML support for Facebook and thinking about how to incorporate support for it into the Starter Kit. I haven’t decided yet if it should be added directly to the existing master page or add another master page or some other approach. If you feel strongly either way please let me know.

If you would like to add support for XFBML simply replace existing site.master with the following:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="FacebookApp.Site" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
<head runat="server">
    <title>Untitled Page</title>
    <!-- Load Javascript for Facebook Connect -->
    <script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
</head>
<body>
  <form id="form1" runat="server">
  <div>
      <asp:contentplaceholder id="MainContentPlaceHolder" runat="server"></asp:contentplaceholder>
  </div>
  </form>
  <script type="text/javascript">FB_RequireFeatures(["XFBML"], function(){ FB.Facebook.init('<%=ConfigurationSettings.AppSettings["APIKey"] %>', "xd_receiver.htm"); });</script>
</body>
</html>

Add an HTML file called xd_receiver.htm to the root of your project with this content:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cross-Domain Receiver Page</title>
</head>
<body>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.debug.js" type="text/javascript"></script> 
</body>
</html>

Once you’ve made these changes you can start using XFBML tags. Here’s an example of the <fb:user-status /> added to the Default.aspx page:

<%@ MasterType VirtualPath="~/Site.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="Server"> <h1>ASP.NET Starter Kit Application</h1> <fb:user-status uid="<%=Master.API.uid%>" /><br /> ...
# Monday, November 10, 2008

Importing photos from Picasa to Facebook always fails

Posted @ 1:09PM

Categories: General

Tags:

Over the past few months I’ve tried numerous times to import pictures into Facebook from Picasa using the import option that’s part of Facebook. Each time I try I almost always get "Importing from external sites failed. Please try again later". I think out of ~50 times I’ve tried it’s managed to work only twice but it seems more or less broken with no additional information as to what’s wrong nor any way to actually debug the problem. Here’s what I’m seeing: image

The above screenshot is from the Import option on the Profile tab.

If you’re having this problem as well please post a follow-up message here about it. If you know how/who to contact at Facebook I’d sure like to know.

Missing Install Script Extensions menu item in TestComplete

Posted @ 10:30AM

Categories: howto | Testing

Tags:  | 

Recently, I upgraded my copy of TestComplete from v6.4 to v6.5 which includes a cool new feature called Script Extensions. The online help for this feature mentions a new File|Install Script Extensions... menu item which, after upgrading was not present on the File menu.

Fortunately, there is a simple workaround which is to manually place the item onto the menu as follows:

TestComplete Customize dialog

  1. Right click on the toolbar and select Customize...
  2. On the Customize dialog click the Commands tab
  3. Select the Script Extensions Category
  4. Select the "Install Script Extensions..." item
  5. Drag/drop it onto the File menu

At present, I’m still experimenting with Script Extensions but they look very powerful and are a welcome addition to TestComplete.

# Thursday, November 06, 2008

Facebook Starter Kit updated (again) now to v2.0 release code

Posted @ 9:01PM

Categories: Facebook

Tags:

I wasn’t sure how long it was going to take to move from RC3 to the released v2.0 of the Facebook Developer’s Toolkit (FDT) but I wouldn’t have guessed it would only be hours after I posted my latest update. Anyway, here is an updated update of the v2.0 Facebook Starter Kit.

For detailed instructions on how to get started developing a Facebook Applications take a look at my wiki page which is now updated for v2.0 of FDT.

Enjoy and feedback welcome...

Facebook Developer Toolkit Starter Kit updated to v2.0 RC3

Posted @ 8:34AM

Categories: Facebook

Tags:

UPDATED: Download now points to the v2.0 release code version and here is my wiki page about using the Starter Kit.

Now that the Facebook Developer Toolkit has reached v2.0 RC3 I’ve updated my Starter Kit with the download, for VS.NET 2008, is available here. The new Toolkit has changed dramatically since v1.7 and now utilizes LINQ to XSD and Facebook.xsd to wrap the API. While a complete departure from the previous release I think the new release more natural and maps directly to the FB API as well as the documentation. Kudos to the Clarity team.

# Tuesday, October 28, 2008

VS.NET needs implicit closing of debugger files like Delphi

Posted @ 9:18AM

Categories: .NET | Development

Tags:  | 

One of the features I really miss from Delphi is the option to close files implicitly opened while debugging. You know, those files that are opened by the debugger as your stepping through code. In Delphi, those files are closed automatically at the end of the debug session thus helping keep you focused on the code you’ve been working on. I was just wading through all of the open files in my current solution and trying to close files I no longer wanted open the vast majority of which were opened during a debug session. After closing 6-8 files manually I clicked on the tab dropdown and there was still a huge list of open files so my usual approach is to close all my tabs and start opening files individually again. Here is the option as it appears in Delphi, note the default is checked. I’m sure lots of Delphi developers now take this option for granted.

Delphi Environment Options dialog

I wonder if CodeGear will have this in Prism? Anyone know how/where to make a VS.NET feature requests?

[Update: Oct. 30, 2008] Thanks to a comment I’ve logged a suggestion for this feature and if this is something you would like to see as well please vote for this request. Warning, that link may require login.

# Sunday, October 26, 2008

Using LINQ on results from SubSonic's generic ExecuteTypedList

Posted @ 10:43PM

Categories: .NET | Programming

Tags:  | 

Lately, I’ve been working on the Purchase Order portion of the EDI system I’ve blogged about. The system makes use of SubSonic, a .NET DAL framework, which comes in handy when dealing with the DB of an ERP system with 429 tables and approaching 2000 SPROCs.

Recently, I worked on the EDI 856 which is an "Advanced Ship Notice" (ASN) document that includes shipping details for the PO. Included in the line item details, as stored in the DB, are "special services" which have to be separated out from normal line items within the document. The are reason they’re stored together is historic though tangential to my point. Fetching the 856 line item data is done via a stored proc and the result set is an aggregate of fields from a number of tables as well as calculated values. Fortunately, Subsonic can generate wrappers for calling SPROCs though doesn’t provide a wrapper for the result set in cases such as this.

Working with SPROC results using SubSonic

Subsonic generates a generic method called ExecuteTypedList<> that takes a class that will be the type of an IList returned from the call like this:

SPs.SaRptShipConfirmDetails(OrderHeaderID, true).ExecuteTypedList<ShipmentDetail>(); 

SaRptShipConfirmDetails is a wrapper for the like named SPROC and this call returns an IList<ShipmentDetail> where ShipmentDetail declared as follows:

public class ShipmentDetail
{
    public int LineNumber { get; set; }
    public string SKU { get; set; }
    public string ProductDescription { get; set; }
    public int Ordered { get; set; }
    public int Committed { get; set; }
    public int Shipped { get; set; }
    public decimal Price { get; set; }
    public decimal Amount { get; set; }
    public string CountryOfOrigin { get; set; }
    public decimal UnitWeight { get; set; }
    public string SizeName { get; set; }
    public int OrderDetailID { get; set; }
    public int ProductID { get; set; }
    public string BuyerProductCode { get; set; }
    public string UOMCode { get; set; }
    public string EDIUOMCode { get; set; }
    public int ShipmentDetailId { get; set; }
}

The get/set declarations above are required allowing ExecuteTypedList<> to determine where to stuff the returned SPROC column values into the ShipmentDetail structure. In fact, the SubSonic sources for the underlying SqlQuery.BuildTypedResult method read "//coerce the values, using some light reflection". From there you can easily use LINQ to query the IList results as desired. Below is a very simple example of filtering out these "special services" by ProductID:

var lineitems = from p in Details
                    where !p.ProductID.Equals(52276) &&
                    !p.ProductID.Equals(53257)
                    select p;

Clearly this is a simple example and it would be easy enough to write logic to skip the two ProductIDs indicated though simply playing around with LINQ in this manner has been interesting. For example, it gave me an opportunity to experiment with code completion in such a case which was interesting. I definitely recommend setting up a similar example where it’s easy to test the results and give yourself time to get used to "thinking" LINQ.

Using LINQ to query for specific instances of a class within an array

Another case where LINQ came in handy was in finding data read into an in memory structure of an EDI document. I’ve created a class hierarchy for working with EDI segments which make up an EDI document and with LINQ can now easily query a loaded document looking for specific segment instances like this:

public EdiRecord[] FindSegments<T>()
{
    var query = from EdiRecord s in this
                where s.GetType() == typeof(T)
                select s;
    return query.ToArray<EdiRecord>();
}

FindSegments is a generic method that takes the class that I’m looking for an returns an array of all the instances of that class type found. I’ll admit that starting to use LINQ has been an interesting if not counter intuitive experience for me as it’s hard not to think of doing this sort of thing the "old fashioned" way and immediate start writing that code.

Lastly, a minor blog note, I’m testing a new syntax highlighter via Windows Live Writer so it will be interesting to see how well it works (or not).

Anyway, what’s been your experience using LINQ?