K2 – Accessing environment fields from code

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

2 Responses to “K2 – Accessing environment fields from code”

  1. Glad you found the site useful!

  2. […] related posts: (automatically generated)NLB Clustering of K2 with MOSS and Reporting servicesK2 – Accessing environment fields from codeHow to Change IP Address in an Oracle Applications […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: