Skip to main content
Nintex Community Menu Bar

error:checking the status of startprocessinstance when called from an aspx page

  • June 10, 2009
  • 3 replies
  • 18 views

Forum|alt.badge.img+1

We have a  Sharepoint 2007 and k2 blackpearl, within sharepoint we run an aspx page. This page updates sharepoint user permissions and sharepoint list items based upon user input. We want to check that the k2 process that we have started to do the above completes successfully. we use the startprocessinstance function with synchronous true and we are returned an error. so, we always get an exception whether the process completes successfully or not.


 Can anyone please help, sample of our code is below


try
            {


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


                connectionString.Authenticate = true;
                connectionString.Host = "localhost";
                connectionString.Integrated = true;
                connectionString.IsPrimaryLogin = true;
                connectionString.Port = 5252;
                connectionString.UserID = "administrator";
                connectionString.WindowsDomain = "k2demo";
                connectionString.Password = "k2pass";
                connectionString.SecurityLabelName = "K2"; //the default label


                SourceCode.Workflow.Client.Connection connection = new SourceCode.Workflow.Client.Connection();


                //open connection to K2 server
                connection.Open("localhost", connectionString.ToString());


                //create process instance
                ProcessInstance processInstance = connection.CreateProcessInstance("K2InviteUserToBidReviewTestErrorProcess");


                //populate data fields                             
                //processInstance.DataFields["siteName"].Value = SPContext.Current.Web.Url;
                //processInstance.DataFields["listUsers"].Value = users;
                //processInstance.DataFields["GateLibraryName"].Value = libraryName.Trim();
                //processInstance.DataFields["reviewURL"].Value = url.Trim();


                ////set process folio
                //processInstance.Folio = _processFolio + System.DateTime.Today.ToString();


                //start the process
                connection.StartProcessInstance(processInstance, true);



                if (processInstance.Status1.Equals(ProcessInstance.Status.Completed))
                {
                    _message = "Gate has been invited for review.";
                    //lblMessage.Text = libraryName + " Gate have been invited for review.";
                }
                else if (processInstance.Status1 == ProcessInstance.Status.Error)
                {
                    _message = "This process is in an error state -> Gate was not invited for review.";
                    throw new System.Exception(_message);
                }
                //_message = processInstance.Status1.ToString();
            }
            catch (Exception exp)
            {
               response.write(exp.ToString());


            }
           


The Error we get is:



at SourceCode.Workflow.Client.SocketClient.Recv(UInt32 sock, SByte* buf, Int32 len) at SourceCode.Workflow.Client.SocketClient.Receive() at SourceCode.Workflow.Client.InternalConnection.Call(ArchiveX ar, MessageType msgtype) at SourceCode.Workflow.Client.InternalConnection.CallFunction(ArchiveX ar) at SourceCode.Workflow.Client.Connection.StartProcessInstance(ProcessInstance ProcInst, Boolean Sync) at K2.MOSS.ManageTeamMembers.ManageTeamMembers.StartK2Process(String strProjectName, String strProcessName, String activityName, String users)



 


 

3 replies

Forum|alt.badge.img+5
  • June 10, 2009

Hi There,

 

If you set the K2HostServerLog file logging to be in debug mode do you see an error thrown in the running of the process which might help you track down which stage in the workflow the exception is being raised?

 

 


Forum|alt.badge.img+2

Hi,


 


We're also encountering this error intermittently. Please tell us how you resolve this issue.


 


Thanks,


Andrew


Forum|alt.badge.img+1
  • September 8, 2010

Hi,


Try


processinstance.Status == "4"  (This means its stopped)


processinstance.Status =="2" (This means its active)


Hope that helps/works.