Sign in to follow this  
atifkhan

Cache problem while fetching data in AngularGauge

Recommended Posts

I have the following code file;

1) Home.aspx.cs 

if (File.Exists(Server.MapPath("FusionWidgetsMyFirstChartData Chart.xml")))

File.Delete(Server.MapPath("FusionWidgetsMyFirstChartData Chart.xml"));

 

//Writing XML

XmlDocument doc = new XmlDocument();

XMLStr = "";

XMLStr = XMLStr + "<chart lowerLimit='0' upperLimit='100' lowerLimitDisplay='Bad' upperLimitDisplay='Good' gaugeStartAngle='180' gaugeEndAngle='0' palette='1' numberSuffix='%' tickValueDistance='20' showValue='1'>";

XMLStr = XMLStr + "<colorRange>";

XMLStr = XMLStr + "<color minValue='0' maxValue='75' code='FF654F'/>";

XMLStr = XMLStr + "<color minValue='75' maxValue='90' code='F6BD0F'/>";

XMLStr = XMLStr + "<color minValue='90' maxValue='100' code='8BBA00'/>";

XMLStr = XMLStr + "</colorRange>";

XMLStr = XMLStr + "<dials>";

XMLStr = XMLStr + "<dial value='" + Convert.ToString(((SiteReady * 100) / NoSchools)) + "' rearExtension='10'/>";

XMLStr = XMLStr + "</dials>";

XMLStr = XMLStr + "</chart>";

doc.LoadXml((XMLStr));

doc.Save(Server.MapPath("FusionWidgetsMyFirstChartData Chart.xml"));

 

AngularGaugeURL = Request.Url.AbsoluteUri;

AngularGaugeURL = AngularGaugeURL.Replace("home.aspx", "");

AngularGaugeURL = AngularGaugeURL + "FusionWidgets/MyFirstChart/MyFirstChart.html";

2) Home.aspx

<iframe frameborder=0 style="background-color:Bisque" height="300" width="100%" src="<%=AngularGaugeURL%>"></iframe>

3) MyFirstChart.html

<html>

<head>

  <title>My first chart using FusionWidgets</title>

  <script language="JavaScript" src="../Charts/FusionCharts.js"></script>

</head>

<body bgcolor="#ffffff">

  <div id="chartdiv" align="center">

The chart will appear within this DIV. This text will be replaced by the chart.

  </div>

  <script type="text/javascript">

var myChart = new FusionCharts("../Charts/AngularGauge.swf", "myChartId", "400", "200", "0", "0");

myChart.setDataURL("Data Chart.xml?NoCache=.microtime()");

myChart.render("chartdiv");

  </script>

</body>

</html>

 

 

4) Data Chart.xml

<chart lowerLimit="0" upperLimit="100" lowerLimitDisplay="Bad" upperLimitDisplay="Good" gaugeStartAngle="180" gaugeEndAngle="0" palette="1" numberSuffix="%" tickValueDistance="20" showValue="1">

  <colorRange>

  <color minValue="0" maxValue="75" code="FF654F" />

  <color minValue="75" maxValue="90" code="F6BD0F" />

  <color minValue="90" maxValue="100" code="8BBA00" />

  </colorRange>

  <dials>

  <dial value="74" rearExtension="10" />

  </dials>

</chart>

Data Chart.XML is generated on runtime from Home.aspx.cs page. Now the problem is that, Data Chart.XML changes the data in it but it is not reflecting on Home.aspx. This is cache problem. Can any one tell me where should I place cache clear code? and what is the actual code to resolve this cache problem?

Share this post


Link to post
Share on other sites
Guest Rajroop

Hi,

I am afraid, your code :

"Data Chart.xml?NoCache=.microtime()"

seems to be using something that is taken from PHP samples.

Please use DateTime class of ASP.NET to pass timestamp to the noCache querystring.

Make sure to call a DateTime a function that returns something like time passed since midnight in miliseconds etc. Please avoid using timestamps that has a : in it.

I hope this helps. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this