Things hard and not so hard.... RSS 2.0
# Monday, February 11, 2013

After wrestling with this tonight for sometime I’ve finally cracked it. SP2013 RTMed and alot of the sample code fails due to the fact that you need to now add ‘..;odata=verbose’ onto pretty much every call to SharePoint.

Basically you get a series of errors such as:

MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/atom+xml;type=entry, application/atom+xml, application/json;odata=verbose

 

Previously alot of the sample code has

$.getJSON(….) as part of the call to the server – as mentioned we now need to add some custom header values of ‘odata=verbose’, so to save you hours of slogging on this, the getJSON call doesn’t allow custom header values. You need to use the $.ajax(…) for these calls.

READING FROM A LIST

function getCustomers() {
 

  // begin work to call across network
  var requestUri = _spPageContextInfo.webAbsoluteUrl +
                "/_api/Web/Lists/getByTitle('CustomersREST')/items/" +
                "?$select=Id,FirstName,Title,WorkPhone" +
                "&$orderby=Title,FirstName";
   
  var requestHeaders = {
      "accept": "application/json;odata=verbose"
  }
    // execute AJAX request
  $.ajax({
      url: requestUri,
      type: 'GET',
      dataType: 'json',
      headers: requestHeaders,
      success: onDataReturned,
      error: onError
  });
}

 

UPDATING A LIST ITEM

//Sample code to update a Customer List Item in a Customer List called ‘CustomersREST’

function updateCustomer(dialogResult, returnValue) {

  if (dialogResult == SP.UI.DialogResult.OK) {
    var Id = returnValue.Id;
    var FirstName = returnValue.FirstName;
    var LastName = returnValue.LastName;
    var WorkPhone = returnValue.WorkPhone;
    var etag = returnValue.etag;

    var requestUri = _spPageContextInfo.webAbsoluteUrl +
              "/_api/Web/Lists/getByTitle('CustomersREST')/items(" + Id + ")";

    var customerData = {
      __metadata: { "type": "SP.Data.CustomersRESTListItem" },
      Title: LastName,
      FirstName: FirstName,
      WorkPhone: WorkPhone
    };

    requestBody = JSON.stringify(customerData);

    var requestHeaders = {
        "accept": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
        "X-HTTP-Method": "MERGE",
        "content-length": requestBody.length,
        "content-type" : "application/json;odata=verbose",
        "If-Match": etag
    }

    $.ajax({
      url: requestUri,
      type: "POST",
      contentType: "application/json;odata=verbose",
      headers: requestHeaders,
      data: requestBody,
      success: onSuccess,
      error: onError
    });

  }

}

Monday, February 11, 2013 10:47:06 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
.NET Developer | SharePoint | 2013 | Tips
# Tuesday, November 20, 2012

While on SharePoint 2013 training we came across all the different ways of calling SharePoint and it’s data through JavaScript, JQuery and all the bits.

It was all looking good until we needed to update sharepoint – e.g. a list, a list item etc.

The MS Course notes say – “if you’re in SharePoint you can get the Form Digest from the main SharePoint Form….”

 

What about if you’re running outside of SharePoint (a Provider App – they now call it, or Cloud Hosted…depending on who wrote the help article)

 

The answer in the notes is… go and make an old fashion call to Sites.asmx SOAP WebService…. from client side javascript this is going to be a feat.

….

The Answer – make a REST call to get the ‘Context Info’ first, then you’ll have the form digest and you’re done.

http://msdn.microsoft.com/en-us/library/fp142386(office.15).aspx#bk_synchronize (just at the top of this page)

 

Table 1. SPContextWebInformation structure initialization properties

Property

Description

webFullUrl

Gets the server-relative URL of the nearest site.

siteFullUrl

Gets the server-relative URL of the root of the site collection that the site is contained within.

If the nearest web is the root of a site collection, then the value of the webFullUrl property is equal to the siteFullUrl property.

formDigestValue

Gets the server's request form digest.

LibraryVersion

Gets the current version of the REST library.

SupportedSchemaVersions

Gets the versions of the schema of the REST/CSOM library that are supported.

To access this information, use the /contextinfo operator. For example:

http://server/web/doclib/forms/_api/contextinfo

To increase security against cross-site scripting attempts, the /contextinfo operator accepts only POST requests.

Tuesday, November 20, 2012 3:43:32 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
Dev | SharePoint | 2013 | Tips
# Tuesday, November 13, 2012

Hi folks, I’m just blown away by all the goodies in these 2 releases

1) the SP1

2) the Feature Pack SP1

Both have some pretty big improvements, especially around the SharePoint 2013 <-> SQL scenario and pivot tables, analysis, mining etc.

There’s even SQL Services that continuously copy data from Oracle to SQL – this I’ll have to try on my next BizTalk project.

Check it out - http://www.microsoft.com/en-us/download/details.aspx?id=35580

Now I’d love to have a single download for them all…. Smile

Tuesday, November 13, 2012 10:17:18 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
BizTalk | General | SharePoint | 2013
# Tuesday, September 18, 2012

Here's something I go this morning which I think is a SharePoint error:

Tuesday, September 18, 2012 10:53:25 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010
# Thursday, August 30, 2012

I recently ran into an interesting one while building some InfoPath forms for SP2010/2013 forms services.

I wanted to return some Rich Text (XHTML) fields back from a WCF WebService call.

I was at the point as a developer, where I couldn’t even say ‘Works on my machine…’.

The problem was – no matter what I tried, I would always have *plain text* and no ‘richness’ of the Rich Text. Didn’t work for me.

So I have:

1) a basic WCF Web service – running on my dev environment.

2) an InfoPath Form that makes the call and displays the results.

The WCF Service:

image

This is the field that I eventually want to return as RichText to InfoPath.

Here’s the Service Method code (which basically goes into a file and returns back a list of clauses) – just focus on the CONTENT = …GetXHTMLRichText(…)

image

 

InfoPath and Returning a RichTextField
2 things need to happen for this to work.

