K2Mng and K2ROM

Last post 03-12-2008, 1:35 PM by cmurphy54. 8 replies.
Sort Posts: Previous Next
  •  02-28-2008, 11:43 PM 22194

    K2Mng and K2ROM

    I have a .Net application that facilitates redirecting a worklist item.  Basically all Worklist items are listed using K2Mng and the GetWorklistItems method.  When the user selects the item to be redirected I use RedirectWorklistItem to move the item to the new user. 

    I now need to update a process datafield for the process instance that the worklist item represents.  As far as I can tell I need to use K2ROM to do this, as K2Mng has no access to process data fields.  What is the best way to get a K2ROM processInstance from a K2Mng WorklistItem?

  •  02-29-2008, 12:52 AM 22196 in reply to 22194

    Re: K2Mng and K2ROM

    I can get this to work, but it seems very loose, and relies on a the process instance having a unique Folio (which I do).

    • Use K2Mng GetWorkListItems
    • Use K2Mng.GetProcessInstances and find the process with the matching folio
    • Use K2ROM.OpenProcessInstance using the processID from above

    As I said this works, but seems a little "loose".  Is there a better way?

    What would I do If my folio values where not unique?

     

  •  02-29-2008, 5:48 AM 22202 in reply to 22196

    Re: K2Mng and K2ROM

    TM01, this is just a guess, but i think you can just use the value of the K2Mng.WorklistItem.ID as if it were the same exact thing as the K2ROM.WorklistItem.SerialNumber

    So, take the value from you call K2Manager.RedirectWorklistItem(worklistItem.ID, strDestUser)

    and just use that same value in the K2ROM.Connection.OpenWorklistItem(worklistItem.ID, etc. etc.)

    i'm mixing my syntax here because you'd need to create a connection object first in K2ROM, it's not a static method, but you probably get the point since you using the API already.

    here's what i'm basing my guess on:

    if you take a look at the K2 database (and this is on K2.net 2003 sp2a, by the way) you'll find a couple of stored procedures that pretty much mimc the API interface.

    CREATE PROCEDURE kWorklistItemRedirect @ProcInstID INT, @EventInstID INT, @User NVARCHAR(128) 

    CREATE PROCEDURE kWorklistItemOpen @ProcInstID INT, @EventInstID INT, @Platform NVARCHAR(128), @Alloc BIT, @IgnoreStatus BIT

    the parameters of these sprocs are so close to the API that i can only assume they match up and that the SerialNumber in K2 is just a ProcInstID and an EventInstID concatenated and split up by the API before making the db call.

    that would lead me to believe you can just use the worklistitem.ID as a worklistItem.SerialNumber and get that connection you're looking for.

    hope that helps.

     


    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.
  •  03-02-2008, 9:58 AM 22236 in reply to 22202

    Re: K2Mng and K2ROM

    Thanks, but there is no K2ROM OpenWorkListItem that takes an ID  as a parameter (not that I can find anyway).

     I have managed to find out the the ID returned for a worklist item vvia the K2ROM is the same as the the ID of the same process returned via K2Mng - I guess that should be expected.  Just no way of accessing via this ID in K2ROM (except opening the worklist of the user, and looping until I find the ID).

     

     

  •  03-11-2008, 12:59 PM 22451 in reply to 22236

    Re: K2Mng and K2ROM

    TM01 -- you're right, it was my bad guess. 

    the following code is tested and confirms your last post.  it seems the only way to get at this ID would be to loop through all worklist items though.

     

    k2rom_conn = new SourceCode.K2ROM.Connection();
    k2rom_conn.Open("k2megasrv");
       
    foreach (K2ROM.WorklistItem wli in k2rom_conn.OpenWorklist("ASP"))
    {
        int id = wli.ID;
    }
       
    k2mng_conn = new SourceCode.K2Mng.K2Manager();
    k2mng_conn.Login("k2megasrv",5252);

    foreach (K2MNG.WorkListItem wli in k2mng_conn.GetWorkListItems("k2mega\\administrator","","","","",null,null))
    {
        long id2 = wli.ID;
    }


    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.
  •  03-11-2008, 1:09 PM 22452 in reply to 22236

    Re: K2Mng and K2ROM

    TM01 -- just another thought ... K2ROM.WorklistItem has a redirect method directly on that class.  Could you not use that instead of the K2MNG namespace to do your redirecting?
    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.
  •  03-11-2008, 2:05 PM 22453 in reply to 22452

    Re: K2Mng and K2ROM

    K2ROM has a method called OpenWorklist() which can take in a WorklistCriteria filter. This makes it so you don't have to retrieve all items and then iterate. Folio is one of the options to filter on, but in the event folio isn't unique you can use a bunch of other things (like process id). It is also quite powerful because you can filter on multiple values, etc.

    An example of this would be:

    K2ROM.Connection conn = <open the connection, etc> 
    int processId = 418;
    
    K2ROM.WorklistCriteria criteria = 
            new K2ROM.WorklistCriteria();
    criteria.Platform = "ASP";
    criteria.NoData = true;
    
    criteria.AddFilterField(K2ROM.WCField.ProcessID, 
            K2ROM.WCCompare.Equal, processId);
    
    K2ROM.Worklist list = conn.OpenWorklist(criteria);
    
    foreach( WorklistItem item in list )
    {
    //Do whatever you need to do to the items that matched your filter
    }
    

    Colin
    K2 Insider
    K2 Blog: K2 Thought
  •  03-12-2008, 1:18 PM 22488 in reply to 22453

    Re: K2Mng and K2ROM

     

    Public Property

     NoData

    WorklistItem objects returned in the collection will be loaded with no process or activity data. Setting this to true will have a direct impact on performance during the retrieval of the collection

    FYI, setting it to true would be faster but would not be able to access these when you loop through the WorkItems.

    Default is false. 

    oWorkListItem.ProcessInstance.DataFields("fieldname1").Value.ToString 

    oWorkListItem.ProcessInstance.XmlFields("FormData").Value 

  •  03-12-2008, 1:35 PM 22492 in reply to 22488

    Re: K2Mng and K2ROM

    Correct.

     In the case where you are just doing redirects (such as in this post) or something that doesn't require access to datafields/xmlfields then setting NoData = true is more performant, but when you actually need to do something to the process/activity data then you should set this to false (or not set it at all since false is the default).


    Colin
    K2 Insider
    K2 Blog: K2 Thought
View as RSS news feed in XML