开发者

Connection.OpenWorklistItem throwing Worklistitem not found error in K2 Blackpearl

开发者 https://www.devze.com 2023-04-10 04:44 出处:网络
A little background. I\'m upgrading a project that was written by someone using k2 2003 to use k2 Blackpearl.

A little background. I'm upgrading a project that was written by someone using k2 2003 to use k2 Blackpearl. The orignal k2 2003 process has the following destination rule and client event using 1 slot

public class DestinationRule_e68c062c1c8d41f5a80ba96b065f76f7 
{ 
   public void Main(ref DestinationRuleContext K2) 
   { 
     K2.ResolveQueuesToUsers = true; 
    K2.Destinations.Add(DestinationType.User, K2.ProcessInstance.Originator.FQN); 
    } 
} 


public class EventItem_5e24182cd2b9469aa5314aafaa0abeff 
{ 
  public void Main(ClientEventContext K2) 
  { 
    K2.VerifyCredentials = false; 
   try 
   {   
     K2.ProcessInstance.DataFields["CurrentSerialNo"].Value = K2.SerialNumber; 
   } 
   catch (System.Exception ex) 
   {   
     throw new System.Exception(ex.Message); 
   } 
}

NOTE that there is no call to "K2.AddWorklist" in the code above. Should there be?

The process uses a data field to store the serial number and then uses the serial number for opening a worklistitem and then finishing it like so(using K2ROM dll) from a web app:

//using k2 2003 
  public void FinishWorkItem()


  {
        if (this.ProcessInstance != null)
        {
            if (!string.IsNullOrEmpty(this.CurrentSerialNo))
            {
                WorklistItem item = null;
                Connection connection = GetConnection();
                try
                {
                    item = connection.OpenWorklistItem(this.CurrentSerialNo, "ASP");
                }
                catch { }
                if (item != null)
                {
                    this.CurrentSerialNo = string.Empty;
                    item.Finish();
                }
            }
        }
        else
        {
            throw new Exception("Cannot finish work item where ProcessInstance is null (calling from KOProcessInstance)");
        }
    }

Note how the OpenWorklistItem uses the "this.CurrentSerialNumber" which is the value of the serial number from the data field for opening and finishing the worklistitem. This seems to work fine in 2003

I re-wrote this method to use the BlackPearl API(SourceCode.Workflow.Client.dll) as follows:

//same code using BlackPearl 
 public void FinishWorkItem(IClientDocumentEntity currentClientDocument)
    {
        if (this.ProcessInstance != null)
        {
            if (!string.IsNullOrEmpty(this.CurrentSerialNo))
            {
                WorklistItem item = null;
                item = connection.OpenWorklistItem(this.CurrentSerialNo,"ASP");
                if (item != null)
                {
                    if (item.Actions.Count > 0)
                    {
                        foreach (SourceCode.Workflow.Client.Ac开发者_如何学Gotion action in item.Actions)
                        {
                            if (string.Compare(action.Name, "Finish", true) == 0)
                            {
                                action.Execute();
                                break;
                            }
                        }
                    }
                    this.CurrentSerialNo = string.Empty;
                }
            }
        }
        else
        {
            throw new Exception("Cannot finish work item where ProcessInstance is null (calling from KOProcessInstance)");
        }
    }

The connection.OpenWorklistItem(this.CurrentSerialNo,"ASP") is throwing the following error 26030 Worklist item ,13351,144 not found for at

My question is whether there has been a change in behavior in the OpenWorklistItem call from 2003 to Blackpearl? The "FinishWorkItem" method in my snippet from K2 2003 above is executed by an account that is an 'Admin' in K2 2003 and it seems to be working fine in Production currently which leads me to believe that K2 2003 allows opening a WorklistItem using serial number regardless of the user to which the item is assigned to and finishing it if the code is executed by an account that is an Admin on the K2 2003 server. Is this statement correct? Has this behavior changed in BlackPearl? If so, what should I do differently to make things work.

Also,is storing K2.SerialNumber as a data field in the process instance the right thing to do. I'm not sure I understand whether if there are multiple destination users, will the data field contain the serial number of the last destination user and whether opening the worklist item using this serial number is the right thing to do.

Thanks.


The change is that the serial number is now in the format {ProcInstID}_{ActInstDestID}, for example '18_1'. The 2003 serial numbers were in the format {ProcInstID},{ActInstDestID}[,{EventInstID}] - so in your specific case replacing the comma with an underscore should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消