ZoneCalculateEvent throws "exception: The ConnectionString property has not been initialized."

rated by 0 users
This post has 8 Replies | 1 Follower

Top 500 Contributor
Posts 24
Points 57
davehacker Posted: Mon, Jul 21 2008 12:11 PM

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\thoughts!  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);

  • | Post Points: 4
Top 10 Contributor
Posts 629
Points 3,311
DavidL replied on Mon, Jul 21 2008 5:51 PM

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.

The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
  • | Post Points: 4
Top 500 Contributor
Posts 24
Points 57

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());

  • | Post Points: 1
Top 500 Contributor
Posts 24
Points 57

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

  • | Post Points: 1
Top 500 Contributor
Posts 24
Points 57

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);

  • | Post Points: 4
Top 10 Contributor
Posts 336
Points 992
dc replied on Mon, Jul 28 2008 12:27

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);

  • | Post Points: 4
Top 500 Contributor
Posts 24
Points 57
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! 
  • | Post Points: 4
Not Ranked
Posts 6
Points 9
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.
-- Lee Adams lee@k2.com The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
Not Ranked
Posts 6
Points 9

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.               

-- Lee Adams lee@k2.com The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
Page 1 of 1 (9 items) | RSS