1. When InfoPath adds the WCF Service to the form, it needs to ‘detect’ the field correctly when it build the underlying schema.

image

You need (nb – ‘Content’ is my field name):
<xs:element minOccurs="0" name="Content" nillable="true">
                <xs:complexType mixed='true'>
                    <xs:sequence>
                        <xs:any minOccurs="0" processContents="lax" maxOccurs="unbounded" namespace="http://www.w3.org/1999/xhtml"></xs:any>
                    </xs:sequence>
                </xs:complexType>

</xs:element>

Note the namespace on the ANY element above – this is the winner to tell InfoPath that this is a richtext field.

2. When returning data via this field (in my case the ‘Content’ field), it needs to be in a certain shape, as in:
<Content xmlns=http://yournamespace>
    <span xmlns="http://www.w3.org/1999/xhtml">Rich text here</div>
</Content>


Your rich text content needs to be ‘wrapped’ for InfoPath to play nicely with it.

This was the purpose of my GetXMLRichText method as

image

 

The gotcha:

When I pointed InfoPath at my webservice and added a service reference I was getting back a SimpleType for the field and not a ComplexType/Rich Text field.

The WCF Service WSDL was ‘almost there’ but not close enough:
image

The Content field described in a ComplexType which is almost there, but not quite.

It’s missing the <xs:complexType mixed=’true’>…<xs:any namespace=’http://www.w3.org/1999/xhtml’ …/>. The rest were good.

The fix:

Cutting a long story short, the simplest way forward here was to simply edit the form components that InfoPath had built and correct the schema. Then reuse the form.

The form looks like this:

image

 

From the File->Publish->Export Source Files you can get to the source and edit the correct schema (XSD) file.

image
Close the form down in InfoPath (or you may even need to close InfoPath) to edit the Schema.

image

You may need to hunt through a few of them to find the right one. My file was GetKCCTerms12.xsd

Modify, save and close that file.

Right click on manifest.xsf –> Design to launch InfoPath and then select Save As to work with it as *.XSN form (*.xsn files are just CABs with all these files inside)

image

The final result as viewed from an InfoPath form – notice the bolding sent through.

Enjoy,

Mick.

Thursday, August 30, 2012 9:25:47 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
.NET Developer | Dev | SharePoint | 2010 | Tips
# Friday, February 10, 2012

You know it’s a Friday when…who can spot the ‘yes/no/cancel’ buttons?

image

Friday, February 10, 2012 11:09:15 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
SharePoint | 2010 | Tips
# Tuesday, October 18, 2011

While wrestling with SharePoint 2007 SP2 today, I got a great error message.

“SharePoint Products and Technologies Configuration Wiza” – Wizzzzzaaaaaaaaahhhhhhh!
(this sits nicely with Shazza, Mappa, Timmy, Kimmy, and on it goes…”)

image

Now to sort the problem out…

Tuesday, October 18, 2011 12:52:55 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
General | SharePoint | Tips
# Monday, July 04, 2011

See you there folks…I’m coming up from the trenches to share what’s in the real world with the class…content types, deployments etc.

Hope to see you there.

 

 

 

clip_image001

Sydney | SharePoint 2010 Bootcamp

“The best course I have done in years!”

“A fantastic course. Mick really has depth of knowledge and is a very engaging trainer”

 

REGISTER TODAY - 4 seats left!

Special offer of 15% discount if book & pay before June 30th 2011.

 

 

Overview

This is a 5-day bootcamp designed for both IT Professionals and Developers packed with fun and technical training to explore the features of SharePoint 2010 ‘out of the box’.

 At course completion students will be able to upgrade their SharePoint V3 sites/portals to SharePoint 2010, to implement and extend Microsoft Office client side solutions, and also implement custom workflows developed in Visual Studio.

 They’ll be equipped to care for their SharePoint farm, back it up and restore it, and set up and configure SharePoint 2010 infrastructure. Architecting the portal and sub-sites layouts is streamlined using best strategies and known best practices within the SharePoint space.

 Students will create custom WebParts and SharePoint customisations easily, as well as site wide features, event handlers and InfoPath Forms based solutions. They will also explore Excel Services and Business Intelligence Offerings.

 Be ready to roll up your sleeves and start your adventure here!

Date:                     Monday 25 – Friday 29 July 2011
Instructor:           Mick Badran – MVP
Location:             Breeze Office
                               
Edgecliff Court,
                                Suite 5a
                               
2 New McLean Street, Edgecliff NSW 2027

Time:                    8.30am – 4.30pm
Duration:             5 Days
Course Price:     $3,450.00 + GST

Register NOW: Emmav(AT)breeze(DOT)net(NO DOT)

 

 

Monday, July 04, 2011 9:51:23 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
Events | SharePoint | 2010 | Training
# Wednesday, March 09, 2011

Firstly thanks for all that attended my 5pm - ‘fireside’ session.

I definitely was a first for me having a session so late in the day. I took my shoes off, wiggled my toes and got into it up on stage.

The session was pretty light and easy to follow along as to get bogged down into the deep technicalities of data storage within SharePoint was going to put all to sleep.

During the session I spoke about (& demo-ed) each approach from Site/Web Property bags, Custom Service Apps, Lists/External Lists Pros and Cons of each – all good.

Here’s my slide deck guys – Enjoy.

image


UPDATED – DEMOS USED IN THE PRESENTATION
DEMOS

Wednesday, March 09, 2011 11:53:37 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [3] -
Events | SPC2011 | SharePoint | 2010
# Thursday, January 27, 2011

image

While looking into an authentication problem I discovered this ‘new’ header sent back from a SharePoint 2010 machine.

Health Score? hmmm… I thought, what’s the max and what’s the min values. Is this good/bad? or don’t care?

So SharePoint 2010 has several Throttling features it used such as Client Auto Back-off which predominately when triggered, prioritises HTTP requests – such as HTTP POSTS are non delayed or throttled, but HTTP GETs are and new HTTP connections are throttled.

