Welcome to K2 Underground Sign In | Join | Help
How to programmatically change the value of a string table entry

Below is an example of how to use the SourceCode.Workflow.Management.dll to retrieve the current StringTable for a specific Process and then modify the value of a specific entry in the stringtable:

 

    private void EditStringTableForProcess(string strProcName, string strFieldName, string strNewValue)
    {
        // create a connection string
        SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connBldr =
                new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();

        // force the connection string to a specific credential of k2 server admin
        connBldr.Authenticate = true;
        connBldr.Host = "localhost";
        connBldr.IsPrimaryLogin = true;
        connBldr.SecurityLabelName = "K2";
        connBldr.Port = 5555;
        connBldr.Integrated = true;
        connBldr.UserID = "BPService";
        connBldr.Password = "k2pass";
        connBldr.WindowsDomain = "K2Demo.local";

        // instantiate a connection with this connection string
        SourceCode.Workflow.Management.WorkflowManagementServer server = new SourceCode.Workflow.Management.WorkflowManagementServer("blackpearl", 5555);
        server.CreateConnection();
        server.Connection.Open(connBldr.ToString());

        foreach (SourceCode.Workflow.Management.ProcessSet ps in server.GetProcSets())
        {
            // find the specific process
            if (ps.FullName == strProcName)
            {
                // get the name of the stringtable
                string strStringTableName = ps.StringTable;
                SourceCode.Workflow.Management.StringTable st = server.GetStringTable(strStringTableName);
                // set the value of the entry
                server.EditStringTableEntry(strStringTableName, strFieldName, strFieldName, strNewValue);

                break;
            }
        }
        // close the connection
        server.Connection.Close();
    }
 

 

Published Wednesday, April 16, 2008 6:39 PM by Bob

Comments

No Comments

Anonymous comments are disabled
Powered by Community Server (Commercial Edition), by Telligent Systems