Archive for the K2 [blackpearl] Category

K2 – Accessing environment fields from code

Posted in ASP / ASP.Net, K2 [blackpearl], Snippets on March 20, 2008 by Si

So I needed to get at the K2 blackpearl environment settings from the aspx pages I have been putting together. A quick trawl on the K2 user group (www.k2underground.com) quickly led to some code that lets you do just that (code below is based on that). You need to know the host server name and port number, but I put that in my web.config file to allow for configuration later when we move to the staging and live servers.

Using SourceCode.Workflow.Management;

WorkflowManagementServer server = new WorkflowManagementServer("blackpearl", 5555);

server.Open();

SourceCode.Workflow.Management.StringTable st = server.GetStringTable("Development");

SourceCode.Workflow.Management.StringTableEntry ste = st["field name"].Value;

server.Connection.Close();

Easy! Just remember to add a reference to the right assembly, SourceCode.Workflow.Management.

Advertisements

Joining the ASP.Net party – better late than never

Posted in ASP / ASP.Net, K2 [blackpearl] with tags , , on March 13, 2008 by Si

Yes folks, forever at the cutting edge of technology I have this week taken my first dive into the exciting world of ASP.Net 2, naturally on a key business project with short timescales – that’s the way we like ’em!!

We have been developing some K2 [blackpearl] workflows, and had prepared beautiful InfoPath forms for handling user input and the like. However, trying to deploy the workflows to just six pilot SharePoint sites brought me that close from throwing my laptop out the window and storming off in frustration. K2 is simply not designed for that kind of deployment, but we had to get the pilot rolling and so that’s what we did. New deployments of smart objects and workflows customised for each site – torture!

So…… I am still in the job, and I have an undamaged laptop. We have decided to abandon the InfoPath forms as they were just too limiting, and abandon the pesky smart objects as well, and instead head over to ASP.Net 2 forms, with an even smarter interface! Yay! By doing this, we are able to code behind each page in order to do the stuff we couldn’t easily do before, like identify which site we are coming from, get into the SharePoint object model, and ultimately deploy just one version of our workflows that will apply to all sites.

My starting point for this adventure was the K2 Forms Generation wizard, which was very kind enough to generate a basic page which tied into the workflow server backend, so I had the hard work done for me. All that remained was a bit of css to get the right layout, and perhaps the use of a master page or two (as is good practice). And indeed, here I am, almost at the end of my first week, and I have the first page done! Ok it was a simple “type text in box, select value, click submit” page so not particularly taxing, but an achievement none the less I feel. I also have a tidy structured rough slap-dash class library containing a lot of functions I will use in the rest of the pages, and a crumb trail-type thing generated from an xml file. I’ll be the first to admit that it isn’t necessarily the smartest (in terms of code) solution, but it works, and that for me, at the moment, is the main thing.

Short timescales – well, it’s all got to be done by the end of this month (March), so no pressure! tick, tock, tick, tock……..

Si