SharePoint 2010
[Image via Tihomir Ignatov]

Setting up a SharePoint Development Server

Recently I wanted to start some SharePoint 2010 development, and taking Microsoft’s recommendation that developing for SharePoint be conducted on a machine that already has it installed, I set out to create development-optimized SharePoint environment. One of the greatest tools I came across was the SharePoint 2010 Easy Setup Script. The script is a set ofWindows PowerShell scripts that install and configure all the pre-requisites and products to get you developing for SharePoint in no time. Running these scripts will install evaluation versions of:

  • SharePoint Server 2010 + pre-requisites (Standalone)
  • Visual Studio 2010 Ultimate Edition
  • Silverlight 4 Tools for Visual Studio
  • Expression Studio 4 Ultimate
  • Open XML SDK
  • Visual Studio SDK
  • Visual Studio SharePoint Power Tools
  • Office 2010 Professional Plus
  • SharePoint Designer 2010
  • Visio 2010

After downloading and extracting, the installation files will be installed to C:\SharePoint2010EasySetup by default. The next step is to configure the scripts:

Configuring the Installation Scripts

Navigate to C:\SharePoint2010EasySetup\Labs\EasySetup\Source and locate the config.xml file. This is the file you want to modify. Here you can set up a virtual hard disk to install applications to and comment out any applications that you do notwant installed. In my case I wanted to do a fresh install of a Windows 7 64bit operating system on my local operating system, rather than on a virtual disk (it’s recommended to do a fresh install when installing to your local os). After editing the configuration file you will want to save the configuration file and then execute the run.bat file.

Running the scripts:

In the same directory running the Run.bat file will execute the Windows PowerShell scripts in the correct order.  The scripts will download the evaluation versions of the software, install them and configure them. During this process I was asked to reboot several times.

SharePoint 2010 Development Resources:

If you are completely new to SharePoint development I found some of the following resources helpful:

  • SharePoint Server Virtual Labs: MSDN has some free virtual labs. You can use Hyper V to remote into the remote machine provided by Microsoft, which is preconfigured for you to follow the training labs. While these labs are ready to go and everything is set up for you, I did find the remote connection a little slow.
  • Share Point 2010 Training Videos: Microsoft MSDN has some great SharePoint videos that I found very helpful. The videos also link to corresponding labs for you to try your new skills, as well as provide quizzes to make sure you really understand the material.
  • SharePoint 2010 Books: I have been reading SharePoint master Tom Rizzo’s Professional SharePoint 2010 Development
  • Also, for those interested in Team-Based SP development, MVP Andrew Connell has written a very thorough and cohesive article for MSDN on the subject.http://msdn.microsoft.com/en-us/library/gg512102.aspx

This article and many others like this can be found on my SoftArtisans blog.

I was recently asked to work on a site running FMyScript. The problem was this every time a voting link was clicked the link would just disappear and the votes were not updated.

The solution was two fold:

Part 1:
The first problem was the voting links has a ‘ in the string such as “I’m really sad to hear that” So I just changed the string instead of finding all the places I might have to escape it. I figured I am is better grammar anyways.

Part 2:
The domain must the config file. That means if you set up your site with the www in the url and someone goes to your site without the www in the url the voting system will not work.

I modified the .htaccess files to force www by adding the following lines:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]

I hope this helps someone.

Disclaimer: While this article was written before I started working at SoftArtisans, I do work at SoftArtisans now.  Support for SoftArtisans products can be found at http://support.softartisans.com/

So today I tried out a product from SoftArtisans called OfficeWriter specifically the WordWriter feature. You can find a Demo here. I set out to create an application that would allow me to fill in a form and generate mailing labels to be printed. I found out that with SoftArtisans product this was extremely easy.

First I created a Mail Merge template in Microsoft office. You can download a copy of my Label Template if you would like.

Then I wrote the following code:

  protected void generateBtn_Click(object sender, EventArgs e)
        {
            // Variables
            object[] arrValues = { firstNameTxt.Text, lastNameTxt.Text, addressTxt.Text, cityTxt.Text, stateTxt.Text, zipCodeTxt.Text };
            generateLabels(arrValues);

        }

        private void generateLabels(object[] arrValues)
        {
            WordTemplate wt = new WordTemplate();
            wt.Open("C:/labels.doc");
            string[] arrNameFields = { "First_Name", "Last_Name", "Address_Line_1", "City", "State", "ZIP_Code" };

            //Bind Mail Merge Fields with Data
            wt.SetDataSource(arrValues, arrNameFields);

            wt.Process();
            //Save to browser
            wt.Save(Page.Response, "Labels.doc", false);
        }

with the following front end:

When opening the generate document I had the following output:

You can download my solution here, but remember that you need an Office Writer license or you must be using the demo license.

So in one of my recent projects I had to parse a Flickr feed and extract the image urls the code I came up with is as follows:

<?php
/* Author: Samuel Haddad
 * SimpleXML Flicker Feed Parser
 */
//Feed URL in RSS Format
$url ="http://api.flickr.com/services/feeds/photos_public.gne?lang=en-us&format=rss_200"; //FEED URL

//Use simple XML to parse the feed
$xml = simplexml_load_file($url);
$items = $xml->xpath('/rss/channel/item');
foreach($items as $item){
 $nsmedia = $item->children('http://search.yahoo.com/mrss/');
 $img = $nsmedia->content->attributes();
 echo $img; //URL of Image
 echo "<br/>";
}
?>

Of course my code did more then just extract the URL, but I will leave the rest up to the creative developers.

Akismet

Many avid bloggers are already familiar with Akismet and rightfully so.  Akismet does an amazing job of eliminating spam. It will catch 99% of spam and put it in the spam queue.  Head over to http://akismet.com/ and install Akismet. You will need to sign up for a WordPress account and get an API key. Don’t worry it takes 2 seconds and is worth it. Once Akismet is installed need to go to your Akismet Configuration, which is under plugins, and enter your WordPress API key. There is also a check box label “Automatically discard spam comments on posts older than a month.”  I chose to uncheck this. With this checked if Akismet detects spam on a post you wrote over a month ago it will just delete it. While Akismet is really good there is a chance you could lose some legitimate comments. If you combine this plugin with the one below there is really no use for this. However the choice is yours.  After that it is just a matter of waiting and letting Akismet do its work.

Akismet will install a little control panel to view statistics it will look something like this:

Akismet Control Panel

From the WordPress dashboard you will want to check your Spam Queue to make sure that no legitimate messages get through. It does not happen often, but it does.

WP-Ban

Akismet does an amazing  job of stoping spam comments from getting to your inbox. How about stoping spam before it ever gets submitted? That is were WP-Ban comes in. WP-Ban can be found at http://wordpress.org/extend/plugins/wp-ban/

Basically this can be used to block anyone from ever viewing your blog on the IP level.  Granted many spammers will jump though proxies and use 10 different IP’s in a minute. I noticed that I was getting 100’s of spam comments from 1 or 2 IP addresses. I would block that one IP for example the following 4 IP addresses accounted for over 400 spam comments in a day:

194.8.75.149
194.8.75.163
194.8.75.220
194.8.74.220

Blocking those 4 IP address pretty much stopped my spam.

I would be very selective in blocking IP addresses, do not use ranges and never block your own IP.  Over the past week I have seen spam almost stop dead in it’s tracks.