Here is one MS page that barely describes the Header – could do with updating that one.

SharePoint 2010 determines the health of a server by initially looking at system counters.

Let’s dig further….

Upon Reflecting the classic Microsoft.SharePoint.dll, there’s a Microsoft.SharePoint.Diagnostics section which I thought would be a great place to start. I found a
SPWebFrontEndDiagnosticsPerformanceCounterProvider class (amongst others there’s a SPDatabaseServer class as well)

image

The line above collection[0] = …. refers to the following collection

image

So putting all this together, the performance counters are:

  • WebAppPool - “SharePoint Foundation”
    • Global Heap Size
    • Native Heap Count
    • Process ID
  • OWSTimer & W3WP
    • Private Bytes
  • Processor (_total)
    • Processor Time

It appears the main class behind all of this is
SPHttpThrottleSettings where it appears that the throttling setting is turned off in ‘Single-Server’ deployments.

Digging further I came across the big-daddy class of it all (I think) -

image
SPPerformanceInspector – notice the method IsInThrottling() and the other is 2 constants that describe the displayed Throttled messages.

I also noticed another method on this class SetupRegKeyHealthScore.
Where HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\WSS\ServerHealthScore is the actual value you want to assign.

image

A value of 0 is great, 10 is bad. Over 10 means the server will go into Throttling (letting your clients know as well).

There’s many other things here, but I’ve got to head swimming.

Hope we unraveled this mystery a little more.

Mick.

Thursday, January 27, 2011 4:43:16 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
SharePoint | 2010 | Tips
# Monday, January 17, 2011

I recently came across a SharePoint Portal that previously was working a treat up until Christmas (just gone) and then the client got this on their Create Site Page:

image

So the good old “Parameter name: key” error…that old chestnut I thought (like I had any idea at that stage).
Null – is always an interesting thing. So something is going through a collection and not finding the value, not that they should have tested for the existence of the value first…but we’ll leave that for another story.

Why this was happening now? I haven’t got to the bottom of it, could be an update? security patch? SQL update? code somewhere? I find these things happen on the night before an important release date.

So after sheer luck of me just ‘doodling’ on the Create Site Page, this appears to have fixed it:

image

From the highlighted area – just simply fill in the empty(null) search box EVEN though we are Creating a Site here.

Go figure…

Do I add SharePoint to the Wonders of the World list?

Monday, January 17, 2011 12:33:00 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
SharePoint | 2010 | Tips
# Wednesday, November 17, 2010

Hi folks, I’ve got a lot of requests for when/where these are on, so we’re off and running next week in Brisbane with 2 seats left.

Just a quick blurb on the course -


The Breeze SharePoint 2010 Bootcamp has been designed to provide just that. Our customers asked for an in-depth, technical, customized course that, if they were to spend $$s on just one SharePoint  2010 course this year, would give them enough knowledge of the technology to build real world solutions.

These bootcamps have been written for the ITPro & Developer who need to upgrade their SharePoint skills, or are just starting out with SharePoint 2010.

Check them out HERE

Wednesday, November 17, 2010 9:55:16 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
Events | SharePoint | 2010 | Training
# Monday, October 25, 2010

Here’s something that I hope to save a few hours to you – InfoPath Forms Services.

I recently ran into this dreaded error – "InfoPath Forms Services is not turned on” when trying to configure it from within SharePoint Central Administration –> General Application Settings.

Forms Services is part of SharePoint Enterprise Services (usually activated via a Farm/Web Application/Site Collection or Site feature) and it relies upon the State Service.

So on our intranet, we’re revamping some InfoPath forms that were working in SP2007 and a new SP2010 using the database detach/attach method saw the intranet up and running…almost…except for this InfoPath Forms Services.

Most posts on the web talk about simply not having the feature enabled for either a Site collection, and/or Central Admin (and various other red herrings in my case)
http://stackoverflow.com/questions/1237956/infopath-forms-services-is-not-turned-on
http://mundeep.wordpress.com/2009/02/17/infopath-forms-services-is-not-turned-on/

Basically my source of truth was SharePoint Manager 2010 (great tool from CODEPLEX) which allows connections to SharePoint via the APIs as a standalone application (tip: make sure you launch it in ‘run in administrator’ mode).

From here I saw that on my install I was missing Forms Services listed in the Farm’s Service Applications
image

I initially thought it was some permissions issue and that I couldn’t see the service under that account (even though I was farm admin), so I launched and checked under the installer account and got the same result.

My next questions were: How does Forms Services become missing? How do you manually install/enable it?

In this case, I had a classroom SharePoint 2010 VM easily available and looking at it through SharePoint Manager, low and behold the Forms Service service was there!! Listed.

The machine I was having trouble with was a standard clean install, that I didn’t automatically run the Configuration Wizard on – as I wanted to have control over the naming of DBs. That was pretty much the difference between the two machines.

So I tried a few things:

a) installing just the InfoPath Web Admin Feature - stsadm -o installfeature -name IPFSAdminWeb –force and then activating it with stsadm -o activatefeature -name IPFSAdminWeb -url http://sp2010:10000 –force (no luck, it just gave me the InfoPath config under the Central Admin)

b) reran the configuration wizard

c) repaired setup

d) tried to run just the InfoPath Forms Services MSI from the install source.

…all to no avail.

InfoPath Forms Services – now with ‘deeper’ integration with SharePoint 2010, an internal service but with no real apparent way of getting to it.

The Answer:
I got thinking and I decided to attempt a backup of the Service from my VM and restore just the Service to the intranet Farm.

- Perform a backup of just the configuration

image

image

Then from there I did a restore (more in hope than anything) such that this process would ‘inject’ the right settings into the Farm Database.

image

At this point anything with InfoPath Forms Services on it was a bonus.

In any rate, here’s the backup file in ZIP format from my VM, that you can use to restore if ever faced with a similar challenge :)

Monday, October 25, 2010 8:02:10 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010 | Tips
# Tuesday, October 12, 2010

