Skip to main content

I am trying to use ZoneCalculateEvent to get the due date for an item, taking into account working days specified on the K2 server.  However, everytime I call ZoneCalculateEvent it throws the following: "exception: The ConnectionString property has not been initialized.".  Following is the example code...does anyone have any ideas?  We've given the account specified in our connection string all the permissions we can think of.  Thanks in advance for any ideas houghts!  Also, some WorkflowManagementServer functions seem to work, but definitely not ZoneCalculateEvent.


WorkflowManagementServer workflowManagementServer = new WorkflowManagementServer();


 


 


workflowManagementServer.CreateConnection();


 


 


workflowManagementServer.OpenEx(WMS_CONNECTION_STRING); //tried Open as well with same results.  OpenEx always returns true in my tests


 


Date Time dueDate = workflowManagementServer.ZoneCalculateEvent(DateTime.Now, timeSpan);



 


After the call to CreateConnection, call the Open method on workflowManagementServer.Connection.


Check out the Developer Reference for several examples on creating and using connection strings.


Thanks for the response.


 I got the same results when I used workflowManagementServer.Connection.Open versus workflowManagementServer.Open.  It still threw the ConnectionString exception.


 However, your tip about looking in the Developer Reference seems to help.  Rather than just passing my long connection string, I used the method from the Developer Reference.  So i'm guessing there was just something wrong with my connection string.  Even though the information in my string seems to be the same info I'm building here, there was probably something wrong.  Following is the code that I used from the Developer Reference to create the connection string in case anybody cares.  Thanks again for the help.


SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString = new              SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();

 


connectionString.Authenticate = true;            connectionString.Host = K2Server;


connectionString.Integrated = true;            connectionString.IsPrimaryLogin = true;


connectionString.Port = K2Port;


WorkflowManagementServer workflowServer = new WorkflowManagementServer();


workflowServer.CreateConnection();


workflowServer.Connection.Open(connectionString.ToString());


Sorry, the code I just posted is formatted poorly.  Basically, using the SCConnectionStringBuilder class seemed to fix the issue.


Ooops, I still get the connection string error.  I've tried to narrow things down as much as possible.  I have 2 methods to get the connection, but either way I get this error as soon as I call the ZonCalculateEvent function.  Does anybody have any more ideas?  Here is my code:


//method 1 to create and open connection


WorkflowManagementServer workflowManagementServer =

new WorkflowManagementServer();


workflowManagementServer.Connection = workflowManagementServer.CreateConnection();


SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionObject


=

new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();


connectionObject.Authenticate =

true;


connectionObject.Host =

"MyServerName";


connectionObject.Integrated =

true;


connectionObject.IsPrimaryLogin =

true;


connectionObject.Port = 5555;


workflowManagementServer.Connection.Open(connectionObject.ToString());


//this crashes...causes exception "The ConnectionString property has not been initialized."


DateTime dueDate = workflowManagementServer.ZoneCalculateEvent(DateTime.Now, timeSpan);


 


//method 2


workflowManagementServer =

new WorkflowManagementServer(managementServerName, 5555);


workflowManagementServer.Connection = workflowManagementServer.CreateConnection();


workflowManagementServer.Open();


//this crashes...causes exception "The ConnectionString property has not been initialized."


DateTime dueDate = workflowManagementServer.ZoneCalculateEvent(DateTime.Now, timeSpan);


Hi Dave,

The error message is a bit misleading, but you are basically missing the zone from which you want to get the due date. So add the following line before calling the ZoneCalculateEvent and it should work:

wfManagementServer.ZoneLoad("My Zone");

The following worked for me:
WorkflowManagementServer wfManagementServer = new WorkflowManagementServer();


wfManagementServer.CreateConnection();


SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionObject = new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();


connectionObject.Host = "blackpearl";
connectionObject.Integrated = true;
connectionObject.IsPrimaryLogin = true;
connectionObject.Port = 5555;


wfManagementServer.Connection.Open(connectionObject.ConnectionString);


TimeSpan tSpan = new TimeSpan(0, 10, 0);
wfManagementServer.ZoneLoad("My Zone");
DateTime dueDate = wfManagementServer.ZoneCalculateEvent(DateTime.Now, tSpan);


Thanks, I appreciate it.  I will definitely give your suggestion a try.  I thought this was working without specifying the time zone (I only have one, which is the default) but it is definitely worth a shot! 
Did that fix the error? I seem to get the same thing when I reboot the K2 server. I have to go into the management console and view the working zones before this fixes itself.

I've done some testing now and it seems that you have to call 


workflowServer.ZoneLoad("Standard");


before ZoneCalculateEvent, otherwise this error occurs the first time the K2 Blackpearl service is restarted. This happens even if you specifiy the Zone in ZoneCalculateEvent.               


Reply