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.
WorkflowManagementServer server = new WorkflowManagementServer("blackpearl", 5555);
SourceCode.Workflow.Management.StringTable st = server.GetStringTable("Development");
SourceCode.Workflow.Management.StringTableEntry ste = st["field name"].Value;
Easy! Just remember to add a reference to the right assembly, SourceCode.Workflow.Management.