Today I decided to crack open the BTS 2010 SharePoint WS Adapter to see if it takes advantage of the great new interfaces exposed by SharePoint 2010, specifically Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll.

At a glance, the benefits of this new Client APIs are:

  1. Runs on a non SharePoint installed box.
  2. Lightweight and flexible – only get back what you ask for. As opposed to the classic SP Server API that populates the SPWeb collection (for e.g.) only if you just want the title field and not 10MBs worth of other data.
  3. Batch approach – load up several commands and batch them over the wire when needed.
  4. Supports both read/write from the client back to SP Server.
  5. Uses XML and JSON over the wire – small and fast.
  6. We can’t do *everything* we can on the Server Side – e.g. Service Application management, i.e. kicking off a search index crawl.

A little piccy of what’s going on:

image

Some classic piece of code to achieve document library reading:

1 static void Main(string[] args) 2 { 3 ClientContext ctx = new ClientContext("http://intranet"); 4 Web web = ctx.Web; 5 List docs = web.Lists.GetByTitle("Shared Documents"); 6 ListItemCollection items = docs.GetItems(CamlQuery.CreateAllItemsQuery()); 7 ctx.Load<Web>(web); 8 ctx.Load(docs); 9 ctx.Load(items); 10 ctx.ExecuteQuery(); 11 Console.WriteLine("The list has {0} items.", docs.ItemCount); 12 foreach (ListItem item in items) 13 { 14 Console.WriteLine("Item:{0}", item["Title"]); 15 } 16 //delete an item. 17 //items[1].Update(); 18 //items[1].DeleteObject(); 19 //ctx.Load(items); 20 //ctx.ExecuteQuery(); 21 Console.ReadLine(); 22 }

Note: Line 10 is where all the magic happens – if you imagine, we load up the client OM classes and the props etc. are all ‘blank’ until we do an ExecuteQuery() which then populates what we ask for.

The above sample is pretty simple showing how to connect to a document library on a ‘remote’ server (security allowing – I didn’t add a ctx.Credentials=… line in the above, but all possible).

So let’s move on a crack open the BTS 2010 SharePoint WS Adapter…

Just before we go there I’d like to point out that the Microsoft.SharePoint.dll (aka Server API) has the ability to connect to remote servers, although the code needs to be executed on a machine that has a local SharePoint install.

e.g.

SPSite site = new SPSite(“http://remoteserver.acme.com”);

SPWeb web = site.OpenWeb();

What I am trying to avoid with the BTS SharePoint adapter is the need to have the ‘BTS Web Service’ component installed on remote Farms. Just complicates the issue far too much with the SharePoint admins.

The BTS 2010 Story

I setup and installed the BTS SharePoint WS Adapter through the Configuration.exe tool successfully.

Essentially this tools runs a ‘web site check’ to make sure SharePoint is successfully setup and installed.

image

To make this happen, the configuration tool runs either:

  1. Microsoft.BizTalk.KwTpm.StsOmInterop3.exe – for WSSv3
  2. Microsoft.BizTalk.KwTpm.StsOmInterop4.exe – for WSSv4

to determine the site as follows:

image

Note: The URL and note the URL in the BTS Configuration above. Here I’ve already configured the adapter and I’m just showing the commands that the configurator runs behind the scenes.

Once configuration is complete you will see a new virtual directory added  to your selected site e.g. http://intranet.

As shown in IIS Manager.

image

Depending on the SharePoint version this virtual directory will map to:

  1. C:\Program Files (x86)\Microsoft BizTalk Server 2010\Business Activity Services\BTSharePointV4AdapterWS
    or
  2. C:\Program Files (x86)\Microsoft BizTalk Server 2010\Business Activity Services\BTSharePointV3AdapterWS (previous bts2009 adapter)

A Basic BTS/SharePoint picture

Essentially the BTS SharePoint Adapter consists of 2 parts:

  1. A BTS Adapter that talks to the BTS SharePoint WS. This is a ‘classic’ adapter and does not talk the newer WCF framework (which does have advantages and disadvantages)
  2. A BTS SharePoint WS – this does all the work against the SharePoint library and talks local SharePoint APIs.

image

 

Let’s look closer at the BTSharePointV4AdapterWS folder

image

- this folder, or addition needs to be available locally to whichever SharePoint site you are calling through the OOTB BTS SharePoint adapter, even though the SharePoint APIs support remote Servers.

- the bin folder has the Microsoft.BizTalk.KwTpm.WssV4Adapter.WebService.dll which is 78kb.

I wanted to find out whether this DLL used the new SharePoint Client APIs when meant having a peek at the ‘references’ of this DLL in IL.

Dissassembling Microsoft.BizTalk.KwTpm.WssV4Adapter.WebService.dll

Using .NET Reflector I was able to get this picture…

image

NOTE: on this list there is Microsoft.SharePoint, but not Microsoft.SharePoint.Client.dll
(this is not looking good…could be late bound, but… I doubt it)

Digging into the actual WssAdapter class we get the following of note:

image

The GetDocuments(string, string, string, Int32, DocExtOfficeIntegration)… is a key method.

The APIs show that the 1st parameter is a siteUrl (and following the implementation code through) which has the potential to point to another SharePoint server to make the connection (in the RequestInfo class if you’re going to dig yourself :))
Note: the PREVIOUS version, BTS2009 has the same Interface/Method signature and it requires the BTS SharePoint Adapter WS to be deployed on the remote SharePoint Server, even though the signature looks as though it will support the remote server.

So in conclusion the BTS SharePoint Adapter WebService has:

  1. NOT got any newer SharePoint Client API code within in.
  2. The ability to contact a remote server through the WebService APIs.
  3. But depends on whether the BTS Adapter will pass the ‘remote’ URL to the ‘local’ WS, or will the Adapter try to contact the remote SharePoint Server directly looking for a WS there???

I’m thinking it’s the latter…

A little more to unravel the SharePoint mystery…

Tuesday, October 12, 2010 1:08:00 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
BizTalk | 2010 | Insights | SharePoint | SharePoint | 2010
# Monday, September 20, 2010

The scene looks like this – while teaching a SharePoint 2010 class I decided to build a Feature that used one of the OOTB Service Applications of SharePoint 2010.

image 

I decided to create a PDF Converter ‘Feature’ that used the Word Automation Services hosted in SharePoint 2010. Looking into the Word Automation Services, I’d say that if you’ve already got a PDF creation process going, then stick with it as it appears this service is pretty simple. However if you’ve got nothing, then Word Automation Services will be great!
(Having spent a previous life in a graphics company, there are many options that go with creating just that perfect PDF…I could find none of these here :()

image
(yes the pdf icon needs work…)

So I created a VS.NET 2010 Solution with a Feature.
image

The PDFConverter.cs is where the crux of the work is – the rest of the solution is working out just the right spot to call it.

Couple of Interesting Points about the Solution

1. ScriptLink – using this from a CustomAction within an Elements file allows to inject Script into a site where the Feature is Activated. There is also ScriptBody that allows you to inject script code right there.

2. RegistrationType – being declared as a FileType, currently this will work with docx. Feel free to experiment and extend out.
Also, seeing this action is activated on a list item, we need to track what list it came from {ListId} and the item in that list {ItemId} which is an integer.

1 <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 2 <CustomAction Id="MicksPDFScript" 3 ScriptSrc="~site/_layouts/WordAutomationServices/Scripts/MoveItMoveIt.js" 4 Location="ScriptLink"> 5 </CustomAction> 6 7 <CustomAction Id="MicksPDFConverter" 8 RegistrationType="FileType" 9 RegistrationId="docx" 10 Location="EditControlBlock" 11 Sequence="106" 12 Title="Convert to PDF" 13 ImageUrl="~site/_layouts/WordAutomationServices/Images/pdf.gif" 14 > 15 <UrlAction Url="javascript:MicksOpenDialog('{ListId}','{ItemId}');"/> 16 </CustomAction> 17 18 </Elements> 19

3. Code that actually does the work – is pretty simple really with Folders and entire Document Libraries able to be passed to the Conversion Job.
One annoying thing is that below in Line15, conversionJob.Start() is called, really a job gets created and added to the Job Timer queue. Regardless of what goes on, the Started property always returns true.

Typically I’ve found the Timer Job to kick in every 5 mins to process the conversions and eventually a PDF file is seen in the library.

1 public bool Convert(string srcFile,string dstFile) 2 { 3 4 //create references to the Word Services. 5 var wdProxy = (WordServiceApplicationProxy)SPServiceContext.Current.GetDefaultProxy(typeof(WordServiceApplicationProxy)); 6 var conversionJob = new ConversionJob(wdProxy); 7 8 conversionJob.UserToken = SPContext.Current.Web.CurrentUser.UserToken; 9 conversionJob.Name = "Micks PDF Conversion Job " + DateTime.Now.ToString("hhmmss"); 10 conversionJob.Settings.OutputFormat = SaveFormat.PDF; 11 conversionJob.Settings.OutputSaveBehavior = SaveBehavior.AlwaysOverwrite; 12 13 conversionJob.AddFile(srcFile, dstFile); 14 15 conversionJob.Start(); 16 return (conversionJob.Started); 17 18 }

A couple of screen shots in action:

image

image

image

Of course this is not production ready, but it should give you a great start in getting there. To start, simply install and Activate the Feature on a site collection to see the functionality.

Go to a document library and activate the item drop down to see the Convert to PDF option. Must be a DOCX file currently.

Grab the VSNET2010 Solution and go for it – have fun.

Monday, September 20, 2010 9:06:48 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [2] -
.NET Developer | SharePoint | 2010

The other day I had a need to create many word documents in code and publish them up to a SharePoint 2010 site.

1 static void Main(string[] args) 2 { 3 int iMAXDocs = 200; 4 string fpath = Path.Combine(Directory.GetCurrentDirectory(), "Docs"); 5 Directory.CreateDirectory(fpath); 6 Console.WriteLine("Path created"); 7 for (int i = 0; i < iMAXDocs; i++) 8 { 9 string docname = Path.Combine(fpath, "Doc" + i.ToString() + ".docx"); 10 CreateWordDoc(docname); 11 Console.WriteLine("Created Doc {0} of {1}", i, iMAXDocs); 12 } 13 14 }

So essentially it went something like that…with the key really being line#10 – CreateWordDoc(…). The CreateWordDoc routine also adds a couple of custom String properties to the document.

1 private static void CreateWordDoc(string docname) 2 { 3 using (WordprocessingDocument package = 4 WordprocessingDocument.Create(docname, WordprocessingDocumentType.Document)) 5 { 6 // Add a new main document part. 7 package.AddMainDocumentPart(); 8 9 // Create the Document DOM - which could be from a template XML file or so. 10 package.MainDocumentPart.Document = 11 new Document( 12 new Body( 13 new Paragraph( 14 new Run( 15 new Text("Hello World!"))))); 16 17 //add props. 18 CustomFilePropertiesPart pt = package.CustomFilePropertiesPart; 19 if (pt==null) 20 pt = package.AddCustomFilePropertiesPart(); 21 22 XmlDocument xdoc = new XmlDocument(); 23 xdoc.LoadXml("<Properties xmlns='http://schemas.openxmlformats.org/officeDocument/2006/custom-properties' " 24 + "xmlns:vt='http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'>" 25 + "<property fmtid='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' pid='2' name='temp'> " 26 + "<vt:lpwstr>Done in Open XML</vt:lpwstr>" 27 + "</property>" 28 + "<property fmtid='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' pid='3' name='micksdemo'>" 29 + "<vt:lpwstr>SharePoint is Cool</vt:lpwstr>" 30 + "</property>" 31 + "</Properties>"); 32 33 //save the props 34 xdoc.Save(pt.GetStream()); 35 36 // Save changes to the main document part. 37 package.MainDocumentPart.Document.Save(); 38 39 } 40 }

All in all pretty straight forward using OpenXML Format SDK 2.0

Here’s the VS.NET2010 Solution of the above code -

Monday, September 20, 2010 1:44:10 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010
# Friday, August 13, 2010

Well folks, after a recent week of performance issues running a SharePoint 2010 VM image (40GB) on Virtual Box (v3.0.14 & v3.2.8) Olaf (a fellow Breezer) and I sat down and put our thinking caps on as how to improve things.

- Hyper-V wasn’t an option due to classroom setups and portability issues.

After scouring the forums, posts, blogs and other to see how to squeeze every last bit of performance from Virtual Box – I’ve come to the conclusion that current versions just don’t take full advantage of Core i7 architectures, hence they run dog slow (1 virtual cpu seems to run better than multiple).

Enter VMWare – I’m relatively new to the world of VMWare, although others on my team swear by it.

So I downloaded VMWare Player (free) image

And configured a Virtual Machine (or two)

image

So the issue is (as I’m sure you’re well aware if you’re reading this), is that booting up Windows 2008 R2 (in my case), the native disks are SCSI and we get the dreaded Inaccessible Boot Device error (stop 0x7B).

(Back in WinXP, Win2000 & Win2003 (I think) there *used* to be a recovery option that you could repair my boot environment and it would ‘rediscover’ all the disks etc and you’d be on your way)

The aim is boot into Windows, allow it to discover, load and install the VMWare SCSI drivers (from LSI…) and then in theory you’re good to go.

After drilling down through the VMWare forums (a foreign place for me), there’s a few articles on ‘injecting drivers’ into the system, startup etc – none of these techniques worked for me (I booted to Repair window and ran regedit to ‘tweak’ some startup registry keys).

Still stuck and after many hours we noticed that CD/DVD (IDE) was an available device on the system as follows:

image

I thought “I wonder if I can attach the VHD as an IDE??”

After locating the VMWare VM config file – a *.VMX file I saw a couple of entries…

ide1:0.present = "TRUE"
ide1:0.filename = “…MicksBootIso.iso”

 

So I thought, let me try

 

ide1:0.present = "TRUE"
ide1:0.filename= "D:\VHDs\VHDs\SharePoint2010_v2_Child.vhd"

 

image


Saved and booted up like a bought one!

So for now…this works fantastically AND THE PERFORMANCE is at least 3-4 times faster than Virtual Box for this image. Just really snappy!

Here’s a sample file attached – enjoy.

Windows Server 2008 R2 x64.zip (1.12 KB)
Friday, August 13, 2010 5:10:29 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
BizTalk | General | SharePoint
# Wednesday, July 28, 2010

Olaf and I were cracking away on some SharePoint 2010 work which we thought should be simple…point SPMetal to the site and start LINQ-ing to our hearts content…..

with the one exception that we couldn’t select items from a list based on their Content Type.

By default SPMetal.exe doesn’t include these ‘system’ fields (apart from ID + Title – go figure) and the secret is to use an Override file.

The good oil is:http://msdn.microsoft.com/en-us/library/ee535056.aspx
(Here’s a good article on how .NET Types are mapped to SharePoint - http://msdn.microsoft.com/en-us/library/ee536245.aspx)

The simple override/parameters file:

<Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal">
  <ContentType Name="Item" Class="Item">
    <Column Name="ContentType" Member="ContentType" />
  
  </ContentType>
 
</Web>

 

The SPMetal Command Line

image

The VS.NET Code

 static void Main(string[] args)
        {
            using (BreezeDataContext dc = new BreezeDataContext("http://breezelocal"))
            {
                var myitems = from i in dc.GetList<ContentListTraining>("My Content List")
                              where i.ContentType == "Training"
                              select i;
                var courses = myitems.ToList<ContentListTraining>();

                Console.WriteLine("There are {0} items",courses[0].Title);
                   
            }

            Console.ReadLine();
        }
Wednesday, July 28, 2010 6:10:19 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
.NET Developer | SharePoint | 2010 | Tips
# Friday, July 16, 2010

I’m in the process of planning a SP2007 to SP2010 ‘migration’ moving over the content database and other web artifacts.

I was making sure all things were ticked off and available in the new SP2010 environment such as – additional external scripts, paths, externally accessible images, webparts + flash movie files.

Migrated over – fired up the browser and after some minor tweaking most things came over, except for the flash movies.

The flash movie was not being displayed.

So naturally you think – must be a path, permission, activeX, flash object declaration, upload or even a masterpage might need a tweak…

Fired up FireBug in firefox and went to work – we could access the *.swf file directly from within the browser, but when the Page loaded with the link in there… no go.

In fact we got a ‘304 not modified’ response within FireBug – which seems pretty normal if the flash player already has the movie locally and it’s just comparing the server version versus the local…but still no flash playing.

SharePoint 2010 Web Applications restrict ‘active’ content – aka Flash out of the box.

After some digging and a seemingly unrelated option appeared in Web Application –> General Settings.
Browser File Handling - Default setting: STRICT

This was the culprit, setting this to permissive did the trick.

image

Wow! Have a great weekend folks!

Friday, July 16, 2010 1:51:43 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010 | Tips
# Monday, July 12, 2010

Breeze SharePoint 2010 Bootcamp

The Breeze SharePoint 2010 Bootcamp is here!

 

 
Breeze SharePoint 2010 Bootcamps – Building Real World Solutions

The eagerly anticipated SharePoint 2010 Bootcamps are underway in Australia, and here’s what some of the excitement is about. Technical training this year is all about value for money. After the change in the economy, customers are more careful about where their training budget is being allocated. This year, customers need technical training that is relevant and an investment to their business. They are looking for knowledge that will improve business efficiencies, provide real world scenarios and give students the confidence to be hands-on when they leave the classroom.

The new Breeze SharePoint 2010 Bootcamp has been designed to provide just that. Our customers asked for an in-depth, technical, customized course that, if they were to spend $$s on just one SharePoint  2010 course this year, would give them enough knowledge of the technology to build real world solutions.

These bootcamps have been written for the ITPro & Developer who need to upgrade their SharePoint skills, or are just starting out with SharePoint 2010.

Be ready to roll up your sleeves and start your adventure here.

Sydney: 2nd August 2010

Price: $3450 ex GST

Register NOW: info {at} breeze {d.o.t.} net

*Quote this blog article to receive a special promotion.

Enjoy,

Mick.

p.s. anyone seen the octopus…I’ve got destiny with it….

Monday, July 12, 2010 11:21:46 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010 | Training
# Saturday, April 24, 2010

Well if you’re cracking on and updating your SharePoint Beta 2 Installs to RTM and wanting to make it out the door while there’s some daylight left…then you’re better than me…right now it’s dark! :)

Ok – so I figured, no probs just do a stsadm –o addcontentdb … and we’re well on our way, exactly the same from Beta 1 to Beta 2.

This time SharePoint RTM doesn’t want to play. I got this error:

Sequence [Microsoft.SharePoint.Upgrade.SPContentDatabaseSequence] cannot upgrade
an object [SPContentDatabase Name=WSS_Content_Int2010] whose build version
[14.0.4536.1000] is too old. Upgrade requires [14.0.4730.1000] or higher.

So as you can see the Version numbers of my Beta2 ContentDB is close, but RTM is not playing.
 
I thought I’d take a punt and see what happened:
  1. Open up the ContentDB in SQL Management Studio and open up the Tables folder.
  2. Locate the Versions Table (down the bottom).
  3. Open the Versions Table in Edit Mode and modify the Rows which have a Version=14.0.4536.1000 next to them.
  4. Simply change the version number to 14.0.4730.1000
  5. Save the changes
  6. Rerun the stsadm –o addcontentdb command and bob’s your uncle.

The ContentDB I used here was 18GB in size and all has come up trumps.

This may save you a bit of time and sure it’s a hack, but we’re now in RTM land.

Good luck :)

 
 

image

Saturday, April 24, 2010 10:13:39 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010

I’ve just spent the past couple of days looking into the ‘upgrade’ process and I’ve come out the other side. Here’s a quick jot down of what I encountered

  1. Environment: Single WFE (Win2K8 R2 x64) and a separate SQL 2008 x64 'backend’. Currently running SP2010 Beta2 with content databases around 13GB
  2. I haven’t uninstalled any of the existing SP2010 beta 2 bits – this is a VM and I have a handy backup, so in case of emergency break glass was my plan b.
  3. Launched Setup.bat – up came the intro screen and I selected Install PreReqs. In my case the prereqs failed their first installed with it grumbling about the IIS Web Role not present (but this was an existing SP2010 server, so obviously the Web Role was present and correctly running).

    Ran the PreReqs again and all was fine :)
  4. Setup.exe – launched the product, provided a license key and we ran all the way through no problems. Interestingly thRege installer didn’t mention anything like “…I found a previous version of SharePoint do you want to …”
  5. Configuration Wizard – this is where my trouble started.
    1. As the Wizard was launching, it appeared not to be able to recognise the fact that we were already in a farm. It was like we were running on a machine, where the DB Server wasn’t accessible.

      I ‘removed’ the Server from the Farm (which were the only options in the Wizard for me)
    2. Re-ran the Wizard Take#2, supplied the details at the beginning, Server Farm etc etc and sent it on it’s way.
    3. The Wizard ran up to step 3 of 10 (where it configures the Farm DB + creates the SharePoint Web Services IIS Site) and then FAILED. What I noticed that the FarmDB was created successfully, but the IIS side was failing.
      (The error logs spoke about a socket based error – which I think was unrelated)
    4. Tweaking, rerunning the Wizard didn’t fix things…so here’s my fix….
    5. I also uninstalled SP2010 RTM a few times and reinstalled, but same error
  6. The fix -
    1. Delete the \14 hive
    2. Delete the Registry Key (and all under it) HKLM\Software\Microsoft\Shared Tools\Web Server Extensions
    3. Uninstall/reinstall the IIS Web Role on the Server
  7. Repair the SharePoint install from rerunning Setup.exe – repair option. (you might be able to leave this step out, but I deleted the Web Server Extensions key after I installed SP2010, so I needed it to be rewritten)
  8. Run Config Wizard
  9. Upgrade any Content DBs you want to mount – through stsadm –o addcontentdb or Mount-ContentDB (powershell)

I’m sure you’ll be able to shorten this list of steps when you upgrade, but I’ve got to get on and configure this environment.

Have fun,

Mick.

Saturday, April 24, 2010 9:31:07 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010
# Thursday, April 22, 2010

Well folks we are partnering with Education leaders in the APAC region Excom to deliver to you our Breeze SharePoint 2010 Bootcamp.

I’ve recently come out of that code cave…the place which I’m sure a lot of us know all too well. I discovered people…and conversations again :)

We’ve put together 13 modules of original material and labs to match based on real world examples. For e.g. Integrating with Oracle EB from SharePoint 2010 via the BizTalk Adapter Pack (being a BTS MVP I couldn’t resist that one).

I ran a course in Melbourne the week before last and it was a solid week which the students loved with the average score for the course being 8.2 (with 9 being the top)

Our next city is Sydney this coming month and I’ve managed to grab a couple of seats for you.

To Register in a city near you – click here

 

image

Thursday, April 22, 2010 9:01:58 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010 | Training
# Monday, April 19, 2010

May 12th has always been the big date for the release of the products, the icons will be all completed (no more purple dots) questions about performance (how many, how big, how fast…) can all start to be answered in the real world about lists and list sizes.

The Launch of Office 2010 and SharePoint 2010 is due on May 12th.

Those on MSDN and TechNet will get access on April 22nd to start downloading.

image
image

Monday, April 19, 2010 4:08:41 PM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
Office | SharePoint | 2010
# Friday, April 02, 2010

While writing a lab for an up and coming SharePoint 2010 course I came across a few handy things.

I’ve always been a big fan of the developer dashboard and until recently the example code has been a little scarce.

Fortunately I’ve found a couple of gems

- one from Paul Andrew’s blog on how to get your own text in the debug tree
using (SPMonitoredScope sc = new SPMonitoredScope(“Some timed scope”))
{
  // some code in here that you think may take time
}

and for the right side of the screen:
SPCriticalTraceCounter.AddDataToScope(uCounter, “Your category”, traceLevel, “Detailed long message”);

- and the 2nd is an extension that sits on the Dashboard page that plots the time taken for each component to process/render in the tree (it does this client side using jquery and an ASCX control)
http://devdashvis.codeplex.com/releases/view/36559

Check them out.

Cheers,

Mick.

Friday, April 02, 2010 1:25:44 AM (AUS Eastern Standard Time, UTC+10:00)  #    Comments [0] -
SharePoint | 2010
# Thursday, December 10, 2009

Came across a great MS Article that gives you the broad brush strokes of updates and changes.

Very handy one


http://technet.microsoft.com/en-us/sharepoint/ee518662.aspx

Enjoy!
Thursday, December 10, 2009 9:22:47 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
SharePoint | Guides | 2010
# Saturday, November 21, 2009

Hi guys, I’ve been busy over the recent months always working and planning new ways to train, deliver and impart knowledge to *you* in a variety of different ways.

Truth be told our Region with respect to SharePoint Adoption and Knowledge, has been ahead of the curve worlwide – that you guys “SharePoint-ies”.
With the release of SharePoint 2010 soon-ish, we’ve been busy – to bring you the best value and the most effective training for your time.

For the release of SharePoint 2007 some numbers:

  1. We trained over 1400 students on our Breeze SharePoint Bootcamp (we cover technical in-depth approx 80-85% of major SharePoint features in a week. Not for the faint hearted)
  2. You guys demanded excellence and we gave you that.
  3. We train 50% of the time and consult 50% – we bring real world knowledge into the classroom, what works, what doesn’t from a business perspective.
  4. We’ve rolled out over 1000 different SharePoint 2007 sites (and are currently working on migrations to SP2010)
  5. The buck stops with me – which can be good thing…so I’m told :)

    The big congrats goes to you! For being driven, demanding better, demanding more detail and better knowledge, you demand that the bar is raised and meet and excel that challenge.

Breeze has partnered with Microsoft & Excom, allowing us to each focus on our strengths, delivering to you the best possible offering in this space.

I’m pretty excited to announce our SharePoint 2010 Series running in Melb + Sydney initially (+ others soon)
(running at Microsoft Offices)

A Special Blog Reader offer: Would you like me to Webcast these sessions for those whom can’t make it?
Add a comment on this Post to let me know – I’ll get back to you with details.
(we are giving away goodies and offers but I can’t tell you too much)

Here’s the formal blurb: ------ snip ------

image

                     image


 

Microsoft Australia, is pleased to invite you to a FREE Seminar on SharePoint 2010.

Melbourne – December 2, 2009

Sydney – December 11, 2009

Delivered by Breeze & EXCOM Education, this seminar is the first in a series that are designed to get you across the new functionality of SharePoint 2010 and importantly how your business can benefit.

SharePoint 2010 is the business collaboration platform that enables you to connect and empower people through formal and informal business communities, within the enterprise and beyond, and to manage content throughout the information lifecycle.

This next release of SharePoint has some exciting new enhancements for IT Professionals and Developers we think you will want to see for yourself!

This seminar is for all SharePoint enthusiasts from IT Professionals, Developers to Business Decision Makers and Information Workers. Bring along your questions to the unveiling of SharePoint 2010!

Seats are limited. Register NOW !!!!
For more information and to register, click HERE

image

Saturday, November 21, 2009 12:14:28 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [3] -
SharePoint | 2010 | Training
# Friday, November 20, 2009
We're moving into a public beta of Dublin "Windows Server AppFabric" which you can grab from HERE.

What does it mean - here's a blurb from the site.

So Velocity (distributed caching mechanism) is rolled up into this Beta (previously a MS Partner did some benchmarking on Velocity which you can find a great white paper HERE)

Previously myself and Scotty wrote a hefty technical Dublin Course which the folks at TechEd loved - we did this on some early bits of 'Dublin'. Realtime monitoring + tracking as well as recoverability were some highlights of our 3D Realtime maze process we built up in the labs.

Here's a blurb from the AppFabric server (it's a shame that SP2010 didn't use this framework for it's WF hosting...but that would have impacted delivery)

Enjoy

-------- Snippet ----------

Windows Server AppFabric has these core capabilities:

  • For Web applications, AppFabric provides caching capabilities to provide high-speed access, scale, and high availability to application data. This feature was previously codenamed "Velocity"
  • For composite applications, AppFabric makes it easier to build and manage services built using Windows Workflow Foundation and Windows Communication Foundation. This feature was previously codenamed "Dublin."



Friday, November 20, 2009 9:12:32 AM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
BizTalk | Insights | SharePoint | AppFabricServer
Archive
<August 2014>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
Blogroll
 AppFabric CAT
AppFabric Windows Server Customer Advisory Team - New Blog.
[Feed] BizTalk 2006 - Windows SharePoint Services adapter
BizTalk 2006 Sharepoint adapter!!
 Breeze SharePoint 2010 Bootcamp
Breeze SharePoint 2010 Bootcamp
[Feed] BTS 2006 R2/EDI
[Feed] Chris Vidotto (MS BTS Legend)
Needs no intro....
 Mark Daunt
BTS/SPS/.NET GURU!!!
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014
Breeze
Sign In
Statistics
Total Posts: 603
This Year: 7
This Month: 0
This Week: 0
Comments: 270
All Content © 2014, Breeze