cancel
Showing results for 
Search instead for 
Did you mean: 

Need some help understanding Connection Refresh/XML Data Connection

Former Member
0 Kudos

Background:

I have an XML Data Connection on my Xcelsius Dashboard and a Connection Refresh button to trigger it. The XML Data Connection is tied to a Default.aspx with Default.aspx.cs code-behind.

Default.aspx has the following code, just something to send back to a single cell in the dashboard:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="screenshot._Default" %>

<%

    //tester to see that script executes
    String sXML;

    sXML = "<data><variable name=" + '\u0022' + "Range_0" + '\u0022' + "><row><column>Script Executed</column></row></variable></data>";

    Response.Write(sXML);
    
%>

Default.aspx.cs does the following:

The code-behind takes a screenshot of the dashboard and opens the Outlook email client with that screenshot already attached. From here the user can fill out To, Subject, and Body and then send the email. The code to do all of this is located in (might this be the cause?):

protected void Page_Load(object sender, EventArgs e)

Issue:

All of this works and it works well. But it only works 1 time. After the 1st execution of the code-behind if i adjust my dashboard and click the Connection Refresh button a 2nd time, nothing happens. No screenshot is generated and no Outlook email pops up. In order to send an additional screenshot I would need to close the dashboard and reopen it. I'd imagine there is a way for my Connection Refresh button to execute the Default.aspx and its code-behind each time the button is clicked, but I am still learning about the functionality of this feature.

My Connection Refresh button and XML Data Connection are not set to "Refresh Before/After components are loaded" and neither one is tied to a trigger cell. I don't believe using either of these options would solve my problem, but you may see or know something I don't.

Any help or explanation would be greatly appreciated! If any additional information is needed please let me know. Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Scott,

Glad to see your e-mail solution is coming along nicely!

I think your problem may be because of the way IE/flash caches calls to external objects. You may need to add "?rand()" to the end of the URL (after .aspx).

Here's a Ryan Goodman post explaining it: http://ryangoodman.net/blog/index.php/2008/06/20/xml-maps-best-practices-for-xcelsius-2008

You may need some other logic to make sure that the RAND function is triggered to update.

Former Member
0 Kudos

Thanks for the reply David,

One thing I've noticed with that ?rand parameter for my URL is that seems to just prevent it from being cached on the initial load. Which means I can still get my screenshot functionality to execute once but can not take any additional screenshots after that unless I close and re-load the dashboard.

Has anyone else used an XML Data Connection and Connection Refresh button as an 'Execute' type of functionality? I basically just want my script to fire off each time I click the button, which is why i'm having a hard time figuring out why this is so hard (for lack of a better explanation, haha). I will keep looking into it though, as I may be able to jimmy-rig something with passing a value from my declared Range in my spreadsheet and working with the 'Trigger when cell changes' feature of the Connection Refresh button.

I will post back if I find a solution. If anyone has additional tips or ideas please feel free to share, thanks!

Former Member
0 Kudos

Thanks for leading me in the right direction David. You were correct about the cache. A simple method to clear the cache after my script executes seems to have done the trick. I put the following code in my .aspx.cs and called the method at the very end of my .aspx. Now everything works like a charm!

public void ClearApplicationCache()
        {

            List<string> keys = new List<string>();

            // retrieve application Cache enumerator
            IDictionaryEnumerator enumerator = Cache.GetEnumerator();

            // copy all keys that currently exist in Cache
            while (enumerator.MoveNext())
            {
                keys.Add(enumerator.Key.ToString());
            }

            // delete every key from cache
            for (int i = 0; i < keys.Count; i++)
            {
                Cache.Remove(keys<i>);
            }

        }

Answers (0)