K2 IPC with Visual Studio

  • 15 October 2014
  • 2 replies
  • 0 views

Badge +1

Hello all,

 

I am working on a project where I have set up an IPC process successfully and it is firing as expected. One of the requirements is to set the duration and the priority on these processes based on database columns. I have pulled the info in to activity level fields and have opened up the designer but am unable to figure out how to assign these values to the IPC process through visual studio. There is not much API documentation when it comes to working within events. Does anyone have a code snippet or link that will show how to assign variables within the IPC event when using Visual Studio?


2 replies

Badge +8

Rather than trying to set these variables from an IPC, can you set it from the other side?  i.e. from the child process when it kicks off?

Badge +1

Hello @sbrownhuntoilco,

 

I have tried to change the expected duration on the side of the child process, but it doesn't seem to be working. I have tried to set it on the ProcessInstance, ActivityDestinationInstance, ActivityInstance and EventInstance. None of these seem to be making a difference. For testing I am setting the ExpectedDuration to 86400 to denote a day but this will need to be dynamic later. Any other ideas?

Badge +1

OK, I've been able to figure this out. THe code to change the priority and estimated duration on an activity is as follows:

 

DateTime due = (DateTime)(K2.ProcessInstance.DataFields["DueDate"].Value);
TimeSpan duration = due - K2.ProcessInstance.StartDate;

K2.ActivityInstanceDestination.ActivityInstance.ProcessInstance.Priority = 0;
K2.ActivityInstanceDestination.ActivityInstance.ProcessInstance.ExpectedDuration = (int)duration.TotalSeconds;

 There are a few things to note though. 1. The expected duration is in seconds. 2. The priorites are from 0 - Highest to 2 Lowest. 3. It does not affect the activity instance overdue flag in the worklist control from the control pack. If any one knows how to do this on the IPC parent side and/or affect the activity instance overdue flag then please add to the conversation.

Reply