Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum

CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Provide Progress Update to the Client for a CSLA Command Object

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 1 Reply | 1 Follower

    Top 50 Contributor
    174 Posts
    tarekahf posted on Mon, Feb 20 2012 2:23 AM

    I need your help how to implement this requirement.

    I am planning to use this Progress Bar control:


    to provide progress update for a CSLA Command Object which I have developed. See soruce code below:

        Public Function RefreshDBFields(ByVal theUserCtrlInfoPack As UserCtrlInfoPack, ByVal DoGetCountOnly As Boolean) As RefreshDBFieldsCommand
            Dim result As RefreshDBFieldsCommand
            result = DataPortal.Execute(Of RefreshDBFieldsCommand)(New RefreshDBFieldsCommand(theUserCtrlInfoPack, DoGetCountOnly))
            Return result
        End Function

        Public Class RefreshDBFieldsCommand
            Inherits CommandBase

            Private mRecordsToBeRefreshedCnt As Integer
            Private mRecordsRefreshedCnt As Integer
            Private mDoGetCountOnly As Boolean
            Private mRecordVersion As Integer
            Private mUserCtrlInfoPack As UserCtrlInfoPack

            Public ReadOnly Property RecordsToBeRefreshedCnt() As Integer
                    Return mRecordsToBeRefreshedCnt
                End Get
            End Property

            Public ReadOnly Property RecordsRefreshedCnt() As Integer
                    Return mRecordsRefreshedCnt
                End Get
            End Property

            Public Sub New(ByVal theUserCtrlInfoPack As UserCtrlInfoPack, ByVal DoGetCountOnly As Boolean)
                mUserCtrlInfoPack = theUserCtrlInfoPack
                mDoGetCountOnly = DoGetCountOnly
            End Sub

            Protected Overrides Sub DataPortal_Execute()
                Using cn As New SqlConnection(Database.SPMSFormDB)
                    Using cm As SqlCommand = cn.CreateCommand
                        cm.CommandType = CommandType.StoredProcedure
                        cm.CommandText = "uspSPMSFormListGetRecVer"
                        cm.Parameters.AddWithValue("@RecVer", mRecordVersion)
                        mRecordsToBeRefreshedCnt = 0
                        mRecordsRefreshedCnt = 0
                        Using da As New SqlDataAdapter(cm)
                            Using ds As New DataSet
                                mRecordsToBeRefreshedCnt = ds.Tables(0).Rows.Count
                                If Not mDoGetCountOnly Then
                                    For Each theRow As DataRow In ds.Tables(0).Rows
                                        mRecordsToBeRefreshedCnt += 1
                                        Dim theSPMSForm As SPMSForm
                                        Dim theStaffID As String
                                        Dim theReviewFrom As String
                                        theStaffID = theRow.Item("StaffID")
                                        theReviewFrom = theRow.Item("ReviewFrom")
                                        theSPMSForm = SPMSForm.GetSPMSForm(mUserCtrlInfoPack, theReviewFrom)
                                        mRecordsRefreshedCnt += 1
                                        theSPMSForm = Nothing
                                End If
                            End Using
                        End Using
                    End Using
                End Using

            End Sub
        End Class

     In summary, the above command will read the SPMS (Staff Performance) Forms Data Source from XML (Text) Data Files, and copy the results to SQL Server Table. The above implementaion is structured in a very similar way to the CSLA Sample Business Object "Project.vb", the ExistsCommand object impementation.

    I want provide feedback to the client about the progress using the properties "RecordsToBeRefreshedCnt" and "RecordsRefreshedCnt", and update the Progress Bar.

    I think I need to do the following:

    1. Create a Button on a ASP.NET Web Form to call "RefreshDBFields" from a thread.

    2. On Click of this Button, create a thread, which will call the function "RefreshDBFields", store the result in a session variable "RefreshDBFieldsSession".

    3. After creating the thread, enable refresh of the Web Form every, say, 3 seconds. Trigger the Progress Bar. Should I use Ajax Update Panel?

    4. Inside the Refresh Event, get the object from the session variable "RefreshDBFieldsSession", and read the progress, and update the progress bar.

    5. When the update is completed, kill the thread, and remove the progress bar.

    I need your feedback on this, any any recommendation.


    Answered (Verified) Verified Answer

    Top 50 Contributor
    174 Posts
    Verified by tarekahf

    Just to confirm that I managed to implement the required functinoality.

    For more details, check here:



    Page 1 of 1 (2 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems