Connecting to the SmartObject Server
Connecting to a SmartObject is the first step in using custom code to interact with stored data. The name and port number of the Server are required. Typically you should build a connection string with the SCConnectionStringBuilder class, then instantiate and open the connection, perform what ever actions you want with the SmartObject, then close the connection.
Connecting to a SmartObject
//Build up a connection string with the SCConnectionStringBuilder
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder hostServerConnectionString = new SCConnectionStringBuilder();
hostServerConnectionString.Host = "localhost"; //name of the K2 host server, or the name of the DNS entry pointing to the K2 Farm
hostServerConnectionString.Port = 5555; //use port 5555 for all non-workflow client connections
hostServerConnectionString.IsPrimaryLogin = true; //true = re-authenticate user, false = use cached security credentials
hostServerConnectionString.Integrated = true; //true = use the logged on user, false = use the specified user
//Open the connection to K2
SourceCode.SmartObjects.Client.SmartObjectClientServer soServer = new SmartObjectClientServer();
soServer.CreateConnection();
soServer.Connection.Open(hostServerConnectionString.ToString());
//Once you've interacted with the SmartObject, close the connection
soServer.Connection.Close();