locked
Can i use the same session to refresh same workbook from two different threads (Async calls) RRS feed

  • Question

  • Hi all,

    Below is the scenario.

    I have some workbooks on the server. i am using Excel service webservice to refresh and render the workbooks from client code.

    For a single workbook, user can create some parameter combinations and then invoke the refresh. The code now takes the combination of parameters one by one and refreshes the workbook.

    Pseudo code

    Foreach (parameters in parametercombination)

    {

          //Initialize the webservice

         // Load the workbook

          //Set the parameters

         // Call refresh

        // wait till refresh completes

        // Go to next

    }

    I later moved to async to render so that I can pass the parameters and call the refresh and start the next one.

    Pseudo code

    Foreach (parameters in parametercombination)

    {

          //Initialize the webservice

         // Load the workbook

          //Set the parameters

         // Call render async

        //  Go to next

    }

    I know that when i call the refresh a session id is created when workbook is loaded. I want to use the use the same session for the subsequent refreshes. So basically what i want to do is that I want to open the session once, refreshes all workbook (same workbook for different combinations ) and then close the session

    Pseudo code

    // Get the Session id

    Foreach (parameters in parametercombination)

    {

          //Initialize the webservice - use the session id here

          //Set the parameters

         // Call refresh async

        //  Go to next

    }

    is this possible. One issue i forsee is that by the time the 1st workbook is refreshing the second call may invoke the the refresh.

    Will this type of scenario work fine ?

    Any suggestion on this. Also if possible how many combinations should be safe to refresh at any time.

    - Girija


    • Edited by Girija Beuria Friday, May 11, 2012 9:24 PM Formatted text
    Friday, May 11, 2012 9:23 PM

Answers

All replies

  • Hi Girija_Shankar,

    You can add some java script on your page to reload your excel file. I’m not sure it could get the parameters between different threads.

    <script type="text/javascript">
     
    var ewa = null;
     
    // Add event handler for onload event.
    if (window.attachEvent) 
    { 
        window.attachEvent("onload", ewaOmPageLoad);    
    } 
    else 
    { 
        window.addEventListener("DOMContentLoaded", ewaOmPageLoad, false); 
    }
    // Add event handler for applicationReady event.
    function ewaOmPageLoad() 
    { 
    Ewa.EwaControl.add_applicationReady(getEwa); 
    } 
    function getEwa()
    {        
        // Get a reference to the Excel Services Web Part.
        ewa = Ewa.EwaControl.getInstances().getItem(0);                                     
    }  
    function refreshAllAsyncButton()
    {
        // Refresh all data connections.
        ewa.getActiveWorkbook().refreshAllAsync(refreshAllAsyncCallBack);
    }     
    function refreshAllAsyncCallBack(asyncResult)
    {
        // Get the value from asyncResult if the asynchronous operation was successful.
        if (asyncResult.getCode() == 0)
        {
            // Display refresh success message.
            window.status = "Data connection refresh successful!";
        }
        else 
        {
             alert("Operation failed with error message " + asyncResult.getDescription() + ".");
        }    
    } 
    </script>
    <input type="button" id="RefreshAllConns" value="Refresh Connections" onclick="refreshAllAsyncButton()" />

    You can refer to the following link.

    http://msdn.microsoft.com/en-us/library/ee589064.aspx

    http://office.microsoft.com/en-us/sharepoint-server-help/refresh-external-data-in-excel-services-HA010105474.aspx

    Thanks,

    Jack

    Tuesday, May 15, 2012 7:45 AM
    Moderator
  • I am not using any java script so i donot think i can use ewa.

    I am calling refresh from a class library after which i export and  copy the refreshed sheet to another location.

    - Girija

    Tuesday, May 15, 2012 4:44 PM
  • Hi Girija_Shankar,

    The same workbook might be opened in several different sessions at the same time by different users. But you want use the same session in different threads, as far as I know this is difficult according to Sessions and session time-outs in a workbook in the browser.

    More about it, please refer to the following link.

    http://office.microsoft.com/en-us/sharepoint-server-help/refresh-external-data-in-excel-services-HA010105474.aspx

    Thanks,

    Jack

    Wednesday, May 16, 2012 4:52 AM
    Moderator