Tuesday, October 05, 2010

New Kayak Build: Black Pearl

Two years on from building a Guillemot Kayaks Night Heron stitch and glue I’ve just purchased plans for a Bjorn Thomasson Black Pearl. The Night Heron is a great kayak that’s very quick in the water but I just enjoyed the building side too much so I’ve decided to try building a strip kayak. Rather than go with something closer to the Night Heron I decided to go down a slightly different path:

  • As light as possible – means small or low volume
  • Doesn’t need speed – the Night Heron fulfils that requirement for me
  • Play boat – I’ve taken up canoe polo so I want the most manuverable sea kayak experience I can get – something that will respond to hip/torso movement.

I think the Black Pearl will do this but the proof will be in the pudding. You don’t just order this off the book – the plans are custom printed to your height, arm span and hip measurements.

I’ll update the blog as I go. It will take awhile – no rush as I have an existing kayak already.

Monday, October 04, 2010

Populating a Word Document from a Sharepoint List

I thought this would be simpler since Sharepoint and Word are so closely related. A mail merge based on list data perhaps? Maybe it’s possible with an office data connection file but I couldn’t figure it out.

Well, it was useful to me so here’s how I did it with Powershell and Word automation. The example here is a list of standards and the output will be a list of those standards formatted on one Word document. The soap call from powershell comes from somewhere on the net with an added soapaction header. The list has been created with folder items so it needs to list the items recursively – this wouldn’t apply to a normal list. You’ll figure it out as you start looking at the xml attributes. Best way to make progress with these sharepoint soap calls is to use Wireshark in combination with Stramit Caml Viewer.

Here we go…

function Execute-SOAPRequest 
[Xml] $SOAPRequest,
[String] $SOAPAction,
[String] $URL
write-host "Sending SOAP Request To Server: $URL"
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction","`"" + $SOAPAction + "`"")

$soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
$soapWebRequest.Accept = "text/xml"
$soapWebRequest.Method = "POST"

write-host "Authenticating"
$soapWebRequest.Credentials = [System.Net.CredentialCache]::DefaultCredentials
if($soapWebRequest.Proxy -ne $null) {
$soapWebRequest.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

write-host "Initiating Send."
$requestStream = $soapWebRequest.GetRequestStream()

write-host "Send Complete, Waiting For Response."
$resp = $soapWebRequest.GetResponse()
$responseStream = $resp.GetResponseStream()
$soapReader = [System.IO.StreamReader]($responseStream)
$ReturnXml = [Xml] $soapReader.ReadToEnd()

write-host "Response Received."

return $ReturnXml

function Add-Standard
[String] $Standard,
[String] $Justification,
$p = $Doc.Paragraphs.Add()
$p.Range.Text = $Standard
$p.Format.Style = "Heading 1"

$p = $Doc.Paragraphs.Add()
$p.Range.Text = $Justification

$d4 = [xml] @"
<?xml version="
1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<ViewAttributes Scope="Recursive"/>

# create a document from list data!
$w = new-object -com Word.Application
$w.Visible = $true
$d = $w.Documents.Add()

Execute-SOAPRequest -SOAPRequest $d4 -SOAPAction "
http://schemas.microsoft.com/sharepoint/soap/GetListItems" -URL "http://<some sharepoint site>/sites/CTO/_vti_bin/lists.asmx" |
foreach {$_.Envelope.Body.GetListItemsResponse.GetListItemsResult.listitems.data.row |
foreach {Add-Standard -Standard $_.ows_Standard -Justification $_.ows_Justification -d $d }