Royi Namir
Royi Namir

Reputation: 148744

Get Progress status of a long executed SP in Asp.net?

I have SP in SqlServer (2005+) which uses cursor and do some stuff (on 10,000 rows)

I need something like a progress bar ( to see in my c# web site.).

I can take the 10,000 divided by 100 in such that each 1000 records it will do ( using sql print command) : process of another 1000 is done !!!

But I want to catch that print ( each new print) in my asp.net web site.

how can I catch the print commands / or is there any better way of doing this ?

Upvotes: 2

Views: 530

Answers (1)

Kinexus
Kinexus

Reputation: 12904

The process we used to implement something similiar is a little more complicated, but it does work.

We created a webservice that had a number of methods, for example;

[SoapDocumentMethod(OneWay = true), WebMethod]
public void StartUpdate(string reference)

[WebMethod]
public ProcessStatus GetProcessStatus(string reference)

A call to the asynch webmethod would start the process running and passed in a reference number to identify itself. This in turn called a stored procedure which used an update on iterations of the cursor to update another table with 'reference', 'count' and 'status'

The GetProcessStatus would then pass this reference in and pass back the current count and status. If the status was completed, we could move on, alternatively, you could use the 'count' at this point to update the status. An example of this;

protected void Page_Load(object sender, EventArgs e)
    {
        this.JavaScript.Text = string.Format("<script>setTimeout(\"{0}\", {1});</script>", 
            this.Page.GetPostBackClientEvent(this.btnRefresh, ""), 3000);


        ProcessStatus status= Class.GetProcessStatus(reference);

        lblCount.Text = status.Count.ToString();



        if (import.Status == (int)ProcessStatus.Status.Complete)
        {
            Globals.GoUrl("/Import/File/Map.aspx");
        }
    }

Hope that helps.

Upvotes: 1

Related Questions