asp.net generate monthly reports 30-minute process and update browser label with status

97 views Asked by At

Using VS-Express-Web-2012 ASP.NET WebForms and Reportviewer control to generate reports. There are a list of customers (selected by the user), a list of email-recipients for each customer, and a list of reports to be generated for each recipient. The data for each report is based on the customer, the recipient and the report. An email is generated (text and pdf-attachments) for each recipient.

The problem is this process may take many minutes -- up to 30 minutes. We would like the process to put status-text into a label on the browser at various points in the process (Customer:001, Recipient:001, Email generated.)

We have researched this and cannot seem to get text to the label during the points in the process -- Asynch and threading and cannot get this working, mainly since these strategies are not compatible for an ASP web-application.

We have tried using javascript to invoke a button-click that would resume the process, but we cannot get the process to run by itself, as noted here...

1) Button click starts the process for Customer=1, Recipient=1.

2) After the email is created the following is prepared for the response by advancing the Recipient and possibly the Customer, for the next iteration coming back on a subsequent postback to the server AFTER the response.

The process is a set of nested For-loops (one for Customer, one for Recipient and one for Report) that executes once for each postback...

ASPX:

<div hidden="hidden">
  <asp:Button  ID="hidCmdDoPostBack" runat="server" Text="Button" 
      CommandArgument="commandargument" CommandName="commandname" />
</div>

<script type="text/javascript">
  function DoStart(p_sCommand, p_sCommandArgument) {
     var oCtrlButton      = document.getElementById('<%=hidCmdDoPostBack.ClientID%>');
     var hidPassedArgument = document.getElementById('<%=hidPassedArgument.ClientID%>');
     alert("DoStart() : hidPassedArgument.value = " + hidPassedArgument.value + " , " + p_sCommandArgument);
     if ((oCtrlButton != null)) {  // && (p_sCommand != 'STOP')) {
        oCtrlButton.click();
     }
  }
</script>

SERVER-CODE: (VB.NET)

...
  For iLoopCust As Int16 = iNdxCustomer To iNdxCustomer
    ...
     For iLoopContact As Int16 = iNdxContact To iNdxContact
        ...
        For iloopReport As Int16 = 0 To iNdxReportLast
           ...
        Next iLoopReport
     Next iLoopContact
  Next iLoopCust

     ScriptManager.RegisterStartupScript(hidCmdDoPostBack, cmdStart.GetType(), "KDoCommand", Nothing, True)
     ScriptManager.RegisterStartupScript(hidCmdDoPostBack, cmdStart.GetType(), "KDoCommand", String.Format("DoStart('RESUME', '{0},{1},{2}');", iNdxCustomer, iNdxContact, iNdxReportLast), True)

3) However the 'DoStart' javascript function is not invoked on the response back to the client.

Your comments and solutions are welcome. Thanks...John

0

There are 0 answers