' Copyright (c) 2003, Plumtree Software

' All rights reserved.

' Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

' 1.  Neither the name of Plumtree Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission; 

' 2.  Licensee acknowledges that no license or other permission is granted herein with respect to any third party software and that Licensee may not use the code in any way that would infringe any third party right.

' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, NONINFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. REGARDLESS OF THE BASIS OF RECOVERY CLAIMED, WHETHER UNDER ANY CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE AND STRICT LIABILITY), BREACH OF STATUTORY DUTY, PRINCIPLES OF CONTRIBUTION OR 
' ANY OTHER THEORY OF LIABILITY, IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
' THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE; AND IN NO EVENT WILL THE COPYRIGHT OWNER'S OR CONTRIBUTORS' EXCEED $10,000.


Imports System
Imports System.Text
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Imports Plumtree.Remote.Portlet
Imports Plumtree.Remote.PRC
Imports Plumtree.Remote.PRC.Collaboration
Imports Plumtree.Remote.PRC.Collaboration.Project
Imports Plumtree.Remote.PRC.Collaboration.Tasklist



Public Class TaskListExamplesVB
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Protected TreeView As System.Web.UI.WebControls.Literal

    Protected WithEvents OptionsButton As System.Web.UI.WebControls.Button
    Protected WithEvents OptionsDropDownList As System.Web.UI.WebControls.DropDownList
    Protected WithEvents CreateTaskListPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents TaskListName As System.Web.UI.WebControls.TextBox
    Protected WithEvents TaskListDescription As System.Web.UI.WebControls.TextBox
    Protected WithEvents CreateTaskListButton As System.Web.UI.WebControls.Button
    Protected WithEvents RemoveTaskListID As System.Web.UI.WebControls.TextBox
    Protected WithEvents RemoveTaskListButton As System.Web.UI.WebControls.Button
    Protected WithEvents RemoveTaskListPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents SearchTaskListsPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents SearchSampleProjectLink As System.Web.UI.WebControls.LinkButton
    Protected WithEvents SearchTaskListsInOtherProjectButton As System.Web.UI.WebControls.Button
    Protected WithEvents SearchTaskListsProjectID As System.Web.UI.WebControls.TextBox
    Protected WithEvents CreateTopLevelTaskPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents TaskName As System.Web.UI.WebControls.TextBox
    Protected WithEvents TaskDescription As System.Web.UI.WebControls.TextBox
    Protected WithEvents ContainingTaskListID As System.Web.UI.WebControls.TextBox
    Protected WithEvents CreateTopLevelTaskButton As System.Web.UI.WebControls.Button
    Protected WithEvents RemoveTaskPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents RemoveTaskID As System.Web.UI.WebControls.TextBox
    Protected WithEvents RemoveTaskButton As System.Web.UI.WebControls.Button
    Protected WithEvents SearchTasksPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents SearchTasksTaskListID As System.Web.UI.WebControls.TextBox
    Protected WithEvents SearchTasksButton As System.Web.UI.WebControls.Button
    Protected WithEvents CreateSubTaskPanel As System.Web.UI.WebControls.Panel
    Protected WithEvents SubTaskParentTaskID As System.Web.UI.WebControls.TextBox
    Protected WithEvents SubTaskName As System.Web.UI.WebControls.TextBox
    Protected WithEvents SubTaskDescription As System.Web.UI.WebControls.TextBox
    Protected WithEvents CreateSubTaskButton As System.Web.UI.WebControls.Button


    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Dim sampleProject As IProject = Nothing

    Dim tasklistManager As ITaskListManager
    Dim remoteSession As IRemoteSession
    Dim collabFactory As ICollaborationFactory
    Shared isLoaded As Boolean

    Dim tasklistOptions() As String = {"Create task list", _
                                                "Remove task list", _
                                                "Search task lists", _
                                                "Create top-level task", _
                                                "Remove task", _
                                                "Search tasks", _
                                                "Create sub-task", _
                                                "Shows all task lists and tasks"}

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim portletContext As IPortletContext = PortletContextFactory.CreatePortletContext(Request, Response)
        remoteSession = portletContext.GetRemotePortalSession()
        'remoteSession = RemoteSessionFactory.GetExplicitLoginContext(New Uri("http://carolvm2:11080/ptapi/services/QueryInterfaceAPI"), "Administrator", "")

        collabFactory = remoteSession.GetCollaborationFactory()
        tasklistManager = collabFactory.GetTaskListManager()

        sampleProject = DirectCast(Session.Item("edk_sample_project"), IProject)

        
        If sampleProject Is Nothing Then
            Response.Redirect("../project/ProjectCreatorVB.aspx?source=../tasklist/TaskListExampleVB.aspx")
        End If

        sampleProject = DirectCast(Session("edk_sample_project"), IProject)
        If (sampleProject Is Nothing) Then
            sampleProject = collabFactory.GetProjectManager.CreateProject("TestTaskList", "Blah")
            sampleProject.Store()
        End If

        If (Not isLoaded) _
            Or (OptionsDropDownList Is Nothing) _
            Or (OptionsDropDownList.SelectedIndex = -1) Then
            OptionsDropDownList.DataSource = tasklistOptions
            OptionsDropDownList.DataBind()     'binds the data
            isLoaded = True
        End If

        GetPostBackEventReference(Me)
    End Sub

    'creates a task list
    Public Function CreateAndStoreTaskList(ByVal project As IProject, ByVal name As String, ByVal description As String) As ITaskList
        Dim tasklist As ITaskList = tasklistManager.CreateTaskList(project, name, description)
        'call Store() to persist to the task list
        tasklist.Store()
        Return tasklist
    End Function

    'creates a sub-task
    Public Function CreateAndStoreSubTask(ByVal parentTask As ITask, ByVal name As String, ByVal description As String, ByVal startTime As DateTime, ByVal endTime As DateTime) As ITask
        'CreateSubTask() will create a persisted task, so
        'Store() does not need to be called to persist the task properties unless additional properties are set.
        Dim subtask As ITask = parentTask.CreateSubTask(name, description, startTime, endTime)

        'If you want to set additional properties, make sure that Store() is called, otherwisethe changes will not be persisted.
        subtask.Risk = TaskRisks.Low
        subtask.Status = TaskStatuses.FiftyPercentCompleted

        'call Store() to persist to the addditional properties set on the sub-task
        subtask.Store()
        Return subtask
    End Function

    'removes a task 
    Public Function RemoveTask(ByVal task As ITask) As Boolean
        Dim removed As Boolean = False
        Dim taskID As Integer = task.ID
        Dim tasklist As ITaskList = task.ContainingTaskList

        If (tasklist Is Nothing) Then
            removed = False
        Else
            tasklist.RemoveTask(task)

            'trying to retrieve the task after removal, should retrieve nothing
            Dim taskAfterRemoval As ITask = tasklistManager.GetTask(taskID)
            If (taskAfterRemoval Is Nothing) Then
                removed = True
            Else
                removed = False
            End If
        End If
        Return removed
    End Function

    'removes a task list
    Public Function RemoveTasklist(ByVal tasklist As ITaskList) As Boolean
        Dim removed As Boolean = False
        Dim tasklistID As Integer = tasklist.ID
        tasklistManager.RemoveTaskList(tasklist)
        'trying to retrieve the task list after removal, should retrieve nothing
        Dim taskListAfterRemoval As ITaskList = tasklistManager.GetTaskList(tasklistID)
        If (taskListAfterRemoval Is Nothing) Then
            removed = True
        Else
            removed = False
        End If
        Return removed
    End Function


    'search all task lists in a project with default tasklist filter
    Public Function GetTaskLists(ByVal project As IProject) As ITaskList()
        Dim filter As ITaskListFilter = tasklistManager.CreateTaskListFilter()
        Dim children As ITaskList() = tasklistManager.QueryTaskLists(project, filter)
        Return children
    End Function

    'search all task lists in a task list with default task filter
    Public Function GetTasks(ByVal tasklist As ITaskList) As ITask()
        Dim filter As ITaskFilter = tasklistManager.CreateTaskFilter()
        Dim tasks As ITask() = tasklistManager.QueryTasks(tasklist, filter)
        Return tasks
    End Function

    'creates a task
    Public Function CreateAndStoreTopLevelTask(ByVal tasklist As ITaskList, ByVal name As String, ByVal description As String, ByVal startTime As DateTime, ByVal endTime As DateTime) As ITask
        Dim task As ITask = tasklist.CreateTask(name, description, startTime, endTime)
        'If you want to set additional properties, make sure that Store() is called, otherwise the changes will not be persisted.
        'For example,
        task.Notes = "Notes for sample TopLevel Task"
        task.Risk = TaskRisks.Medium
        task.Status = TaskStatuses.Pending

        'call Store to persist to the task
        task.Store()
        Return task
    End Function

    Public Sub ShowAll()
        Dim tasklists As ITaskList() = GetTaskLists(sampleProject)
        TreeView = New Literal
        TreeView.Text = ""
        For i As Integer = 0 To tasklists.Length - 1
            TreeView.Text &= AppendTasklist(tasklists(i)).Text
        Next i
        Response.Write(TreeView.Text)
    End Sub


    Public Function AppendTasklist(ByVal tasklist As ITaskList) As LiteralControl

        If (tasklist Is Nothing) Then
            Return Nothing
        End If

        Dim html As StringBuilder = New StringBuilder
        html.Append(tasklist.Name)
        html.Append(" (id=")
        html.Append(tasklist.ID)
        html.Append(")")
        html.Append(" [<a href=""" & tasklist.DetailsURL & """>")
        html.Append("details")
        html.Append("</a>]")
        html.Append("<br/>")
        Dim rv As LiteralControl = New LiteralControl(html.ToString())

        Dim childTasks As ITask() = GetTasks(tasklist)
        For i As Integer = 0 To childTasks.Length - 1
            rv.Text &= AppendTask(childTasks(i)).Text
        Next i
        Return rv
    End Function

    Public Function AppendTask(ByVal task As ITask) As LiteralControl
        Dim html As StringBuilder = New StringBuilder

        html.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
        html.Append("-" & task.Name)
        html.Append(" (id=")
        html.Append(task.ID)
        html.Append(")")

        html.Append(" [<a href=""" & task.DetailsURL & """>")
        html.Append("details")
        html.Append("</a>]")
        html.Append("<br/>")
        Dim rv As LiteralControl = New LiteralControl(html.ToString())
        Return rv
    End Function


    Public Sub RenderTaskLists(ByVal project As IProject)
        If Not (Project Is Nothing) Then
            Dim tasklists() As ITaskList = GetTaskLists(Project)
            Dim html As StringBuilder = New StringBuilder

            If (tasklists.Length > 0) Then
                html.Append("Project with name=")
                html.Append(Project.Name)
                html.Append(", ID=")
                html.Append(Project.ID)
                html.Append(" has ")
                html.Append(tasklists.Length)
                html.Append(" tasklists.")
                html.Append("<br/>")
                html.Append("<br/>")

                'now print out all searched task lists               
                For i As Integer = 0 To tasklists.Length - 1
                    html.Append(i)
                    html.Append(". ")
                    html.Append(tasklists(i).Name)
                    html.Append(" (id=")
                    html.Append(tasklists(i).ID)
                    html.Append(") [<a href=""" & tasklists(i).DetailsURL & """>")
                    html.Append("details")
                    html.Append("</a>]")
                    html.Append("<br/>")
                Next i

            Else
                html.Append("No task lists found in project with ID : ")
                html.Append(Project.ID)
                html.Append(".")
            End If
            Response.Write(html.ToString())
        End If
        SearchTaskListsPanel.Visible = False
    End Sub


    Private Sub OptionsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsButton.Click

        'Create task list
        If (OptionsDropDownList.SelectedIndex = 0) Then
            CreateTaskListPanel.Visible = True
            CreateTaskListPanel.Enabled = True

            'Remove task list
        ElseIf (OptionsDropDownList.SelectedIndex = 1) Then
            RemoveTaskListPanel.Visible = True
            RemoveTaskListPanel.Enabled = True

        ElseIf (OptionsDropDownList.SelectedIndex = 2) Then
            SearchTaskListsPanel.Visible = True
            SearchTaskListsPanel.Enabled = True

        ElseIf (OptionsDropDownList.SelectedIndex = 3) Then
            CreateTopLevelTaskPanel.Visible = True
            CreateTopLevelTaskPanel.Enabled = True

        ElseIf (OptionsDropDownList.SelectedIndex = 4) Then
            RemoveTaskPanel.Visible = True
            RemoveTaskPanel.Enabled = True

        ElseIf (OptionsDropDownList.SelectedIndex = 5) Then
            SearchTasksPanel.Visible = True
            SearchTasksPanel.Enabled = True

        ElseIf (OptionsDropDownList.SelectedIndex = 6) Then
            CreateSubTaskPanel.Visible = True
            CreateSubTaskPanel.Enabled = True
        ElseIf (OptionsDropDownList.SelectedIndex = 7) Then
            ShowAll()
        End If

    End Sub


    Private Sub CreateTaskListButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateTaskListButton.Click
        CreateTaskListPanel.Visible = True

        Dim name As String
        If (TaskListName.Text Is Nothing) Then
            name = "SampleTaskList"
        Else
            name = TaskListName.Text
        End If

        Dim description As String
        If (TaskListDescription.Text Is Nothing) Then
            description = "SampleTaskListDescription"
        Else
            description = TaskListDescription.Text
        End If

        Dim tasklist As ITaskList
        If (Not sampleProject Is Nothing) Then

        End If

        tasklist = CreateAndStoreTaskList(sampleProject, name, description)

        Dim html As StringBuilder = New StringBuilder
        html.Append("Created task list has name=")
        html.Append(tasklist.Name)
        html.Append(", ID=")
        html.Append(tasklist.ID)
        html.Append(" [<a href=""" & tasklist.DetailsURL & """>")
        html.Append("details")
        html.Append("</a>]")
        html.Append("<br/>")
        Response.Write(html.ToString())
        CreateTaskListPanel.Visible = False

    End Sub

    Private Sub RemoveTaskListButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveTaskListButton.Click
        Dim tasklist As ITaskList = Nothing
        Dim tasklistID As Integer = -1

        Try
            tasklistID = Integer.Parse(RemoveTaskListID.Text)
            tasklist = tasklistManager.GetTaskList(tasklistID)
            If (tasklist Is Nothing) Then
                Response.Write("Could not find task list with ID : " & tasklistID)
            End If

        Catch ex As FormatException
            Response.Write("Cannot parse task list ID: [" & RemoveTaskListID.Text & "]")
        Catch err As Exception
            Response.Write("Cannot parse task list ID: [" & RemoveTaskListID.Text & "] - " & err.Message)

        End Try

        If Not (tasklist Is Nothing) Then
            Dim html As StringBuilder = New StringBuilder
            If (RemoveTasklist(tasklist)) Then
                html.Append("Task list with ID=")
                html.Append(tasklistID)
                html.Append(" removed.")
            Else
                html.Append("Failed to remove task list with ID : ")
                html.Append(tasklistID)
                html.Append(".")
            End If
            Response.Write(html.ToString())
        End If
        RemoveTaskListPanel.Visible = False


    End Sub

    Private Sub SearchTaskListsInOtherProjectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchTaskListsInOtherProjectButton.Click
        SearchTaskListsPanel.Visible = True
        Dim project As IProject = Nothing
        Dim projectID As Integer = -1

        Try
            projectID = Integer.Parse(SearchTaskListsProjectID.Text)
            project = collabFactory.GetProjectManager().GetProject(projectID)

            If (project Is Nothing) Then
                Response.Write("Could not find project with ID: " & projectID)
            End If
        Catch ex As FormatException
            Response.Write("Cannot parse project ID: [" + SearchTaskListsProjectID.Text + "]")
        End Try
        RenderTaskLists(project)
    End Sub

    Private Sub SearchSampleProjectLink_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchSampleProjectLink.Click
        RenderTaskLists(sampleProject)
    End Sub

    Private Sub CreateTopLevelTaskButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateTopLevelTaskButton.Click
        Dim tasklistID As Integer = -1
        Dim tasklist As ITaskList = Nothing
        Try
            tasklistID = Integer.Parse(ContainingTaskListID.Text)
            tasklist = tasklistManager.GetTaskList(tasklistID)
            If (tasklist Is Nothing) Then
                Response.Write("Could not find task list with ID: " & tasklistID)
            End If
        Catch ex As FormatException
            Response.Write("Cannot parse task list ID: [" & ContainingTaskListID.Text & "]")
        End Try

        Dim name As String = "SampleTask"
        If Not (TaskName.Text Is Nothing) Then
            name = TaskName.Text
        End If

        Dim description As String = "SampleTaskDescription"
        If Not (TaskDescription.Text Is Nothing) Then
            description = TaskDescription.Text
        End If

        Dim task As ITask = Nothing
        If Not (tasklist Is Nothing) Then
            task = CreateAndStoreTopLevelTask(tasklist, name, description, New DateTime, New DateTime)

            Dim html As StringBuilder = New StringBuilder
            html.Append("Created task has name=")
            html.Append(task.Name)
            html.Append(", ID=")
            html.Append(task.ID)
            html.Append(" [<a href=""" & task.DetailsURL & """>")
            html.Append("details")
            html.Append("</a>]")
            html.Append("<br/>")
            Response.Write(html.ToString())
            CreateTopLevelTaskPanel.Visible = False
        End If
        CreateTopLevelTaskPanel.Visible = False

    End Sub

    Private Sub RemoveTaskButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveTaskButton.Click
        Dim task As ITask = Nothing
        Dim taskID As Integer = -1

        Try
            taskID = Integer.Parse(RemoveTaskID.Text)
            task = tasklistManager.GetTask(taskID)
            If task Is Nothing Then

                Response.Write("Could not find task with ID : " & taskID)
            End If

        Catch ex As FormatException
            Response.Write("Cannot parse task ID: [" & RemoveTaskID.Text & "]")
        End Try

        If Not (task Is Nothing) Then
            Dim html As StringBuilder = New StringBuilder

            If (RemoveTask(task)) Then

                html.Append("Task with ID=")
                html.Append(taskID)
                html.Append(" removed.")

            Else
                html.Append("Failed to remove task with ID=")
                html.Append(taskID)
                html.Append(".")
            End If
            Response.Write(html.ToString())
        End If
        RemoveTaskPanel.Visible = False

    End Sub

    Private Sub SearchTasksButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchTasksButton.Click
        Dim tasklist As ITaskList = Nothing
        Dim tasklistID As Integer = -1

        Try
            tasklistID = Integer.Parse(SearchTasksTaskListID.Text)
            tasklist = tasklistManager.GetTaskList(tasklistID)
            If (tasklist Is Nothing) Then
                Response.Write("Could not find task list with ID : " & tasklistID)
            End If

        Catch ex As FormatException
            Response.Write("Cannot parse task list ID: [" & SearchTasksTaskListID.Text & "]")
        End Try
        If Not (tasklist Is Nothing) Then
            Dim tasks As ITask() = GetTasks(tasklist)
            Dim html As StringBuilder = New StringBuilder
            If (tasks.Length > 0) Then
                html.Append("Task list with name=")
                html.Append(tasklist.Name)
                html.Append(", ID=")
                html.Append(tasklist.ID)
                html.Append(" has ")
                html.Append(tasks.Length)
                html.Append(" tasks.")
                html.Append("<br/>")
                html.Append("<br/>")

                'now print out all searched task lists
                For i As Integer = 0 To tasks.Length - 1
                    html.Append(i)
                    html.Append(". ")
                    html.Append(tasks(i).Name)
                    html.Append(" (id=")
                    html.Append(tasks(i).ID)
                    html.Append(") [<a href=""" & tasks(i).DetailsURL & """>")
                    html.Append("details")
                    html.Append("</a>]")
                    html.Append("<br/>")
                Next i

            Else

                html.Append("No tasks found in task list with ID : ")
                html.Append(tasklist.ID)
                html.Append(".")
            End If
            Response.Write(html.ToString())
        End If
        SearchTasksPanel.Visible = False
    End Sub

    Private Sub CreateSubTaskButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateSubTaskButton.Click
        Dim parentTaskID As Integer = -1
        Dim parentTask As ITask = Nothing
        Try
            parentTaskID = Integer.Parse(SubTaskParentTaskID.Text)
            parentTask = tasklistManager.GetTask(parentTaskID)
            If (parentTask Is Nothing) Then
                Response.Write("Could not find task with ID: " & parentTaskID)
            End If

        Catch ex As FormatException
            Response.Write("Cannot parse task ID: [" & SubTaskParentTaskID.Text & "]")
        End Try
        Dim name As String = "SampleSubTask"
        Dim description As String = "SampleSubTaskDescription"

        If Not (Nothing Is SubTaskName.Text) Or Not ("".Equals(SubTaskName.Text)) Then
            name = SubTaskName.Text
        End If

        If Not (Nothing Is SubTaskDescription.Text) Or Not ("".Equals(SubTaskDescription.Text)) Then
            description = SubTaskDescription.Text
        End If

        Dim subTask As ITask = Nothing
        If Not (parentTask Is Nothing) Then
            subTask = CreateAndStoreSubTask(parentTask, name, description, New DateTime, New DateTime)

            Dim html As StringBuilder = New StringBuilder
            html.Append("Created sub-task has name=")
            html.Append(subTask.Name)
            html.Append(", ID=")
            html.Append(subTask.ID)
            html.Append(" [<a href=""" + subTask.DetailsURL & """>")
            html.Append("details")
            html.Append("</a>]")
            html.Append("<br/>")
            Response.Write(html.ToString())
        End If
        CreateSubTaskPanel.Visible = False

    End Sub
End Class
