in Search
 
Home Blogs Forums Marketplace Files
 
 
 

Teamplate.BLL.BProcess.UpdateTask

Last post 07-02-2008, 2:10 PM by crathermel. 10 replies.
Sort Posts: Previous Next
  •  10-03-2007, 12:58 PM 13021

    Teamplate.BLL.BProcess.UpdateTask

    Hello,

    I am upgrading captaris 5.0 to 6.0 and thus need to upgrade the web application that uses the API to .NET 2.0.  In doing so I am running into some problems w/ the UpdateTask function.

    I have attached a little code below to help w/ explain the situation.  All the variables have data in them and the Teamplate.BLL.BProcess is declared but I still get the error: Object reference not set to an instance of an object.

    Is the taskid = -1 making it crash ?

     

    Thanks for your help,

    Christopher Rathermel

    Code:

    Dim Process As New Teamplate.BLL.BProcess

    Process.UpdateTask(PID, TID, dueDate.NewDate(days), tplateID, "Normal")

    Variable values:

    Process status = InComplete
    PID = 32639
    TID = -1
    dueDate.NewDate(days): 10/8/2007 2:38:45 PM
    days = 3
    tplateID = 603

     

    Error Message: Could not update task Object reference not set to an instance of an object.
    Source: TeamplateBLL
    Stack Trace: at Teamplate.BLL.BProcess.UpdateTask(Int32 processID, Int32 taskID, DateTime dueDate, Int32 responsibleID, String priority, String cost, String estimation) at Teamplate.BLL.BProcess.UpdateTask(Int32 processID, Int32 taskID, DateTime dueDate, Int32 responsibleID, String priority) at CA.ReassignTask.reassign(BProcess pro, Int32 tplateID, String newName, String oldName, String reason, Int32 PID, Int32 TID, Int32 days)
    URL: /workflow.net.deve/CA/wfrmCADataEntry.aspx?PID=32640&TID=125&token=chvVXMSF1BzwcdoDe899FfSxnhSrmxrr219T6Uvjv7MjryZE5QSx69RqVW7LmyFVumb%252FKBAgKejfYJ4c%252FzIV%252F%252F7whqQWr5okO8wjqyYfK%252Foj7rYdm%252BT0B0ANOOb5mS84KDxBUcOKLwvz8sPO80gCdm3PhHuSB0eCKP2H3vE6wdIIu40wpu6JbJuaLRMjZnQmcXNXrV22Eq94%252BcYtm4PBCOnTegZRdzXQHUFpVc0F2xudw9p6y7TqYd6VLwFY0IdJR85MIcGy0hYIk7gix05C1al1RK%252BFaXTfPysIW7PadpyxZusDZMgHV7a6LnHE2agCWssd%252BdKu5mXfLKDyDlgue%252FPRaZ9Ni%252Fnw6QAK7Gn7j4Q%252FIeioPm18%252BfGbI8MCLgLPl6spSeXXq%252Fk%3d
    Date/Time:

    10/3/2007 2:46:20 PM

     

    Function documentation that I found:

     

    BProcess::UpdateTask(Int32, Int32,

    DateTime, Int32, String) : Boolean

    Updates task information

    Syntax:

    bool UpdateTask(int iProcessID, int iTaskID, DateTime dtDueDate, int iResponsibleID, string

    strPriority);

    Parameters:

    Int32 iProcessId Id of process

    Int32 iTaskID Id of task

    DateTime dtDueDate Due date for task

    Int32 iResponsibleID Responsible User

    String strPriority Priority

    Return:

    Boolean Returns true if successful, otherwise false

  •  10-03-2007, 1:13 PM 13022 in reply to 13021

    Re: Teamplate.BLL.BProcess.UpdateTask

    Hello Christopher,

    You have to set Session Token and load Process before you invoke Process.UpdateTask:

    Teamplate.BLL.BProcess oPr = new Teamplate.BLL.BProcess();

    oPr.SetSessionToken(_Token);

    oPr.Load(4760);

    oPr.UpdateTask(4760, 2, DateTime.Now, 0, "Normal");

    oPr.Dispose();

    Best Regards,

    Galina

  •  10-03-2007, 1:47 PM 13024 in reply to 13022

    Re: Teamplate.BLL.BProcess.UpdateTask

    Galina,

     

    I actually do set the Session before the UpdateTask call but didn't include it in my origional post for simplicity. 

     

    Here are some more code to explain my situation:  (Look for: 'Error is here!!!!! )

     

    Dim pro As Teamplate.BLL.BProcess

    Dim px As New CA.LoadBProcess

    Dim nextTID As Integer

    Dim respID As Integer

    Dim tplateID As Integer

    Dim taskRe As CA.ReassignTask = New CA.ReassignTask

    tplateID = CInt(Request.Cookies("TPLATE")("TPLATEID"))

    pro = px.getBProcess()    'The Session is set here.  Check below for details

    pro.SetTextValue("JOBEXTRA", "TBLJOBEXTRADETAILS/APPRTID", txtStaffApprovalid.Text)

    pro.SetTextValue("JOBEXTRA", "TBLJOBEXTRADETAILS/APPRNAME", txtStaffApprovalname.Text)

    respID = pro.GetOwner()

    pro.WorkflowAdvance(CInt(Request.QueryString("TID")), "")

    nextTID = pro.GetNextTaskID(respID, Teamplate.BLL.BProcess.TaskStatus.Waiting)

    taskRe.reassign(pro, CInt(txtStaffApprovalid.Text), txtStaffApprovalname.Text, Request.Cookies("TPLATE")("NAME"), "Send data for approval.", CInt(Request.QueryString("PID")), nextTID, 3)   'Error is here!!!!!  Check below for more details

     

    Class Functions referenced above:

    Public Class LoadBProcess

    Public Function getBProcess() As Teamplate.BLL.BProcess

    Dim Token As String

    Dim Session As Teamplate.BLL.BSession

    Session = New Teamplate.BLL.BSession

    Session.Connect(Current.Request.Cookies("TPLATE")("UID").ToString, "")

    Token = Session.GetToken()

    Dim Process As Teamplate.BLL.BProcess

    Process = New Teamplate.BLL.BProcess

    Process.SetSessionToken(Token)

    Process.Load(CInt(Current.Request.QueryString("PID")))

    Return Process

    End Function

    End Class

     

     

    Public Sub reassign(ByVal pro As BProcess, ByVal tplateID As Integer, ByVal newName As String, ByVal oldName As String, ByVal reason As String, ByVal PID As Integer, ByVal TID As Integer, ByVal days As Integer)

    Dim Process As New Teamplate.BLL.BProcess

    Dim procDetails As New StringBuilder

    Dim proName As New StringBuilder

    Dim dt As New DataTable

    dt = getName(tplateID)

    proName.Append(PID)

    proName.Append(" - CA Process - ")

    proName.Append(LCase(CStr(DataBinder.Eval(dt, "defaultView.[0].NAME"))))

    Try

    Process = pro

    procDetails.Append("<hr><font color=Red>Task Reassigned to ")

    procDetails.Append(newName)

    procDetails.Append("<br>Reason: ")

    procDetails.Append(reason)

    procDetails.Append("<br>")

    procDetails.Append("by: ")

    procDetails.Append(oldName)

    procDetails.Append("<br>")

    procDetails.Append(Date.Now)

    procDetails.Append("</font><br>")

    procDetails.Append(Replace(Replace(Process.GetTextValue("OTHER", "OTHER/PROCESSDETAILS"), "<font color=Red>", ""), "</font>", ""))

    Process.SetTextValue("OTHER", "OTHER/PROCESSDETAILS", procDetails.ToString)

    Dim dueDate As New CA.BusinessDays

    Process.UpdateTask(PID, TID, dueDate.NewDate(days), tplateID, "Normal") 'Error is here!!!!!

    Process.SetName(proName.ToString)

    Process.SaveFile()

    Catch o As Exception

    Dim catchMe As New CA.CaughtError

    catchMe.showMeTheError(o)

    Finally

    If Not (Process Is Nothing) Then

    Process.Dispose()

    End If

    Process = Nothing

    procDetails = Nothing

    End Try

    End Sub

  •  10-03-2007, 3:18 PM 13025 in reply to 13024

    Re: Teamplate.BLL.BProcess.UpdateTask

    Hi Christopher,

    nextTID = pro.GetNextTaskID(respID, Teamplate.BLL.BProcess.TaskStatus.Waiting)

    The nextTID integer has the value of -1, and that couses the error.

    Best Regards,

    Galina

     

  •  10-03-2007, 4:23 PM 13026 in reply to 13025

    Re: Teamplate.BLL.BProcess.UpdateTask

    Hey Galina,

    Do have any idea why the GetNextTaskId function would return "-1" ?

    Also do you know what are the acceptable values that the UpdateTask function supports for the taskid parameter?

     

    PS:  This code did work for the 5.0 version of the API .dll in the .NET 1.1 framework.

    Thanks a lot for your help,

    Christopher

  •  10-04-2007, 10:01 AM 13031 in reply to 13026

    Re: Teamplate.BLL.BProcess.UpdateTask

    Hi Christopher,

    GetNextTaskId() will return -1 in the following cases:

    1. GetNextTaskId(intRespID,Teamplate.BLL.BProcess.TaskStatus.Waiting)

    there are no tasks in Waiting state, or intRespID is not valid Workflow user ID, or task that is in waiting state is alredy assigned to the user Id that does not match the value of intRespID

    2. GetNextTaskId(intRespID,Teamplate.BLL.BProcess.TaskStatus.Ready)

    there are no tasks in Ready state, or intRespID is not valid Workflow user ID, or task that is in ready state is alredy assigned to the user Id that does not match the value of intRespID

    If you have parallel tasks that are in ready state, say Task Id 5 and Task Id 6, GetNextTaskId(intRespID,Teamplate.BLL.BProcess.TaskStatus.Ready) where both parameters are correct will return 5.

    Acceptable values for UpdateTask are:

    valid Workflow user ID,valid Task Id (e.g. the model has tasks with IDs 2,3,4, if you pass 5 the update will fail),valid Due Date(DateTime datatype), valid Task Priority value (you can use Teamplate.BLL.TaskPriority enum to ensure the valid value is passed e.g. Teamplate.BLL.TaskPriority.Normal.ToString()).

    You code worked in 5.0 only under specific condition: you had several parallel tasks and updated next task when one of parallel tasks has been advanced (not the last one though), in this case your next task was in Waiting state.

    If understand correctly you want to set Task due date and responsible Id. The best way to accomplish this is to set these properties on the Task Ready event.

    e.g.

    Sub Task3_Ready(ByVal data As System.Object)
     Task3.DueDate = dNewDate
     If Not data Is Nothing Then
      Task3.ResponsibleId = CInt(data)
     End If 
    End Sub

    When you invoke WorkflowAdvance you can pass responsible Id to the next Task ready event

    oPr.WorkflowAdvance(3, 6); where 3 is task id and 6 is user Id

    Best Regards,

    Galina

  •  10-10-2007, 8:15 AM 13062 in reply to 13031

    Re: Teamplate.BLL.BProcess.UpdateTask

    Hello Galina,

    First of all, thanks again for your detailed response. 

    I am having a little trouble understanding your response to apply it to my problem.

    Quote:
    "You code worked in 5.0 only under specific condition: you had several parallel tasks and updated next task when one of parallel tasks has been advanced (not the last one though), in this case your next task was in Waiting state."

    I think if I can understand this statement I would be able to apply your recommendations.  What is different from the 5.0 version and the 6.0 version that applies to my workflow? 

    You recommended using the Task Ready Event.  I am not sure what this is (dll function, class function made by the programmer, some custom workflow event that needs to be applied to the model).  Also how would you declare the "Task3" variable to have access to those properties w/o using the UpdateTask Function of the API?

    Thanks again,

    Christopher


  •  10-10-2007, 10:57 AM 13067 in reply to 13062

    Re: Teamplate.BLL.BProcess.UpdateTask

    Hi Christopher,

    First on task statuses, how and when the status of task changes:

    For example, I have a model that consists of 4 web tasks: TaskWebForm2 , TaskWebform3 , TaskWebForm4, TaskWebForm5. TaskWebForm# is the name of web task object in the model and processes based out of this model.

    TaskWebForm2 links to TaskWebForm3 and TaskWebForm4 with no business rules(that makes 3 and 4 parallel tasks). TaskWebForm3 and TaskWebForm4 have links to TaskWebform5 (you can execute 5 when both 3 and 4 are completed).

    When I advance TaskWebForm2 (BProcess.WorkflowAdvance(2,Nothing)), 2 becomes Completed, and 3 4 change their status to Ready (as they are parallel tasks they can be executed in any order). When I advance  say TaskWebForm4, it changes its status to Completed, TaskWebForm3 remains in ready state, and TaskWebForm5 changes its status to Waiting. When TaskWebForm3 is advanced(in this case the last parallel task) 3 becomes Completed, and TaskWebForm5 changes its status to Ready.

    In the example above  (I do not know how you designed the workflow) nextTID = pro.GetNextTaskID(respID, Teamplate.BLL.BProcess.TaskStatus.Waiting) will work only when TaskWebForm4 (BProcess.WorkflowAdvance(4,Nothing)) is advanced and TaskWebForm5 becomes Waiting.

    There is no difference in task changing status between 5.0 and 6.0.

    Second, task events. Any Task object in a model has Ready/Execute/Complete/Failed/Overdue/Reset events. If you open your model select a task you will see all the events available for this task object. When you double-click on say Complete event of TaskWebForm4 the following script will be generated in the script view of the model:

    Sub TaskWebForm4_Complete(ByVal data As System.Object)

    End Sub

    When in your Web form you advance say TaskWebForm4 you can pass any data to this task Complete event or next task Ready event: BProcess.WorkflowAdvance(4,17) 17 here is user id I want TaskWebForm5 to be assigned.

    Sub TaskWebForm4_Complete(ByVal data As System.Object)
     'check if any data has been passed by BProcess.WorkflowAdvance
     If Not data Is Nothing Then
      TaskWebForm5.ResponsibleId = CInt(data)
     End If
    End Sub

    Or use Ready event of next task:

    Sub TaskWebForm5_Ready(ByVal data As System.Object)
     If Not data Is Nothing Then
      TaskWebForm5.ResponsibleId = CInt(data)
     End If
    End Sub

    Sorry for the long expanation, I hope it helps.

    Best Regards,

    Galina

     

  •  10-11-2007, 11:11 AM 13074 in reply to 13067

    Re: Teamplate.BLL.BProcess.UpdateTask

    Galina,

    I think I finally understand what you are getting at.  However, the GetNextTaskId shouldn't be returning "-1" and that is my problem.  This works fine in 2 different environments in captaris 5.0 and .NET 1.1.  Your suggested work around, by setting the process attribute on the Completed or Ready event, might work but it would require a lot of code re-write that isn't in the time budget for this project and if there is no difference between the .NET 1.1  and the 2.0 dlls I am guessing there is something else wrong w/ the set up or db connection causing the error rather than syntax or code design.

    I was hopping to get upgraded to captaris 6.0 or 6.5 to stay within support but I am guessing that it just isn't going to happen w/ the problems I have run into w/ this app. 

    As result it is likely that I will be upgrading the application to 2.0 using windows workflow foundation as a replacement.  Not complaining or putting fault, just letting you know what I am planning on doing for reference or feedback.

    Thanks for all your help on this topic. 

    Regards,

    Christopher
  •  07-02-2008, 9:42 AM 14033 in reply to 13074

    Re: Teamplate.BLL.BProcess.UpdateTask

    Hey,

    Well almost a year has past and I am revisiting the conversion of our application that uses captaris.  I have the application deployed in the 2.0 framework w/ captaris 6.0 on two test servers (front end and sql). 

    I am still receiving the "-1" when I run the GetNextTaskID function.  I am passing the function a valid tplateID and my models have not changed and are working in captaris version 5.0 and framework 1.1. 

    I am able to create an instance of a new "task" and complete the first step "CA Data Entry".  The WorkflowAdvance() function appears to work correctly but after the task list advanced I have code that assigns it to the new user.  This is the approver that user that is set in the "CA Data Entry" step.  It can be the same as the user who created the task or different.  Below I have just set to myself (1908). 

    I see that the status of the tasks in the TASK table are InActive.  Did something change from 5.0 to 6.0 of when a task is in the waiting stage?

    Any ideas how to fix this? 

     

    Code:

    Dim pro As Teamplate.BLL.BProcess

    Dim px As New CA.LoadBProcess

    Dim nextTID As Integer

    Dim respID As Integer

    Dim tplateID As Integer

    Dim taskRe As CA.ReassignTask = New CA.ReassignTask

     

    tplateID = CInt(Request.Cookies("TPLATE")("TPLATEID"))

    pro = px.getBProcess()

    pro.SetTextValue("JOBEXTRA", "TBLJOBEXTRADETAILS/APPRTID", Me.rcbApproval.SelectedValue)

    pro.SetTextValue("JOBEXTRA", "TBLJOBEXTRADETAILS/APPRNAME", Me.rcbApproval.Text)

    respID = pro.GetOwner()

    pro.WorkflowAdvance(CInt(Request.QueryString("TID")), "")

    nextTID = pro.GetNextTaskID(respID, Teamplate.BLL.BProcess.TaskStatus.Waiting)

    System.Web.HttpContext.Current.Response.Write("respID: " & respID & "<br/>")

    System.Web.HttpContext.Current.Response.Write("Me.rcbApproval.SelectedValue: " & Me.rcbApproval.SelectedValue & "<br/>")

    System.Web.HttpContext.Current.Response.Write("Me.rcbApproval.Value: " & Me.rcbApproval.Value & "<br/>")

    System.Web.HttpContext.Current.Response.Write("Me.rcbApproval.Text: " & Me.rcbApproval.Text & "<br/>")

    System.Web.HttpContext.Current.Response.Write("Request.Cookies(TPLATE)(NAME): " & Request.Cookies("TPLATE")("NAME") & "<br/>")

    System.Web.HttpContext.Current.Response.Write("CInt(Request.QueryString(PID)): " & CInt(Request.QueryString("PID")) & "<br/>")

    System.Web.HttpContext.Current.Response.Write("nextTID: " & nextTID & "<br/>")

    System.Web.HttpContext.Current.Response.End()

     

    Print Out:

    respID: 1908
    Me.rcbApproval.SelectedValue: 1908
    Me.rcbApproval.Value: 1908
    Me.rcbApproval.Text: Rathermel, Christopher
    Request.Cookies(TPLATE)(NAME): Christopher K Rathermel
    CInt(Request.QueryString(PID)): 32660
    nextTID: -1

    User from DB:

    guid id sid domain name descrp email
    004e930b-b786-4591-b9ae-049177435230 1908 0 VIRCHOWKRAUSE CR10718 Christopher Rathermel CRathermel@virchowkrause.com

     

    Table TASK

    PID ID NAME INSTANCEID STATUS RESPONSIBLEID ASSIGNED STARTDATE COMPLETEDATE DUEDATE
    32660 6 Client/Project Data Approval 0 Ready 1908 NULL 7/2/2008 10:05 NULL 7/2/2009 9:51
    32660 7 Project Referrals 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 15 VKEB Project Approval 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 16 CFS Project Approval 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 17 VK Capital Project Approval 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 18 VKWM Project Approval 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 19 Civic Project Approval 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 33 Proposal 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 99 VKLLP Project Approval 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 114 Data Creation 0 InActive 1908 NULL 7/2/2008 9:51 NULL 7/2/2009 9:51
    32660 125 CA Data Entry 0 Complete 1908 NULL 7/2/2008 9:51 7/2/2008 10:05 7/7/2008 9:51

     

     

  •  07-02-2008, 2:10 PM 14034 in reply to 14033

    Re: Teamplate.BLL.BProcess.UpdateTask

    Okay the jig is up: 

    I changed the GetNextTaskId function to this and it worked:

    nextTID = pro.GetNextTaskID(respID, Teamplate.BLL.BProcess.TaskStatus.Ready)

     

    Why did this change and why when I asked has anything changed to I get the standard "nothing has changed between the v5.0 and v6.0."

    Thanks,

    Chris

View as RSS news feed in XML
  Privacy    Site Terms   Contact Administrator